babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342
  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/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** 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 */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** 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 */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** 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 */
  686. static readonly GEQUAL: number;
  687. /** 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 */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = linear */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * 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.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * 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.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. 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>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * 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".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Classed used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * 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"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * 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"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * 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)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * 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
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. 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;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. 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;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * 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"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * 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".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Creates a right-handed perspective projection matrix
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar defines the far clip plane
  4496. * @returns a new matrix as a right-handed perspective projection matrix
  4497. */
  4498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4499. /**
  4500. * Stores a right-handed perspective projection into a given matrix
  4501. * @param fov defines the horizontal field of view
  4502. * @param aspect defines the aspect ratio
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @param result defines the target matrix
  4506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4507. */
  4508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4509. /**
  4510. * Stores a perspective projection for WebVR info a given matrix
  4511. * @param fov defines the field of view
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4516. */
  4517. static PerspectiveFovWebVRToRef(fov: {
  4518. upDegrees: number;
  4519. downDegrees: number;
  4520. leftDegrees: number;
  4521. rightDegrees: number;
  4522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4523. /**
  4524. * Computes a complete transformation matrix
  4525. * @param viewport defines the viewport to use
  4526. * @param world defines the world matrix
  4527. * @param view defines the view matrix
  4528. * @param projection defines the projection matrix
  4529. * @param zmin defines the near clip plane
  4530. * @param zmax defines the far clip plane
  4531. * @returns the transformation matrix
  4532. */
  4533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4534. /**
  4535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4536. * @param matrix defines the matrix to use
  4537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4538. */
  4539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4540. /**
  4541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4542. * @param matrix defines the matrix to use
  4543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4544. */
  4545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4546. /**
  4547. * Compute the transpose of a given matrix
  4548. * @param matrix defines the matrix to transpose
  4549. * @returns the new matrix
  4550. */
  4551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4552. /**
  4553. * Compute the transpose of a matrix and store it in a target matrix
  4554. * @param matrix defines the matrix to transpose
  4555. * @param result defines the target matrix
  4556. */
  4557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4558. /**
  4559. * Computes a reflection matrix from a plane
  4560. * @param plane defines the reflection plane
  4561. * @returns a new matrix
  4562. */
  4563. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4564. /**
  4565. * Computes a reflection matrix from a plane
  4566. * @param plane defines the reflection plane
  4567. * @param result defines the target matrix
  4568. */
  4569. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4570. /**
  4571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4572. * @param xaxis defines the value of the 1st axis
  4573. * @param yaxis defines the value of the 2nd axis
  4574. * @param zaxis defines the value of the 3rd axis
  4575. * @param result defines the target matrix
  4576. */
  4577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4578. /**
  4579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4580. * @param quat defines the quaternion to use
  4581. * @param result defines the target matrix
  4582. */
  4583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4584. }
  4585. /**
  4586. * @hidden
  4587. */
  4588. export class TmpVectors {
  4589. static Vector2: Vector2[];
  4590. static Vector3: Vector3[];
  4591. static Vector4: Vector4[];
  4592. static Quaternion: Quaternion[];
  4593. static Matrix: Matrix[];
  4594. }
  4595. }
  4596. declare module "babylonjs/Maths/math.path" {
  4597. import { DeepImmutable, Nullable } from "babylonjs/types";
  4598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4599. /**
  4600. * Defines potential orientation for back face culling
  4601. */
  4602. export enum Orientation {
  4603. /**
  4604. * Clockwise
  4605. */
  4606. CW = 0,
  4607. /** Counter clockwise */
  4608. CCW = 1
  4609. }
  4610. /** Class used to represent a Bezier curve */
  4611. export class BezierCurve {
  4612. /**
  4613. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4614. * @param t defines the time
  4615. * @param x1 defines the left coordinate on X axis
  4616. * @param y1 defines the left coordinate on Y axis
  4617. * @param x2 defines the right coordinate on X axis
  4618. * @param y2 defines the right coordinate on Y axis
  4619. * @returns the interpolated value
  4620. */
  4621. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4622. }
  4623. /**
  4624. * Defines angle representation
  4625. */
  4626. export class Angle {
  4627. private _radians;
  4628. /**
  4629. * Creates an Angle object of "radians" radians (float).
  4630. * @param radians the angle in radians
  4631. */
  4632. constructor(radians: number);
  4633. /**
  4634. * Get value in degrees
  4635. * @returns the Angle value in degrees (float)
  4636. */
  4637. degrees(): number;
  4638. /**
  4639. * Get value in radians
  4640. * @returns the Angle value in radians (float)
  4641. */
  4642. radians(): number;
  4643. /**
  4644. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4645. * @param a defines first vector
  4646. * @param b defines second vector
  4647. * @returns a new Angle
  4648. */
  4649. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4650. /**
  4651. * Gets a new Angle object from the given float in radians
  4652. * @param radians defines the angle value in radians
  4653. * @returns a new Angle
  4654. */
  4655. static FromRadians(radians: number): Angle;
  4656. /**
  4657. * Gets a new Angle object from the given float in degrees
  4658. * @param degrees defines the angle value in degrees
  4659. * @returns a new Angle
  4660. */
  4661. static FromDegrees(degrees: number): Angle;
  4662. }
  4663. /**
  4664. * This represents an arc in a 2d space.
  4665. */
  4666. export class Arc2 {
  4667. /** Defines the start point of the arc */
  4668. startPoint: Vector2;
  4669. /** Defines the mid point of the arc */
  4670. midPoint: Vector2;
  4671. /** Defines the end point of the arc */
  4672. endPoint: Vector2;
  4673. /**
  4674. * Defines the center point of the arc.
  4675. */
  4676. centerPoint: Vector2;
  4677. /**
  4678. * Defines the radius of the arc.
  4679. */
  4680. radius: number;
  4681. /**
  4682. * Defines the angle of the arc (from mid point to end point).
  4683. */
  4684. angle: Angle;
  4685. /**
  4686. * Defines the start angle of the arc (from start point to middle point).
  4687. */
  4688. startAngle: Angle;
  4689. /**
  4690. * Defines the orientation of the arc (clock wise/counter clock wise).
  4691. */
  4692. orientation: Orientation;
  4693. /**
  4694. * Creates an Arc object from the three given points : start, middle and end.
  4695. * @param startPoint Defines the start point of the arc
  4696. * @param midPoint Defines the midlle point of the arc
  4697. * @param endPoint Defines the end point of the arc
  4698. */
  4699. constructor(
  4700. /** Defines the start point of the arc */
  4701. startPoint: Vector2,
  4702. /** Defines the mid point of the arc */
  4703. midPoint: Vector2,
  4704. /** Defines the end point of the arc */
  4705. endPoint: Vector2);
  4706. }
  4707. /**
  4708. * Represents a 2D path made up of multiple 2D points
  4709. */
  4710. export class Path2 {
  4711. private _points;
  4712. private _length;
  4713. /**
  4714. * If the path start and end point are the same
  4715. */
  4716. closed: boolean;
  4717. /**
  4718. * Creates a Path2 object from the starting 2D coordinates x and y.
  4719. * @param x the starting points x value
  4720. * @param y the starting points y value
  4721. */
  4722. constructor(x: number, y: number);
  4723. /**
  4724. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4725. * @param x the added points x value
  4726. * @param y the added points y value
  4727. * @returns the updated Path2.
  4728. */
  4729. addLineTo(x: number, y: number): Path2;
  4730. /**
  4731. * 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.
  4732. * @param midX middle point x value
  4733. * @param midY middle point y value
  4734. * @param endX end point x value
  4735. * @param endY end point y value
  4736. * @param numberOfSegments (default: 36)
  4737. * @returns the updated Path2.
  4738. */
  4739. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4740. /**
  4741. * Closes the Path2.
  4742. * @returns the Path2.
  4743. */
  4744. close(): Path2;
  4745. /**
  4746. * Gets the sum of the distance between each sequential point in the path
  4747. * @returns the Path2 total length (float).
  4748. */
  4749. length(): number;
  4750. /**
  4751. * Gets the points which construct the path
  4752. * @returns the Path2 internal array of points.
  4753. */
  4754. getPoints(): Vector2[];
  4755. /**
  4756. * Retreives the point at the distance aways from the starting point
  4757. * @param normalizedLengthPosition the length along the path to retreive the point from
  4758. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4759. */
  4760. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4761. /**
  4762. * Creates a new path starting from an x and y position
  4763. * @param x starting x value
  4764. * @param y starting y value
  4765. * @returns a new Path2 starting at the coordinates (x, y).
  4766. */
  4767. static StartingAt(x: number, y: number): Path2;
  4768. }
  4769. /**
  4770. * Represents a 3D path made up of multiple 3D points
  4771. */
  4772. export class Path3D {
  4773. /**
  4774. * an array of Vector3, the curve axis of the Path3D
  4775. */
  4776. path: Vector3[];
  4777. private _curve;
  4778. private _distances;
  4779. private _tangents;
  4780. private _normals;
  4781. private _binormals;
  4782. private _raw;
  4783. private _alignTangentsWithPath;
  4784. private readonly _pointAtData;
  4785. /**
  4786. * new Path3D(path, normal, raw)
  4787. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4788. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4789. * @param path an array of Vector3, the curve axis of the Path3D
  4790. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4791. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4792. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4793. */
  4794. constructor(
  4795. /**
  4796. * an array of Vector3, the curve axis of the Path3D
  4797. */
  4798. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4799. /**
  4800. * Returns the Path3D array of successive Vector3 designing its curve.
  4801. * @returns the Path3D array of successive Vector3 designing its curve.
  4802. */
  4803. getCurve(): Vector3[];
  4804. /**
  4805. * Returns the Path3D array of successive Vector3 designing its curve.
  4806. * @returns the Path3D array of successive Vector3 designing its curve.
  4807. */
  4808. getPoints(): Vector3[];
  4809. /**
  4810. * @returns the computed length (float) of the path.
  4811. */
  4812. length(): number;
  4813. /**
  4814. * Returns an array populated with tangent vectors on each Path3D curve point.
  4815. * @returns an array populated with tangent vectors on each Path3D curve point.
  4816. */
  4817. getTangents(): Vector3[];
  4818. /**
  4819. * Returns an array populated with normal vectors on each Path3D curve point.
  4820. * @returns an array populated with normal vectors on each Path3D curve point.
  4821. */
  4822. getNormals(): Vector3[];
  4823. /**
  4824. * Returns an array populated with binormal vectors on each Path3D curve point.
  4825. * @returns an array populated with binormal vectors on each Path3D curve point.
  4826. */
  4827. getBinormals(): Vector3[];
  4828. /**
  4829. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4830. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4831. */
  4832. getDistances(): number[];
  4833. /**
  4834. * Returns an interpolated point along this path
  4835. * @param position the position of the point along this path, from 0.0 to 1.0
  4836. * @returns a new Vector3 as the point
  4837. */
  4838. getPointAt(position: number): Vector3;
  4839. /**
  4840. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4841. * @param position the position of the point along this path, from 0.0 to 1.0
  4842. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4843. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4844. */
  4845. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4846. /**
  4847. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4848. * @param position the position of the point along this path, from 0.0 to 1.0
  4849. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4850. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4851. */
  4852. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4853. /**
  4854. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4857. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4858. */
  4859. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4860. /**
  4861. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4862. * @param position the position of the point along this path, from 0.0 to 1.0
  4863. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4864. */
  4865. getDistanceAt(position: number): number;
  4866. /**
  4867. * Returns the array index of the previous point of an interpolated point along this path
  4868. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4869. * @returns the array index
  4870. */
  4871. getPreviousPointIndexAt(position: number): number;
  4872. /**
  4873. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4874. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4875. * @returns the sub position
  4876. */
  4877. getSubPositionAt(position: number): number;
  4878. /**
  4879. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4880. * @param target the vector of which to get the closest position to
  4881. * @returns the position of the closest virtual point on this path to the target vector
  4882. */
  4883. getClosestPositionTo(target: Vector3): number;
  4884. /**
  4885. * Returns a sub path (slice) of this path
  4886. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4887. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4888. * @returns a sub path (slice) of this path
  4889. */
  4890. slice(start?: number, end?: number): Path3D;
  4891. /**
  4892. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4893. * @param path path which all values are copied into the curves points
  4894. * @param firstNormal which should be projected onto the curve
  4895. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4896. * @returns the same object updated.
  4897. */
  4898. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4899. private _compute;
  4900. private _getFirstNonNullVector;
  4901. private _getLastNonNullVector;
  4902. private _normalVector;
  4903. /**
  4904. * Updates the point at data for an interpolated point along this curve
  4905. * @param position the position of the point along this curve, from 0.0 to 1.0
  4906. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4907. * @returns the (updated) point at data
  4908. */
  4909. private _updatePointAtData;
  4910. /**
  4911. * Updates the point at data from the specified parameters
  4912. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4913. * @param point the interpolated point
  4914. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4915. */
  4916. private _setPointAtData;
  4917. /**
  4918. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4919. */
  4920. private _updateInterpolationMatrix;
  4921. }
  4922. /**
  4923. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4924. * A Curve3 is designed from a series of successive Vector3.
  4925. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4926. */
  4927. export class Curve3 {
  4928. private _points;
  4929. private _length;
  4930. /**
  4931. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4932. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4933. * @param v1 (Vector3) the control point
  4934. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4935. * @param nbPoints (integer) the wanted number of points in the curve
  4936. * @returns the created Curve3
  4937. */
  4938. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4939. /**
  4940. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4941. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4942. * @param v1 (Vector3) the first control point
  4943. * @param v2 (Vector3) the second control point
  4944. * @param v3 (Vector3) the end point of the Cubic Bezier
  4945. * @param nbPoints (integer) the wanted number of points in the curve
  4946. * @returns the created Curve3
  4947. */
  4948. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4949. /**
  4950. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4951. * @param p1 (Vector3) the origin point of the Hermite Spline
  4952. * @param t1 (Vector3) the tangent vector at the origin point
  4953. * @param p2 (Vector3) the end point of the Hermite Spline
  4954. * @param t2 (Vector3) the tangent vector at the end point
  4955. * @param nbPoints (integer) the wanted number of points in the curve
  4956. * @returns the created Curve3
  4957. */
  4958. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4959. /**
  4960. * Returns a Curve3 object along a CatmullRom Spline curve :
  4961. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4962. * @param nbPoints (integer) the wanted number of points between each curve control points
  4963. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4964. * @returns the created Curve3
  4965. */
  4966. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4967. /**
  4968. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4969. * A Curve3 is designed from a series of successive Vector3.
  4970. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4971. * @param points points which make up the curve
  4972. */
  4973. constructor(points: Vector3[]);
  4974. /**
  4975. * @returns the Curve3 stored array of successive Vector3
  4976. */
  4977. getPoints(): Vector3[];
  4978. /**
  4979. * @returns the computed length (float) of the curve.
  4980. */
  4981. length(): number;
  4982. /**
  4983. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4984. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4985. * curveA and curveB keep unchanged.
  4986. * @param curve the curve to continue from this curve
  4987. * @returns the newly constructed curve
  4988. */
  4989. continue(curve: DeepImmutable<Curve3>): Curve3;
  4990. private _computeLength;
  4991. }
  4992. }
  4993. declare module "babylonjs/Animations/easing" {
  4994. /**
  4995. * This represents the main contract an easing function should follow.
  4996. * Easing functions are used throughout the animation system.
  4997. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4998. */
  4999. export interface IEasingFunction {
  5000. /**
  5001. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5002. * of the easing function.
  5003. * The link below provides some of the most common examples of easing functions.
  5004. * @see https://easings.net/
  5005. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5006. * @returns the corresponding value on the curve defined by the easing function
  5007. */
  5008. ease(gradient: number): number;
  5009. }
  5010. /**
  5011. * Base class used for every default easing function.
  5012. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5013. */
  5014. export class EasingFunction implements IEasingFunction {
  5015. /**
  5016. * Interpolation follows the mathematical formula associated with the easing function.
  5017. */
  5018. static readonly EASINGMODE_EASEIN: number;
  5019. /**
  5020. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5021. */
  5022. static readonly EASINGMODE_EASEOUT: number;
  5023. /**
  5024. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5025. */
  5026. static readonly EASINGMODE_EASEINOUT: number;
  5027. private _easingMode;
  5028. /**
  5029. * Sets the easing mode of the current function.
  5030. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5031. */
  5032. setEasingMode(easingMode: number): void;
  5033. /**
  5034. * Gets the current easing mode.
  5035. * @returns the easing mode
  5036. */
  5037. getEasingMode(): number;
  5038. /**
  5039. * @hidden
  5040. */
  5041. easeInCore(gradient: number): number;
  5042. /**
  5043. * Given an input gradient between 0 and 1, this returns the corresponding value
  5044. * of the easing function.
  5045. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5046. * @returns the corresponding value on the curve defined by the easing function
  5047. */
  5048. ease(gradient: number): number;
  5049. }
  5050. /**
  5051. * Easing function with a circle shape (see link below).
  5052. * @see https://easings.net/#easeInCirc
  5053. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5054. */
  5055. export class CircleEase extends EasingFunction implements IEasingFunction {
  5056. /** @hidden */
  5057. easeInCore(gradient: number): number;
  5058. }
  5059. /**
  5060. * Easing function with a ease back shape (see link below).
  5061. * @see https://easings.net/#easeInBack
  5062. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5063. */
  5064. export class BackEase extends EasingFunction implements IEasingFunction {
  5065. /** Defines the amplitude of the function */
  5066. amplitude: number;
  5067. /**
  5068. * Instantiates a back ease easing
  5069. * @see https://easings.net/#easeInBack
  5070. * @param amplitude Defines the amplitude of the function
  5071. */
  5072. constructor(
  5073. /** Defines the amplitude of the function */
  5074. amplitude?: number);
  5075. /** @hidden */
  5076. easeInCore(gradient: number): number;
  5077. }
  5078. /**
  5079. * Easing function with a bouncing shape (see link below).
  5080. * @see https://easings.net/#easeInBounce
  5081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5082. */
  5083. export class BounceEase extends EasingFunction implements IEasingFunction {
  5084. /** Defines the number of bounces */
  5085. bounces: number;
  5086. /** Defines the amplitude of the bounce */
  5087. bounciness: number;
  5088. /**
  5089. * Instantiates a bounce easing
  5090. * @see https://easings.net/#easeInBounce
  5091. * @param bounces Defines the number of bounces
  5092. * @param bounciness Defines the amplitude of the bounce
  5093. */
  5094. constructor(
  5095. /** Defines the number of bounces */
  5096. bounces?: number,
  5097. /** Defines the amplitude of the bounce */
  5098. bounciness?: number);
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a power of 3 shape (see link below).
  5104. * @see https://easings.net/#easeInCubic
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class CubicEase extends EasingFunction implements IEasingFunction {
  5108. /** @hidden */
  5109. easeInCore(gradient: number): number;
  5110. }
  5111. /**
  5112. * Easing function with an elastic shape (see link below).
  5113. * @see https://easings.net/#easeInElastic
  5114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5115. */
  5116. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5117. /** Defines the number of oscillations*/
  5118. oscillations: number;
  5119. /** Defines the amplitude of the oscillations*/
  5120. springiness: number;
  5121. /**
  5122. * Instantiates an elastic easing function
  5123. * @see https://easings.net/#easeInElastic
  5124. * @param oscillations Defines the number of oscillations
  5125. * @param springiness Defines the amplitude of the oscillations
  5126. */
  5127. constructor(
  5128. /** Defines the number of oscillations*/
  5129. oscillations?: number,
  5130. /** Defines the amplitude of the oscillations*/
  5131. springiness?: number);
  5132. /** @hidden */
  5133. easeInCore(gradient: number): number;
  5134. }
  5135. /**
  5136. * Easing function with an exponential shape (see link below).
  5137. * @see https://easings.net/#easeInExpo
  5138. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5139. */
  5140. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5141. /** Defines the exponent of the function */
  5142. exponent: number;
  5143. /**
  5144. * Instantiates an exponential easing function
  5145. * @see https://easings.net/#easeInExpo
  5146. * @param exponent Defines the exponent of the function
  5147. */
  5148. constructor(
  5149. /** Defines the exponent of the function */
  5150. exponent?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. /**
  5155. * Easing function with a power shape (see link below).
  5156. * @see https://easings.net/#easeInQuad
  5157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5158. */
  5159. export class PowerEase extends EasingFunction implements IEasingFunction {
  5160. /** Defines the power of the function */
  5161. power: number;
  5162. /**
  5163. * Instantiates an power base easing function
  5164. * @see https://easings.net/#easeInQuad
  5165. * @param power Defines the power of the function
  5166. */
  5167. constructor(
  5168. /** Defines the power of the function */
  5169. power?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power of 2 shape (see link below).
  5175. * @see https://easings.net/#easeInQuad
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with a power of 4 shape (see link below).
  5184. * @see https://easings.net/#easeInQuart
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5188. /** @hidden */
  5189. easeInCore(gradient: number): number;
  5190. }
  5191. /**
  5192. * Easing function with a power of 5 shape (see link below).
  5193. * @see https://easings.net/#easeInQuint
  5194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5195. */
  5196. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5197. /** @hidden */
  5198. easeInCore(gradient: number): number;
  5199. }
  5200. /**
  5201. * Easing function with a sin shape (see link below).
  5202. * @see https://easings.net/#easeInSine
  5203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5204. */
  5205. export class SineEase extends EasingFunction implements IEasingFunction {
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a bezier shape (see link below).
  5211. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5215. /** Defines the x component of the start tangent in the bezier curve */
  5216. x1: number;
  5217. /** Defines the y component of the start tangent in the bezier curve */
  5218. y1: number;
  5219. /** Defines the x component of the end tangent in the bezier curve */
  5220. x2: number;
  5221. /** Defines the y component of the end tangent in the bezier curve */
  5222. y2: number;
  5223. /**
  5224. * Instantiates a bezier function
  5225. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5226. * @param x1 Defines the x component of the start tangent in the bezier curve
  5227. * @param y1 Defines the y component of the start tangent in the bezier curve
  5228. * @param x2 Defines the x component of the end tangent in the bezier curve
  5229. * @param y2 Defines the y component of the end tangent in the bezier curve
  5230. */
  5231. constructor(
  5232. /** Defines the x component of the start tangent in the bezier curve */
  5233. x1?: number,
  5234. /** Defines the y component of the start tangent in the bezier curve */
  5235. y1?: number,
  5236. /** Defines the x component of the end tangent in the bezier curve */
  5237. x2?: number,
  5238. /** Defines the y component of the end tangent in the bezier curve */
  5239. y2?: number);
  5240. /** @hidden */
  5241. easeInCore(gradient: number): number;
  5242. }
  5243. }
  5244. declare module "babylonjs/Maths/math.color" {
  5245. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5246. /**
  5247. * Class used to hold a RBG color
  5248. */
  5249. export class Color3 {
  5250. /**
  5251. * Defines the red component (between 0 and 1, default is 0)
  5252. */
  5253. r: number;
  5254. /**
  5255. * Defines the green component (between 0 and 1, default is 0)
  5256. */
  5257. g: number;
  5258. /**
  5259. * Defines the blue component (between 0 and 1, default is 0)
  5260. */
  5261. b: number;
  5262. /**
  5263. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5264. * @param r defines the red component (between 0 and 1, default is 0)
  5265. * @param g defines the green component (between 0 and 1, default is 0)
  5266. * @param b defines the blue component (between 0 and 1, default is 0)
  5267. */
  5268. constructor(
  5269. /**
  5270. * Defines the red component (between 0 and 1, default is 0)
  5271. */
  5272. r?: number,
  5273. /**
  5274. * Defines the green component (between 0 and 1, default is 0)
  5275. */
  5276. g?: number,
  5277. /**
  5278. * Defines the blue component (between 0 and 1, default is 0)
  5279. */
  5280. b?: number);
  5281. /**
  5282. * Creates a string with the Color3 current values
  5283. * @returns the string representation of the Color3 object
  5284. */
  5285. toString(): string;
  5286. /**
  5287. * Returns the string "Color3"
  5288. * @returns "Color3"
  5289. */
  5290. getClassName(): string;
  5291. /**
  5292. * Compute the Color3 hash code
  5293. * @returns an unique number that can be used to hash Color3 objects
  5294. */
  5295. getHashCode(): number;
  5296. /**
  5297. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5298. * @param array defines the array where to store the r,g,b components
  5299. * @param index defines an optional index in the target array to define where to start storing values
  5300. * @returns the current Color3 object
  5301. */
  5302. toArray(array: FloatArray, index?: number): Color3;
  5303. /**
  5304. * Returns a new Color4 object from the current Color3 and the given alpha
  5305. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5306. * @returns a new Color4 object
  5307. */
  5308. toColor4(alpha?: number): Color4;
  5309. /**
  5310. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5311. * @returns the new array
  5312. */
  5313. asArray(): number[];
  5314. /**
  5315. * Returns the luminance value
  5316. * @returns a float value
  5317. */
  5318. toLuminance(): number;
  5319. /**
  5320. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5321. * @param otherColor defines the second operand
  5322. * @returns the new Color3 object
  5323. */
  5324. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5325. /**
  5326. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5327. * @param otherColor defines the second operand
  5328. * @param result defines the Color3 object where to store the result
  5329. * @returns the current Color3
  5330. */
  5331. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5332. /**
  5333. * Determines equality between Color3 objects
  5334. * @param otherColor defines the second operand
  5335. * @returns true if the rgb values are equal to the given ones
  5336. */
  5337. equals(otherColor: DeepImmutable<Color3>): boolean;
  5338. /**
  5339. * Determines equality between the current Color3 object and a set of r,b,g values
  5340. * @param r defines the red component to check
  5341. * @param g defines the green component to check
  5342. * @param b defines the blue component to check
  5343. * @returns true if the rgb values are equal to the given ones
  5344. */
  5345. equalsFloats(r: number, g: number, b: number): boolean;
  5346. /**
  5347. * Multiplies in place each rgb value by scale
  5348. * @param scale defines the scaling factor
  5349. * @returns the updated Color3
  5350. */
  5351. scale(scale: number): Color3;
  5352. /**
  5353. * Multiplies the rgb values by scale and stores the result into "result"
  5354. * @param scale defines the scaling factor
  5355. * @param result defines the Color3 object where to store the result
  5356. * @returns the unmodified current Color3
  5357. */
  5358. scaleToRef(scale: number, result: Color3): Color3;
  5359. /**
  5360. * Scale the current Color3 values by a factor and add the result to a given Color3
  5361. * @param scale defines the scale factor
  5362. * @param result defines color to store the result into
  5363. * @returns the unmodified current Color3
  5364. */
  5365. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5366. /**
  5367. * Clamps the rgb values by the min and max values and stores the result into "result"
  5368. * @param min defines minimum clamping value (default is 0)
  5369. * @param max defines maximum clamping value (default is 1)
  5370. * @param result defines color to store the result into
  5371. * @returns the original Color3
  5372. */
  5373. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5374. /**
  5375. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5376. * @param otherColor defines the second operand
  5377. * @returns the new Color3
  5378. */
  5379. add(otherColor: DeepImmutable<Color3>): Color3;
  5380. /**
  5381. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5382. * @param otherColor defines the second operand
  5383. * @param result defines Color3 object to store the result into
  5384. * @returns the unmodified current Color3
  5385. */
  5386. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5387. /**
  5388. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5389. * @param otherColor defines the second operand
  5390. * @returns the new Color3
  5391. */
  5392. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5393. /**
  5394. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5395. * @param otherColor defines the second operand
  5396. * @param result defines Color3 object to store the result into
  5397. * @returns the unmodified current Color3
  5398. */
  5399. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5400. /**
  5401. * Copy the current object
  5402. * @returns a new Color3 copied the current one
  5403. */
  5404. clone(): Color3;
  5405. /**
  5406. * Copies the rgb values from the source in the current Color3
  5407. * @param source defines the source Color3 object
  5408. * @returns the updated Color3 object
  5409. */
  5410. copyFrom(source: DeepImmutable<Color3>): Color3;
  5411. /**
  5412. * Updates the Color3 rgb values from the given floats
  5413. * @param r defines the red component to read from
  5414. * @param g defines the green component to read from
  5415. * @param b defines the blue component to read from
  5416. * @returns the current Color3 object
  5417. */
  5418. copyFromFloats(r: number, g: number, b: number): Color3;
  5419. /**
  5420. * Updates the Color3 rgb values from the given floats
  5421. * @param r defines the red component to read from
  5422. * @param g defines the green component to read from
  5423. * @param b defines the blue component to read from
  5424. * @returns the current Color3 object
  5425. */
  5426. set(r: number, g: number, b: number): Color3;
  5427. /**
  5428. * Compute the Color3 hexadecimal code as a string
  5429. * @returns a string containing the hexadecimal representation of the Color3 object
  5430. */
  5431. toHexString(): string;
  5432. /**
  5433. * Computes a new Color3 converted from the current one to linear space
  5434. * @returns a new Color3 object
  5435. */
  5436. toLinearSpace(): Color3;
  5437. /**
  5438. * Converts current color in rgb space to HSV values
  5439. * @returns a new color3 representing the HSV values
  5440. */
  5441. toHSV(): Color3;
  5442. /**
  5443. * Converts current color in rgb space to HSV values
  5444. * @param result defines the Color3 where to store the HSV values
  5445. */
  5446. toHSVToRef(result: Color3): void;
  5447. /**
  5448. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5449. * @param convertedColor defines the Color3 object where to store the linear space version
  5450. * @returns the unmodified Color3
  5451. */
  5452. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5453. /**
  5454. * Computes a new Color3 converted from the current one to gamma space
  5455. * @returns a new Color3 object
  5456. */
  5457. toGammaSpace(): Color3;
  5458. /**
  5459. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5460. * @param convertedColor defines the Color3 object where to store the gamma space version
  5461. * @returns the unmodified Color3
  5462. */
  5463. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5464. private static _BlackReadOnly;
  5465. /**
  5466. * Convert Hue, saturation and value to a Color3 (RGB)
  5467. * @param hue defines the hue
  5468. * @param saturation defines the saturation
  5469. * @param value defines the value
  5470. * @param result defines the Color3 where to store the RGB values
  5471. */
  5472. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5473. /**
  5474. * Creates a new Color3 from the string containing valid hexadecimal values
  5475. * @param hex defines a string containing valid hexadecimal values
  5476. * @returns a new Color3 object
  5477. */
  5478. static FromHexString(hex: string): Color3;
  5479. /**
  5480. * Creates a new Color3 from the starting index of the given array
  5481. * @param array defines the source array
  5482. * @param offset defines an offset in the source array
  5483. * @returns a new Color3 object
  5484. */
  5485. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5486. /**
  5487. * Creates a new Color3 from integer values (< 256)
  5488. * @param r defines the red component to read from (value between 0 and 255)
  5489. * @param g defines the green component to read from (value between 0 and 255)
  5490. * @param b defines the blue component to read from (value between 0 and 255)
  5491. * @returns a new Color3 object
  5492. */
  5493. static FromInts(r: number, g: number, b: number): Color3;
  5494. /**
  5495. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5496. * @param start defines the start Color3 value
  5497. * @param end defines the end Color3 value
  5498. * @param amount defines the gradient value between start and end
  5499. * @returns a new Color3 object
  5500. */
  5501. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5502. /**
  5503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5504. * @param left defines the start value
  5505. * @param right defines the end value
  5506. * @param amount defines the gradient factor
  5507. * @param result defines the Color3 object where to store the result
  5508. */
  5509. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5510. /**
  5511. * Returns a Color3 value containing a red color
  5512. * @returns a new Color3 object
  5513. */
  5514. static Red(): Color3;
  5515. /**
  5516. * Returns a Color3 value containing a green color
  5517. * @returns a new Color3 object
  5518. */
  5519. static Green(): Color3;
  5520. /**
  5521. * Returns a Color3 value containing a blue color
  5522. * @returns a new Color3 object
  5523. */
  5524. static Blue(): Color3;
  5525. /**
  5526. * Returns a Color3 value containing a black color
  5527. * @returns a new Color3 object
  5528. */
  5529. static Black(): Color3;
  5530. /**
  5531. * Gets a Color3 value containing a black color that must not be updated
  5532. */
  5533. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5534. /**
  5535. * Returns a Color3 value containing a white color
  5536. * @returns a new Color3 object
  5537. */
  5538. static White(): Color3;
  5539. /**
  5540. * Returns a Color3 value containing a purple color
  5541. * @returns a new Color3 object
  5542. */
  5543. static Purple(): Color3;
  5544. /**
  5545. * Returns a Color3 value containing a magenta color
  5546. * @returns a new Color3 object
  5547. */
  5548. static Magenta(): Color3;
  5549. /**
  5550. * Returns a Color3 value containing a yellow color
  5551. * @returns a new Color3 object
  5552. */
  5553. static Yellow(): Color3;
  5554. /**
  5555. * Returns a Color3 value containing a gray color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Gray(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a teal color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Teal(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a random color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Random(): Color3;
  5569. }
  5570. /**
  5571. * Class used to hold a RBGA color
  5572. */
  5573. export class Color4 {
  5574. /**
  5575. * Defines the red component (between 0 and 1, default is 0)
  5576. */
  5577. r: number;
  5578. /**
  5579. * Defines the green component (between 0 and 1, default is 0)
  5580. */
  5581. g: number;
  5582. /**
  5583. * Defines the blue component (between 0 and 1, default is 0)
  5584. */
  5585. b: number;
  5586. /**
  5587. * Defines the alpha component (between 0 and 1, default is 1)
  5588. */
  5589. a: number;
  5590. /**
  5591. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5592. * @param r defines the red component (between 0 and 1, default is 0)
  5593. * @param g defines the green component (between 0 and 1, default is 0)
  5594. * @param b defines the blue component (between 0 and 1, default is 0)
  5595. * @param a defines the alpha component (between 0 and 1, default is 1)
  5596. */
  5597. constructor(
  5598. /**
  5599. * Defines the red component (between 0 and 1, default is 0)
  5600. */
  5601. r?: number,
  5602. /**
  5603. * Defines the green component (between 0 and 1, default is 0)
  5604. */
  5605. g?: number,
  5606. /**
  5607. * Defines the blue component (between 0 and 1, default is 0)
  5608. */
  5609. b?: number,
  5610. /**
  5611. * Defines the alpha component (between 0 and 1, default is 1)
  5612. */
  5613. a?: number);
  5614. /**
  5615. * Adds in place the given Color4 values to the current Color4 object
  5616. * @param right defines the second operand
  5617. * @returns the current updated Color4 object
  5618. */
  5619. addInPlace(right: DeepImmutable<Color4>): Color4;
  5620. /**
  5621. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5622. * @returns the new array
  5623. */
  5624. asArray(): number[];
  5625. /**
  5626. * Stores from the starting index in the given array the Color4 successive values
  5627. * @param array defines the array where to store the r,g,b components
  5628. * @param index defines an optional index in the target array to define where to start storing values
  5629. * @returns the current Color4 object
  5630. */
  5631. toArray(array: number[], index?: number): Color4;
  5632. /**
  5633. * Determines equality between Color4 objects
  5634. * @param otherColor defines the second operand
  5635. * @returns true if the rgba values are equal to the given ones
  5636. */
  5637. equals(otherColor: DeepImmutable<Color4>): boolean;
  5638. /**
  5639. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5640. * @param right defines the second operand
  5641. * @returns a new Color4 object
  5642. */
  5643. add(right: DeepImmutable<Color4>): Color4;
  5644. /**
  5645. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5646. * @param right defines the second operand
  5647. * @returns a new Color4 object
  5648. */
  5649. subtract(right: DeepImmutable<Color4>): Color4;
  5650. /**
  5651. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5652. * @param right defines the second operand
  5653. * @param result defines the Color4 object where to store the result
  5654. * @returns the current Color4 object
  5655. */
  5656. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5657. /**
  5658. * Creates a new Color4 with the current Color4 values multiplied by scale
  5659. * @param scale defines the scaling factor to apply
  5660. * @returns a new Color4 object
  5661. */
  5662. scale(scale: number): Color4;
  5663. /**
  5664. * Multiplies the current Color4 values by scale and stores the result in "result"
  5665. * @param scale defines the scaling factor to apply
  5666. * @param result defines the Color4 object where to store the result
  5667. * @returns the current unmodified Color4
  5668. */
  5669. scaleToRef(scale: number, result: Color4): Color4;
  5670. /**
  5671. * Scale the current Color4 values by a factor and add the result to a given Color4
  5672. * @param scale defines the scale factor
  5673. * @param result defines the Color4 object where to store the result
  5674. * @returns the unmodified current Color4
  5675. */
  5676. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5677. /**
  5678. * Clamps the rgb values by the min and max values and stores the result into "result"
  5679. * @param min defines minimum clamping value (default is 0)
  5680. * @param max defines maximum clamping value (default is 1)
  5681. * @param result defines color to store the result into.
  5682. * @returns the cuurent Color4
  5683. */
  5684. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5685. /**
  5686. * Multipy an Color4 value by another and return a new Color4 object
  5687. * @param color defines the Color4 value to multiply by
  5688. * @returns a new Color4 object
  5689. */
  5690. multiply(color: Color4): Color4;
  5691. /**
  5692. * Multipy a Color4 value by another and push the result in a reference value
  5693. * @param color defines the Color4 value to multiply by
  5694. * @param result defines the Color4 to fill the result in
  5695. * @returns the result Color4
  5696. */
  5697. multiplyToRef(color: Color4, result: Color4): Color4;
  5698. /**
  5699. * Creates a string with the Color4 current values
  5700. * @returns the string representation of the Color4 object
  5701. */
  5702. toString(): string;
  5703. /**
  5704. * Returns the string "Color4"
  5705. * @returns "Color4"
  5706. */
  5707. getClassName(): string;
  5708. /**
  5709. * Compute the Color4 hash code
  5710. * @returns an unique number that can be used to hash Color4 objects
  5711. */
  5712. getHashCode(): number;
  5713. /**
  5714. * Creates a new Color4 copied from the current one
  5715. * @returns a new Color4 object
  5716. */
  5717. clone(): Color4;
  5718. /**
  5719. * Copies the given Color4 values into the current one
  5720. * @param source defines the source Color4 object
  5721. * @returns the current updated Color4 object
  5722. */
  5723. copyFrom(source: Color4): Color4;
  5724. /**
  5725. * Copies the given float values into the current one
  5726. * @param r defines the red component to read from
  5727. * @param g defines the green component to read from
  5728. * @param b defines the blue component to read from
  5729. * @param a defines the alpha component to read from
  5730. * @returns the current updated Color4 object
  5731. */
  5732. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5733. /**
  5734. * Copies the given float values into the current one
  5735. * @param r defines the red component to read from
  5736. * @param g defines the green component to read from
  5737. * @param b defines the blue component to read from
  5738. * @param a defines the alpha component to read from
  5739. * @returns the current updated Color4 object
  5740. */
  5741. set(r: number, g: number, b: number, a: number): Color4;
  5742. /**
  5743. * Compute the Color4 hexadecimal code as a string
  5744. * @returns a string containing the hexadecimal representation of the Color4 object
  5745. */
  5746. toHexString(): string;
  5747. /**
  5748. * Computes a new Color4 converted from the current one to linear space
  5749. * @returns a new Color4 object
  5750. */
  5751. toLinearSpace(): Color4;
  5752. /**
  5753. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5754. * @param convertedColor defines the Color4 object where to store the linear space version
  5755. * @returns the unmodified Color4
  5756. */
  5757. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5758. /**
  5759. * Computes a new Color4 converted from the current one to gamma space
  5760. * @returns a new Color4 object
  5761. */
  5762. toGammaSpace(): Color4;
  5763. /**
  5764. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5765. * @param convertedColor defines the Color4 object where to store the gamma space version
  5766. * @returns the unmodified Color4
  5767. */
  5768. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5769. /**
  5770. * Creates a new Color4 from the string containing valid hexadecimal values
  5771. * @param hex defines a string containing valid hexadecimal values
  5772. * @returns a new Color4 object
  5773. */
  5774. static FromHexString(hex: string): Color4;
  5775. /**
  5776. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5777. * @param left defines the start value
  5778. * @param right defines the end value
  5779. * @param amount defines the gradient factor
  5780. * @returns a new Color4 object
  5781. */
  5782. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5783. /**
  5784. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5785. * @param left defines the start value
  5786. * @param right defines the end value
  5787. * @param amount defines the gradient factor
  5788. * @param result defines the Color4 object where to store data
  5789. */
  5790. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5791. /**
  5792. * Creates a new Color4 from a Color3 and an alpha value
  5793. * @param color3 defines the source Color3 to read from
  5794. * @param alpha defines the alpha component (1.0 by default)
  5795. * @returns a new Color4 object
  5796. */
  5797. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5798. /**
  5799. * Creates a new Color4 from the starting index element of the given array
  5800. * @param array defines the source array to read from
  5801. * @param offset defines the offset in the source array
  5802. * @returns a new Color4 object
  5803. */
  5804. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5805. /**
  5806. * Creates a new Color3 from integer values (< 256)
  5807. * @param r defines the red component to read from (value between 0 and 255)
  5808. * @param g defines the green component to read from (value between 0 and 255)
  5809. * @param b defines the blue component to read from (value between 0 and 255)
  5810. * @param a defines the alpha component to read from (value between 0 and 255)
  5811. * @returns a new Color3 object
  5812. */
  5813. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5814. /**
  5815. * Check the content of a given array and convert it to an array containing RGBA data
  5816. * If the original array was already containing count * 4 values then it is returned directly
  5817. * @param colors defines the array to check
  5818. * @param count defines the number of RGBA data to expect
  5819. * @returns an array containing count * 4 values (RGBA)
  5820. */
  5821. static CheckColors4(colors: number[], count: number): number[];
  5822. }
  5823. /**
  5824. * @hidden
  5825. */
  5826. export class TmpColors {
  5827. static Color3: Color3[];
  5828. static Color4: Color4[];
  5829. }
  5830. }
  5831. declare module "babylonjs/Animations/animationKey" {
  5832. /**
  5833. * Defines an interface which represents an animation key frame
  5834. */
  5835. export interface IAnimationKey {
  5836. /**
  5837. * Frame of the key frame
  5838. */
  5839. frame: number;
  5840. /**
  5841. * Value at the specifies key frame
  5842. */
  5843. value: any;
  5844. /**
  5845. * The input tangent for the cubic hermite spline
  5846. */
  5847. inTangent?: any;
  5848. /**
  5849. * The output tangent for the cubic hermite spline
  5850. */
  5851. outTangent?: any;
  5852. /**
  5853. * The animation interpolation type
  5854. */
  5855. interpolation?: AnimationKeyInterpolation;
  5856. }
  5857. /**
  5858. * Enum for the animation key frame interpolation type
  5859. */
  5860. export enum AnimationKeyInterpolation {
  5861. /**
  5862. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5863. */
  5864. STEP = 1
  5865. }
  5866. }
  5867. declare module "babylonjs/Animations/animationRange" {
  5868. /**
  5869. * Represents the range of an animation
  5870. */
  5871. export class AnimationRange {
  5872. /**The name of the animation range**/
  5873. name: string;
  5874. /**The starting frame of the animation */
  5875. from: number;
  5876. /**The ending frame of the animation*/
  5877. to: number;
  5878. /**
  5879. * Initializes the range of an animation
  5880. * @param name The name of the animation range
  5881. * @param from The starting frame of the animation
  5882. * @param to The ending frame of the animation
  5883. */
  5884. constructor(
  5885. /**The name of the animation range**/
  5886. name: string,
  5887. /**The starting frame of the animation */
  5888. from: number,
  5889. /**The ending frame of the animation*/
  5890. to: number);
  5891. /**
  5892. * Makes a copy of the animation range
  5893. * @returns A copy of the animation range
  5894. */
  5895. clone(): AnimationRange;
  5896. }
  5897. }
  5898. declare module "babylonjs/Animations/animationEvent" {
  5899. /**
  5900. * Composed of a frame, and an action function
  5901. */
  5902. export class AnimationEvent {
  5903. /** The frame for which the event is triggered **/
  5904. frame: number;
  5905. /** The event to perform when triggered **/
  5906. action: (currentFrame: number) => void;
  5907. /** Specifies if the event should be triggered only once**/
  5908. onlyOnce?: boolean | undefined;
  5909. /**
  5910. * Specifies if the animation event is done
  5911. */
  5912. isDone: boolean;
  5913. /**
  5914. * Initializes the animation event
  5915. * @param frame The frame for which the event is triggered
  5916. * @param action The event to perform when triggered
  5917. * @param onlyOnce Specifies if the event should be triggered only once
  5918. */
  5919. constructor(
  5920. /** The frame for which the event is triggered **/
  5921. frame: number,
  5922. /** The event to perform when triggered **/
  5923. action: (currentFrame: number) => void,
  5924. /** Specifies if the event should be triggered only once**/
  5925. onlyOnce?: boolean | undefined);
  5926. /** @hidden */
  5927. _clone(): AnimationEvent;
  5928. }
  5929. }
  5930. declare module "babylonjs/Behaviors/behavior" {
  5931. import { Nullable } from "babylonjs/types";
  5932. /**
  5933. * Interface used to define a behavior
  5934. */
  5935. export interface Behavior<T> {
  5936. /** gets or sets behavior's name */
  5937. name: string;
  5938. /**
  5939. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5940. */
  5941. init(): void;
  5942. /**
  5943. * Called when the behavior is attached to a target
  5944. * @param target defines the target where the behavior is attached to
  5945. */
  5946. attach(target: T): void;
  5947. /**
  5948. * Called when the behavior is detached from its target
  5949. */
  5950. detach(): void;
  5951. }
  5952. /**
  5953. * Interface implemented by classes supporting behaviors
  5954. */
  5955. export interface IBehaviorAware<T> {
  5956. /**
  5957. * Attach a behavior
  5958. * @param behavior defines the behavior to attach
  5959. * @returns the current host
  5960. */
  5961. addBehavior(behavior: Behavior<T>): T;
  5962. /**
  5963. * Remove a behavior from the current object
  5964. * @param behavior defines the behavior to detach
  5965. * @returns the current host
  5966. */
  5967. removeBehavior(behavior: Behavior<T>): T;
  5968. /**
  5969. * Gets a behavior using its name to search
  5970. * @param name defines the name to search
  5971. * @returns the behavior or null if not found
  5972. */
  5973. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5974. }
  5975. }
  5976. declare module "babylonjs/Misc/smartArray" {
  5977. /**
  5978. * Defines an array and its length.
  5979. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5980. */
  5981. export interface ISmartArrayLike<T> {
  5982. /**
  5983. * The data of the array.
  5984. */
  5985. data: Array<T>;
  5986. /**
  5987. * The active length of the array.
  5988. */
  5989. length: number;
  5990. }
  5991. /**
  5992. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5993. */
  5994. export class SmartArray<T> implements ISmartArrayLike<T> {
  5995. /**
  5996. * The full set of data from the array.
  5997. */
  5998. data: Array<T>;
  5999. /**
  6000. * The active length of the array.
  6001. */
  6002. length: number;
  6003. protected _id: number;
  6004. /**
  6005. * Instantiates a Smart Array.
  6006. * @param capacity defines the default capacity of the array.
  6007. */
  6008. constructor(capacity: number);
  6009. /**
  6010. * Pushes a value at the end of the active data.
  6011. * @param value defines the object to push in the array.
  6012. */
  6013. push(value: T): void;
  6014. /**
  6015. * Iterates over the active data and apply the lambda to them.
  6016. * @param func defines the action to apply on each value.
  6017. */
  6018. forEach(func: (content: T) => void): void;
  6019. /**
  6020. * Sorts the full sets of data.
  6021. * @param compareFn defines the comparison function to apply.
  6022. */
  6023. sort(compareFn: (a: T, b: T) => number): void;
  6024. /**
  6025. * Resets the active data to an empty array.
  6026. */
  6027. reset(): void;
  6028. /**
  6029. * Releases all the data from the array as well as the array.
  6030. */
  6031. dispose(): void;
  6032. /**
  6033. * Concats the active data with a given array.
  6034. * @param array defines the data to concatenate with.
  6035. */
  6036. concat(array: any): void;
  6037. /**
  6038. * Returns the position of a value in the active data.
  6039. * @param value defines the value to find the index for
  6040. * @returns the index if found in the active data otherwise -1
  6041. */
  6042. indexOf(value: T): number;
  6043. /**
  6044. * Returns whether an element is part of the active data.
  6045. * @param value defines the value to look for
  6046. * @returns true if found in the active data otherwise false
  6047. */
  6048. contains(value: T): boolean;
  6049. private static _GlobalId;
  6050. }
  6051. /**
  6052. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6053. * The data in this array can only be present once
  6054. */
  6055. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6056. private _duplicateId;
  6057. /**
  6058. * Pushes a value at the end of the active data.
  6059. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6060. * @param value defines the object to push in the array.
  6061. */
  6062. push(value: T): void;
  6063. /**
  6064. * Pushes a value at the end of the active data.
  6065. * If the data is already present, it won t be added again
  6066. * @param value defines the object to push in the array.
  6067. * @returns true if added false if it was already present
  6068. */
  6069. pushNoDuplicate(value: T): boolean;
  6070. /**
  6071. * Resets the active data to an empty array.
  6072. */
  6073. reset(): void;
  6074. /**
  6075. * Concats the active data with a given array.
  6076. * This ensures no dupplicate will be present in the result.
  6077. * @param array defines the data to concatenate with.
  6078. */
  6079. concatWithNoDuplicate(array: any): void;
  6080. }
  6081. }
  6082. declare module "babylonjs/Cameras/cameraInputsManager" {
  6083. import { Nullable } from "babylonjs/types";
  6084. import { Camera } from "babylonjs/Cameras/camera";
  6085. /**
  6086. * @ignore
  6087. * This is a list of all the different input types that are available in the application.
  6088. * Fo instance: ArcRotateCameraGamepadInput...
  6089. */
  6090. export var CameraInputTypes: {};
  6091. /**
  6092. * This is the contract to implement in order to create a new input class.
  6093. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6094. */
  6095. export interface ICameraInput<TCamera extends Camera> {
  6096. /**
  6097. * Defines the camera the input is attached to.
  6098. */
  6099. camera: Nullable<TCamera>;
  6100. /**
  6101. * Gets the class name of the current intput.
  6102. * @returns the class name
  6103. */
  6104. getClassName(): string;
  6105. /**
  6106. * Get the friendly name associated with the input class.
  6107. * @returns the input friendly name
  6108. */
  6109. getSimpleName(): string;
  6110. /**
  6111. * Attach the input controls to a specific dom element to get the input from.
  6112. * @param element Defines the element the controls should be listened from
  6113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6114. */
  6115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6116. /**
  6117. * Detach the current controls from the specified dom element.
  6118. * @param element Defines the element to stop listening the inputs from
  6119. */
  6120. detachControl(element: Nullable<HTMLElement>): void;
  6121. /**
  6122. * Update the current camera state depending on the inputs that have been used this frame.
  6123. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6124. */
  6125. checkInputs?: () => void;
  6126. }
  6127. /**
  6128. * Represents a map of input types to input instance or input index to input instance.
  6129. */
  6130. export interface CameraInputsMap<TCamera extends Camera> {
  6131. /**
  6132. * Accessor to the input by input type.
  6133. */
  6134. [name: string]: ICameraInput<TCamera>;
  6135. /**
  6136. * Accessor to the input by input index.
  6137. */
  6138. [idx: number]: ICameraInput<TCamera>;
  6139. }
  6140. /**
  6141. * This represents the input manager used within a camera.
  6142. * It helps dealing with all the different kind of input attached to a camera.
  6143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6144. */
  6145. export class CameraInputsManager<TCamera extends Camera> {
  6146. /**
  6147. * Defines the list of inputs attahed to the camera.
  6148. */
  6149. attached: CameraInputsMap<TCamera>;
  6150. /**
  6151. * Defines the dom element the camera is collecting inputs from.
  6152. * This is null if the controls have not been attached.
  6153. */
  6154. attachedElement: Nullable<HTMLElement>;
  6155. /**
  6156. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6157. */
  6158. noPreventDefault: boolean;
  6159. /**
  6160. * Defined the camera the input manager belongs to.
  6161. */
  6162. camera: TCamera;
  6163. /**
  6164. * Update the current camera state depending on the inputs that have been used this frame.
  6165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6166. */
  6167. checkInputs: () => void;
  6168. /**
  6169. * Instantiate a new Camera Input Manager.
  6170. * @param camera Defines the camera the input manager blongs to
  6171. */
  6172. constructor(camera: TCamera);
  6173. /**
  6174. * Add an input method to a camera
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. * @param input camera input method
  6177. */
  6178. add(input: ICameraInput<TCamera>): void;
  6179. /**
  6180. * Remove a specific input method from a camera
  6181. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6182. * @param inputToRemove camera input method
  6183. */
  6184. remove(inputToRemove: ICameraInput<TCamera>): void;
  6185. /**
  6186. * Remove a specific input type from a camera
  6187. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6188. * @param inputType the type of the input to remove
  6189. */
  6190. removeByType(inputType: string): void;
  6191. private _addCheckInputs;
  6192. /**
  6193. * Attach the input controls to the currently attached dom element to listen the events from.
  6194. * @param input Defines the input to attach
  6195. */
  6196. attachInput(input: ICameraInput<TCamera>): void;
  6197. /**
  6198. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6199. * @param element Defines the dom element to collect the events from
  6200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6201. */
  6202. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6203. /**
  6204. * Detach the current manager inputs controls from a specific dom element.
  6205. * @param element Defines the dom element to collect the events from
  6206. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6207. */
  6208. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6209. /**
  6210. * Rebuild the dynamic inputCheck function from the current list of
  6211. * defined inputs in the manager.
  6212. */
  6213. rebuildInputCheck(): void;
  6214. /**
  6215. * Remove all attached input methods from a camera
  6216. */
  6217. clear(): void;
  6218. /**
  6219. * Serialize the current input manager attached to a camera.
  6220. * This ensures than once parsed,
  6221. * the input associated to the camera will be identical to the current ones
  6222. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6223. */
  6224. serialize(serializedCamera: any): void;
  6225. /**
  6226. * Parses an input manager serialized JSON to restore the previous list of inputs
  6227. * and states associated to a camera.
  6228. * @param parsedCamera Defines the JSON to parse
  6229. */
  6230. parse(parsedCamera: any): void;
  6231. }
  6232. }
  6233. declare module "babylonjs/Meshes/buffer" {
  6234. import { Nullable, DataArray } from "babylonjs/types";
  6235. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6236. /**
  6237. * Class used to store data that will be store in GPU memory
  6238. */
  6239. export class Buffer {
  6240. private _engine;
  6241. private _buffer;
  6242. /** @hidden */
  6243. _data: Nullable<DataArray>;
  6244. private _updatable;
  6245. private _instanced;
  6246. private _divisor;
  6247. /**
  6248. * Gets the byte stride.
  6249. */
  6250. readonly byteStride: number;
  6251. /**
  6252. * Constructor
  6253. * @param engine the engine
  6254. * @param data the data to use for this buffer
  6255. * @param updatable whether the data is updatable
  6256. * @param stride the stride (optional)
  6257. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6258. * @param instanced whether the buffer is instanced (optional)
  6259. * @param useBytes set to true if the stride in in bytes (optional)
  6260. * @param divisor sets an optional divisor for instances (1 by default)
  6261. */
  6262. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6263. /**
  6264. * Create a new VertexBuffer based on the current buffer
  6265. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6266. * @param offset defines offset in the buffer (0 by default)
  6267. * @param size defines the size in floats of attributes (position is 3 for instance)
  6268. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6269. * @param instanced defines if the vertex buffer contains indexed data
  6270. * @param useBytes defines if the offset and stride are in bytes *
  6271. * @param divisor sets an optional divisor for instances (1 by default)
  6272. * @returns the new vertex buffer
  6273. */
  6274. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6275. /**
  6276. * Gets a boolean indicating if the Buffer is updatable?
  6277. * @returns true if the buffer is updatable
  6278. */
  6279. isUpdatable(): boolean;
  6280. /**
  6281. * Gets current buffer's data
  6282. * @returns a DataArray or null
  6283. */
  6284. getData(): Nullable<DataArray>;
  6285. /**
  6286. * Gets underlying native buffer
  6287. * @returns underlying native buffer
  6288. */
  6289. getBuffer(): Nullable<DataBuffer>;
  6290. /**
  6291. * Gets the stride in float32 units (i.e. byte stride / 4).
  6292. * May not be an integer if the byte stride is not divisible by 4.
  6293. * DEPRECATED. Use byteStride instead.
  6294. * @returns the stride in float32 units
  6295. */
  6296. getStrideSize(): number;
  6297. /**
  6298. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6299. * @param data defines the data to store
  6300. */
  6301. create(data?: Nullable<DataArray>): void;
  6302. /** @hidden */
  6303. _rebuild(): void;
  6304. /**
  6305. * Update current buffer data
  6306. * @param data defines the data to store
  6307. */
  6308. update(data: DataArray): void;
  6309. /**
  6310. * Updates the data directly.
  6311. * @param data the new data
  6312. * @param offset the new offset
  6313. * @param vertexCount the vertex count (optional)
  6314. * @param useBytes set to true if the offset is in bytes
  6315. */
  6316. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6317. /**
  6318. * Release all resources
  6319. */
  6320. dispose(): void;
  6321. }
  6322. /**
  6323. * Specialized buffer used to store vertex data
  6324. */
  6325. export class VertexBuffer {
  6326. /** @hidden */
  6327. _buffer: Buffer;
  6328. private _kind;
  6329. private _size;
  6330. private _ownsBuffer;
  6331. private _instanced;
  6332. private _instanceDivisor;
  6333. /**
  6334. * The byte type.
  6335. */
  6336. static readonly BYTE: number;
  6337. /**
  6338. * The unsigned byte type.
  6339. */
  6340. static readonly UNSIGNED_BYTE: number;
  6341. /**
  6342. * The short type.
  6343. */
  6344. static readonly SHORT: number;
  6345. /**
  6346. * The unsigned short type.
  6347. */
  6348. static readonly UNSIGNED_SHORT: number;
  6349. /**
  6350. * The integer type.
  6351. */
  6352. static readonly INT: number;
  6353. /**
  6354. * The unsigned integer type.
  6355. */
  6356. static readonly UNSIGNED_INT: number;
  6357. /**
  6358. * The float type.
  6359. */
  6360. static readonly FLOAT: number;
  6361. /**
  6362. * Gets or sets the instance divisor when in instanced mode
  6363. */
  6364. instanceDivisor: number;
  6365. /**
  6366. * Gets the byte stride.
  6367. */
  6368. readonly byteStride: number;
  6369. /**
  6370. * Gets the byte offset.
  6371. */
  6372. readonly byteOffset: number;
  6373. /**
  6374. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6375. */
  6376. readonly normalized: boolean;
  6377. /**
  6378. * Gets the data type of each component in the array.
  6379. */
  6380. readonly type: number;
  6381. /**
  6382. * Constructor
  6383. * @param engine the engine
  6384. * @param data the data to use for this vertex buffer
  6385. * @param kind the vertex buffer kind
  6386. * @param updatable whether the data is updatable
  6387. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6388. * @param stride the stride (optional)
  6389. * @param instanced whether the buffer is instanced (optional)
  6390. * @param offset the offset of the data (optional)
  6391. * @param size the number of components (optional)
  6392. * @param type the type of the component (optional)
  6393. * @param normalized whether the data contains normalized data (optional)
  6394. * @param useBytes set to true if stride and offset are in bytes (optional)
  6395. * @param divisor defines the instance divisor to use (1 by default)
  6396. */
  6397. 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);
  6398. /** @hidden */
  6399. _rebuild(): void;
  6400. /**
  6401. * Returns the kind of the VertexBuffer (string)
  6402. * @returns a string
  6403. */
  6404. getKind(): string;
  6405. /**
  6406. * Gets a boolean indicating if the VertexBuffer is updatable?
  6407. * @returns true if the buffer is updatable
  6408. */
  6409. isUpdatable(): boolean;
  6410. /**
  6411. * Gets current buffer's data
  6412. * @returns a DataArray or null
  6413. */
  6414. getData(): Nullable<DataArray>;
  6415. /**
  6416. * Gets underlying native buffer
  6417. * @returns underlying native buffer
  6418. */
  6419. getBuffer(): Nullable<DataBuffer>;
  6420. /**
  6421. * Gets the stride in float32 units (i.e. byte stride / 4).
  6422. * May not be an integer if the byte stride is not divisible by 4.
  6423. * DEPRECATED. Use byteStride instead.
  6424. * @returns the stride in float32 units
  6425. */
  6426. getStrideSize(): number;
  6427. /**
  6428. * Returns the offset as a multiple of the type byte length.
  6429. * DEPRECATED. Use byteOffset instead.
  6430. * @returns the offset in bytes
  6431. */
  6432. getOffset(): number;
  6433. /**
  6434. * Returns the number of components per vertex attribute (integer)
  6435. * @returns the size in float
  6436. */
  6437. getSize(): number;
  6438. /**
  6439. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6440. * @returns true if this buffer is instanced
  6441. */
  6442. getIsInstanced(): boolean;
  6443. /**
  6444. * Returns the instancing divisor, zero for non-instanced (integer).
  6445. * @returns a number
  6446. */
  6447. getInstanceDivisor(): number;
  6448. /**
  6449. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6450. * @param data defines the data to store
  6451. */
  6452. create(data?: DataArray): void;
  6453. /**
  6454. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6455. * This function will create a new buffer if the current one is not updatable
  6456. * @param data defines the data to store
  6457. */
  6458. update(data: DataArray): void;
  6459. /**
  6460. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6461. * Returns the directly updated WebGLBuffer.
  6462. * @param data the new data
  6463. * @param offset the new offset
  6464. * @param useBytes set to true if the offset is in bytes
  6465. */
  6466. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6467. /**
  6468. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6469. */
  6470. dispose(): void;
  6471. /**
  6472. * Enumerates each value of this vertex buffer as numbers.
  6473. * @param count the number of values to enumerate
  6474. * @param callback the callback function called for each value
  6475. */
  6476. forEach(count: number, callback: (value: number, index: number) => void): void;
  6477. /**
  6478. * Positions
  6479. */
  6480. static readonly PositionKind: string;
  6481. /**
  6482. * Normals
  6483. */
  6484. static readonly NormalKind: string;
  6485. /**
  6486. * Tangents
  6487. */
  6488. static readonly TangentKind: string;
  6489. /**
  6490. * Texture coordinates
  6491. */
  6492. static readonly UVKind: string;
  6493. /**
  6494. * Texture coordinates 2
  6495. */
  6496. static readonly UV2Kind: string;
  6497. /**
  6498. * Texture coordinates 3
  6499. */
  6500. static readonly UV3Kind: string;
  6501. /**
  6502. * Texture coordinates 4
  6503. */
  6504. static readonly UV4Kind: string;
  6505. /**
  6506. * Texture coordinates 5
  6507. */
  6508. static readonly UV5Kind: string;
  6509. /**
  6510. * Texture coordinates 6
  6511. */
  6512. static readonly UV6Kind: string;
  6513. /**
  6514. * Colors
  6515. */
  6516. static readonly ColorKind: string;
  6517. /**
  6518. * Matrix indices (for bones)
  6519. */
  6520. static readonly MatricesIndicesKind: string;
  6521. /**
  6522. * Matrix weights (for bones)
  6523. */
  6524. static readonly MatricesWeightsKind: string;
  6525. /**
  6526. * Additional matrix indices (for bones)
  6527. */
  6528. static readonly MatricesIndicesExtraKind: string;
  6529. /**
  6530. * Additional matrix weights (for bones)
  6531. */
  6532. static readonly MatricesWeightsExtraKind: string;
  6533. /**
  6534. * Deduces the stride given a kind.
  6535. * @param kind The kind string to deduce
  6536. * @returns The deduced stride
  6537. */
  6538. static DeduceStride(kind: string): number;
  6539. /**
  6540. * Gets the byte length of the given type.
  6541. * @param type the type
  6542. * @returns the number of bytes
  6543. */
  6544. static GetTypeByteLength(type: number): number;
  6545. /**
  6546. * Enumerates each value of the given parameters as numbers.
  6547. * @param data the data to enumerate
  6548. * @param byteOffset the byte offset of the data
  6549. * @param byteStride the byte stride of the data
  6550. * @param componentCount the number of components per element
  6551. * @param componentType the type of the component
  6552. * @param count the number of values to enumerate
  6553. * @param normalized whether the data is normalized
  6554. * @param callback the callback function called for each value
  6555. */
  6556. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6557. private static _GetFloatValue;
  6558. }
  6559. }
  6560. declare module "babylonjs/Collisions/intersectionInfo" {
  6561. import { Nullable } from "babylonjs/types";
  6562. /**
  6563. * @hidden
  6564. */
  6565. export class IntersectionInfo {
  6566. bu: Nullable<number>;
  6567. bv: Nullable<number>;
  6568. distance: number;
  6569. faceId: number;
  6570. subMeshId: number;
  6571. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6572. }
  6573. }
  6574. declare module "babylonjs/Maths/math.plane" {
  6575. import { DeepImmutable } from "babylonjs/types";
  6576. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6577. /**
  6578. * Represens a plane by the equation ax + by + cz + d = 0
  6579. */
  6580. export class Plane {
  6581. private static _TmpMatrix;
  6582. /**
  6583. * Normal of the plane (a,b,c)
  6584. */
  6585. normal: Vector3;
  6586. /**
  6587. * d component of the plane
  6588. */
  6589. d: number;
  6590. /**
  6591. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6592. * @param a a component of the plane
  6593. * @param b b component of the plane
  6594. * @param c c component of the plane
  6595. * @param d d component of the plane
  6596. */
  6597. constructor(a: number, b: number, c: number, d: number);
  6598. /**
  6599. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6600. */
  6601. asArray(): number[];
  6602. /**
  6603. * @returns a new plane copied from the current Plane.
  6604. */
  6605. clone(): Plane;
  6606. /**
  6607. * @returns the string "Plane".
  6608. */
  6609. getClassName(): string;
  6610. /**
  6611. * @returns the Plane hash code.
  6612. */
  6613. getHashCode(): number;
  6614. /**
  6615. * Normalize the current Plane in place.
  6616. * @returns the updated Plane.
  6617. */
  6618. normalize(): Plane;
  6619. /**
  6620. * Applies a transformation the plane and returns the result
  6621. * @param transformation the transformation matrix to be applied to the plane
  6622. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6623. */
  6624. transform(transformation: DeepImmutable<Matrix>): Plane;
  6625. /**
  6626. * Calcualtte the dot product between the point and the plane normal
  6627. * @param point point to calculate the dot product with
  6628. * @returns the dot product (float) of the point coordinates and the plane normal.
  6629. */
  6630. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6631. /**
  6632. * Updates the current Plane from the plane defined by the three given points.
  6633. * @param point1 one of the points used to contruct the plane
  6634. * @param point2 one of the points used to contruct the plane
  6635. * @param point3 one of the points used to contruct the plane
  6636. * @returns the updated Plane.
  6637. */
  6638. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6639. /**
  6640. * Checks if the plane is facing a given direction
  6641. * @param direction the direction to check if the plane is facing
  6642. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6643. * @returns True is the vector "direction" is the same side than the plane normal.
  6644. */
  6645. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6646. /**
  6647. * Calculates the distance to a point
  6648. * @param point point to calculate distance to
  6649. * @returns the signed distance (float) from the given point to the Plane.
  6650. */
  6651. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6652. /**
  6653. * Creates a plane from an array
  6654. * @param array the array to create a plane from
  6655. * @returns a new Plane from the given array.
  6656. */
  6657. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6658. /**
  6659. * Creates a plane from three points
  6660. * @param point1 point used to create the plane
  6661. * @param point2 point used to create the plane
  6662. * @param point3 point used to create the plane
  6663. * @returns a new Plane defined by the three given points.
  6664. */
  6665. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6666. /**
  6667. * Creates a plane from an origin point and a normal
  6668. * @param origin origin of the plane to be constructed
  6669. * @param normal normal of the plane to be constructed
  6670. * @returns a new Plane the normal vector to this plane at the given origin point.
  6671. * Note : the vector "normal" is updated because normalized.
  6672. */
  6673. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6674. /**
  6675. * Calculates the distance from a plane and a point
  6676. * @param origin origin of the plane to be constructed
  6677. * @param normal normal of the plane to be constructed
  6678. * @param point point to calculate distance to
  6679. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6680. */
  6681. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6682. }
  6683. }
  6684. declare module "babylonjs/Culling/boundingSphere" {
  6685. import { DeepImmutable } from "babylonjs/types";
  6686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6687. import { Plane } from "babylonjs/Maths/math.plane";
  6688. /**
  6689. * Class used to store bounding sphere information
  6690. */
  6691. export class BoundingSphere {
  6692. /**
  6693. * Gets the center of the bounding sphere in local space
  6694. */
  6695. readonly center: Vector3;
  6696. /**
  6697. * Radius of the bounding sphere in local space
  6698. */
  6699. radius: number;
  6700. /**
  6701. * Gets the center of the bounding sphere in world space
  6702. */
  6703. readonly centerWorld: Vector3;
  6704. /**
  6705. * Radius of the bounding sphere in world space
  6706. */
  6707. radiusWorld: number;
  6708. /**
  6709. * Gets the minimum vector in local space
  6710. */
  6711. readonly minimum: Vector3;
  6712. /**
  6713. * Gets the maximum vector in local space
  6714. */
  6715. readonly maximum: Vector3;
  6716. private _worldMatrix;
  6717. private static readonly TmpVector3;
  6718. /**
  6719. * Creates a new bounding sphere
  6720. * @param min defines the minimum vector (in local space)
  6721. * @param max defines the maximum vector (in local space)
  6722. * @param worldMatrix defines the new world matrix
  6723. */
  6724. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6725. /**
  6726. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6727. * @param min defines the new minimum vector (in local space)
  6728. * @param max defines the new maximum vector (in local space)
  6729. * @param worldMatrix defines the new world matrix
  6730. */
  6731. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6732. /**
  6733. * Scale the current bounding sphere by applying a scale factor
  6734. * @param factor defines the scale factor to apply
  6735. * @returns the current bounding box
  6736. */
  6737. scale(factor: number): BoundingSphere;
  6738. /**
  6739. * Gets the world matrix of the bounding box
  6740. * @returns a matrix
  6741. */
  6742. getWorldMatrix(): DeepImmutable<Matrix>;
  6743. /** @hidden */
  6744. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6745. /**
  6746. * Tests if the bounding sphere is intersecting the frustum planes
  6747. * @param frustumPlanes defines the frustum planes to test
  6748. * @returns true if there is an intersection
  6749. */
  6750. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6751. /**
  6752. * Tests if the bounding sphere center is in between the frustum planes.
  6753. * Used for optimistic fast inclusion.
  6754. * @param frustumPlanes defines the frustum planes to test
  6755. * @returns true if the sphere center is in between the frustum planes
  6756. */
  6757. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6758. /**
  6759. * Tests if a point is inside the bounding sphere
  6760. * @param point defines the point to test
  6761. * @returns true if the point is inside the bounding sphere
  6762. */
  6763. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6764. /**
  6765. * Checks if two sphere intersct
  6766. * @param sphere0 sphere 0
  6767. * @param sphere1 sphere 1
  6768. * @returns true if the speres intersect
  6769. */
  6770. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6771. }
  6772. }
  6773. declare module "babylonjs/Culling/boundingBox" {
  6774. import { DeepImmutable } from "babylonjs/types";
  6775. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6776. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6777. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6778. import { Plane } from "babylonjs/Maths/math.plane";
  6779. /**
  6780. * Class used to store bounding box information
  6781. */
  6782. export class BoundingBox implements ICullable {
  6783. /**
  6784. * Gets the 8 vectors representing the bounding box in local space
  6785. */
  6786. readonly vectors: Vector3[];
  6787. /**
  6788. * Gets the center of the bounding box in local space
  6789. */
  6790. readonly center: Vector3;
  6791. /**
  6792. * Gets the center of the bounding box in world space
  6793. */
  6794. readonly centerWorld: Vector3;
  6795. /**
  6796. * Gets the extend size in local space
  6797. */
  6798. readonly extendSize: Vector3;
  6799. /**
  6800. * Gets the extend size in world space
  6801. */
  6802. readonly extendSizeWorld: Vector3;
  6803. /**
  6804. * Gets the OBB (object bounding box) directions
  6805. */
  6806. readonly directions: Vector3[];
  6807. /**
  6808. * Gets the 8 vectors representing the bounding box in world space
  6809. */
  6810. readonly vectorsWorld: Vector3[];
  6811. /**
  6812. * Gets the minimum vector in world space
  6813. */
  6814. readonly minimumWorld: Vector3;
  6815. /**
  6816. * Gets the maximum vector in world space
  6817. */
  6818. readonly maximumWorld: Vector3;
  6819. /**
  6820. * Gets the minimum vector in local space
  6821. */
  6822. readonly minimum: Vector3;
  6823. /**
  6824. * Gets the maximum vector in local space
  6825. */
  6826. readonly maximum: Vector3;
  6827. private _worldMatrix;
  6828. private static readonly TmpVector3;
  6829. /**
  6830. * @hidden
  6831. */
  6832. _tag: number;
  6833. /**
  6834. * Creates a new bounding box
  6835. * @param min defines the minimum vector (in local space)
  6836. * @param max defines the maximum vector (in local space)
  6837. * @param worldMatrix defines the new world matrix
  6838. */
  6839. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6840. /**
  6841. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6842. * @param min defines the new minimum vector (in local space)
  6843. * @param max defines the new maximum vector (in local space)
  6844. * @param worldMatrix defines the new world matrix
  6845. */
  6846. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6847. /**
  6848. * Scale the current bounding box by applying a scale factor
  6849. * @param factor defines the scale factor to apply
  6850. * @returns the current bounding box
  6851. */
  6852. scale(factor: number): BoundingBox;
  6853. /**
  6854. * Gets the world matrix of the bounding box
  6855. * @returns a matrix
  6856. */
  6857. getWorldMatrix(): DeepImmutable<Matrix>;
  6858. /** @hidden */
  6859. _update(world: DeepImmutable<Matrix>): void;
  6860. /**
  6861. * Tests if the bounding box is intersecting the frustum planes
  6862. * @param frustumPlanes defines the frustum planes to test
  6863. * @returns true if there is an intersection
  6864. */
  6865. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6866. /**
  6867. * Tests if the bounding box is entirely inside the frustum planes
  6868. * @param frustumPlanes defines the frustum planes to test
  6869. * @returns true if there is an inclusion
  6870. */
  6871. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6872. /**
  6873. * Tests if a point is inside the bounding box
  6874. * @param point defines the point to test
  6875. * @returns true if the point is inside the bounding box
  6876. */
  6877. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6878. /**
  6879. * Tests if the bounding box intersects with a bounding sphere
  6880. * @param sphere defines the sphere to test
  6881. * @returns true if there is an intersection
  6882. */
  6883. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6884. /**
  6885. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6886. * @param min defines the min vector to use
  6887. * @param max defines the max vector to use
  6888. * @returns true if there is an intersection
  6889. */
  6890. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6891. /**
  6892. * Tests if two bounding boxes are intersections
  6893. * @param box0 defines the first box to test
  6894. * @param box1 defines the second box to test
  6895. * @returns true if there is an intersection
  6896. */
  6897. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6898. /**
  6899. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6900. * @param minPoint defines the minimum vector of the bounding box
  6901. * @param maxPoint defines the maximum vector of the bounding box
  6902. * @param sphereCenter defines the sphere center
  6903. * @param sphereRadius defines the sphere radius
  6904. * @returns true if there is an intersection
  6905. */
  6906. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6907. /**
  6908. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6909. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6910. * @param frustumPlanes defines the frustum planes to test
  6911. * @return true if there is an inclusion
  6912. */
  6913. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6914. /**
  6915. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6916. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6917. * @param frustumPlanes defines the frustum planes to test
  6918. * @return true if there is an intersection
  6919. */
  6920. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6921. }
  6922. }
  6923. declare module "babylonjs/Collisions/collider" {
  6924. import { Nullable, IndicesArray } from "babylonjs/types";
  6925. import { Vector3 } from "babylonjs/Maths/math.vector";
  6926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6927. import { Plane } from "babylonjs/Maths/math.plane";
  6928. /** @hidden */
  6929. export class Collider {
  6930. /** Define if a collision was found */
  6931. collisionFound: boolean;
  6932. /**
  6933. * Define last intersection point in local space
  6934. */
  6935. intersectionPoint: Vector3;
  6936. /**
  6937. * Define last collided mesh
  6938. */
  6939. collidedMesh: Nullable<AbstractMesh>;
  6940. private _collisionPoint;
  6941. private _planeIntersectionPoint;
  6942. private _tempVector;
  6943. private _tempVector2;
  6944. private _tempVector3;
  6945. private _tempVector4;
  6946. private _edge;
  6947. private _baseToVertex;
  6948. private _destinationPoint;
  6949. private _slidePlaneNormal;
  6950. private _displacementVector;
  6951. /** @hidden */
  6952. _radius: Vector3;
  6953. /** @hidden */
  6954. _retry: number;
  6955. private _velocity;
  6956. private _basePoint;
  6957. private _epsilon;
  6958. /** @hidden */
  6959. _velocityWorldLength: number;
  6960. /** @hidden */
  6961. _basePointWorld: Vector3;
  6962. private _velocityWorld;
  6963. private _normalizedVelocity;
  6964. /** @hidden */
  6965. _initialVelocity: Vector3;
  6966. /** @hidden */
  6967. _initialPosition: Vector3;
  6968. private _nearestDistance;
  6969. private _collisionMask;
  6970. collisionMask: number;
  6971. /**
  6972. * Gets the plane normal used to compute the sliding response (in local space)
  6973. */
  6974. readonly slidePlaneNormal: Vector3;
  6975. /** @hidden */
  6976. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6977. /** @hidden */
  6978. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6979. /** @hidden */
  6980. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6981. /** @hidden */
  6982. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6983. /** @hidden */
  6984. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _getResponse(pos: Vector3, vel: Vector3): void;
  6987. }
  6988. }
  6989. declare module "babylonjs/Culling/boundingInfo" {
  6990. import { DeepImmutable } from "babylonjs/types";
  6991. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6992. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6993. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6994. import { Plane } from "babylonjs/Maths/math.plane";
  6995. import { Collider } from "babylonjs/Collisions/collider";
  6996. /**
  6997. * Interface for cullable objects
  6998. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6999. */
  7000. export interface ICullable {
  7001. /**
  7002. * Checks if the object or part of the object is in the frustum
  7003. * @param frustumPlanes Camera near/planes
  7004. * @returns true if the object is in frustum otherwise false
  7005. */
  7006. isInFrustum(frustumPlanes: Plane[]): boolean;
  7007. /**
  7008. * Checks if a cullable object (mesh...) is in the camera frustum
  7009. * Unlike isInFrustum this cheks the full bounding box
  7010. * @param frustumPlanes Camera near/planes
  7011. * @returns true if the object is in frustum otherwise false
  7012. */
  7013. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7014. }
  7015. /**
  7016. * Info for a bounding data of a mesh
  7017. */
  7018. export class BoundingInfo implements ICullable {
  7019. /**
  7020. * Bounding box for the mesh
  7021. */
  7022. readonly boundingBox: BoundingBox;
  7023. /**
  7024. * Bounding sphere for the mesh
  7025. */
  7026. readonly boundingSphere: BoundingSphere;
  7027. private _isLocked;
  7028. private static readonly TmpVector3;
  7029. /**
  7030. * Constructs bounding info
  7031. * @param minimum min vector of the bounding box/sphere
  7032. * @param maximum max vector of the bounding box/sphere
  7033. * @param worldMatrix defines the new world matrix
  7034. */
  7035. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7036. /**
  7037. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7038. * @param min defines the new minimum vector (in local space)
  7039. * @param max defines the new maximum vector (in local space)
  7040. * @param worldMatrix defines the new world matrix
  7041. */
  7042. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * min vector of the bounding box/sphere
  7045. */
  7046. readonly minimum: Vector3;
  7047. /**
  7048. * max vector of the bounding box/sphere
  7049. */
  7050. readonly maximum: Vector3;
  7051. /**
  7052. * If the info is locked and won't be updated to avoid perf overhead
  7053. */
  7054. isLocked: boolean;
  7055. /**
  7056. * Updates the bounding sphere and box
  7057. * @param world world matrix to be used to update
  7058. */
  7059. update(world: DeepImmutable<Matrix>): void;
  7060. /**
  7061. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7062. * @param center New center of the bounding info
  7063. * @param extend New extend of the bounding info
  7064. * @returns the current bounding info
  7065. */
  7066. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7067. /**
  7068. * Scale the current bounding info by applying a scale factor
  7069. * @param factor defines the scale factor to apply
  7070. * @returns the current bounding info
  7071. */
  7072. scale(factor: number): BoundingInfo;
  7073. /**
  7074. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7075. * @param frustumPlanes defines the frustum to test
  7076. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7077. * @returns true if the bounding info is in the frustum planes
  7078. */
  7079. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7080. /**
  7081. * Gets the world distance between the min and max points of the bounding box
  7082. */
  7083. readonly diagonalLength: number;
  7084. /**
  7085. * Checks if a cullable object (mesh...) is in the camera frustum
  7086. * Unlike isInFrustum this cheks the full bounding box
  7087. * @param frustumPlanes Camera near/planes
  7088. * @returns true if the object is in frustum otherwise false
  7089. */
  7090. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7091. /** @hidden */
  7092. _checkCollision(collider: Collider): boolean;
  7093. /**
  7094. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7095. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7096. * @param point the point to check intersection with
  7097. * @returns if the point intersects
  7098. */
  7099. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7100. /**
  7101. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7102. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7103. * @param boundingInfo the bounding info to check intersection with
  7104. * @param precise if the intersection should be done using OBB
  7105. * @returns if the bounding info intersects
  7106. */
  7107. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7108. }
  7109. }
  7110. declare module "babylonjs/Maths/math.functions" {
  7111. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7112. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7113. /**
  7114. * Extracts minimum and maximum values from a list of indexed positions
  7115. * @param positions defines the positions to use
  7116. * @param indices defines the indices to the positions
  7117. * @param indexStart defines the start index
  7118. * @param indexCount defines the end index
  7119. * @param bias defines bias value to add to the result
  7120. * @return minimum and maximum values
  7121. */
  7122. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7123. minimum: Vector3;
  7124. maximum: Vector3;
  7125. };
  7126. /**
  7127. * Extracts minimum and maximum values from a list of positions
  7128. * @param positions defines the positions to use
  7129. * @param start defines the start index in the positions array
  7130. * @param count defines the number of positions to handle
  7131. * @param bias defines bias value to add to the result
  7132. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7133. * @return minimum and maximum values
  7134. */
  7135. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7136. minimum: Vector3;
  7137. maximum: Vector3;
  7138. };
  7139. }
  7140. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7141. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7142. /** @hidden */
  7143. export class WebGLDataBuffer extends DataBuffer {
  7144. private _buffer;
  7145. constructor(resource: WebGLBuffer);
  7146. readonly underlyingResource: any;
  7147. }
  7148. }
  7149. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7150. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7151. import { Nullable } from "babylonjs/types";
  7152. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7153. /** @hidden */
  7154. export class WebGLPipelineContext implements IPipelineContext {
  7155. engine: ThinEngine;
  7156. program: Nullable<WebGLProgram>;
  7157. context?: WebGLRenderingContext;
  7158. vertexShader?: WebGLShader;
  7159. fragmentShader?: WebGLShader;
  7160. isParallelCompiled: boolean;
  7161. onCompiled?: () => void;
  7162. transformFeedback?: WebGLTransformFeedback | null;
  7163. readonly isAsync: boolean;
  7164. readonly isReady: boolean;
  7165. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7166. }
  7167. }
  7168. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7169. import { FloatArray, Nullable } from "babylonjs/types";
  7170. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7171. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7172. module "babylonjs/Engines/thinEngine" {
  7173. interface ThinEngine {
  7174. /**
  7175. * Create an uniform buffer
  7176. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7177. * @param elements defines the content of the uniform buffer
  7178. * @returns the webGL uniform buffer
  7179. */
  7180. createUniformBuffer(elements: FloatArray): DataBuffer;
  7181. /**
  7182. * Create a dynamic uniform buffer
  7183. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7184. * @param elements defines the content of the uniform buffer
  7185. * @returns the webGL uniform buffer
  7186. */
  7187. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7188. /**
  7189. * Update an existing uniform buffer
  7190. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7191. * @param uniformBuffer defines the target uniform buffer
  7192. * @param elements defines the content to update
  7193. * @param offset defines the offset in the uniform buffer where update should start
  7194. * @param count defines the size of the data to update
  7195. */
  7196. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7197. /**
  7198. * Bind an uniform buffer to the current webGL context
  7199. * @param buffer defines the buffer to bind
  7200. */
  7201. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7202. /**
  7203. * Bind a buffer to the current webGL context at a given location
  7204. * @param buffer defines the buffer to bind
  7205. * @param location defines the index where to bind the buffer
  7206. */
  7207. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7208. /**
  7209. * Bind a specific block at a given index in a specific shader program
  7210. * @param pipelineContext defines the pipeline context to use
  7211. * @param blockName defines the block name
  7212. * @param index defines the index where to bind the block
  7213. */
  7214. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7215. }
  7216. }
  7217. }
  7218. declare module "babylonjs/Materials/uniformBuffer" {
  7219. import { Nullable, FloatArray } from "babylonjs/types";
  7220. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7221. import { Engine } from "babylonjs/Engines/engine";
  7222. import { Effect } from "babylonjs/Materials/effect";
  7223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7224. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7225. import { Color3 } from "babylonjs/Maths/math.color";
  7226. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7227. /**
  7228. * Uniform buffer objects.
  7229. *
  7230. * Handles blocks of uniform on the GPU.
  7231. *
  7232. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7233. *
  7234. * For more information, please refer to :
  7235. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7236. */
  7237. export class UniformBuffer {
  7238. private _engine;
  7239. private _buffer;
  7240. private _data;
  7241. private _bufferData;
  7242. private _dynamic?;
  7243. private _uniformLocations;
  7244. private _uniformSizes;
  7245. private _uniformLocationPointer;
  7246. private _needSync;
  7247. private _noUBO;
  7248. private _currentEffect;
  7249. /** @hidden */
  7250. _alreadyBound: boolean;
  7251. private static _MAX_UNIFORM_SIZE;
  7252. private static _tempBuffer;
  7253. /**
  7254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7255. * This is dynamic to allow compat with webgl 1 and 2.
  7256. * You will need to pass the name of the uniform as well as the value.
  7257. */
  7258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7259. /**
  7260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7261. * This is dynamic to allow compat with webgl 1 and 2.
  7262. * You will need to pass the name of the uniform as well as the value.
  7263. */
  7264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7265. /**
  7266. * Lambda to Update a single float in a uniform buffer.
  7267. * This is dynamic to allow compat with webgl 1 and 2.
  7268. * You will need to pass the name of the uniform as well as the value.
  7269. */
  7270. updateFloat: (name: string, x: number) => void;
  7271. /**
  7272. * Lambda to Update a vec2 of float in a uniform buffer.
  7273. * This is dynamic to allow compat with webgl 1 and 2.
  7274. * You will need to pass the name of the uniform as well as the value.
  7275. */
  7276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7277. /**
  7278. * Lambda to Update a vec3 of float in a uniform buffer.
  7279. * This is dynamic to allow compat with webgl 1 and 2.
  7280. * You will need to pass the name of the uniform as well as the value.
  7281. */
  7282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7283. /**
  7284. * Lambda to Update a vec4 of float in a uniform buffer.
  7285. * This is dynamic to allow compat with webgl 1 and 2.
  7286. * You will need to pass the name of the uniform as well as the value.
  7287. */
  7288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7289. /**
  7290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7291. * This is dynamic to allow compat with webgl 1 and 2.
  7292. * You will need to pass the name of the uniform as well as the value.
  7293. */
  7294. updateMatrix: (name: string, mat: Matrix) => void;
  7295. /**
  7296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7297. * This is dynamic to allow compat with webgl 1 and 2.
  7298. * You will need to pass the name of the uniform as well as the value.
  7299. */
  7300. updateVector3: (name: string, vector: Vector3) => void;
  7301. /**
  7302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7303. * This is dynamic to allow compat with webgl 1 and 2.
  7304. * You will need to pass the name of the uniform as well as the value.
  7305. */
  7306. updateVector4: (name: string, vector: Vector4) => void;
  7307. /**
  7308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7309. * This is dynamic to allow compat with webgl 1 and 2.
  7310. * You will need to pass the name of the uniform as well as the value.
  7311. */
  7312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7313. /**
  7314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7319. /**
  7320. * Instantiates a new Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. * @param engine Define the engine the buffer is associated with
  7329. * @param data Define the data contained in the buffer
  7330. * @param dynamic Define if the buffer is updatable
  7331. */
  7332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7333. /**
  7334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7335. * or just falling back on setUniformXXX calls.
  7336. */
  7337. readonly useUbo: boolean;
  7338. /**
  7339. * Indicates if the WebGL underlying uniform buffer is in sync
  7340. * with the javascript cache data.
  7341. */
  7342. readonly isSync: boolean;
  7343. /**
  7344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7345. * Also, a dynamic UniformBuffer will disable cache verification and always
  7346. * update the underlying WebGL uniform buffer to the GPU.
  7347. * @returns if Dynamic, otherwise false
  7348. */
  7349. isDynamic(): boolean;
  7350. /**
  7351. * The data cache on JS side.
  7352. * @returns the underlying data as a float array
  7353. */
  7354. getData(): Float32Array;
  7355. /**
  7356. * The underlying WebGL Uniform buffer.
  7357. * @returns the webgl buffer
  7358. */
  7359. getBuffer(): Nullable<DataBuffer>;
  7360. /**
  7361. * std140 layout specifies how to align data within an UBO structure.
  7362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7363. * for specs.
  7364. */
  7365. private _fillAlignment;
  7366. /**
  7367. * Adds an uniform in the buffer.
  7368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7369. * for the layout to be correct !
  7370. * @param name Name of the uniform, as used in the uniform block in the shader.
  7371. * @param size Data size, or data directly.
  7372. */
  7373. addUniform(name: string, size: number | number[]): void;
  7374. /**
  7375. * Adds a Matrix 4x4 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param mat A 4x4 matrix.
  7378. */
  7379. addMatrix(name: string, mat: Matrix): void;
  7380. /**
  7381. * Adds a vec2 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param x Define the x component value of the vec2
  7384. * @param y Define the y component value of the vec2
  7385. */
  7386. addFloat2(name: string, x: number, y: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param x Define the x component value of the vec3
  7391. * @param y Define the y component value of the vec3
  7392. * @param z Define the z component value of the vec3
  7393. */
  7394. addFloat3(name: string, x: number, y: number, z: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param color Define the vec3 from a Color
  7399. */
  7400. addColor3(name: string, color: Color3): void;
  7401. /**
  7402. * Adds a vec4 to the uniform buffer.
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param color Define the rgb components from a Color
  7405. * @param alpha Define the a component of the vec4
  7406. */
  7407. addColor4(name: string, color: Color3, alpha: number): void;
  7408. /**
  7409. * Adds a vec3 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param vector Define the vec3 components from a Vector
  7412. */
  7413. addVector3(name: string, vector: Vector3): void;
  7414. /**
  7415. * Adds a Matrix 3x3 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. */
  7418. addMatrix3x3(name: string): void;
  7419. /**
  7420. * Adds a Matrix 2x2 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. */
  7423. addMatrix2x2(name: string): void;
  7424. /**
  7425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7426. */
  7427. create(): void;
  7428. /** @hidden */
  7429. _rebuild(): void;
  7430. /**
  7431. * Updates the WebGL Uniform Buffer on the GPU.
  7432. * If the `dynamic` flag is set to true, no cache comparison is done.
  7433. * Otherwise, the buffer will be updated only if the cache differs.
  7434. */
  7435. update(): void;
  7436. /**
  7437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7439. * @param data Define the flattened data
  7440. * @param size Define the size of the data.
  7441. */
  7442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7443. private _valueCache;
  7444. private _cacheMatrix;
  7445. private _updateMatrix3x3ForUniform;
  7446. private _updateMatrix3x3ForEffect;
  7447. private _updateMatrix2x2ForEffect;
  7448. private _updateMatrix2x2ForUniform;
  7449. private _updateFloatForEffect;
  7450. private _updateFloatForUniform;
  7451. private _updateFloat2ForEffect;
  7452. private _updateFloat2ForUniform;
  7453. private _updateFloat3ForEffect;
  7454. private _updateFloat3ForUniform;
  7455. private _updateFloat4ForEffect;
  7456. private _updateFloat4ForUniform;
  7457. private _updateMatrixForEffect;
  7458. private _updateMatrixForUniform;
  7459. private _updateVector3ForEffect;
  7460. private _updateVector3ForUniform;
  7461. private _updateVector4ForEffect;
  7462. private _updateVector4ForUniform;
  7463. private _updateColor3ForEffect;
  7464. private _updateColor3ForUniform;
  7465. private _updateColor4ForEffect;
  7466. private _updateColor4ForUniform;
  7467. /**
  7468. * Sets a sampler uniform on the effect.
  7469. * @param name Define the name of the sampler.
  7470. * @param texture Define the texture to set in the sampler
  7471. */
  7472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7473. /**
  7474. * Directly updates the value of the uniform in the cache AND on the GPU.
  7475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7476. * @param data Define the flattened data
  7477. */
  7478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7479. /**
  7480. * Binds this uniform buffer to an effect.
  7481. * @param effect Define the effect to bind the buffer to
  7482. * @param name Name of the uniform block in the shader.
  7483. */
  7484. bindToEffect(effect: Effect, name: string): void;
  7485. /**
  7486. * Disposes the uniform buffer.
  7487. */
  7488. dispose(): void;
  7489. }
  7490. }
  7491. declare module "babylonjs/Misc/iInspectable" {
  7492. /**
  7493. * Enum that determines the text-wrapping mode to use.
  7494. */
  7495. export enum InspectableType {
  7496. /**
  7497. * Checkbox for booleans
  7498. */
  7499. Checkbox = 0,
  7500. /**
  7501. * Sliders for numbers
  7502. */
  7503. Slider = 1,
  7504. /**
  7505. * Vector3
  7506. */
  7507. Vector3 = 2,
  7508. /**
  7509. * Quaternions
  7510. */
  7511. Quaternion = 3,
  7512. /**
  7513. * Color3
  7514. */
  7515. Color3 = 4,
  7516. /**
  7517. * String
  7518. */
  7519. String = 5
  7520. }
  7521. /**
  7522. * Interface used to define custom inspectable properties.
  7523. * This interface is used by the inspector to display custom property grids
  7524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7525. */
  7526. export interface IInspectable {
  7527. /**
  7528. * Gets the label to display
  7529. */
  7530. label: string;
  7531. /**
  7532. * Gets the name of the property to edit
  7533. */
  7534. propertyName: string;
  7535. /**
  7536. * Gets the type of the editor to use
  7537. */
  7538. type: InspectableType;
  7539. /**
  7540. * Gets the minimum value of the property when using in "slider" mode
  7541. */
  7542. min?: number;
  7543. /**
  7544. * Gets the maximum value of the property when using in "slider" mode
  7545. */
  7546. max?: number;
  7547. /**
  7548. * Gets the setp to use when using in "slider" mode
  7549. */
  7550. step?: number;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/timingTools" {
  7554. /**
  7555. * Class used to provide helper for timing
  7556. */
  7557. export class TimingTools {
  7558. /**
  7559. * Polyfill for setImmediate
  7560. * @param action defines the action to execute after the current execution block
  7561. */
  7562. static SetImmediate(action: () => void): void;
  7563. }
  7564. }
  7565. declare module "babylonjs/Misc/instantiationTools" {
  7566. /**
  7567. * Class used to enable instatition of objects by class name
  7568. */
  7569. export class InstantiationTools {
  7570. /**
  7571. * Use this object to register external classes like custom textures or material
  7572. * to allow the laoders to instantiate them
  7573. */
  7574. static RegisteredExternalClasses: {
  7575. [key: string]: Object;
  7576. };
  7577. /**
  7578. * Tries to instantiate a new object from a given class name
  7579. * @param className defines the class name to instantiate
  7580. * @returns the new object or null if the system was not able to do the instantiation
  7581. */
  7582. static Instantiate(className: string): any;
  7583. }
  7584. }
  7585. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7586. /**
  7587. * Define options used to create a depth texture
  7588. */
  7589. export class DepthTextureCreationOptions {
  7590. /** Specifies whether or not a stencil should be allocated in the texture */
  7591. generateStencil?: boolean;
  7592. /** Specifies whether or not bilinear filtering is enable on the texture */
  7593. bilinearFiltering?: boolean;
  7594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7595. comparisonFunction?: number;
  7596. /** Specifies if the created texture is a cube texture */
  7597. isCube?: boolean;
  7598. }
  7599. }
  7600. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7601. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7602. import { Nullable } from "babylonjs/types";
  7603. import { Scene } from "babylonjs/scene";
  7604. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7605. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7606. module "babylonjs/Engines/thinEngine" {
  7607. interface ThinEngine {
  7608. /**
  7609. * Creates a depth stencil cube texture.
  7610. * This is only available in WebGL 2.
  7611. * @param size The size of face edge in the cube texture.
  7612. * @param options The options defining the cube texture.
  7613. * @returns The cube texture
  7614. */
  7615. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7616. /**
  7617. * Creates a cube texture
  7618. * @param rootUrl defines the url where the files to load is located
  7619. * @param scene defines the current scene
  7620. * @param files defines the list of files to load (1 per face)
  7621. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7622. * @param onLoad defines an optional callback raised when the texture is loaded
  7623. * @param onError defines an optional callback raised if there is an issue to load the texture
  7624. * @param format defines the format of the data
  7625. * @param forcedExtension defines the extension to use to pick the right loader
  7626. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7630. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7631. * @returns the cube texture as an InternalTexture
  7632. */
  7633. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7634. /**
  7635. * Creates a cube texture
  7636. * @param rootUrl defines the url where the files to load is located
  7637. * @param scene defines the current scene
  7638. * @param files defines the list of files to load (1 per face)
  7639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7640. * @param onLoad defines an optional callback raised when the texture is loaded
  7641. * @param onError defines an optional callback raised if there is an issue to load the texture
  7642. * @param format defines the format of the data
  7643. * @param forcedExtension defines the extension to use to pick the right loader
  7644. * @returns the cube texture as an InternalTexture
  7645. */
  7646. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7647. /**
  7648. * Creates a cube texture
  7649. * @param rootUrl defines the url where the files to load is located
  7650. * @param scene defines the current scene
  7651. * @param files defines the list of files to load (1 per face)
  7652. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7653. * @param onLoad defines an optional callback raised when the texture is loaded
  7654. * @param onError defines an optional callback raised if there is an issue to load the texture
  7655. * @param format defines the format of the data
  7656. * @param forcedExtension defines the extension to use to pick the right loader
  7657. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7660. * @returns the cube texture as an InternalTexture
  7661. */
  7662. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7663. /** @hidden */
  7664. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7665. /** @hidden */
  7666. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7669. /** @hidden */
  7670. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7671. /**
  7672. * @hidden
  7673. */
  7674. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7675. }
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7679. import { Nullable } from "babylonjs/types";
  7680. import { Scene } from "babylonjs/scene";
  7681. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7682. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7683. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7684. /**
  7685. * Class for creating a cube texture
  7686. */
  7687. export class CubeTexture extends BaseTexture {
  7688. private _delayedOnLoad;
  7689. /**
  7690. * The url of the texture
  7691. */
  7692. url: string;
  7693. /**
  7694. * Gets or sets the center of the bounding box associated with the cube texture.
  7695. * It must define where the camera used to render the texture was set
  7696. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7697. */
  7698. boundingBoxPosition: Vector3;
  7699. private _boundingBoxSize;
  7700. /**
  7701. * Gets or sets the size of the bounding box associated with the cube texture
  7702. * When defined, the cubemap will switch to local mode
  7703. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7704. * @example https://www.babylonjs-playground.com/#RNASML
  7705. */
  7706. /**
  7707. * Returns the bounding box size
  7708. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7709. */
  7710. boundingBoxSize: Vector3;
  7711. protected _rotationY: number;
  7712. /**
  7713. * Sets texture matrix rotation angle around Y axis in radians.
  7714. */
  7715. /**
  7716. * Gets texture matrix rotation angle around Y axis radians.
  7717. */
  7718. rotationY: number;
  7719. /**
  7720. * Are mip maps generated for this texture or not.
  7721. */
  7722. readonly noMipmap: boolean;
  7723. private _noMipmap;
  7724. private _files;
  7725. protected _forcedExtension: Nullable<string>;
  7726. private _extensions;
  7727. private _textureMatrix;
  7728. private _format;
  7729. private _createPolynomials;
  7730. /** @hidden */
  7731. _prefiltered: boolean;
  7732. /**
  7733. * Creates a cube texture from an array of image urls
  7734. * @param files defines an array of image urls
  7735. * @param scene defines the hosting scene
  7736. * @param noMipmap specifies if mip maps are not used
  7737. * @returns a cube texture
  7738. */
  7739. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7740. /**
  7741. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7742. * @param url defines the url of the prefiltered texture
  7743. * @param scene defines the scene the texture is attached to
  7744. * @param forcedExtension defines the extension of the file if different from the url
  7745. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7746. * @return the prefiltered texture
  7747. */
  7748. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7749. /**
  7750. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7751. * as prefiltered data.
  7752. * @param rootUrl defines the url of the texture or the root name of the six images
  7753. * @param scene defines the scene the texture is attached to
  7754. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7755. * @param noMipmap defines if mipmaps should be created or not
  7756. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7757. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7758. * @param onError defines a callback triggered in case of error during load
  7759. * @param format defines the internal format to use for the texture once loaded
  7760. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7761. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7762. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @return the cube texture
  7766. */
  7767. 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);
  7768. /**
  7769. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7770. */
  7771. readonly isPrefiltered: boolean;
  7772. /**
  7773. * Get the current class name of the texture useful for serialization or dynamic coding.
  7774. * @returns "CubeTexture"
  7775. */
  7776. getClassName(): string;
  7777. /**
  7778. * Update the url (and optional buffer) of this texture if url was null during construction.
  7779. * @param url the url of the texture
  7780. * @param forcedExtension defines the extension to use
  7781. * @param onLoad callback called when the texture is loaded (defaults to null)
  7782. */
  7783. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7784. /**
  7785. * Delays loading of the cube texture
  7786. * @param forcedExtension defines the extension to use
  7787. */
  7788. delayLoad(forcedExtension?: string): void;
  7789. /**
  7790. * Returns the reflection texture matrix
  7791. * @returns the reflection texture matrix
  7792. */
  7793. getReflectionTextureMatrix(): Matrix;
  7794. /**
  7795. * Sets the reflection texture matrix
  7796. * @param value Reflection texture matrix
  7797. */
  7798. setReflectionTextureMatrix(value: Matrix): void;
  7799. /**
  7800. * Parses text to create a cube texture
  7801. * @param parsedTexture define the serialized text to read from
  7802. * @param scene defines the hosting scene
  7803. * @param rootUrl defines the root url of the cube texture
  7804. * @returns a cube texture
  7805. */
  7806. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7807. /**
  7808. * Makes a clone, or deep copy, of the cube texture
  7809. * @returns a new cube texture
  7810. */
  7811. clone(): CubeTexture;
  7812. }
  7813. }
  7814. declare module "babylonjs/Materials/materialDefines" {
  7815. /**
  7816. * Manages the defines for the Material
  7817. */
  7818. export class MaterialDefines {
  7819. /** @hidden */
  7820. protected _keys: string[];
  7821. private _isDirty;
  7822. /** @hidden */
  7823. _renderId: number;
  7824. /** @hidden */
  7825. _areLightsDirty: boolean;
  7826. /** @hidden */
  7827. _areLightsDisposed: boolean;
  7828. /** @hidden */
  7829. _areAttributesDirty: boolean;
  7830. /** @hidden */
  7831. _areTexturesDirty: boolean;
  7832. /** @hidden */
  7833. _areFresnelDirty: boolean;
  7834. /** @hidden */
  7835. _areMiscDirty: boolean;
  7836. /** @hidden */
  7837. _areImageProcessingDirty: boolean;
  7838. /** @hidden */
  7839. _normals: boolean;
  7840. /** @hidden */
  7841. _uvs: boolean;
  7842. /** @hidden */
  7843. _needNormals: boolean;
  7844. /** @hidden */
  7845. _needUVs: boolean;
  7846. [id: string]: any;
  7847. /**
  7848. * Specifies if the material needs to be re-calculated
  7849. */
  7850. readonly isDirty: boolean;
  7851. /**
  7852. * Marks the material to indicate that it has been re-calculated
  7853. */
  7854. markAsProcessed(): void;
  7855. /**
  7856. * Marks the material to indicate that it needs to be re-calculated
  7857. */
  7858. markAsUnprocessed(): void;
  7859. /**
  7860. * Marks the material to indicate all of its defines need to be re-calculated
  7861. */
  7862. markAllAsDirty(): void;
  7863. /**
  7864. * Marks the material to indicate that image processing needs to be re-calculated
  7865. */
  7866. markAsImageProcessingDirty(): void;
  7867. /**
  7868. * Marks the material to indicate the lights need to be re-calculated
  7869. * @param disposed Defines whether the light is dirty due to dispose or not
  7870. */
  7871. markAsLightDirty(disposed?: boolean): void;
  7872. /**
  7873. * Marks the attribute state as changed
  7874. */
  7875. markAsAttributesDirty(): void;
  7876. /**
  7877. * Marks the texture state as changed
  7878. */
  7879. markAsTexturesDirty(): void;
  7880. /**
  7881. * Marks the fresnel state as changed
  7882. */
  7883. markAsFresnelDirty(): void;
  7884. /**
  7885. * Marks the misc state as changed
  7886. */
  7887. markAsMiscDirty(): void;
  7888. /**
  7889. * Rebuilds the material defines
  7890. */
  7891. rebuild(): void;
  7892. /**
  7893. * Specifies if two material defines are equal
  7894. * @param other - A material define instance to compare to
  7895. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7896. */
  7897. isEqual(other: MaterialDefines): boolean;
  7898. /**
  7899. * Clones this instance's defines to another instance
  7900. * @param other - material defines to clone values to
  7901. */
  7902. cloneTo(other: MaterialDefines): void;
  7903. /**
  7904. * Resets the material define values
  7905. */
  7906. reset(): void;
  7907. /**
  7908. * Converts the material define values to a string
  7909. * @returns - String of material define information
  7910. */
  7911. toString(): string;
  7912. }
  7913. }
  7914. declare module "babylonjs/Materials/colorCurves" {
  7915. import { Effect } from "babylonjs/Materials/effect";
  7916. /**
  7917. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7918. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7919. * 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;
  7920. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7921. */
  7922. export class ColorCurves {
  7923. private _dirty;
  7924. private _tempColor;
  7925. private _globalCurve;
  7926. private _highlightsCurve;
  7927. private _midtonesCurve;
  7928. private _shadowsCurve;
  7929. private _positiveCurve;
  7930. private _negativeCurve;
  7931. private _globalHue;
  7932. private _globalDensity;
  7933. private _globalSaturation;
  7934. private _globalExposure;
  7935. /**
  7936. * Gets the global Hue value.
  7937. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7938. */
  7939. /**
  7940. * Sets the global Hue value.
  7941. * 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).
  7942. */
  7943. globalHue: number;
  7944. /**
  7945. * Gets the global Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. /**
  7950. * Sets the global Density value.
  7951. * 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.
  7952. * Values less than zero provide a filter of opposite hue.
  7953. */
  7954. globalDensity: number;
  7955. /**
  7956. * Gets the global Saturation value.
  7957. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7958. */
  7959. /**
  7960. * Sets the global Saturation value.
  7961. * 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.
  7962. */
  7963. globalSaturation: number;
  7964. /**
  7965. * Gets the global Exposure value.
  7966. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7967. */
  7968. /**
  7969. * Sets the global Exposure value.
  7970. * 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.
  7971. */
  7972. globalExposure: number;
  7973. private _highlightsHue;
  7974. private _highlightsDensity;
  7975. private _highlightsSaturation;
  7976. private _highlightsExposure;
  7977. /**
  7978. * Gets the highlights Hue value.
  7979. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7980. */
  7981. /**
  7982. * Sets the highlights Hue value.
  7983. * 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).
  7984. */
  7985. highlightsHue: number;
  7986. /**
  7987. * Gets the highlights Density value.
  7988. * 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.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. /**
  7992. * Sets the highlights Density value.
  7993. * 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.
  7994. * Values less than zero provide a filter of opposite hue.
  7995. */
  7996. highlightsDensity: number;
  7997. /**
  7998. * Gets the highlights Saturation value.
  7999. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8000. */
  8001. /**
  8002. * Sets the highlights Saturation value.
  8003. * 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.
  8004. */
  8005. highlightsSaturation: number;
  8006. /**
  8007. * Gets the highlights Exposure value.
  8008. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8009. */
  8010. /**
  8011. * Sets the highlights Exposure value.
  8012. * 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.
  8013. */
  8014. highlightsExposure: number;
  8015. private _midtonesHue;
  8016. private _midtonesDensity;
  8017. private _midtonesSaturation;
  8018. private _midtonesExposure;
  8019. /**
  8020. * Gets the midtones Hue value.
  8021. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8022. */
  8023. /**
  8024. * Sets the midtones Hue value.
  8025. * 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).
  8026. */
  8027. midtonesHue: number;
  8028. /**
  8029. * Gets the midtones Density value.
  8030. * 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.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. /**
  8034. * Sets the midtones Density value.
  8035. * 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.
  8036. * Values less than zero provide a filter of opposite hue.
  8037. */
  8038. midtonesDensity: number;
  8039. /**
  8040. * Gets the midtones Saturation value.
  8041. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8042. */
  8043. /**
  8044. * Sets the midtones Saturation value.
  8045. * 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.
  8046. */
  8047. midtonesSaturation: number;
  8048. /**
  8049. * Gets the midtones Exposure value.
  8050. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8051. */
  8052. /**
  8053. * Sets the midtones Exposure value.
  8054. * 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.
  8055. */
  8056. midtonesExposure: number;
  8057. private _shadowsHue;
  8058. private _shadowsDensity;
  8059. private _shadowsSaturation;
  8060. private _shadowsExposure;
  8061. /**
  8062. * Gets the shadows Hue value.
  8063. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8064. */
  8065. /**
  8066. * Sets the shadows Hue value.
  8067. * 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).
  8068. */
  8069. shadowsHue: number;
  8070. /**
  8071. * Gets the shadows Density value.
  8072. * 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.
  8073. * Values less than zero provide a filter of opposite hue.
  8074. */
  8075. /**
  8076. * Sets the shadows Density value.
  8077. * 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.
  8078. * Values less than zero provide a filter of opposite hue.
  8079. */
  8080. shadowsDensity: number;
  8081. /**
  8082. * Gets the shadows Saturation value.
  8083. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8084. */
  8085. /**
  8086. * Sets the shadows Saturation value.
  8087. * 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.
  8088. */
  8089. shadowsSaturation: number;
  8090. /**
  8091. * Gets the shadows Exposure value.
  8092. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8093. */
  8094. /**
  8095. * Sets the shadows Exposure value.
  8096. * 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.
  8097. */
  8098. shadowsExposure: number;
  8099. /**
  8100. * Returns the class name
  8101. * @returns The class name
  8102. */
  8103. getClassName(): string;
  8104. /**
  8105. * Binds the color curves to the shader.
  8106. * @param colorCurves The color curve to bind
  8107. * @param effect The effect to bind to
  8108. * @param positiveUniform The positive uniform shader parameter
  8109. * @param neutralUniform The neutral uniform shader parameter
  8110. * @param negativeUniform The negative uniform shader parameter
  8111. */
  8112. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8113. /**
  8114. * Prepare the list of uniforms associated with the ColorCurves effects.
  8115. * @param uniformsList The list of uniforms used in the effect
  8116. */
  8117. static PrepareUniforms(uniformsList: string[]): void;
  8118. /**
  8119. * Returns color grading data based on a hue, density, saturation and exposure value.
  8120. * @param filterHue The hue of the color filter.
  8121. * @param filterDensity The density of the color filter.
  8122. * @param saturation The saturation.
  8123. * @param exposure The exposure.
  8124. * @param result The result data container.
  8125. */
  8126. private getColorGradingDataToRef;
  8127. /**
  8128. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8129. * @param value The input slider value in range [-100,100].
  8130. * @returns Adjusted value.
  8131. */
  8132. private static applyColorGradingSliderNonlinear;
  8133. /**
  8134. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8135. * @param hue The hue (H) input.
  8136. * @param saturation The saturation (S) input.
  8137. * @param brightness The brightness (B) input.
  8138. * @result An RGBA color represented as Vector4.
  8139. */
  8140. private static fromHSBToRef;
  8141. /**
  8142. * Returns a value clamped between min and max
  8143. * @param value The value to clamp
  8144. * @param min The minimum of value
  8145. * @param max The maximum of value
  8146. * @returns The clamped value.
  8147. */
  8148. private static clamp;
  8149. /**
  8150. * Clones the current color curve instance.
  8151. * @return The cloned curves
  8152. */
  8153. clone(): ColorCurves;
  8154. /**
  8155. * Serializes the current color curve instance to a json representation.
  8156. * @return a JSON representation
  8157. */
  8158. serialize(): any;
  8159. /**
  8160. * Parses the color curve from a json representation.
  8161. * @param source the JSON source to parse
  8162. * @return The parsed curves
  8163. */
  8164. static Parse(source: any): ColorCurves;
  8165. }
  8166. }
  8167. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8168. import { Observable } from "babylonjs/Misc/observable";
  8169. import { Nullable } from "babylonjs/types";
  8170. import { Color4 } from "babylonjs/Maths/math.color";
  8171. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8172. import { Effect } from "babylonjs/Materials/effect";
  8173. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8174. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8175. /**
  8176. * Interface to follow in your material defines to integrate easily the
  8177. * Image proccessing functions.
  8178. * @hidden
  8179. */
  8180. export interface IImageProcessingConfigurationDefines {
  8181. IMAGEPROCESSING: boolean;
  8182. VIGNETTE: boolean;
  8183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8184. VIGNETTEBLENDMODEOPAQUE: boolean;
  8185. TONEMAPPING: boolean;
  8186. TONEMAPPING_ACES: boolean;
  8187. CONTRAST: boolean;
  8188. EXPOSURE: boolean;
  8189. COLORCURVES: boolean;
  8190. COLORGRADING: boolean;
  8191. COLORGRADING3D: boolean;
  8192. SAMPLER3DGREENDEPTH: boolean;
  8193. SAMPLER3DBGRMAP: boolean;
  8194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8195. }
  8196. /**
  8197. * @hidden
  8198. */
  8199. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8200. IMAGEPROCESSING: boolean;
  8201. VIGNETTE: boolean;
  8202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8203. VIGNETTEBLENDMODEOPAQUE: boolean;
  8204. TONEMAPPING: boolean;
  8205. TONEMAPPING_ACES: boolean;
  8206. CONTRAST: boolean;
  8207. COLORCURVES: boolean;
  8208. COLORGRADING: boolean;
  8209. COLORGRADING3D: boolean;
  8210. SAMPLER3DGREENDEPTH: boolean;
  8211. SAMPLER3DBGRMAP: boolean;
  8212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8213. EXPOSURE: boolean;
  8214. constructor();
  8215. }
  8216. /**
  8217. * This groups together the common properties used for image processing either in direct forward pass
  8218. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8219. * or not.
  8220. */
  8221. export class ImageProcessingConfiguration {
  8222. /**
  8223. * Default tone mapping applied in BabylonJS.
  8224. */
  8225. static readonly TONEMAPPING_STANDARD: number;
  8226. /**
  8227. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8228. * to other engines rendering to increase portability.
  8229. */
  8230. static readonly TONEMAPPING_ACES: number;
  8231. /**
  8232. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8233. */
  8234. colorCurves: Nullable<ColorCurves>;
  8235. private _colorCurvesEnabled;
  8236. /**
  8237. * Gets wether the color curves effect is enabled.
  8238. */
  8239. /**
  8240. * Sets wether the color curves effect is enabled.
  8241. */
  8242. colorCurvesEnabled: boolean;
  8243. private _colorGradingTexture;
  8244. /**
  8245. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8246. */
  8247. /**
  8248. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8249. */
  8250. colorGradingTexture: Nullable<BaseTexture>;
  8251. private _colorGradingEnabled;
  8252. /**
  8253. * Gets wether the color grading effect is enabled.
  8254. */
  8255. /**
  8256. * Sets wether the color grading effect is enabled.
  8257. */
  8258. colorGradingEnabled: boolean;
  8259. private _colorGradingWithGreenDepth;
  8260. /**
  8261. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8262. */
  8263. /**
  8264. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8265. */
  8266. colorGradingWithGreenDepth: boolean;
  8267. private _colorGradingBGR;
  8268. /**
  8269. * Gets wether the color grading texture contains BGR values.
  8270. */
  8271. /**
  8272. * Sets wether the color grading texture contains BGR values.
  8273. */
  8274. colorGradingBGR: boolean;
  8275. /** @hidden */
  8276. _exposure: number;
  8277. /**
  8278. * Gets the Exposure used in the effect.
  8279. */
  8280. /**
  8281. * Sets the Exposure used in the effect.
  8282. */
  8283. exposure: number;
  8284. private _toneMappingEnabled;
  8285. /**
  8286. * Gets wether the tone mapping effect is enabled.
  8287. */
  8288. /**
  8289. * Sets wether the tone mapping effect is enabled.
  8290. */
  8291. toneMappingEnabled: boolean;
  8292. private _toneMappingType;
  8293. /**
  8294. * Gets the type of tone mapping effect.
  8295. */
  8296. /**
  8297. * Sets the type of tone mapping effect used in BabylonJS.
  8298. */
  8299. toneMappingType: number;
  8300. protected _contrast: number;
  8301. /**
  8302. * Gets the contrast used in the effect.
  8303. */
  8304. /**
  8305. * Sets the contrast used in the effect.
  8306. */
  8307. contrast: number;
  8308. /**
  8309. * Vignette stretch size.
  8310. */
  8311. vignetteStretch: number;
  8312. /**
  8313. * Vignette centre X Offset.
  8314. */
  8315. vignetteCentreX: number;
  8316. /**
  8317. * Vignette centre Y Offset.
  8318. */
  8319. vignetteCentreY: number;
  8320. /**
  8321. * Vignette weight or intensity of the vignette effect.
  8322. */
  8323. vignetteWeight: number;
  8324. /**
  8325. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8326. * if vignetteEnabled is set to true.
  8327. */
  8328. vignetteColor: Color4;
  8329. /**
  8330. * Camera field of view used by the Vignette effect.
  8331. */
  8332. vignetteCameraFov: number;
  8333. private _vignetteBlendMode;
  8334. /**
  8335. * Gets the vignette blend mode allowing different kind of effect.
  8336. */
  8337. /**
  8338. * Sets the vignette blend mode allowing different kind of effect.
  8339. */
  8340. vignetteBlendMode: number;
  8341. private _vignetteEnabled;
  8342. /**
  8343. * Gets wether the vignette effect is enabled.
  8344. */
  8345. /**
  8346. * Sets wether the vignette effect is enabled.
  8347. */
  8348. vignetteEnabled: boolean;
  8349. private _applyByPostProcess;
  8350. /**
  8351. * Gets wether the image processing is applied through a post process or not.
  8352. */
  8353. /**
  8354. * Sets wether the image processing is applied through a post process or not.
  8355. */
  8356. applyByPostProcess: boolean;
  8357. private _isEnabled;
  8358. /**
  8359. * Gets wether the image processing is enabled or not.
  8360. */
  8361. /**
  8362. * Sets wether the image processing is enabled or not.
  8363. */
  8364. isEnabled: boolean;
  8365. /**
  8366. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8367. */
  8368. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8369. /**
  8370. * Method called each time the image processing information changes requires to recompile the effect.
  8371. */
  8372. protected _updateParameters(): void;
  8373. /**
  8374. * Gets the current class name.
  8375. * @return "ImageProcessingConfiguration"
  8376. */
  8377. getClassName(): string;
  8378. /**
  8379. * Prepare the list of uniforms associated with the Image Processing effects.
  8380. * @param uniforms The list of uniforms used in the effect
  8381. * @param defines the list of defines currently in use
  8382. */
  8383. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8384. /**
  8385. * Prepare the list of samplers associated with the Image Processing effects.
  8386. * @param samplersList The list of uniforms used in the effect
  8387. * @param defines the list of defines currently in use
  8388. */
  8389. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8390. /**
  8391. * Prepare the list of defines associated to the shader.
  8392. * @param defines the list of defines to complete
  8393. * @param forPostProcess Define if we are currently in post process mode or not
  8394. */
  8395. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8396. /**
  8397. * Returns true if all the image processing information are ready.
  8398. * @returns True if ready, otherwise, false
  8399. */
  8400. isReady(): boolean;
  8401. /**
  8402. * Binds the image processing to the shader.
  8403. * @param effect The effect to bind to
  8404. * @param overrideAspectRatio Override the aspect ratio of the effect
  8405. */
  8406. bind(effect: Effect, overrideAspectRatio?: number): void;
  8407. /**
  8408. * Clones the current image processing instance.
  8409. * @return The cloned image processing
  8410. */
  8411. clone(): ImageProcessingConfiguration;
  8412. /**
  8413. * Serializes the current image processing instance to a json representation.
  8414. * @return a JSON representation
  8415. */
  8416. serialize(): any;
  8417. /**
  8418. * Parses the image processing from a json representation.
  8419. * @param source the JSON source to parse
  8420. * @return The parsed image processing
  8421. */
  8422. static Parse(source: any): ImageProcessingConfiguration;
  8423. private static _VIGNETTEMODE_MULTIPLY;
  8424. private static _VIGNETTEMODE_OPAQUE;
  8425. /**
  8426. * Used to apply the vignette as a mix with the pixel color.
  8427. */
  8428. static readonly VIGNETTEMODE_MULTIPLY: number;
  8429. /**
  8430. * Used to apply the vignette as a replacement of the pixel color.
  8431. */
  8432. static readonly VIGNETTEMODE_OPAQUE: number;
  8433. }
  8434. }
  8435. declare module "babylonjs/Shaders/postprocess.vertex" {
  8436. /** @hidden */
  8437. export var postprocessVertexShader: {
  8438. name: string;
  8439. shader: string;
  8440. };
  8441. }
  8442. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8444. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8445. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8446. module "babylonjs/Engines/thinEngine" {
  8447. interface ThinEngine {
  8448. /**
  8449. * Creates a new render target texture
  8450. * @param size defines the size of the texture
  8451. * @param options defines the options used to create the texture
  8452. * @returns a new render target texture stored in an InternalTexture
  8453. */
  8454. createRenderTargetTexture(size: number | {
  8455. width: number;
  8456. height: number;
  8457. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8458. /**
  8459. * Creates a depth stencil texture.
  8460. * This is only available in WebGL 2 or with the depth texture extension available.
  8461. * @param size The size of face edge in the texture.
  8462. * @param options The options defining the texture.
  8463. * @returns The texture
  8464. */
  8465. createDepthStencilTexture(size: number | {
  8466. width: number;
  8467. height: number;
  8468. }, options: DepthTextureCreationOptions): InternalTexture;
  8469. /** @hidden */
  8470. _createDepthStencilTexture(size: number | {
  8471. width: number;
  8472. height: number;
  8473. }, options: DepthTextureCreationOptions): InternalTexture;
  8474. }
  8475. }
  8476. }
  8477. declare module "babylonjs/Maths/math.axis" {
  8478. import { Vector3 } from "babylonjs/Maths/math.vector";
  8479. /** Defines supported spaces */
  8480. export enum Space {
  8481. /** Local (object) space */
  8482. LOCAL = 0,
  8483. /** World space */
  8484. WORLD = 1,
  8485. /** Bone space */
  8486. BONE = 2
  8487. }
  8488. /** Defines the 3 main axes */
  8489. export class Axis {
  8490. /** X axis */
  8491. static X: Vector3;
  8492. /** Y axis */
  8493. static Y: Vector3;
  8494. /** Z axis */
  8495. static Z: Vector3;
  8496. }
  8497. }
  8498. declare module "babylonjs/Cameras/targetCamera" {
  8499. import { Nullable } from "babylonjs/types";
  8500. import { Camera } from "babylonjs/Cameras/camera";
  8501. import { Scene } from "babylonjs/scene";
  8502. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8503. /**
  8504. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8505. * This is the base of the follow, arc rotate cameras and Free camera
  8506. * @see http://doc.babylonjs.com/features/cameras
  8507. */
  8508. export class TargetCamera extends Camera {
  8509. private static _RigCamTransformMatrix;
  8510. private static _TargetTransformMatrix;
  8511. private static _TargetFocalPoint;
  8512. /**
  8513. * Define the current direction the camera is moving to
  8514. */
  8515. cameraDirection: Vector3;
  8516. /**
  8517. * Define the current rotation the camera is rotating to
  8518. */
  8519. cameraRotation: Vector2;
  8520. /**
  8521. * When set, the up vector of the camera will be updated by the rotation of the camera
  8522. */
  8523. updateUpVectorFromRotation: boolean;
  8524. private _tmpQuaternion;
  8525. /**
  8526. * Define the current rotation of the camera
  8527. */
  8528. rotation: Vector3;
  8529. /**
  8530. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8531. */
  8532. rotationQuaternion: Quaternion;
  8533. /**
  8534. * Define the current speed of the camera
  8535. */
  8536. speed: number;
  8537. /**
  8538. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8539. * around all axis.
  8540. */
  8541. noRotationConstraint: boolean;
  8542. /**
  8543. * Define the current target of the camera as an object or a position.
  8544. */
  8545. lockedTarget: any;
  8546. /** @hidden */
  8547. _currentTarget: Vector3;
  8548. /** @hidden */
  8549. _initialFocalDistance: number;
  8550. /** @hidden */
  8551. _viewMatrix: Matrix;
  8552. /** @hidden */
  8553. _camMatrix: Matrix;
  8554. /** @hidden */
  8555. _cameraTransformMatrix: Matrix;
  8556. /** @hidden */
  8557. _cameraRotationMatrix: Matrix;
  8558. /** @hidden */
  8559. _referencePoint: Vector3;
  8560. /** @hidden */
  8561. _transformedReferencePoint: Vector3;
  8562. protected _globalCurrentTarget: Vector3;
  8563. protected _globalCurrentUpVector: Vector3;
  8564. /** @hidden */
  8565. _reset: () => void;
  8566. private _defaultUp;
  8567. /**
  8568. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8569. * This is the base of the follow, arc rotate cameras and Free camera
  8570. * @see http://doc.babylonjs.com/features/cameras
  8571. * @param name Defines the name of the camera in the scene
  8572. * @param position Defines the start position of the camera in the scene
  8573. * @param scene Defines the scene the camera belongs to
  8574. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8575. */
  8576. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8577. /**
  8578. * Gets the position in front of the camera at a given distance.
  8579. * @param distance The distance from the camera we want the position to be
  8580. * @returns the position
  8581. */
  8582. getFrontPosition(distance: number): Vector3;
  8583. /** @hidden */
  8584. _getLockedTargetPosition(): Nullable<Vector3>;
  8585. private _storedPosition;
  8586. private _storedRotation;
  8587. private _storedRotationQuaternion;
  8588. /**
  8589. * Store current camera state of the camera (fov, position, rotation, etc..)
  8590. * @returns the camera
  8591. */
  8592. storeState(): Camera;
  8593. /**
  8594. * Restored camera state. You must call storeState() first
  8595. * @returns whether it was successful or not
  8596. * @hidden
  8597. */
  8598. _restoreStateValues(): boolean;
  8599. /** @hidden */
  8600. _initCache(): void;
  8601. /** @hidden */
  8602. _updateCache(ignoreParentClass?: boolean): void;
  8603. /** @hidden */
  8604. _isSynchronizedViewMatrix(): boolean;
  8605. /** @hidden */
  8606. _computeLocalCameraSpeed(): number;
  8607. /**
  8608. * Defines the target the camera should look at.
  8609. * @param target Defines the new target as a Vector or a mesh
  8610. */
  8611. setTarget(target: Vector3): void;
  8612. /**
  8613. * Return the current target position of the camera. This value is expressed in local space.
  8614. * @returns the target position
  8615. */
  8616. getTarget(): Vector3;
  8617. /** @hidden */
  8618. _decideIfNeedsToMove(): boolean;
  8619. /** @hidden */
  8620. _updatePosition(): void;
  8621. /** @hidden */
  8622. _checkInputs(): void;
  8623. protected _updateCameraRotationMatrix(): void;
  8624. /**
  8625. * 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)
  8626. * @returns the current camera
  8627. */
  8628. private _rotateUpVectorWithCameraRotationMatrix;
  8629. private _cachedRotationZ;
  8630. private _cachedQuaternionRotationZ;
  8631. /** @hidden */
  8632. _getViewMatrix(): Matrix;
  8633. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8634. /**
  8635. * @hidden
  8636. */
  8637. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8638. /**
  8639. * @hidden
  8640. */
  8641. _updateRigCameras(): void;
  8642. private _getRigCamPositionAndTarget;
  8643. /**
  8644. * Gets the current object class name.
  8645. * @return the class name
  8646. */
  8647. getClassName(): string;
  8648. }
  8649. }
  8650. declare module "babylonjs/Events/keyboardEvents" {
  8651. /**
  8652. * Gather the list of keyboard event types as constants.
  8653. */
  8654. export class KeyboardEventTypes {
  8655. /**
  8656. * The keydown event is fired when a key becomes active (pressed).
  8657. */
  8658. static readonly KEYDOWN: number;
  8659. /**
  8660. * The keyup event is fired when a key has been released.
  8661. */
  8662. static readonly KEYUP: number;
  8663. }
  8664. /**
  8665. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8666. */
  8667. export class KeyboardInfo {
  8668. /**
  8669. * Defines the type of event (KeyboardEventTypes)
  8670. */
  8671. type: number;
  8672. /**
  8673. * Defines the related dom event
  8674. */
  8675. event: KeyboardEvent;
  8676. /**
  8677. * Instantiates a new keyboard info.
  8678. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8679. * @param type Defines the type of event (KeyboardEventTypes)
  8680. * @param event Defines the related dom event
  8681. */
  8682. constructor(
  8683. /**
  8684. * Defines the type of event (KeyboardEventTypes)
  8685. */
  8686. type: number,
  8687. /**
  8688. * Defines the related dom event
  8689. */
  8690. event: KeyboardEvent);
  8691. }
  8692. /**
  8693. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8694. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8695. */
  8696. export class KeyboardInfoPre extends KeyboardInfo {
  8697. /**
  8698. * Defines the type of event (KeyboardEventTypes)
  8699. */
  8700. type: number;
  8701. /**
  8702. * Defines the related dom event
  8703. */
  8704. event: KeyboardEvent;
  8705. /**
  8706. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8707. */
  8708. skipOnPointerObservable: boolean;
  8709. /**
  8710. * Instantiates a new keyboard pre info.
  8711. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8712. * @param type Defines the type of event (KeyboardEventTypes)
  8713. * @param event Defines the related dom event
  8714. */
  8715. constructor(
  8716. /**
  8717. * Defines the type of event (KeyboardEventTypes)
  8718. */
  8719. type: number,
  8720. /**
  8721. * Defines the related dom event
  8722. */
  8723. event: KeyboardEvent);
  8724. }
  8725. }
  8726. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8727. import { Nullable } from "babylonjs/types";
  8728. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8729. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8730. /**
  8731. * Manage the keyboard inputs to control the movement of a free camera.
  8732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8733. */
  8734. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8735. /**
  8736. * Defines the camera the input is attached to.
  8737. */
  8738. camera: FreeCamera;
  8739. /**
  8740. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8741. */
  8742. keysUp: number[];
  8743. /**
  8744. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8745. */
  8746. keysDown: number[];
  8747. /**
  8748. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8749. */
  8750. keysLeft: number[];
  8751. /**
  8752. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8753. */
  8754. keysRight: number[];
  8755. private _keys;
  8756. private _onCanvasBlurObserver;
  8757. private _onKeyboardObserver;
  8758. private _engine;
  8759. private _scene;
  8760. /**
  8761. * Attach the input controls to a specific dom element to get the input from.
  8762. * @param element Defines the element the controls should be listened from
  8763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8764. */
  8765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8766. /**
  8767. * Detach the current controls from the specified dom element.
  8768. * @param element Defines the element to stop listening the inputs from
  8769. */
  8770. detachControl(element: Nullable<HTMLElement>): void;
  8771. /**
  8772. * Update the current camera state depending on the inputs that have been used this frame.
  8773. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8774. */
  8775. checkInputs(): void;
  8776. /**
  8777. * Gets the class name of the current intput.
  8778. * @returns the class name
  8779. */
  8780. getClassName(): string;
  8781. /** @hidden */
  8782. _onLostFocus(): void;
  8783. /**
  8784. * Get the friendly name associated with the input class.
  8785. * @returns the input friendly name
  8786. */
  8787. getSimpleName(): string;
  8788. }
  8789. }
  8790. declare module "babylonjs/Lights/shadowLight" {
  8791. import { Camera } from "babylonjs/Cameras/camera";
  8792. import { Scene } from "babylonjs/scene";
  8793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8795. import { Light } from "babylonjs/Lights/light";
  8796. /**
  8797. * Interface describing all the common properties and methods a shadow light needs to implement.
  8798. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8799. * as well as binding the different shadow properties to the effects.
  8800. */
  8801. export interface IShadowLight extends Light {
  8802. /**
  8803. * The light id in the scene (used in scene.findLighById for instance)
  8804. */
  8805. id: string;
  8806. /**
  8807. * The position the shdow will be casted from.
  8808. */
  8809. position: Vector3;
  8810. /**
  8811. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8812. */
  8813. direction: Vector3;
  8814. /**
  8815. * The transformed position. Position of the light in world space taking parenting in account.
  8816. */
  8817. transformedPosition: Vector3;
  8818. /**
  8819. * The transformed direction. Direction of the light in world space taking parenting in account.
  8820. */
  8821. transformedDirection: Vector3;
  8822. /**
  8823. * The friendly name of the light in the scene.
  8824. */
  8825. name: string;
  8826. /**
  8827. * Defines the shadow projection clipping minimum z value.
  8828. */
  8829. shadowMinZ: number;
  8830. /**
  8831. * Defines the shadow projection clipping maximum z value.
  8832. */
  8833. shadowMaxZ: number;
  8834. /**
  8835. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8836. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8837. */
  8838. computeTransformedInformation(): boolean;
  8839. /**
  8840. * Gets the scene the light belongs to.
  8841. * @returns The scene
  8842. */
  8843. getScene(): Scene;
  8844. /**
  8845. * Callback defining a custom Projection Matrix Builder.
  8846. * This can be used to override the default projection matrix computation.
  8847. */
  8848. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8849. /**
  8850. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8851. * @param matrix The materix to updated with the projection information
  8852. * @param viewMatrix The transform matrix of the light
  8853. * @param renderList The list of mesh to render in the map
  8854. * @returns The current light
  8855. */
  8856. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8857. /**
  8858. * Gets the current depth scale used in ESM.
  8859. * @returns The scale
  8860. */
  8861. getDepthScale(): number;
  8862. /**
  8863. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8864. * @returns true if a cube texture needs to be use
  8865. */
  8866. needCube(): boolean;
  8867. /**
  8868. * Detects if the projection matrix requires to be recomputed this frame.
  8869. * @returns true if it requires to be recomputed otherwise, false.
  8870. */
  8871. needProjectionMatrixCompute(): boolean;
  8872. /**
  8873. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8874. */
  8875. forceProjectionMatrixCompute(): void;
  8876. /**
  8877. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8878. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8879. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8880. */
  8881. getShadowDirection(faceIndex?: number): Vector3;
  8882. /**
  8883. * Gets the minZ used for shadow according to both the scene and the light.
  8884. * @param activeCamera The camera we are returning the min for
  8885. * @returns the depth min z
  8886. */
  8887. getDepthMinZ(activeCamera: Camera): number;
  8888. /**
  8889. * Gets the maxZ used for shadow according to both the scene and the light.
  8890. * @param activeCamera The camera we are returning the max for
  8891. * @returns the depth max z
  8892. */
  8893. getDepthMaxZ(activeCamera: Camera): number;
  8894. }
  8895. /**
  8896. * Base implementation IShadowLight
  8897. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8898. */
  8899. export abstract class ShadowLight extends Light implements IShadowLight {
  8900. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8901. protected _position: Vector3;
  8902. protected _setPosition(value: Vector3): void;
  8903. /**
  8904. * Sets the position the shadow will be casted from. Also use as the light position for both
  8905. * point and spot lights.
  8906. */
  8907. /**
  8908. * Sets the position the shadow will be casted from. Also use as the light position for both
  8909. * point and spot lights.
  8910. */
  8911. position: Vector3;
  8912. protected _direction: Vector3;
  8913. protected _setDirection(value: Vector3): void;
  8914. /**
  8915. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8916. * Also use as the light direction on spot and directional lights.
  8917. */
  8918. /**
  8919. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8920. * Also use as the light direction on spot and directional lights.
  8921. */
  8922. direction: Vector3;
  8923. private _shadowMinZ;
  8924. /**
  8925. * Gets the shadow projection clipping minimum z value.
  8926. */
  8927. /**
  8928. * Sets the shadow projection clipping minimum z value.
  8929. */
  8930. shadowMinZ: number;
  8931. private _shadowMaxZ;
  8932. /**
  8933. * Sets the shadow projection clipping maximum z value.
  8934. */
  8935. /**
  8936. * Gets the shadow projection clipping maximum z value.
  8937. */
  8938. shadowMaxZ: number;
  8939. /**
  8940. * Callback defining a custom Projection Matrix Builder.
  8941. * This can be used to override the default projection matrix computation.
  8942. */
  8943. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8944. /**
  8945. * The transformed position. Position of the light in world space taking parenting in account.
  8946. */
  8947. transformedPosition: Vector3;
  8948. /**
  8949. * The transformed direction. Direction of the light in world space taking parenting in account.
  8950. */
  8951. transformedDirection: Vector3;
  8952. private _needProjectionMatrixCompute;
  8953. /**
  8954. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8955. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8956. */
  8957. computeTransformedInformation(): boolean;
  8958. /**
  8959. * Return the depth scale used for the shadow map.
  8960. * @returns the depth scale.
  8961. */
  8962. getDepthScale(): number;
  8963. /**
  8964. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8965. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8966. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8967. */
  8968. getShadowDirection(faceIndex?: number): Vector3;
  8969. /**
  8970. * Returns the ShadowLight absolute position in the World.
  8971. * @returns the position vector in world space
  8972. */
  8973. getAbsolutePosition(): Vector3;
  8974. /**
  8975. * Sets the ShadowLight direction toward the passed target.
  8976. * @param target The point to target in local space
  8977. * @returns the updated ShadowLight direction
  8978. */
  8979. setDirectionToTarget(target: Vector3): Vector3;
  8980. /**
  8981. * Returns the light rotation in euler definition.
  8982. * @returns the x y z rotation in local space.
  8983. */
  8984. getRotation(): Vector3;
  8985. /**
  8986. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8987. * @returns true if a cube texture needs to be use
  8988. */
  8989. needCube(): boolean;
  8990. /**
  8991. * Detects if the projection matrix requires to be recomputed this frame.
  8992. * @returns true if it requires to be recomputed otherwise, false.
  8993. */
  8994. needProjectionMatrixCompute(): boolean;
  8995. /**
  8996. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8997. */
  8998. forceProjectionMatrixCompute(): void;
  8999. /** @hidden */
  9000. _initCache(): void;
  9001. /** @hidden */
  9002. _isSynchronized(): boolean;
  9003. /**
  9004. * Computes the world matrix of the node
  9005. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9006. * @returns the world matrix
  9007. */
  9008. computeWorldMatrix(force?: boolean): Matrix;
  9009. /**
  9010. * Gets the minZ used for shadow according to both the scene and the light.
  9011. * @param activeCamera The camera we are returning the min for
  9012. * @returns the depth min z
  9013. */
  9014. getDepthMinZ(activeCamera: Camera): number;
  9015. /**
  9016. * Gets the maxZ used for shadow according to both the scene and the light.
  9017. * @param activeCamera The camera we are returning the max for
  9018. * @returns the depth max z
  9019. */
  9020. getDepthMaxZ(activeCamera: Camera): number;
  9021. /**
  9022. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9023. * @param matrix The materix to updated with the projection information
  9024. * @param viewMatrix The transform matrix of the light
  9025. * @param renderList The list of mesh to render in the map
  9026. * @returns The current light
  9027. */
  9028. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9029. }
  9030. }
  9031. declare module "babylonjs/Materials/effectFallbacks" {
  9032. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9033. import { Effect } from "babylonjs/Materials/effect";
  9034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9035. /**
  9036. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9037. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9038. */
  9039. export class EffectFallbacks implements IEffectFallbacks {
  9040. private _defines;
  9041. private _currentRank;
  9042. private _maxRank;
  9043. private _mesh;
  9044. /**
  9045. * Removes the fallback from the bound mesh.
  9046. */
  9047. unBindMesh(): void;
  9048. /**
  9049. * Adds a fallback on the specified property.
  9050. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9051. * @param define The name of the define in the shader
  9052. */
  9053. addFallback(rank: number, define: string): void;
  9054. /**
  9055. * Sets the mesh to use CPU skinning when needing to fallback.
  9056. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9057. * @param mesh The mesh to use the fallbacks.
  9058. */
  9059. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9060. /**
  9061. * Checks to see if more fallbacks are still availible.
  9062. */
  9063. readonly hasMoreFallbacks: boolean;
  9064. /**
  9065. * Removes the defines that should be removed when falling back.
  9066. * @param currentDefines defines the current define statements for the shader.
  9067. * @param effect defines the current effect we try to compile
  9068. * @returns The resulting defines with defines of the current rank removed.
  9069. */
  9070. reduce(currentDefines: string, effect: Effect): string;
  9071. }
  9072. }
  9073. declare module "babylonjs/Materials/materialHelper" {
  9074. import { Nullable } from "babylonjs/types";
  9075. import { Scene } from "babylonjs/scene";
  9076. import { Engine } from "babylonjs/Engines/engine";
  9077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9078. import { Light } from "babylonjs/Lights/light";
  9079. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9080. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9082. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9083. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9084. /**
  9085. * "Static Class" containing the most commonly used helper while dealing with material for
  9086. * rendering purpose.
  9087. *
  9088. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9089. *
  9090. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9091. */
  9092. export class MaterialHelper {
  9093. /**
  9094. * Bind the current view position to an effect.
  9095. * @param effect The effect to be bound
  9096. * @param scene The scene the eyes position is used from
  9097. */
  9098. static BindEyePosition(effect: Effect, scene: Scene): void;
  9099. /**
  9100. * Helps preparing the defines values about the UVs in used in the effect.
  9101. * UVs are shared as much as we can accross channels in the shaders.
  9102. * @param texture The texture we are preparing the UVs for
  9103. * @param defines The defines to update
  9104. * @param key The channel key "diffuse", "specular"... used in the shader
  9105. */
  9106. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9107. /**
  9108. * Binds a texture matrix value to its corrsponding uniform
  9109. * @param texture The texture to bind the matrix for
  9110. * @param uniformBuffer The uniform buffer receivin the data
  9111. * @param key The channel key "diffuse", "specular"... used in the shader
  9112. */
  9113. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9114. /**
  9115. * Gets the current status of the fog (should it be enabled?)
  9116. * @param mesh defines the mesh to evaluate for fog support
  9117. * @param scene defines the hosting scene
  9118. * @returns true if fog must be enabled
  9119. */
  9120. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9121. /**
  9122. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9123. * @param mesh defines the current mesh
  9124. * @param scene defines the current scene
  9125. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9126. * @param pointsCloud defines if point cloud rendering has to be turned on
  9127. * @param fogEnabled defines if fog has to be turned on
  9128. * @param alphaTest defines if alpha testing has to be turned on
  9129. * @param defines defines the current list of defines
  9130. */
  9131. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9132. /**
  9133. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9134. * @param scene defines the current scene
  9135. * @param engine defines the current engine
  9136. * @param defines specifies the list of active defines
  9137. * @param useInstances defines if instances have to be turned on
  9138. * @param useClipPlane defines if clip plane have to be turned on
  9139. */
  9140. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9141. /**
  9142. * Prepares the defines for bones
  9143. * @param mesh The mesh containing the geometry data we will draw
  9144. * @param defines The defines to update
  9145. */
  9146. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9147. /**
  9148. * Prepares the defines for morph targets
  9149. * @param mesh The mesh containing the geometry data we will draw
  9150. * @param defines The defines to update
  9151. */
  9152. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9153. /**
  9154. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9155. * @param mesh The mesh containing the geometry data we will draw
  9156. * @param defines The defines to update
  9157. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9158. * @param useBones Precise whether bones should be used or not (override mesh info)
  9159. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9160. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9161. * @returns false if defines are considered not dirty and have not been checked
  9162. */
  9163. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9164. /**
  9165. * Prepares the defines related to multiview
  9166. * @param scene The scene we are intending to draw
  9167. * @param defines The defines to update
  9168. */
  9169. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9170. /**
  9171. * Prepares the defines related to the light information passed in parameter
  9172. * @param scene The scene we are intending to draw
  9173. * @param mesh The mesh the effect is compiling for
  9174. * @param light The light the effect is compiling for
  9175. * @param lightIndex The index of the light
  9176. * @param defines The defines to update
  9177. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9178. * @param state Defines the current state regarding what is needed (normals, etc...)
  9179. */
  9180. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9181. needNormals: boolean;
  9182. needRebuild: boolean;
  9183. shadowEnabled: boolean;
  9184. specularEnabled: boolean;
  9185. lightmapMode: boolean;
  9186. }): void;
  9187. /**
  9188. * Prepares the defines related to the light information passed in parameter
  9189. * @param scene The scene we are intending to draw
  9190. * @param mesh The mesh the effect is compiling for
  9191. * @param defines The defines to update
  9192. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9193. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9194. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9195. * @returns true if normals will be required for the rest of the effect
  9196. */
  9197. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9198. /**
  9199. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9200. * @param lightIndex defines the light index
  9201. * @param uniformsList The uniform list
  9202. * @param samplersList The sampler list
  9203. * @param projectedLightTexture defines if projected texture must be used
  9204. * @param uniformBuffersList defines an optional list of uniform buffers
  9205. */
  9206. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9207. /**
  9208. * Prepares the uniforms and samplers list to be used in the effect
  9209. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9210. * @param samplersList The sampler list
  9211. * @param defines The defines helping in the list generation
  9212. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9213. */
  9214. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9215. /**
  9216. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9217. * @param defines The defines to update while falling back
  9218. * @param fallbacks The authorized effect fallbacks
  9219. * @param maxSimultaneousLights The maximum number of lights allowed
  9220. * @param rank the current rank of the Effect
  9221. * @returns The newly affected rank
  9222. */
  9223. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9224. private static _TmpMorphInfluencers;
  9225. /**
  9226. * Prepares the list of attributes required for morph targets according to the effect defines.
  9227. * @param attribs The current list of supported attribs
  9228. * @param mesh The mesh to prepare the morph targets attributes for
  9229. * @param influencers The number of influencers
  9230. */
  9231. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9232. /**
  9233. * Prepares the list of attributes required for morph targets according to the effect defines.
  9234. * @param attribs The current list of supported attribs
  9235. * @param mesh The mesh to prepare the morph targets attributes for
  9236. * @param defines The current Defines of the effect
  9237. */
  9238. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9239. /**
  9240. * Prepares the list of attributes required for bones according to the effect defines.
  9241. * @param attribs The current list of supported attribs
  9242. * @param mesh The mesh to prepare the bones attributes for
  9243. * @param defines The current Defines of the effect
  9244. * @param fallbacks The current efffect fallback strategy
  9245. */
  9246. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9247. /**
  9248. * Check and prepare the list of attributes required for instances according to the effect defines.
  9249. * @param attribs The current list of supported attribs
  9250. * @param defines The current MaterialDefines of the effect
  9251. */
  9252. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9253. /**
  9254. * Add the list of attributes required for instances to the attribs array.
  9255. * @param attribs The current list of supported attribs
  9256. */
  9257. static PushAttributesForInstances(attribs: string[]): void;
  9258. /**
  9259. * Binds the light information to the effect.
  9260. * @param light The light containing the generator
  9261. * @param effect The effect we are binding the data to
  9262. * @param lightIndex The light index in the effect used to render
  9263. */
  9264. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9265. /**
  9266. * Binds the lights information from the scene to the effect for the given mesh.
  9267. * @param light Light to bind
  9268. * @param lightIndex Light index
  9269. * @param scene The scene where the light belongs to
  9270. * @param effect The effect we are binding the data to
  9271. * @param useSpecular Defines if specular is supported
  9272. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9273. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9274. */
  9275. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9276. /**
  9277. * Binds the lights information from the scene to the effect for the given mesh.
  9278. * @param scene The scene the lights belongs to
  9279. * @param mesh The mesh we are binding the information to render
  9280. * @param effect The effect we are binding the data to
  9281. * @param defines The generated defines for the effect
  9282. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9283. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9284. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9285. */
  9286. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9287. private static _tempFogColor;
  9288. /**
  9289. * Binds the fog information from the scene to the effect for the given mesh.
  9290. * @param scene The scene the lights belongs to
  9291. * @param mesh The mesh we are binding the information to render
  9292. * @param effect The effect we are binding the data to
  9293. * @param linearSpace Defines if the fog effect is applied in linear space
  9294. */
  9295. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9296. /**
  9297. * Binds the bones information from the mesh to the effect.
  9298. * @param mesh The mesh we are binding the information to render
  9299. * @param effect The effect we are binding the data to
  9300. */
  9301. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9302. /**
  9303. * Binds the morph targets information from the mesh to the effect.
  9304. * @param abstractMesh The mesh we are binding the information to render
  9305. * @param effect The effect we are binding the data to
  9306. */
  9307. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9308. /**
  9309. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9310. * @param defines The generated defines used in the effect
  9311. * @param effect The effect we are binding the data to
  9312. * @param scene The scene we are willing to render with logarithmic scale for
  9313. */
  9314. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9315. /**
  9316. * Binds the clip plane information from the scene to the effect.
  9317. * @param scene The scene the clip plane information are extracted from
  9318. * @param effect The effect we are binding the data to
  9319. */
  9320. static BindClipPlane(effect: Effect, scene: Scene): void;
  9321. }
  9322. }
  9323. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9324. /** @hidden */
  9325. export var packingFunctions: {
  9326. name: string;
  9327. shader: string;
  9328. };
  9329. }
  9330. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9331. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9332. /** @hidden */
  9333. export var shadowMapPixelShader: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9339. /** @hidden */
  9340. export var bonesDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9346. /** @hidden */
  9347. export var morphTargetsVertexGlobalDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9353. /** @hidden */
  9354. export var morphTargetsVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9360. /** @hidden */
  9361. export var instancesDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9367. /** @hidden */
  9368. export var helperFunctions: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9374. /** @hidden */
  9375. export var morphTargetsVertex: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9381. /** @hidden */
  9382. export var instancesVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9388. /** @hidden */
  9389. export var bonesVertex: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9395. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9397. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9398. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9399. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9400. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9401. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9402. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9403. /** @hidden */
  9404. export var shadowMapVertexShader: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9410. /** @hidden */
  9411. export var depthBoxBlurPixelShader: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9417. import { Nullable } from "babylonjs/types";
  9418. import { Scene } from "babylonjs/scene";
  9419. import { Matrix } from "babylonjs/Maths/math.vector";
  9420. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9422. import { Mesh } from "babylonjs/Meshes/mesh";
  9423. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9424. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9425. import { Effect } from "babylonjs/Materials/effect";
  9426. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9427. import "babylonjs/Shaders/shadowMap.fragment";
  9428. import "babylonjs/Shaders/shadowMap.vertex";
  9429. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9430. import { Observable } from "babylonjs/Misc/observable";
  9431. /**
  9432. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9433. */
  9434. export interface ICustomShaderOptions {
  9435. /**
  9436. * Gets or sets the custom shader name to use
  9437. */
  9438. shaderName: string;
  9439. /**
  9440. * The list of attribute names used in the shader
  9441. */
  9442. attributes?: string[];
  9443. /**
  9444. * The list of unifrom names used in the shader
  9445. */
  9446. uniforms?: string[];
  9447. /**
  9448. * The list of sampler names used in the shader
  9449. */
  9450. samplers?: string[];
  9451. /**
  9452. * The list of defines used in the shader
  9453. */
  9454. defines?: string[];
  9455. }
  9456. /**
  9457. * Interface to implement to create a shadow generator compatible with BJS.
  9458. */
  9459. export interface IShadowGenerator {
  9460. /**
  9461. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9462. * @returns The render target texture if present otherwise, null
  9463. */
  9464. getShadowMap(): Nullable<RenderTargetTexture>;
  9465. /**
  9466. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9467. * @returns The render target texture if the shadow map is present otherwise, null
  9468. */
  9469. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9470. /**
  9471. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9472. * @param subMesh The submesh we want to render in the shadow map
  9473. * @param useInstances Defines wether will draw in the map using instances
  9474. * @returns true if ready otherwise, false
  9475. */
  9476. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9477. /**
  9478. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9479. * @param defines Defines of the material we want to update
  9480. * @param lightIndex Index of the light in the enabled light list of the material
  9481. */
  9482. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9483. /**
  9484. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9485. * defined in the generator but impacting the effect).
  9486. * It implies the unifroms available on the materials are the standard BJS ones.
  9487. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9488. * @param effect The effect we are binfing the information for
  9489. */
  9490. bindShadowLight(lightIndex: string, effect: Effect): void;
  9491. /**
  9492. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9493. * (eq to shadow prjection matrix * light transform matrix)
  9494. * @returns The transform matrix used to create the shadow map
  9495. */
  9496. getTransformMatrix(): Matrix;
  9497. /**
  9498. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9499. * Cube and 2D textures for instance.
  9500. */
  9501. recreateShadowMap(): void;
  9502. /**
  9503. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9504. * @param onCompiled Callback triggered at the and of the effects compilation
  9505. * @param options Sets of optional options forcing the compilation with different modes
  9506. */
  9507. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9508. useInstances: boolean;
  9509. }>): void;
  9510. /**
  9511. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9512. * @param options Sets of optional options forcing the compilation with different modes
  9513. * @returns A promise that resolves when the compilation completes
  9514. */
  9515. forceCompilationAsync(options?: Partial<{
  9516. useInstances: boolean;
  9517. }>): Promise<void>;
  9518. /**
  9519. * Serializes the shadow generator setup to a json object.
  9520. * @returns The serialized JSON object
  9521. */
  9522. serialize(): any;
  9523. /**
  9524. * Disposes the Shadow map and related Textures and effects.
  9525. */
  9526. dispose(): void;
  9527. }
  9528. /**
  9529. * Default implementation IShadowGenerator.
  9530. * This is the main object responsible of generating shadows in the framework.
  9531. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9532. */
  9533. export class ShadowGenerator implements IShadowGenerator {
  9534. /**
  9535. * Shadow generator mode None: no filtering applied.
  9536. */
  9537. static readonly FILTER_NONE: number;
  9538. /**
  9539. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9540. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9541. */
  9542. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9543. /**
  9544. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9545. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9546. */
  9547. static readonly FILTER_POISSONSAMPLING: number;
  9548. /**
  9549. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9550. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9551. */
  9552. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9553. /**
  9554. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9555. * edge artifacts on steep falloff.
  9556. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9557. */
  9558. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9559. /**
  9560. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9561. * edge artifacts on steep falloff.
  9562. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9563. */
  9564. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9565. /**
  9566. * Shadow generator mode PCF: Percentage Closer Filtering
  9567. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9568. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9569. */
  9570. static readonly FILTER_PCF: number;
  9571. /**
  9572. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9573. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9574. * Contact Hardening
  9575. */
  9576. static readonly FILTER_PCSS: number;
  9577. /**
  9578. * Reserved for PCF and PCSS
  9579. * Highest Quality.
  9580. *
  9581. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9582. *
  9583. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9584. */
  9585. static readonly QUALITY_HIGH: number;
  9586. /**
  9587. * Reserved for PCF and PCSS
  9588. * Good tradeoff for quality/perf cross devices
  9589. *
  9590. * Execute PCF on a 3*3 kernel.
  9591. *
  9592. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9593. */
  9594. static readonly QUALITY_MEDIUM: number;
  9595. /**
  9596. * Reserved for PCF and PCSS
  9597. * The lowest quality but the fastest.
  9598. *
  9599. * Execute PCF on a 1*1 kernel.
  9600. *
  9601. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9602. */
  9603. static readonly QUALITY_LOW: number;
  9604. /** Gets or sets the custom shader name to use */
  9605. customShaderOptions: ICustomShaderOptions;
  9606. /**
  9607. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9608. */
  9609. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9610. /**
  9611. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9612. */
  9613. onAfterShadowMapRenderObservable: Observable<Effect>;
  9614. /**
  9615. * Observable triggered before a mesh is rendered in the shadow map.
  9616. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9617. */
  9618. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9619. /**
  9620. * Observable triggered after a mesh is rendered in the shadow map.
  9621. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9622. */
  9623. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9624. private _bias;
  9625. /**
  9626. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9627. */
  9628. /**
  9629. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9630. */
  9631. bias: number;
  9632. private _normalBias;
  9633. /**
  9634. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9635. */
  9636. /**
  9637. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9638. */
  9639. normalBias: number;
  9640. private _blurBoxOffset;
  9641. /**
  9642. * Gets the blur box offset: offset applied during the blur pass.
  9643. * Only useful if useKernelBlur = false
  9644. */
  9645. /**
  9646. * Sets the blur box offset: offset applied during the blur pass.
  9647. * Only useful if useKernelBlur = false
  9648. */
  9649. blurBoxOffset: number;
  9650. private _blurScale;
  9651. /**
  9652. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9653. * 2 means half of the size.
  9654. */
  9655. /**
  9656. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9657. * 2 means half of the size.
  9658. */
  9659. blurScale: number;
  9660. private _blurKernel;
  9661. /**
  9662. * Gets the blur kernel: kernel size of the blur pass.
  9663. * Only useful if useKernelBlur = true
  9664. */
  9665. /**
  9666. * Sets the blur kernel: kernel size of the blur pass.
  9667. * Only useful if useKernelBlur = true
  9668. */
  9669. blurKernel: number;
  9670. private _useKernelBlur;
  9671. /**
  9672. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9673. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9674. */
  9675. /**
  9676. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9677. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9678. */
  9679. useKernelBlur: boolean;
  9680. private _depthScale;
  9681. /**
  9682. * Gets the depth scale used in ESM mode.
  9683. */
  9684. /**
  9685. * Sets the depth scale used in ESM mode.
  9686. * This can override the scale stored on the light.
  9687. */
  9688. depthScale: number;
  9689. private _filter;
  9690. /**
  9691. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9692. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9693. */
  9694. /**
  9695. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9696. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9697. */
  9698. filter: number;
  9699. /**
  9700. * Gets if the current filter is set to Poisson Sampling.
  9701. */
  9702. /**
  9703. * Sets the current filter to Poisson Sampling.
  9704. */
  9705. usePoissonSampling: boolean;
  9706. /**
  9707. * Gets if the current filter is set to ESM.
  9708. */
  9709. /**
  9710. * Sets the current filter is to ESM.
  9711. */
  9712. useExponentialShadowMap: boolean;
  9713. /**
  9714. * Gets if the current filter is set to filtered ESM.
  9715. */
  9716. /**
  9717. * Gets if the current filter is set to filtered ESM.
  9718. */
  9719. useBlurExponentialShadowMap: boolean;
  9720. /**
  9721. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9722. * exponential to prevent steep falloff artifacts).
  9723. */
  9724. /**
  9725. * Sets the current filter to "close ESM" (using the inverse of the
  9726. * exponential to prevent steep falloff artifacts).
  9727. */
  9728. useCloseExponentialShadowMap: boolean;
  9729. /**
  9730. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9731. * exponential to prevent steep falloff artifacts).
  9732. */
  9733. /**
  9734. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9735. * exponential to prevent steep falloff artifacts).
  9736. */
  9737. useBlurCloseExponentialShadowMap: boolean;
  9738. /**
  9739. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9740. */
  9741. /**
  9742. * Sets the current filter to "PCF" (percentage closer filtering).
  9743. */
  9744. usePercentageCloserFiltering: boolean;
  9745. private _filteringQuality;
  9746. /**
  9747. * Gets the PCF or PCSS Quality.
  9748. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9749. */
  9750. /**
  9751. * Sets the PCF or PCSS Quality.
  9752. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9753. */
  9754. filteringQuality: number;
  9755. /**
  9756. * Gets if the current filter is set to "PCSS" (contact hardening).
  9757. */
  9758. /**
  9759. * Sets the current filter to "PCSS" (contact hardening).
  9760. */
  9761. useContactHardeningShadow: boolean;
  9762. private _contactHardeningLightSizeUVRatio;
  9763. /**
  9764. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9765. * Using a ratio helps keeping shape stability independently of the map size.
  9766. *
  9767. * It does not account for the light projection as it was having too much
  9768. * instability during the light setup or during light position changes.
  9769. *
  9770. * Only valid if useContactHardeningShadow is true.
  9771. */
  9772. /**
  9773. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9774. * Using a ratio helps keeping shape stability independently of the map size.
  9775. *
  9776. * It does not account for the light projection as it was having too much
  9777. * instability during the light setup or during light position changes.
  9778. *
  9779. * Only valid if useContactHardeningShadow is true.
  9780. */
  9781. contactHardeningLightSizeUVRatio: number;
  9782. private _darkness;
  9783. /** Gets or sets the actual darkness of a shadow */
  9784. darkness: number;
  9785. /**
  9786. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9787. * 0 means strongest and 1 would means no shadow.
  9788. * @returns the darkness.
  9789. */
  9790. getDarkness(): number;
  9791. /**
  9792. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9793. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9794. * @returns the shadow generator allowing fluent coding.
  9795. */
  9796. setDarkness(darkness: number): ShadowGenerator;
  9797. private _transparencyShadow;
  9798. /** Gets or sets the ability to have transparent shadow */
  9799. transparencyShadow: boolean;
  9800. /**
  9801. * Sets the ability to have transparent shadow (boolean).
  9802. * @param transparent True if transparent else False
  9803. * @returns the shadow generator allowing fluent coding
  9804. */
  9805. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9806. private _shadowMap;
  9807. private _shadowMap2;
  9808. /**
  9809. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9810. * @returns The render target texture if present otherwise, null
  9811. */
  9812. getShadowMap(): Nullable<RenderTargetTexture>;
  9813. /**
  9814. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9815. * @returns The render target texture if the shadow map is present otherwise, null
  9816. */
  9817. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9818. /**
  9819. * Gets the class name of that object
  9820. * @returns "ShadowGenerator"
  9821. */
  9822. getClassName(): string;
  9823. /**
  9824. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9825. * @param mesh Mesh to add
  9826. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9827. * @returns the Shadow Generator itself
  9828. */
  9829. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9830. /**
  9831. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9832. * @param mesh Mesh to remove
  9833. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9834. * @returns the Shadow Generator itself
  9835. */
  9836. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9837. /**
  9838. * Controls the extent to which the shadows fade out at the edge of the frustum
  9839. * Used only by directionals and spots
  9840. */
  9841. frustumEdgeFalloff: number;
  9842. private _light;
  9843. /**
  9844. * Returns the associated light object.
  9845. * @returns the light generating the shadow
  9846. */
  9847. getLight(): IShadowLight;
  9848. /**
  9849. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9850. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9851. * It might on the other hand introduce peter panning.
  9852. */
  9853. forceBackFacesOnly: boolean;
  9854. private _scene;
  9855. private _lightDirection;
  9856. private _effect;
  9857. private _viewMatrix;
  9858. private _projectionMatrix;
  9859. private _transformMatrix;
  9860. private _cachedPosition;
  9861. private _cachedDirection;
  9862. private _cachedDefines;
  9863. private _currentRenderID;
  9864. private _boxBlurPostprocess;
  9865. private _kernelBlurXPostprocess;
  9866. private _kernelBlurYPostprocess;
  9867. private _blurPostProcesses;
  9868. private _mapSize;
  9869. private _currentFaceIndex;
  9870. private _currentFaceIndexCache;
  9871. private _textureType;
  9872. private _defaultTextureMatrix;
  9873. private _storedUniqueId;
  9874. /** @hidden */
  9875. static _SceneComponentInitialization: (scene: Scene) => void;
  9876. /**
  9877. * Creates a ShadowGenerator object.
  9878. * A ShadowGenerator is the required tool to use the shadows.
  9879. * Each light casting shadows needs to use its own ShadowGenerator.
  9880. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9881. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9882. * @param light The light object generating the shadows.
  9883. * @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.
  9884. */
  9885. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9886. private _initializeGenerator;
  9887. private _initializeShadowMap;
  9888. private _initializeBlurRTTAndPostProcesses;
  9889. private _renderForShadowMap;
  9890. private _renderSubMeshForShadowMap;
  9891. private _applyFilterValues;
  9892. /**
  9893. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9894. * @param onCompiled Callback triggered at the and of the effects compilation
  9895. * @param options Sets of optional options forcing the compilation with different modes
  9896. */
  9897. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9898. useInstances: boolean;
  9899. }>): void;
  9900. /**
  9901. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9902. * @param options Sets of optional options forcing the compilation with different modes
  9903. * @returns A promise that resolves when the compilation completes
  9904. */
  9905. forceCompilationAsync(options?: Partial<{
  9906. useInstances: boolean;
  9907. }>): Promise<void>;
  9908. /**
  9909. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9910. * @param subMesh The submesh we want to render in the shadow map
  9911. * @param useInstances Defines wether will draw in the map using instances
  9912. * @returns true if ready otherwise, false
  9913. */
  9914. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9915. /**
  9916. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9917. * @param defines Defines of the material we want to update
  9918. * @param lightIndex Index of the light in the enabled light list of the material
  9919. */
  9920. prepareDefines(defines: any, lightIndex: number): void;
  9921. /**
  9922. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9923. * defined in the generator but impacting the effect).
  9924. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9925. * @param effect The effect we are binfing the information for
  9926. */
  9927. bindShadowLight(lightIndex: string, effect: Effect): void;
  9928. /**
  9929. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9930. * (eq to shadow prjection matrix * light transform matrix)
  9931. * @returns The transform matrix used to create the shadow map
  9932. */
  9933. getTransformMatrix(): Matrix;
  9934. /**
  9935. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9936. * Cube and 2D textures for instance.
  9937. */
  9938. recreateShadowMap(): void;
  9939. private _disposeBlurPostProcesses;
  9940. private _disposeRTTandPostProcesses;
  9941. /**
  9942. * Disposes the ShadowGenerator.
  9943. * Returns nothing.
  9944. */
  9945. dispose(): void;
  9946. /**
  9947. * Serializes the shadow generator setup to a json object.
  9948. * @returns The serialized JSON object
  9949. */
  9950. serialize(): any;
  9951. /**
  9952. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9953. * @param parsedShadowGenerator The JSON object to parse
  9954. * @param scene The scene to create the shadow map for
  9955. * @returns The parsed shadow generator
  9956. */
  9957. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9958. }
  9959. }
  9960. declare module "babylonjs/Lights/light" {
  9961. import { Nullable } from "babylonjs/types";
  9962. import { Scene } from "babylonjs/scene";
  9963. import { Vector3 } from "babylonjs/Maths/math.vector";
  9964. import { Color3 } from "babylonjs/Maths/math.color";
  9965. import { Node } from "babylonjs/node";
  9966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9967. import { Effect } from "babylonjs/Materials/effect";
  9968. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9969. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9970. /**
  9971. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9972. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9973. * 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.
  9974. */
  9975. export abstract class Light extends Node {
  9976. /**
  9977. * Falloff Default: light is falling off following the material specification:
  9978. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9979. */
  9980. static readonly FALLOFF_DEFAULT: number;
  9981. /**
  9982. * Falloff Physical: light is falling off following the inverse squared distance law.
  9983. */
  9984. static readonly FALLOFF_PHYSICAL: number;
  9985. /**
  9986. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9987. * to enhance interoperability with other engines.
  9988. */
  9989. static readonly FALLOFF_GLTF: number;
  9990. /**
  9991. * Falloff Standard: light is falling off like in the standard material
  9992. * to enhance interoperability with other materials.
  9993. */
  9994. static readonly FALLOFF_STANDARD: number;
  9995. /**
  9996. * If every light affecting the material is in this lightmapMode,
  9997. * material.lightmapTexture adds or multiplies
  9998. * (depends on material.useLightmapAsShadowmap)
  9999. * after every other light calculations.
  10000. */
  10001. static readonly LIGHTMAP_DEFAULT: number;
  10002. /**
  10003. * material.lightmapTexture as only diffuse lighting from this light
  10004. * adds only specular lighting from this light
  10005. * adds dynamic shadows
  10006. */
  10007. static readonly LIGHTMAP_SPECULAR: number;
  10008. /**
  10009. * material.lightmapTexture as only lighting
  10010. * no light calculation from this light
  10011. * only adds dynamic shadows from this light
  10012. */
  10013. static readonly LIGHTMAP_SHADOWSONLY: number;
  10014. /**
  10015. * Each light type uses the default quantity according to its type:
  10016. * point/spot lights use luminous intensity
  10017. * directional lights use illuminance
  10018. */
  10019. static readonly INTENSITYMODE_AUTOMATIC: number;
  10020. /**
  10021. * lumen (lm)
  10022. */
  10023. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10024. /**
  10025. * candela (lm/sr)
  10026. */
  10027. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10028. /**
  10029. * lux (lm/m^2)
  10030. */
  10031. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10032. /**
  10033. * nit (cd/m^2)
  10034. */
  10035. static readonly INTENSITYMODE_LUMINANCE: number;
  10036. /**
  10037. * Light type const id of the point light.
  10038. */
  10039. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10040. /**
  10041. * Light type const id of the directional light.
  10042. */
  10043. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10044. /**
  10045. * Light type const id of the spot light.
  10046. */
  10047. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10048. /**
  10049. * Light type const id of the hemispheric light.
  10050. */
  10051. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10052. /**
  10053. * Diffuse gives the basic color to an object.
  10054. */
  10055. diffuse: Color3;
  10056. /**
  10057. * Specular produces a highlight color on an object.
  10058. * Note: This is note affecting PBR materials.
  10059. */
  10060. specular: Color3;
  10061. /**
  10062. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10063. * falling off base on range or angle.
  10064. * This can be set to any values in Light.FALLOFF_x.
  10065. *
  10066. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10067. * other types of materials.
  10068. */
  10069. falloffType: number;
  10070. /**
  10071. * Strength of the light.
  10072. * Note: By default it is define in the framework own unit.
  10073. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10074. */
  10075. intensity: number;
  10076. private _range;
  10077. protected _inverseSquaredRange: number;
  10078. /**
  10079. * Defines how far from the source the light is impacting in scene units.
  10080. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10081. */
  10082. /**
  10083. * Defines how far from the source the light is impacting in scene units.
  10084. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10085. */
  10086. range: number;
  10087. /**
  10088. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10089. * of light.
  10090. */
  10091. private _photometricScale;
  10092. private _intensityMode;
  10093. /**
  10094. * Gets the photometric scale used to interpret the intensity.
  10095. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10096. */
  10097. /**
  10098. * Sets the photometric scale used to interpret the intensity.
  10099. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10100. */
  10101. intensityMode: number;
  10102. private _radius;
  10103. /**
  10104. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10105. */
  10106. /**
  10107. * sets the light radius used by PBR Materials to simulate soft area lights.
  10108. */
  10109. radius: number;
  10110. private _renderPriority;
  10111. /**
  10112. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10113. * exceeding the number allowed of the materials.
  10114. */
  10115. renderPriority: number;
  10116. private _shadowEnabled;
  10117. /**
  10118. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10119. * the current shadow generator.
  10120. */
  10121. /**
  10122. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10123. * the current shadow generator.
  10124. */
  10125. shadowEnabled: boolean;
  10126. private _includedOnlyMeshes;
  10127. /**
  10128. * Gets the only meshes impacted by this light.
  10129. */
  10130. /**
  10131. * Sets the only meshes impacted by this light.
  10132. */
  10133. includedOnlyMeshes: AbstractMesh[];
  10134. private _excludedMeshes;
  10135. /**
  10136. * Gets the meshes not impacted by this light.
  10137. */
  10138. /**
  10139. * Sets the meshes not impacted by this light.
  10140. */
  10141. excludedMeshes: AbstractMesh[];
  10142. private _excludeWithLayerMask;
  10143. /**
  10144. * Gets the layer id use to find what meshes are not impacted by the light.
  10145. * Inactive if 0
  10146. */
  10147. /**
  10148. * Sets the layer id use to find what meshes are not impacted by the light.
  10149. * Inactive if 0
  10150. */
  10151. excludeWithLayerMask: number;
  10152. private _includeOnlyWithLayerMask;
  10153. /**
  10154. * Gets the layer id use to find what meshes are impacted by the light.
  10155. * Inactive if 0
  10156. */
  10157. /**
  10158. * Sets the layer id use to find what meshes are impacted by the light.
  10159. * Inactive if 0
  10160. */
  10161. includeOnlyWithLayerMask: number;
  10162. private _lightmapMode;
  10163. /**
  10164. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10165. */
  10166. /**
  10167. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10168. */
  10169. lightmapMode: number;
  10170. /**
  10171. * Shadow generator associted to the light.
  10172. * @hidden Internal use only.
  10173. */
  10174. _shadowGenerator: Nullable<IShadowGenerator>;
  10175. /**
  10176. * @hidden Internal use only.
  10177. */
  10178. _excludedMeshesIds: string[];
  10179. /**
  10180. * @hidden Internal use only.
  10181. */
  10182. _includedOnlyMeshesIds: string[];
  10183. /**
  10184. * The current light unifom buffer.
  10185. * @hidden Internal use only.
  10186. */
  10187. _uniformBuffer: UniformBuffer;
  10188. /** @hidden */
  10189. _renderId: number;
  10190. /**
  10191. * Creates a Light object in the scene.
  10192. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10193. * @param name The firendly name of the light
  10194. * @param scene The scene the light belongs too
  10195. */
  10196. constructor(name: string, scene: Scene);
  10197. protected abstract _buildUniformLayout(): void;
  10198. /**
  10199. * Sets the passed Effect "effect" with the Light information.
  10200. * @param effect The effect to update
  10201. * @param lightIndex The index of the light in the effect to update
  10202. * @returns The light
  10203. */
  10204. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10205. /**
  10206. * Sets the passed Effect "effect" with the Light information.
  10207. * @param effect The effect to update
  10208. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10209. * @returns The light
  10210. */
  10211. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10212. /**
  10213. * Returns the string "Light".
  10214. * @returns the class name
  10215. */
  10216. getClassName(): string;
  10217. /** @hidden */
  10218. readonly _isLight: boolean;
  10219. /**
  10220. * Converts the light information to a readable string for debug purpose.
  10221. * @param fullDetails Supports for multiple levels of logging within scene loading
  10222. * @returns the human readable light info
  10223. */
  10224. toString(fullDetails?: boolean): string;
  10225. /** @hidden */
  10226. protected _syncParentEnabledState(): void;
  10227. /**
  10228. * Set the enabled state of this node.
  10229. * @param value - the new enabled state
  10230. */
  10231. setEnabled(value: boolean): void;
  10232. /**
  10233. * Returns the Light associated shadow generator if any.
  10234. * @return the associated shadow generator.
  10235. */
  10236. getShadowGenerator(): Nullable<IShadowGenerator>;
  10237. /**
  10238. * Returns a Vector3, the absolute light position in the World.
  10239. * @returns the world space position of the light
  10240. */
  10241. getAbsolutePosition(): Vector3;
  10242. /**
  10243. * Specifies if the light will affect the passed mesh.
  10244. * @param mesh The mesh to test against the light
  10245. * @return true the mesh is affected otherwise, false.
  10246. */
  10247. canAffectMesh(mesh: AbstractMesh): boolean;
  10248. /**
  10249. * Sort function to order lights for rendering.
  10250. * @param a First Light object to compare to second.
  10251. * @param b Second Light object to compare first.
  10252. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10253. */
  10254. static CompareLightsPriority(a: Light, b: Light): number;
  10255. /**
  10256. * Releases resources associated with this node.
  10257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10259. */
  10260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10261. /**
  10262. * Returns the light type ID (integer).
  10263. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10264. */
  10265. getTypeID(): number;
  10266. /**
  10267. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10268. * @returns the scaled intensity in intensity mode unit
  10269. */
  10270. getScaledIntensity(): number;
  10271. /**
  10272. * Returns a new Light object, named "name", from the current one.
  10273. * @param name The name of the cloned light
  10274. * @returns the new created light
  10275. */
  10276. clone(name: string): Nullable<Light>;
  10277. /**
  10278. * Serializes the current light into a Serialization object.
  10279. * @returns the serialized object.
  10280. */
  10281. serialize(): any;
  10282. /**
  10283. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10284. * This new light is named "name" and added to the passed scene.
  10285. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10286. * @param name The friendly name of the light
  10287. * @param scene The scene the new light will belong to
  10288. * @returns the constructor function
  10289. */
  10290. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10291. /**
  10292. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10293. * @param parsedLight The JSON representation of the light
  10294. * @param scene The scene to create the parsed light in
  10295. * @returns the created light after parsing
  10296. */
  10297. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10298. private _hookArrayForExcluded;
  10299. private _hookArrayForIncludedOnly;
  10300. private _resyncMeshes;
  10301. /**
  10302. * Forces the meshes to update their light related information in their rendering used effects
  10303. * @hidden Internal Use Only
  10304. */
  10305. _markMeshesAsLightDirty(): void;
  10306. /**
  10307. * Recomputes the cached photometric scale if needed.
  10308. */
  10309. private _computePhotometricScale;
  10310. /**
  10311. * Returns the Photometric Scale according to the light type and intensity mode.
  10312. */
  10313. private _getPhotometricScale;
  10314. /**
  10315. * Reorder the light in the scene according to their defined priority.
  10316. * @hidden Internal Use Only
  10317. */
  10318. _reorderLightsInScene(): void;
  10319. /**
  10320. * Prepares the list of defines specific to the light type.
  10321. * @param defines the list of defines
  10322. * @param lightIndex defines the index of the light for the effect
  10323. */
  10324. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10325. }
  10326. }
  10327. declare module "babylonjs/Actions/action" {
  10328. import { Observable } from "babylonjs/Misc/observable";
  10329. import { Condition } from "babylonjs/Actions/condition";
  10330. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10331. import { ActionManager } from "babylonjs/Actions/actionManager";
  10332. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10333. /**
  10334. * Interface used to define Action
  10335. */
  10336. export interface IAction {
  10337. /**
  10338. * Trigger for the action
  10339. */
  10340. trigger: number;
  10341. /** Options of the trigger */
  10342. triggerOptions: any;
  10343. /**
  10344. * Gets the trigger parameters
  10345. * @returns the trigger parameters
  10346. */
  10347. getTriggerParameter(): any;
  10348. /**
  10349. * Internal only - executes current action event
  10350. * @hidden
  10351. */
  10352. _executeCurrent(evt?: ActionEvent): void;
  10353. /**
  10354. * Serialize placeholder for child classes
  10355. * @param parent of child
  10356. * @returns the serialized object
  10357. */
  10358. serialize(parent: any): any;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. _prepare(): void;
  10364. /**
  10365. * Internal only - manager for action
  10366. * @hidden
  10367. */
  10368. _actionManager: AbstractActionManager;
  10369. /**
  10370. * Adds action to chain of actions, may be a DoNothingAction
  10371. * @param action defines the next action to execute
  10372. * @returns The action passed in
  10373. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10374. */
  10375. then(action: IAction): IAction;
  10376. }
  10377. /**
  10378. * The action to be carried out following a trigger
  10379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10380. */
  10381. export class Action implements IAction {
  10382. /** the trigger, with or without parameters, for the action */
  10383. triggerOptions: any;
  10384. /**
  10385. * Trigger for the action
  10386. */
  10387. trigger: number;
  10388. /**
  10389. * Internal only - manager for action
  10390. * @hidden
  10391. */
  10392. _actionManager: ActionManager;
  10393. private _nextActiveAction;
  10394. private _child;
  10395. private _condition?;
  10396. private _triggerParameter;
  10397. /**
  10398. * An event triggered prior to action being executed.
  10399. */
  10400. onBeforeExecuteObservable: Observable<Action>;
  10401. /**
  10402. * Creates a new Action
  10403. * @param triggerOptions the trigger, with or without parameters, for the action
  10404. * @param condition an optional determinant of action
  10405. */
  10406. constructor(
  10407. /** the trigger, with or without parameters, for the action */
  10408. triggerOptions: any, condition?: Condition);
  10409. /**
  10410. * Internal only
  10411. * @hidden
  10412. */
  10413. _prepare(): void;
  10414. /**
  10415. * Gets the trigger parameters
  10416. * @returns the trigger parameters
  10417. */
  10418. getTriggerParameter(): any;
  10419. /**
  10420. * Internal only - executes current action event
  10421. * @hidden
  10422. */
  10423. _executeCurrent(evt?: ActionEvent): void;
  10424. /**
  10425. * Execute placeholder for child classes
  10426. * @param evt optional action event
  10427. */
  10428. execute(evt?: ActionEvent): void;
  10429. /**
  10430. * Skips to next active action
  10431. */
  10432. skipToNextActiveAction(): void;
  10433. /**
  10434. * Adds action to chain of actions, may be a DoNothingAction
  10435. * @param action defines the next action to execute
  10436. * @returns The action passed in
  10437. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10438. */
  10439. then(action: Action): Action;
  10440. /**
  10441. * Internal only
  10442. * @hidden
  10443. */
  10444. _getProperty(propertyPath: string): string;
  10445. /**
  10446. * Internal only
  10447. * @hidden
  10448. */
  10449. _getEffectiveTarget(target: any, propertyPath: string): any;
  10450. /**
  10451. * Serialize placeholder for child classes
  10452. * @param parent of child
  10453. * @returns the serialized object
  10454. */
  10455. serialize(parent: any): any;
  10456. /**
  10457. * Internal only called by serialize
  10458. * @hidden
  10459. */
  10460. protected _serialize(serializedAction: any, parent?: any): any;
  10461. /**
  10462. * Internal only
  10463. * @hidden
  10464. */
  10465. static _SerializeValueAsString: (value: any) => string;
  10466. /**
  10467. * Internal only
  10468. * @hidden
  10469. */
  10470. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10471. name: string;
  10472. targetType: string;
  10473. value: string;
  10474. };
  10475. }
  10476. }
  10477. declare module "babylonjs/Actions/condition" {
  10478. import { ActionManager } from "babylonjs/Actions/actionManager";
  10479. /**
  10480. * A Condition applied to an Action
  10481. */
  10482. export class Condition {
  10483. /**
  10484. * Internal only - manager for action
  10485. * @hidden
  10486. */
  10487. _actionManager: ActionManager;
  10488. /**
  10489. * Internal only
  10490. * @hidden
  10491. */
  10492. _evaluationId: number;
  10493. /**
  10494. * Internal only
  10495. * @hidden
  10496. */
  10497. _currentResult: boolean;
  10498. /**
  10499. * Creates a new Condition
  10500. * @param actionManager the manager of the action the condition is applied to
  10501. */
  10502. constructor(actionManager: ActionManager);
  10503. /**
  10504. * Check if the current condition is valid
  10505. * @returns a boolean
  10506. */
  10507. isValid(): boolean;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. _getProperty(propertyPath: string): string;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. _getEffectiveTarget(target: any, propertyPath: string): any;
  10518. /**
  10519. * Serialize placeholder for child classes
  10520. * @returns the serialized object
  10521. */
  10522. serialize(): any;
  10523. /**
  10524. * Internal only
  10525. * @hidden
  10526. */
  10527. protected _serialize(serializedCondition: any): any;
  10528. }
  10529. /**
  10530. * Defines specific conditional operators as extensions of Condition
  10531. */
  10532. export class ValueCondition extends Condition {
  10533. /** path to specify the property of the target the conditional operator uses */
  10534. propertyPath: string;
  10535. /** the value compared by the conditional operator against the current value of the property */
  10536. value: any;
  10537. /** the conditional operator, default ValueCondition.IsEqual */
  10538. operator: number;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. private static _IsEqual;
  10544. /**
  10545. * Internal only
  10546. * @hidden
  10547. */
  10548. private static _IsDifferent;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. private static _IsGreater;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. private static _IsLesser;
  10559. /**
  10560. * returns the number for IsEqual
  10561. */
  10562. static readonly IsEqual: number;
  10563. /**
  10564. * Returns the number for IsDifferent
  10565. */
  10566. static readonly IsDifferent: number;
  10567. /**
  10568. * Returns the number for IsGreater
  10569. */
  10570. static readonly IsGreater: number;
  10571. /**
  10572. * Returns the number for IsLesser
  10573. */
  10574. static readonly IsLesser: number;
  10575. /**
  10576. * Internal only The action manager for the condition
  10577. * @hidden
  10578. */
  10579. _actionManager: ActionManager;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. private _target;
  10585. /**
  10586. * Internal only
  10587. * @hidden
  10588. */
  10589. private _effectiveTarget;
  10590. /**
  10591. * Internal only
  10592. * @hidden
  10593. */
  10594. private _property;
  10595. /**
  10596. * Creates a new ValueCondition
  10597. * @param actionManager manager for the action the condition applies to
  10598. * @param target for the action
  10599. * @param propertyPath path to specify the property of the target the conditional operator uses
  10600. * @param value the value compared by the conditional operator against the current value of the property
  10601. * @param operator the conditional operator, default ValueCondition.IsEqual
  10602. */
  10603. constructor(actionManager: ActionManager, target: any,
  10604. /** path to specify the property of the target the conditional operator uses */
  10605. propertyPath: string,
  10606. /** the value compared by the conditional operator against the current value of the property */
  10607. value: any,
  10608. /** the conditional operator, default ValueCondition.IsEqual */
  10609. operator?: number);
  10610. /**
  10611. * Compares the given value with the property value for the specified conditional operator
  10612. * @returns the result of the comparison
  10613. */
  10614. isValid(): boolean;
  10615. /**
  10616. * Serialize the ValueCondition into a JSON compatible object
  10617. * @returns serialization object
  10618. */
  10619. serialize(): any;
  10620. /**
  10621. * Gets the name of the conditional operator for the ValueCondition
  10622. * @param operator the conditional operator
  10623. * @returns the name
  10624. */
  10625. static GetOperatorName(operator: number): string;
  10626. }
  10627. /**
  10628. * Defines a predicate condition as an extension of Condition
  10629. */
  10630. export class PredicateCondition extends Condition {
  10631. /** defines the predicate function used to validate the condition */
  10632. predicate: () => boolean;
  10633. /**
  10634. * Internal only - manager for action
  10635. * @hidden
  10636. */
  10637. _actionManager: ActionManager;
  10638. /**
  10639. * Creates a new PredicateCondition
  10640. * @param actionManager manager for the action the condition applies to
  10641. * @param predicate defines the predicate function used to validate the condition
  10642. */
  10643. constructor(actionManager: ActionManager,
  10644. /** defines the predicate function used to validate the condition */
  10645. predicate: () => boolean);
  10646. /**
  10647. * @returns the validity of the predicate condition
  10648. */
  10649. isValid(): boolean;
  10650. }
  10651. /**
  10652. * Defines a state condition as an extension of Condition
  10653. */
  10654. export class StateCondition extends Condition {
  10655. /** Value to compare with target state */
  10656. value: string;
  10657. /**
  10658. * Internal only - manager for action
  10659. * @hidden
  10660. */
  10661. _actionManager: ActionManager;
  10662. /**
  10663. * Internal only
  10664. * @hidden
  10665. */
  10666. private _target;
  10667. /**
  10668. * Creates a new StateCondition
  10669. * @param actionManager manager for the action the condition applies to
  10670. * @param target of the condition
  10671. * @param value to compare with target state
  10672. */
  10673. constructor(actionManager: ActionManager, target: any,
  10674. /** Value to compare with target state */
  10675. value: string);
  10676. /**
  10677. * Gets a boolean indicating if the current condition is met
  10678. * @returns the validity of the state
  10679. */
  10680. isValid(): boolean;
  10681. /**
  10682. * Serialize the StateCondition into a JSON compatible object
  10683. * @returns serialization object
  10684. */
  10685. serialize(): any;
  10686. }
  10687. }
  10688. declare module "babylonjs/Actions/directActions" {
  10689. import { Action } from "babylonjs/Actions/action";
  10690. import { Condition } from "babylonjs/Actions/condition";
  10691. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10692. /**
  10693. * This defines an action responsible to toggle a boolean once triggered.
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class SwitchBooleanAction extends Action {
  10697. /**
  10698. * The path to the boolean property in the target object
  10699. */
  10700. propertyPath: string;
  10701. private _target;
  10702. private _effectiveTarget;
  10703. private _property;
  10704. /**
  10705. * Instantiate the action
  10706. * @param triggerOptions defines the trigger options
  10707. * @param target defines the object containing the boolean
  10708. * @param propertyPath defines the path to the boolean property in the target object
  10709. * @param condition defines the trigger related conditions
  10710. */
  10711. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10712. /** @hidden */
  10713. _prepare(): void;
  10714. /**
  10715. * Execute the action toggle the boolean value.
  10716. */
  10717. execute(): void;
  10718. /**
  10719. * Serializes the actions and its related information.
  10720. * @param parent defines the object to serialize in
  10721. * @returns the serialized object
  10722. */
  10723. serialize(parent: any): any;
  10724. }
  10725. /**
  10726. * This defines an action responsible to set a the state field of the target
  10727. * to a desired value once triggered.
  10728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10729. */
  10730. export class SetStateAction extends Action {
  10731. /**
  10732. * The value to store in the state field.
  10733. */
  10734. value: string;
  10735. private _target;
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param target defines the object containing the state property
  10740. * @param value defines the value to store in the state field
  10741. * @param condition defines the trigger related conditions
  10742. */
  10743. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10744. /**
  10745. * Execute the action and store the value on the target state property.
  10746. */
  10747. execute(): void;
  10748. /**
  10749. * Serializes the actions and its related information.
  10750. * @param parent defines the object to serialize in
  10751. * @returns the serialized object
  10752. */
  10753. serialize(parent: any): any;
  10754. }
  10755. /**
  10756. * This defines an action responsible to set a property of the target
  10757. * to a desired value once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class SetValueAction extends Action {
  10761. /**
  10762. * The path of the property to set in the target.
  10763. */
  10764. propertyPath: string;
  10765. /**
  10766. * The value to set in the property
  10767. */
  10768. value: any;
  10769. private _target;
  10770. private _effectiveTarget;
  10771. private _property;
  10772. /**
  10773. * Instantiate the action
  10774. * @param triggerOptions defines the trigger options
  10775. * @param target defines the object containing the property
  10776. * @param propertyPath defines the path of the property to set in the target
  10777. * @param value defines the value to set in the property
  10778. * @param condition defines the trigger related conditions
  10779. */
  10780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10781. /** @hidden */
  10782. _prepare(): void;
  10783. /**
  10784. * Execute the action and set the targetted property to the desired value.
  10785. */
  10786. execute(): void;
  10787. /**
  10788. * Serializes the actions and its related information.
  10789. * @param parent defines the object to serialize in
  10790. * @returns the serialized object
  10791. */
  10792. serialize(parent: any): any;
  10793. }
  10794. /**
  10795. * This defines an action responsible to increment the target value
  10796. * to a desired value once triggered.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class IncrementValueAction extends Action {
  10800. /**
  10801. * The path of the property to increment in the target.
  10802. */
  10803. propertyPath: string;
  10804. /**
  10805. * The value we should increment the property by.
  10806. */
  10807. value: any;
  10808. private _target;
  10809. private _effectiveTarget;
  10810. private _property;
  10811. /**
  10812. * Instantiate the action
  10813. * @param triggerOptions defines the trigger options
  10814. * @param target defines the object containing the property
  10815. * @param propertyPath defines the path of the property to increment in the target
  10816. * @param value defines the value value we should increment the property by
  10817. * @param condition defines the trigger related conditions
  10818. */
  10819. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10820. /** @hidden */
  10821. _prepare(): void;
  10822. /**
  10823. * Execute the action and increment the target of the value amount.
  10824. */
  10825. execute(): void;
  10826. /**
  10827. * Serializes the actions and its related information.
  10828. * @param parent defines the object to serialize in
  10829. * @returns the serialized object
  10830. */
  10831. serialize(parent: any): any;
  10832. }
  10833. /**
  10834. * This defines an action responsible to start an animation once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class PlayAnimationAction extends Action {
  10838. /**
  10839. * Where the animation should start (animation frame)
  10840. */
  10841. from: number;
  10842. /**
  10843. * Where the animation should stop (animation frame)
  10844. */
  10845. to: number;
  10846. /**
  10847. * Define if the animation should loop or stop after the first play.
  10848. */
  10849. loop?: boolean;
  10850. private _target;
  10851. /**
  10852. * Instantiate the action
  10853. * @param triggerOptions defines the trigger options
  10854. * @param target defines the target animation or animation name
  10855. * @param from defines from where the animation should start (animation frame)
  10856. * @param end defines where the animation should stop (animation frame)
  10857. * @param loop defines if the animation should loop or stop after the first play
  10858. * @param condition defines the trigger related conditions
  10859. */
  10860. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10861. /** @hidden */
  10862. _prepare(): void;
  10863. /**
  10864. * Execute the action and play the animation.
  10865. */
  10866. execute(): void;
  10867. /**
  10868. * Serializes the actions and its related information.
  10869. * @param parent defines the object to serialize in
  10870. * @returns the serialized object
  10871. */
  10872. serialize(parent: any): any;
  10873. }
  10874. /**
  10875. * This defines an action responsible to stop an animation once triggered.
  10876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10877. */
  10878. export class StopAnimationAction extends Action {
  10879. private _target;
  10880. /**
  10881. * Instantiate the action
  10882. * @param triggerOptions defines the trigger options
  10883. * @param target defines the target animation or animation name
  10884. * @param condition defines the trigger related conditions
  10885. */
  10886. constructor(triggerOptions: any, target: any, condition?: Condition);
  10887. /** @hidden */
  10888. _prepare(): void;
  10889. /**
  10890. * Execute the action and stop the animation.
  10891. */
  10892. execute(): void;
  10893. /**
  10894. * Serializes the actions and its related information.
  10895. * @param parent defines the object to serialize in
  10896. * @returns the serialized object
  10897. */
  10898. serialize(parent: any): any;
  10899. }
  10900. /**
  10901. * This defines an action responsible that does nothing once triggered.
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10903. */
  10904. export class DoNothingAction extends Action {
  10905. /**
  10906. * Instantiate the action
  10907. * @param triggerOptions defines the trigger options
  10908. * @param condition defines the trigger related conditions
  10909. */
  10910. constructor(triggerOptions?: any, condition?: Condition);
  10911. /**
  10912. * Execute the action and do nothing.
  10913. */
  10914. execute(): void;
  10915. /**
  10916. * Serializes the actions and its related information.
  10917. * @param parent defines the object to serialize in
  10918. * @returns the serialized object
  10919. */
  10920. serialize(parent: any): any;
  10921. }
  10922. /**
  10923. * This defines an action responsible to trigger several actions once triggered.
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10925. */
  10926. export class CombineAction extends Action {
  10927. /**
  10928. * The list of aggregated animations to run.
  10929. */
  10930. children: Action[];
  10931. /**
  10932. * Instantiate the action
  10933. * @param triggerOptions defines the trigger options
  10934. * @param children defines the list of aggregated animations to run
  10935. * @param condition defines the trigger related conditions
  10936. */
  10937. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10938. /** @hidden */
  10939. _prepare(): void;
  10940. /**
  10941. * Execute the action and executes all the aggregated actions.
  10942. */
  10943. execute(evt: ActionEvent): void;
  10944. /**
  10945. * Serializes the actions and its related information.
  10946. * @param parent defines the object to serialize in
  10947. * @returns the serialized object
  10948. */
  10949. serialize(parent: any): any;
  10950. }
  10951. /**
  10952. * This defines an action responsible to run code (external event) once triggered.
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10954. */
  10955. export class ExecuteCodeAction extends Action {
  10956. /**
  10957. * The callback function to run.
  10958. */
  10959. func: (evt: ActionEvent) => void;
  10960. /**
  10961. * Instantiate the action
  10962. * @param triggerOptions defines the trigger options
  10963. * @param func defines the callback function to run
  10964. * @param condition defines the trigger related conditions
  10965. */
  10966. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10967. /**
  10968. * Execute the action and run the attached code.
  10969. */
  10970. execute(evt: ActionEvent): void;
  10971. }
  10972. /**
  10973. * This defines an action responsible to set the parent property of the target once triggered.
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10975. */
  10976. export class SetParentAction extends Action {
  10977. private _parent;
  10978. private _target;
  10979. /**
  10980. * Instantiate the action
  10981. * @param triggerOptions defines the trigger options
  10982. * @param target defines the target containing the parent property
  10983. * @param parent defines from where the animation should start (animation frame)
  10984. * @param condition defines the trigger related conditions
  10985. */
  10986. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10987. /** @hidden */
  10988. _prepare(): void;
  10989. /**
  10990. * Execute the action and set the parent property.
  10991. */
  10992. execute(): void;
  10993. /**
  10994. * Serializes the actions and its related information.
  10995. * @param parent defines the object to serialize in
  10996. * @returns the serialized object
  10997. */
  10998. serialize(parent: any): any;
  10999. }
  11000. }
  11001. declare module "babylonjs/Actions/actionManager" {
  11002. import { Nullable } from "babylonjs/types";
  11003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11004. import { Scene } from "babylonjs/scene";
  11005. import { IAction } from "babylonjs/Actions/action";
  11006. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11007. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11008. /**
  11009. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11010. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class ActionManager extends AbstractActionManager {
  11014. /**
  11015. * Nothing
  11016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11017. */
  11018. static readonly NothingTrigger: number;
  11019. /**
  11020. * On pick
  11021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11022. */
  11023. static readonly OnPickTrigger: number;
  11024. /**
  11025. * On left pick
  11026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11027. */
  11028. static readonly OnLeftPickTrigger: number;
  11029. /**
  11030. * On right pick
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11032. */
  11033. static readonly OnRightPickTrigger: number;
  11034. /**
  11035. * On center pick
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly OnCenterPickTrigger: number;
  11039. /**
  11040. * On pick down
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnPickDownTrigger: number;
  11044. /**
  11045. * On double pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnDoublePickTrigger: number;
  11049. /**
  11050. * On pick up
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnPickUpTrigger: number;
  11054. /**
  11055. * On pick out.
  11056. * This trigger will only be raised if you also declared a OnPickDown
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnPickOutTrigger: number;
  11060. /**
  11061. * On long press
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly OnLongPressTrigger: number;
  11065. /**
  11066. * On pointer over
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11068. */
  11069. static readonly OnPointerOverTrigger: number;
  11070. /**
  11071. * On pointer out
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11073. */
  11074. static readonly OnPointerOutTrigger: number;
  11075. /**
  11076. * On every frame
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnEveryFrameTrigger: number;
  11080. /**
  11081. * On intersection enter
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnIntersectionEnterTrigger: number;
  11085. /**
  11086. * On intersection exit
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnIntersectionExitTrigger: number;
  11090. /**
  11091. * On key down
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnKeyDownTrigger: number;
  11095. /**
  11096. * On key up
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnKeyUpTrigger: number;
  11100. private _scene;
  11101. /**
  11102. * Creates a new action manager
  11103. * @param scene defines the hosting scene
  11104. */
  11105. constructor(scene: Scene);
  11106. /**
  11107. * Releases all associated resources
  11108. */
  11109. dispose(): void;
  11110. /**
  11111. * Gets hosting scene
  11112. * @returns the hosting scene
  11113. */
  11114. getScene(): Scene;
  11115. /**
  11116. * Does this action manager handles actions of any of the given triggers
  11117. * @param triggers defines the triggers to be tested
  11118. * @return a boolean indicating whether one (or more) of the triggers is handled
  11119. */
  11120. hasSpecificTriggers(triggers: number[]): boolean;
  11121. /**
  11122. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11123. * speed.
  11124. * @param triggerA defines the trigger to be tested
  11125. * @param triggerB defines the trigger to be tested
  11126. * @return a boolean indicating whether one (or more) of the triggers is handled
  11127. */
  11128. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11129. /**
  11130. * Does this action manager handles actions of a given trigger
  11131. * @param trigger defines the trigger to be tested
  11132. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11133. * @return whether the trigger is handled
  11134. */
  11135. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11136. /**
  11137. * Does this action manager has pointer triggers
  11138. */
  11139. readonly hasPointerTriggers: boolean;
  11140. /**
  11141. * Does this action manager has pick triggers
  11142. */
  11143. readonly hasPickTriggers: boolean;
  11144. /**
  11145. * Registers an action to this action manager
  11146. * @param action defines the action to be registered
  11147. * @return the action amended (prepared) after registration
  11148. */
  11149. registerAction(action: IAction): Nullable<IAction>;
  11150. /**
  11151. * Unregisters an action to this action manager
  11152. * @param action defines the action to be unregistered
  11153. * @return a boolean indicating whether the action has been unregistered
  11154. */
  11155. unregisterAction(action: IAction): Boolean;
  11156. /**
  11157. * Process a specific trigger
  11158. * @param trigger defines the trigger to process
  11159. * @param evt defines the event details to be processed
  11160. */
  11161. processTrigger(trigger: number, evt?: IActionEvent): void;
  11162. /** @hidden */
  11163. _getEffectiveTarget(target: any, propertyPath: string): any;
  11164. /** @hidden */
  11165. _getProperty(propertyPath: string): string;
  11166. /**
  11167. * Serialize this manager to a JSON object
  11168. * @param name defines the property name to store this manager
  11169. * @returns a JSON representation of this manager
  11170. */
  11171. serialize(name: string): any;
  11172. /**
  11173. * Creates a new ActionManager from a JSON data
  11174. * @param parsedActions defines the JSON data to read from
  11175. * @param object defines the hosting mesh
  11176. * @param scene defines the hosting scene
  11177. */
  11178. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11179. /**
  11180. * Get a trigger name by index
  11181. * @param trigger defines the trigger index
  11182. * @returns a trigger name
  11183. */
  11184. static GetTriggerName(trigger: number): string;
  11185. }
  11186. }
  11187. declare module "babylonjs/Culling/ray" {
  11188. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11189. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11191. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11192. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11193. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11194. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11195. import { Plane } from "babylonjs/Maths/math.plane";
  11196. /**
  11197. * Class representing a ray with position and direction
  11198. */
  11199. export class Ray {
  11200. /** origin point */
  11201. origin: Vector3;
  11202. /** direction */
  11203. direction: Vector3;
  11204. /** length of the ray */
  11205. length: number;
  11206. private static readonly TmpVector3;
  11207. private _tmpRay;
  11208. /**
  11209. * Creates a new ray
  11210. * @param origin origin point
  11211. * @param direction direction
  11212. * @param length length of the ray
  11213. */
  11214. constructor(
  11215. /** origin point */
  11216. origin: Vector3,
  11217. /** direction */
  11218. direction: Vector3,
  11219. /** length of the ray */
  11220. length?: number);
  11221. /**
  11222. * Checks if the ray intersects a box
  11223. * @param minimum bound of the box
  11224. * @param maximum bound of the box
  11225. * @param intersectionTreshold extra extend to be added to the box in all direction
  11226. * @returns if the box was hit
  11227. */
  11228. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11229. /**
  11230. * Checks if the ray intersects a box
  11231. * @param box the bounding box to check
  11232. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11233. * @returns if the box was hit
  11234. */
  11235. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11236. /**
  11237. * If the ray hits a sphere
  11238. * @param sphere the bounding sphere to check
  11239. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11240. * @returns true if it hits the sphere
  11241. */
  11242. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11243. /**
  11244. * If the ray hits a triange
  11245. * @param vertex0 triangle vertex
  11246. * @param vertex1 triangle vertex
  11247. * @param vertex2 triangle vertex
  11248. * @returns intersection information if hit
  11249. */
  11250. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11251. /**
  11252. * Checks if ray intersects a plane
  11253. * @param plane the plane to check
  11254. * @returns the distance away it was hit
  11255. */
  11256. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11257. /**
  11258. * Calculate the intercept of a ray on a given axis
  11259. * @param axis to check 'x' | 'y' | 'z'
  11260. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11261. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11262. */
  11263. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11264. /**
  11265. * Checks if ray intersects a mesh
  11266. * @param mesh the mesh to check
  11267. * @param fastCheck if only the bounding box should checked
  11268. * @returns picking info of the intersecton
  11269. */
  11270. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11271. /**
  11272. * Checks if ray intersects a mesh
  11273. * @param meshes the meshes to check
  11274. * @param fastCheck if only the bounding box should checked
  11275. * @param results array to store result in
  11276. * @returns Array of picking infos
  11277. */
  11278. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11279. private _comparePickingInfo;
  11280. private static smallnum;
  11281. private static rayl;
  11282. /**
  11283. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11284. * @param sega the first point of the segment to test the intersection against
  11285. * @param segb the second point of the segment to test the intersection against
  11286. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11287. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11288. */
  11289. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11290. /**
  11291. * Update the ray from viewport position
  11292. * @param x position
  11293. * @param y y position
  11294. * @param viewportWidth viewport width
  11295. * @param viewportHeight viewport height
  11296. * @param world world matrix
  11297. * @param view view matrix
  11298. * @param projection projection matrix
  11299. * @returns this ray updated
  11300. */
  11301. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11302. /**
  11303. * Creates a ray with origin and direction of 0,0,0
  11304. * @returns the new ray
  11305. */
  11306. static Zero(): Ray;
  11307. /**
  11308. * Creates a new ray from screen space and viewport
  11309. * @param x position
  11310. * @param y y position
  11311. * @param viewportWidth viewport width
  11312. * @param viewportHeight viewport height
  11313. * @param world world matrix
  11314. * @param view view matrix
  11315. * @param projection projection matrix
  11316. * @returns new ray
  11317. */
  11318. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11319. /**
  11320. * 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
  11321. * transformed to the given world matrix.
  11322. * @param origin The origin point
  11323. * @param end The end point
  11324. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11325. * @returns the new ray
  11326. */
  11327. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11328. /**
  11329. * Transforms a ray by a matrix
  11330. * @param ray ray to transform
  11331. * @param matrix matrix to apply
  11332. * @returns the resulting new ray
  11333. */
  11334. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11335. /**
  11336. * Transforms a ray by a matrix
  11337. * @param ray ray to transform
  11338. * @param matrix matrix to apply
  11339. * @param result ray to store result in
  11340. */
  11341. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11342. /**
  11343. * Unproject a ray from screen space to object space
  11344. * @param sourceX defines the screen space x coordinate to use
  11345. * @param sourceY defines the screen space y coordinate to use
  11346. * @param viewportWidth defines the current width of the viewport
  11347. * @param viewportHeight defines the current height of the viewport
  11348. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11349. * @param view defines the view matrix to use
  11350. * @param projection defines the projection matrix to use
  11351. */
  11352. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11353. }
  11354. /**
  11355. * Type used to define predicate used to select faces when a mesh intersection is detected
  11356. */
  11357. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11358. module "babylonjs/scene" {
  11359. interface Scene {
  11360. /** @hidden */
  11361. _tempPickingRay: Nullable<Ray>;
  11362. /** @hidden */
  11363. _cachedRayForTransform: Ray;
  11364. /** @hidden */
  11365. _pickWithRayInverseMatrix: Matrix;
  11366. /** @hidden */
  11367. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11368. /** @hidden */
  11369. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11370. }
  11371. }
  11372. }
  11373. declare module "babylonjs/sceneComponent" {
  11374. import { Scene } from "babylonjs/scene";
  11375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11377. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11378. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11379. import { Nullable } from "babylonjs/types";
  11380. import { Camera } from "babylonjs/Cameras/camera";
  11381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11382. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11383. import { AbstractScene } from "babylonjs/abstractScene";
  11384. import { Mesh } from "babylonjs/Meshes/mesh";
  11385. /**
  11386. * Groups all the scene component constants in one place to ease maintenance.
  11387. * @hidden
  11388. */
  11389. export class SceneComponentConstants {
  11390. static readonly NAME_EFFECTLAYER: string;
  11391. static readonly NAME_LAYER: string;
  11392. static readonly NAME_LENSFLARESYSTEM: string;
  11393. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11394. static readonly NAME_PARTICLESYSTEM: string;
  11395. static readonly NAME_GAMEPAD: string;
  11396. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11397. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11398. static readonly NAME_DEPTHRENDERER: string;
  11399. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11400. static readonly NAME_SPRITE: string;
  11401. static readonly NAME_OUTLINERENDERER: string;
  11402. static readonly NAME_PROCEDURALTEXTURE: string;
  11403. static readonly NAME_SHADOWGENERATOR: string;
  11404. static readonly NAME_OCTREE: string;
  11405. static readonly NAME_PHYSICSENGINE: string;
  11406. static readonly NAME_AUDIO: string;
  11407. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11408. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11409. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11410. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11411. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11412. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11413. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11414. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11415. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11416. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11417. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11418. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11419. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11420. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11421. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11422. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11423. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11424. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11425. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11426. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11427. static readonly STEP_AFTERRENDER_AUDIO: number;
  11428. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11429. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11430. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11431. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11432. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11433. static readonly STEP_POINTERMOVE_SPRITE: number;
  11434. static readonly STEP_POINTERDOWN_SPRITE: number;
  11435. static readonly STEP_POINTERUP_SPRITE: number;
  11436. }
  11437. /**
  11438. * This represents a scene component.
  11439. *
  11440. * This is used to decouple the dependency the scene is having on the different workloads like
  11441. * layers, post processes...
  11442. */
  11443. export interface ISceneComponent {
  11444. /**
  11445. * The name of the component. Each component must have a unique name.
  11446. */
  11447. name: string;
  11448. /**
  11449. * The scene the component belongs to.
  11450. */
  11451. scene: Scene;
  11452. /**
  11453. * Register the component to one instance of a scene.
  11454. */
  11455. register(): void;
  11456. /**
  11457. * Rebuilds the elements related to this component in case of
  11458. * context lost for instance.
  11459. */
  11460. rebuild(): void;
  11461. /**
  11462. * Disposes the component and the associated ressources.
  11463. */
  11464. dispose(): void;
  11465. }
  11466. /**
  11467. * This represents a SERIALIZABLE scene component.
  11468. *
  11469. * This extends Scene Component to add Serialization methods on top.
  11470. */
  11471. export interface ISceneSerializableComponent extends ISceneComponent {
  11472. /**
  11473. * Adds all the elements from the container to the scene
  11474. * @param container the container holding the elements
  11475. */
  11476. addFromContainer(container: AbstractScene): void;
  11477. /**
  11478. * Removes all the elements in the container from the scene
  11479. * @param container contains the elements to remove
  11480. * @param dispose if the removed element should be disposed (default: false)
  11481. */
  11482. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11483. /**
  11484. * Serializes the component data to the specified json object
  11485. * @param serializationObject The object to serialize to
  11486. */
  11487. serialize(serializationObject: any): void;
  11488. }
  11489. /**
  11490. * Strong typing of a Mesh related stage step action
  11491. */
  11492. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11493. /**
  11494. * Strong typing of a Evaluate Sub Mesh related stage step action
  11495. */
  11496. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11497. /**
  11498. * Strong typing of a Active Mesh related stage step action
  11499. */
  11500. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11501. /**
  11502. * Strong typing of a Camera related stage step action
  11503. */
  11504. export type CameraStageAction = (camera: Camera) => void;
  11505. /**
  11506. * Strong typing of a Camera Frame buffer related stage step action
  11507. */
  11508. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11509. /**
  11510. * Strong typing of a Render Target related stage step action
  11511. */
  11512. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11513. /**
  11514. * Strong typing of a RenderingGroup related stage step action
  11515. */
  11516. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11517. /**
  11518. * Strong typing of a Mesh Render related stage step action
  11519. */
  11520. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11521. /**
  11522. * Strong typing of a simple stage step action
  11523. */
  11524. export type SimpleStageAction = () => void;
  11525. /**
  11526. * Strong typing of a render target action.
  11527. */
  11528. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11529. /**
  11530. * Strong typing of a pointer move action.
  11531. */
  11532. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11533. /**
  11534. * Strong typing of a pointer up/down action.
  11535. */
  11536. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11537. /**
  11538. * Representation of a stage in the scene (Basically a list of ordered steps)
  11539. * @hidden
  11540. */
  11541. export class Stage<T extends Function> extends Array<{
  11542. index: number;
  11543. component: ISceneComponent;
  11544. action: T;
  11545. }> {
  11546. /**
  11547. * Hide ctor from the rest of the world.
  11548. * @param items The items to add.
  11549. */
  11550. private constructor();
  11551. /**
  11552. * Creates a new Stage.
  11553. * @returns A new instance of a Stage
  11554. */
  11555. static Create<T extends Function>(): Stage<T>;
  11556. /**
  11557. * Registers a step in an ordered way in the targeted stage.
  11558. * @param index Defines the position to register the step in
  11559. * @param component Defines the component attached to the step
  11560. * @param action Defines the action to launch during the step
  11561. */
  11562. registerStep(index: number, component: ISceneComponent, action: T): void;
  11563. /**
  11564. * Clears all the steps from the stage.
  11565. */
  11566. clear(): void;
  11567. }
  11568. }
  11569. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11570. import { Nullable } from "babylonjs/types";
  11571. import { Observable } from "babylonjs/Misc/observable";
  11572. import { Scene } from "babylonjs/scene";
  11573. import { Sprite } from "babylonjs/Sprites/sprite";
  11574. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11575. import { Ray } from "babylonjs/Culling/ray";
  11576. import { Camera } from "babylonjs/Cameras/camera";
  11577. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11578. import { ISceneComponent } from "babylonjs/sceneComponent";
  11579. module "babylonjs/scene" {
  11580. interface Scene {
  11581. /** @hidden */
  11582. _pointerOverSprite: Nullable<Sprite>;
  11583. /** @hidden */
  11584. _pickedDownSprite: Nullable<Sprite>;
  11585. /** @hidden */
  11586. _tempSpritePickingRay: Nullable<Ray>;
  11587. /**
  11588. * All of the sprite managers added to this scene
  11589. * @see http://doc.babylonjs.com/babylon101/sprites
  11590. */
  11591. spriteManagers: Array<ISpriteManager>;
  11592. /**
  11593. * An event triggered when sprites rendering is about to start
  11594. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11595. */
  11596. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11597. /**
  11598. * An event triggered when sprites rendering is done
  11599. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11600. */
  11601. onAfterSpritesRenderingObservable: Observable<Scene>;
  11602. /** @hidden */
  11603. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11604. /** Launch a ray to try to pick a sprite in the scene
  11605. * @param x position on screen
  11606. * @param y position on screen
  11607. * @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
  11608. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11609. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11610. * @returns a PickingInfo
  11611. */
  11612. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11613. /** Use the given ray to pick a sprite in the scene
  11614. * @param ray The ray (in world space) to use to pick meshes
  11615. * @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
  11616. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11617. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11618. * @returns a PickingInfo
  11619. */
  11620. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11621. /** @hidden */
  11622. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11623. /** Launch a ray to try to pick sprites in the scene
  11624. * @param x position on screen
  11625. * @param y position on screen
  11626. * @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
  11627. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11628. * @returns a PickingInfo array
  11629. */
  11630. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11631. /** Use the given ray to pick sprites in the scene
  11632. * @param ray The ray (in world space) to use to pick meshes
  11633. * @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
  11634. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11635. * @returns a PickingInfo array
  11636. */
  11637. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11638. /**
  11639. * Force the sprite under the pointer
  11640. * @param sprite defines the sprite to use
  11641. */
  11642. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11643. /**
  11644. * Gets the sprite under the pointer
  11645. * @returns a Sprite or null if no sprite is under the pointer
  11646. */
  11647. getPointerOverSprite(): Nullable<Sprite>;
  11648. }
  11649. }
  11650. /**
  11651. * Defines the sprite scene component responsible to manage sprites
  11652. * in a given scene.
  11653. */
  11654. export class SpriteSceneComponent implements ISceneComponent {
  11655. /**
  11656. * The component name helpfull to identify the component in the list of scene components.
  11657. */
  11658. readonly name: string;
  11659. /**
  11660. * The scene the component belongs to.
  11661. */
  11662. scene: Scene;
  11663. /** @hidden */
  11664. private _spritePredicate;
  11665. /**
  11666. * Creates a new instance of the component for the given scene
  11667. * @param scene Defines the scene to register the component in
  11668. */
  11669. constructor(scene: Scene);
  11670. /**
  11671. * Registers the component in a given scene
  11672. */
  11673. register(): void;
  11674. /**
  11675. * Rebuilds the elements related to this component in case of
  11676. * context lost for instance.
  11677. */
  11678. rebuild(): void;
  11679. /**
  11680. * Disposes the component and the associated ressources.
  11681. */
  11682. dispose(): void;
  11683. private _pickSpriteButKeepRay;
  11684. private _pointerMove;
  11685. private _pointerDown;
  11686. private _pointerUp;
  11687. }
  11688. }
  11689. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11690. /** @hidden */
  11691. export var fogFragmentDeclaration: {
  11692. name: string;
  11693. shader: string;
  11694. };
  11695. }
  11696. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11697. /** @hidden */
  11698. export var fogFragment: {
  11699. name: string;
  11700. shader: string;
  11701. };
  11702. }
  11703. declare module "babylonjs/Shaders/sprites.fragment" {
  11704. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11705. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11706. /** @hidden */
  11707. export var spritesPixelShader: {
  11708. name: string;
  11709. shader: string;
  11710. };
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11713. /** @hidden */
  11714. export var fogVertexDeclaration: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/sprites.vertex" {
  11720. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11721. /** @hidden */
  11722. export var spritesVertexShader: {
  11723. name: string;
  11724. shader: string;
  11725. };
  11726. }
  11727. declare module "babylonjs/Sprites/spriteManager" {
  11728. import { IDisposable, Scene } from "babylonjs/scene";
  11729. import { Nullable } from "babylonjs/types";
  11730. import { Observable } from "babylonjs/Misc/observable";
  11731. import { Sprite } from "babylonjs/Sprites/sprite";
  11732. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11733. import { Camera } from "babylonjs/Cameras/camera";
  11734. import { Texture } from "babylonjs/Materials/Textures/texture";
  11735. import "babylonjs/Shaders/sprites.fragment";
  11736. import "babylonjs/Shaders/sprites.vertex";
  11737. import { Ray } from "babylonjs/Culling/ray";
  11738. /**
  11739. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11740. */
  11741. export interface ISpriteManager extends IDisposable {
  11742. /**
  11743. * Restricts the camera to viewing objects with the same layerMask.
  11744. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11745. */
  11746. layerMask: number;
  11747. /**
  11748. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11749. */
  11750. isPickable: boolean;
  11751. /**
  11752. * Specifies the rendering group id for this mesh (0 by default)
  11753. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11754. */
  11755. renderingGroupId: number;
  11756. /**
  11757. * Defines the list of sprites managed by the manager.
  11758. */
  11759. sprites: Array<Sprite>;
  11760. /**
  11761. * Tests the intersection of a sprite with a specific ray.
  11762. * @param ray The ray we are sending to test the collision
  11763. * @param camera The camera space we are sending rays in
  11764. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11765. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11766. * @returns picking info or null.
  11767. */
  11768. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11769. /**
  11770. * Intersects the sprites with a ray
  11771. * @param ray defines the ray to intersect with
  11772. * @param camera defines the current active camera
  11773. * @param predicate defines a predicate used to select candidate sprites
  11774. * @returns null if no hit or a PickingInfo array
  11775. */
  11776. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11777. /**
  11778. * Renders the list of sprites on screen.
  11779. */
  11780. render(): void;
  11781. }
  11782. /**
  11783. * Class used to manage multiple sprites on the same spritesheet
  11784. * @see http://doc.babylonjs.com/babylon101/sprites
  11785. */
  11786. export class SpriteManager implements ISpriteManager {
  11787. /** defines the manager's name */
  11788. name: string;
  11789. /** Gets the list of sprites */
  11790. sprites: Sprite[];
  11791. /** Gets or sets the rendering group id (0 by default) */
  11792. renderingGroupId: number;
  11793. /** Gets or sets camera layer mask */
  11794. layerMask: number;
  11795. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11796. fogEnabled: boolean;
  11797. /** Gets or sets a boolean indicating if the sprites are pickable */
  11798. isPickable: boolean;
  11799. /** Defines the default width of a cell in the spritesheet */
  11800. cellWidth: number;
  11801. /** Defines the default height of a cell in the spritesheet */
  11802. cellHeight: number;
  11803. /** Associative array from JSON sprite data file */
  11804. private _cellData;
  11805. /** Array of sprite names from JSON sprite data file */
  11806. private _spriteMap;
  11807. /** True when packed cell data from JSON file is ready*/
  11808. private _packedAndReady;
  11809. /**
  11810. * An event triggered when the manager is disposed.
  11811. */
  11812. onDisposeObservable: Observable<SpriteManager>;
  11813. private _onDisposeObserver;
  11814. /**
  11815. * Callback called when the manager is disposed
  11816. */
  11817. onDispose: () => void;
  11818. private _capacity;
  11819. private _fromPacked;
  11820. private _spriteTexture;
  11821. private _epsilon;
  11822. private _scene;
  11823. private _vertexData;
  11824. private _buffer;
  11825. private _vertexBuffers;
  11826. private _indexBuffer;
  11827. private _effectBase;
  11828. private _effectFog;
  11829. /**
  11830. * Gets or sets the spritesheet texture
  11831. */
  11832. texture: Texture;
  11833. /**
  11834. * Creates a new sprite manager
  11835. * @param name defines the manager's name
  11836. * @param imgUrl defines the sprite sheet url
  11837. * @param capacity defines the maximum allowed number of sprites
  11838. * @param cellSize defines the size of a sprite cell
  11839. * @param scene defines the hosting scene
  11840. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11841. * @param samplingMode defines the smapling mode to use with spritesheet
  11842. * @param fromPacked set to false; do not alter
  11843. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11844. */
  11845. constructor(
  11846. /** defines the manager's name */
  11847. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11848. private _makePacked;
  11849. private _appendSpriteVertex;
  11850. /**
  11851. * Intersects the sprites with a ray
  11852. * @param ray defines the ray to intersect with
  11853. * @param camera defines the current active camera
  11854. * @param predicate defines a predicate used to select candidate sprites
  11855. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11856. * @returns null if no hit or a PickingInfo
  11857. */
  11858. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11859. /**
  11860. * Intersects the sprites with a ray
  11861. * @param ray defines the ray to intersect with
  11862. * @param camera defines the current active camera
  11863. * @param predicate defines a predicate used to select candidate sprites
  11864. * @returns null if no hit or a PickingInfo array
  11865. */
  11866. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11867. /**
  11868. * Render all child sprites
  11869. */
  11870. render(): void;
  11871. /**
  11872. * Release associated resources
  11873. */
  11874. dispose(): void;
  11875. }
  11876. }
  11877. declare module "babylonjs/Sprites/sprite" {
  11878. import { Vector3 } from "babylonjs/Maths/math.vector";
  11879. import { Nullable } from "babylonjs/types";
  11880. import { ActionManager } from "babylonjs/Actions/actionManager";
  11881. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11882. import { Color4 } from "babylonjs/Maths/math.color";
  11883. /**
  11884. * Class used to represent a sprite
  11885. * @see http://doc.babylonjs.com/babylon101/sprites
  11886. */
  11887. export class Sprite {
  11888. /** defines the name */
  11889. name: string;
  11890. /** Gets or sets the current world position */
  11891. position: Vector3;
  11892. /** Gets or sets the main color */
  11893. color: Color4;
  11894. /** Gets or sets the width */
  11895. width: number;
  11896. /** Gets or sets the height */
  11897. height: number;
  11898. /** Gets or sets rotation angle */
  11899. angle: number;
  11900. /** Gets or sets the cell index in the sprite sheet */
  11901. cellIndex: number;
  11902. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11903. cellRef: string;
  11904. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11905. invertU: number;
  11906. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11907. invertV: number;
  11908. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11909. disposeWhenFinishedAnimating: boolean;
  11910. /** Gets the list of attached animations */
  11911. animations: Animation[];
  11912. /** Gets or sets a boolean indicating if the sprite can be picked */
  11913. isPickable: boolean;
  11914. /**
  11915. * Gets or sets the associated action manager
  11916. */
  11917. actionManager: Nullable<ActionManager>;
  11918. private _animationStarted;
  11919. private _loopAnimation;
  11920. private _fromIndex;
  11921. private _toIndex;
  11922. private _delay;
  11923. private _direction;
  11924. private _manager;
  11925. private _time;
  11926. private _onAnimationEnd;
  11927. /**
  11928. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11929. */
  11930. isVisible: boolean;
  11931. /**
  11932. * Gets or sets the sprite size
  11933. */
  11934. size: number;
  11935. /**
  11936. * Creates a new Sprite
  11937. * @param name defines the name
  11938. * @param manager defines the manager
  11939. */
  11940. constructor(
  11941. /** defines the name */
  11942. name: string, manager: ISpriteManager);
  11943. /**
  11944. * Starts an animation
  11945. * @param from defines the initial key
  11946. * @param to defines the end key
  11947. * @param loop defines if the animation must loop
  11948. * @param delay defines the start delay (in ms)
  11949. * @param onAnimationEnd defines a callback to call when animation ends
  11950. */
  11951. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11952. /** Stops current animation (if any) */
  11953. stopAnimation(): void;
  11954. /** @hidden */
  11955. _animate(deltaTime: number): void;
  11956. /** Release associated resources */
  11957. dispose(): void;
  11958. }
  11959. }
  11960. declare module "babylonjs/Collisions/pickingInfo" {
  11961. import { Nullable } from "babylonjs/types";
  11962. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11964. import { Sprite } from "babylonjs/Sprites/sprite";
  11965. import { Ray } from "babylonjs/Culling/ray";
  11966. /**
  11967. * Information about the result of picking within a scene
  11968. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11969. */
  11970. export class PickingInfo {
  11971. /** @hidden */
  11972. _pickingUnavailable: boolean;
  11973. /**
  11974. * If the pick collided with an object
  11975. */
  11976. hit: boolean;
  11977. /**
  11978. * Distance away where the pick collided
  11979. */
  11980. distance: number;
  11981. /**
  11982. * The location of pick collision
  11983. */
  11984. pickedPoint: Nullable<Vector3>;
  11985. /**
  11986. * The mesh corresponding the the pick collision
  11987. */
  11988. pickedMesh: Nullable<AbstractMesh>;
  11989. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11990. bu: number;
  11991. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11992. bv: number;
  11993. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11994. faceId: number;
  11995. /** Id of the the submesh that was picked */
  11996. subMeshId: number;
  11997. /** If a sprite was picked, this will be the sprite the pick collided with */
  11998. pickedSprite: Nullable<Sprite>;
  11999. /**
  12000. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12001. */
  12002. originMesh: Nullable<AbstractMesh>;
  12003. /**
  12004. * The ray that was used to perform the picking.
  12005. */
  12006. ray: Nullable<Ray>;
  12007. /**
  12008. * Gets the normal correspodning to the face the pick collided with
  12009. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12010. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12011. * @returns The normal correspodning to the face the pick collided with
  12012. */
  12013. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12014. /**
  12015. * Gets the texture coordinates of where the pick occured
  12016. * @returns the vector containing the coordnates of the texture
  12017. */
  12018. getTextureCoordinates(): Nullable<Vector2>;
  12019. }
  12020. }
  12021. declare module "babylonjs/Events/pointerEvents" {
  12022. import { Nullable } from "babylonjs/types";
  12023. import { Vector2 } from "babylonjs/Maths/math.vector";
  12024. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12025. import { Ray } from "babylonjs/Culling/ray";
  12026. /**
  12027. * Gather the list of pointer event types as constants.
  12028. */
  12029. export class PointerEventTypes {
  12030. /**
  12031. * 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.
  12032. */
  12033. static readonly POINTERDOWN: number;
  12034. /**
  12035. * The pointerup event is fired when a pointer is no longer active.
  12036. */
  12037. static readonly POINTERUP: number;
  12038. /**
  12039. * The pointermove event is fired when a pointer changes coordinates.
  12040. */
  12041. static readonly POINTERMOVE: number;
  12042. /**
  12043. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12044. */
  12045. static readonly POINTERWHEEL: number;
  12046. /**
  12047. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12048. */
  12049. static readonly POINTERPICK: number;
  12050. /**
  12051. * The pointertap event is fired when a the object has been touched and released without drag.
  12052. */
  12053. static readonly POINTERTAP: number;
  12054. /**
  12055. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12056. */
  12057. static readonly POINTERDOUBLETAP: number;
  12058. }
  12059. /**
  12060. * Base class of pointer info types.
  12061. */
  12062. export class PointerInfoBase {
  12063. /**
  12064. * Defines the type of event (PointerEventTypes)
  12065. */
  12066. type: number;
  12067. /**
  12068. * Defines the related dom event
  12069. */
  12070. event: PointerEvent | MouseWheelEvent;
  12071. /**
  12072. * Instantiates the base class of pointers info.
  12073. * @param type Defines the type of event (PointerEventTypes)
  12074. * @param event Defines the related dom event
  12075. */
  12076. constructor(
  12077. /**
  12078. * Defines the type of event (PointerEventTypes)
  12079. */
  12080. type: number,
  12081. /**
  12082. * Defines the related dom event
  12083. */
  12084. event: PointerEvent | MouseWheelEvent);
  12085. }
  12086. /**
  12087. * This class is used to store pointer related info for the onPrePointerObservable event.
  12088. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12089. */
  12090. export class PointerInfoPre extends PointerInfoBase {
  12091. /**
  12092. * Ray from a pointer if availible (eg. 6dof controller)
  12093. */
  12094. ray: Nullable<Ray>;
  12095. /**
  12096. * Defines the local position of the pointer on the canvas.
  12097. */
  12098. localPosition: Vector2;
  12099. /**
  12100. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12101. */
  12102. skipOnPointerObservable: boolean;
  12103. /**
  12104. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12105. * @param type Defines the type of event (PointerEventTypes)
  12106. * @param event Defines the related dom event
  12107. * @param localX Defines the local x coordinates of the pointer when the event occured
  12108. * @param localY Defines the local y coordinates of the pointer when the event occured
  12109. */
  12110. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12111. }
  12112. /**
  12113. * This type contains all the data related to a pointer event in Babylon.js.
  12114. * 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.
  12115. */
  12116. export class PointerInfo extends PointerInfoBase {
  12117. /**
  12118. * Defines the picking info associated to the info (if any)\
  12119. */
  12120. pickInfo: Nullable<PickingInfo>;
  12121. /**
  12122. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12123. * @param type Defines the type of event (PointerEventTypes)
  12124. * @param event Defines the related dom event
  12125. * @param pickInfo Defines the picking info associated to the info (if any)\
  12126. */
  12127. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12128. /**
  12129. * Defines the picking info associated to the info (if any)\
  12130. */
  12131. pickInfo: Nullable<PickingInfo>);
  12132. }
  12133. /**
  12134. * Data relating to a touch event on the screen.
  12135. */
  12136. export interface PointerTouch {
  12137. /**
  12138. * X coordinate of touch.
  12139. */
  12140. x: number;
  12141. /**
  12142. * Y coordinate of touch.
  12143. */
  12144. y: number;
  12145. /**
  12146. * Id of touch. Unique for each finger.
  12147. */
  12148. pointerId: number;
  12149. /**
  12150. * Event type passed from DOM.
  12151. */
  12152. type: any;
  12153. }
  12154. }
  12155. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12156. import { Observable } from "babylonjs/Misc/observable";
  12157. import { Nullable } from "babylonjs/types";
  12158. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12159. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12160. /**
  12161. * Manage the mouse inputs to control the movement of a free camera.
  12162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12163. */
  12164. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12165. /**
  12166. * Define if touch is enabled in the mouse input
  12167. */
  12168. touchEnabled: boolean;
  12169. /**
  12170. * Defines the camera the input is attached to.
  12171. */
  12172. camera: FreeCamera;
  12173. /**
  12174. * Defines the buttons associated with the input to handle camera move.
  12175. */
  12176. buttons: number[];
  12177. /**
  12178. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12179. */
  12180. angularSensibility: number;
  12181. private _pointerInput;
  12182. private _onMouseMove;
  12183. private _observer;
  12184. private previousPosition;
  12185. /**
  12186. * Observable for when a pointer move event occurs containing the move offset
  12187. */
  12188. onPointerMovedObservable: Observable<{
  12189. offsetX: number;
  12190. offsetY: number;
  12191. }>;
  12192. /**
  12193. * @hidden
  12194. * If the camera should be rotated automatically based on pointer movement
  12195. */
  12196. _allowCameraRotation: boolean;
  12197. /**
  12198. * Manage the mouse inputs to control the movement of a free camera.
  12199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12200. * @param touchEnabled Defines if touch is enabled or not
  12201. */
  12202. constructor(
  12203. /**
  12204. * Define if touch is enabled in the mouse input
  12205. */
  12206. touchEnabled?: boolean);
  12207. /**
  12208. * Attach the input controls to a specific dom element to get the input from.
  12209. * @param element Defines the element the controls should be listened from
  12210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12211. */
  12212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12213. /**
  12214. * Called on JS contextmenu event.
  12215. * Override this method to provide functionality.
  12216. */
  12217. protected onContextMenu(evt: PointerEvent): void;
  12218. /**
  12219. * Detach the current controls from the specified dom element.
  12220. * @param element Defines the element to stop listening the inputs from
  12221. */
  12222. detachControl(element: Nullable<HTMLElement>): void;
  12223. /**
  12224. * Gets the class name of the current intput.
  12225. * @returns the class name
  12226. */
  12227. getClassName(): string;
  12228. /**
  12229. * Get the friendly name associated with the input class.
  12230. * @returns the input friendly name
  12231. */
  12232. getSimpleName(): string;
  12233. }
  12234. }
  12235. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12236. import { Nullable } from "babylonjs/types";
  12237. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12238. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12239. /**
  12240. * Manage the touch inputs to control the movement of a free camera.
  12241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12242. */
  12243. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12244. /**
  12245. * Defines the camera the input is attached to.
  12246. */
  12247. camera: FreeCamera;
  12248. /**
  12249. * Defines the touch sensibility for rotation.
  12250. * The higher the faster.
  12251. */
  12252. touchAngularSensibility: number;
  12253. /**
  12254. * Defines the touch sensibility for move.
  12255. * The higher the faster.
  12256. */
  12257. touchMoveSensibility: number;
  12258. private _offsetX;
  12259. private _offsetY;
  12260. private _pointerPressed;
  12261. private _pointerInput;
  12262. private _observer;
  12263. private _onLostFocus;
  12264. /**
  12265. * Attach the input controls to a specific dom element to get the input from.
  12266. * @param element Defines the element the controls should be listened from
  12267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12268. */
  12269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12270. /**
  12271. * Detach the current controls from the specified dom element.
  12272. * @param element Defines the element to stop listening the inputs from
  12273. */
  12274. detachControl(element: Nullable<HTMLElement>): void;
  12275. /**
  12276. * Update the current camera state depending on the inputs that have been used this frame.
  12277. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12278. */
  12279. checkInputs(): void;
  12280. /**
  12281. * Gets the class name of the current intput.
  12282. * @returns the class name
  12283. */
  12284. getClassName(): string;
  12285. /**
  12286. * Get the friendly name associated with the input class.
  12287. * @returns the input friendly name
  12288. */
  12289. getSimpleName(): string;
  12290. }
  12291. }
  12292. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12293. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12294. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12295. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12296. import { Nullable } from "babylonjs/types";
  12297. /**
  12298. * Default Inputs manager for the FreeCamera.
  12299. * It groups all the default supported inputs for ease of use.
  12300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12301. */
  12302. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12303. /**
  12304. * @hidden
  12305. */
  12306. _mouseInput: Nullable<FreeCameraMouseInput>;
  12307. /**
  12308. * Instantiates a new FreeCameraInputsManager.
  12309. * @param camera Defines the camera the inputs belong to
  12310. */
  12311. constructor(camera: FreeCamera);
  12312. /**
  12313. * Add keyboard input support to the input manager.
  12314. * @returns the current input manager
  12315. */
  12316. addKeyboard(): FreeCameraInputsManager;
  12317. /**
  12318. * Add mouse input support to the input manager.
  12319. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12320. * @returns the current input manager
  12321. */
  12322. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12323. /**
  12324. * Removes the mouse input support from the manager
  12325. * @returns the current input manager
  12326. */
  12327. removeMouse(): FreeCameraInputsManager;
  12328. /**
  12329. * Add touch input support to the input manager.
  12330. * @returns the current input manager
  12331. */
  12332. addTouch(): FreeCameraInputsManager;
  12333. /**
  12334. * Remove all attached input methods from a camera
  12335. */
  12336. clear(): void;
  12337. }
  12338. }
  12339. declare module "babylonjs/Cameras/freeCamera" {
  12340. import { Vector3 } from "babylonjs/Maths/math.vector";
  12341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12342. import { Scene } from "babylonjs/scene";
  12343. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12344. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12345. /**
  12346. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12347. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12348. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12349. */
  12350. export class FreeCamera extends TargetCamera {
  12351. /**
  12352. * Define the collision ellipsoid of the camera.
  12353. * This is helpful to simulate a camera body like the player body around the camera
  12354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12355. */
  12356. ellipsoid: Vector3;
  12357. /**
  12358. * Define an offset for the position of the ellipsoid around the camera.
  12359. * This can be helpful to determine the center of the body near the gravity center of the body
  12360. * instead of its head.
  12361. */
  12362. ellipsoidOffset: Vector3;
  12363. /**
  12364. * Enable or disable collisions of the camera with the rest of the scene objects.
  12365. */
  12366. checkCollisions: boolean;
  12367. /**
  12368. * Enable or disable gravity on the camera.
  12369. */
  12370. applyGravity: boolean;
  12371. /**
  12372. * Define the input manager associated to the camera.
  12373. */
  12374. inputs: FreeCameraInputsManager;
  12375. /**
  12376. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12377. * Higher values reduce sensitivity.
  12378. */
  12379. /**
  12380. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12381. * Higher values reduce sensitivity.
  12382. */
  12383. angularSensibility: number;
  12384. /**
  12385. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12386. */
  12387. keysUp: number[];
  12388. /**
  12389. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12390. */
  12391. keysDown: number[];
  12392. /**
  12393. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12394. */
  12395. keysLeft: number[];
  12396. /**
  12397. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12398. */
  12399. keysRight: number[];
  12400. /**
  12401. * Event raised when the camera collide with a mesh in the scene.
  12402. */
  12403. onCollide: (collidedMesh: AbstractMesh) => void;
  12404. private _collider;
  12405. private _needMoveForGravity;
  12406. private _oldPosition;
  12407. private _diffPosition;
  12408. private _newPosition;
  12409. /** @hidden */
  12410. _localDirection: Vector3;
  12411. /** @hidden */
  12412. _transformedDirection: Vector3;
  12413. /**
  12414. * Instantiates a Free Camera.
  12415. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12416. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12417. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12418. * @param name Define the name of the camera in the scene
  12419. * @param position Define the start position of the camera in the scene
  12420. * @param scene Define the scene the camera belongs to
  12421. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12422. */
  12423. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12424. /**
  12425. * Attached controls to the current camera.
  12426. * @param element Defines the element the controls should be listened from
  12427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12428. */
  12429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12430. /**
  12431. * Detach the current controls from the camera.
  12432. * The camera will stop reacting to inputs.
  12433. * @param element Defines the element to stop listening the inputs from
  12434. */
  12435. detachControl(element: HTMLElement): void;
  12436. private _collisionMask;
  12437. /**
  12438. * Define a collision mask to limit the list of object the camera can collide with
  12439. */
  12440. collisionMask: number;
  12441. /** @hidden */
  12442. _collideWithWorld(displacement: Vector3): void;
  12443. private _onCollisionPositionChange;
  12444. /** @hidden */
  12445. _checkInputs(): void;
  12446. /** @hidden */
  12447. _decideIfNeedsToMove(): boolean;
  12448. /** @hidden */
  12449. _updatePosition(): void;
  12450. /**
  12451. * Destroy the camera and release the current resources hold by it.
  12452. */
  12453. dispose(): void;
  12454. /**
  12455. * Gets the current object class name.
  12456. * @return the class name
  12457. */
  12458. getClassName(): string;
  12459. }
  12460. }
  12461. declare module "babylonjs/Gamepads/gamepad" {
  12462. import { Observable } from "babylonjs/Misc/observable";
  12463. /**
  12464. * Represents a gamepad control stick position
  12465. */
  12466. export class StickValues {
  12467. /**
  12468. * The x component of the control stick
  12469. */
  12470. x: number;
  12471. /**
  12472. * The y component of the control stick
  12473. */
  12474. y: number;
  12475. /**
  12476. * Initializes the gamepad x and y control stick values
  12477. * @param x The x component of the gamepad control stick value
  12478. * @param y The y component of the gamepad control stick value
  12479. */
  12480. constructor(
  12481. /**
  12482. * The x component of the control stick
  12483. */
  12484. x: number,
  12485. /**
  12486. * The y component of the control stick
  12487. */
  12488. y: number);
  12489. }
  12490. /**
  12491. * An interface which manages callbacks for gamepad button changes
  12492. */
  12493. export interface GamepadButtonChanges {
  12494. /**
  12495. * Called when a gamepad has been changed
  12496. */
  12497. changed: boolean;
  12498. /**
  12499. * Called when a gamepad press event has been triggered
  12500. */
  12501. pressChanged: boolean;
  12502. /**
  12503. * Called when a touch event has been triggered
  12504. */
  12505. touchChanged: boolean;
  12506. /**
  12507. * Called when a value has changed
  12508. */
  12509. valueChanged: boolean;
  12510. }
  12511. /**
  12512. * Represents a gamepad
  12513. */
  12514. export class Gamepad {
  12515. /**
  12516. * The id of the gamepad
  12517. */
  12518. id: string;
  12519. /**
  12520. * The index of the gamepad
  12521. */
  12522. index: number;
  12523. /**
  12524. * The browser gamepad
  12525. */
  12526. browserGamepad: any;
  12527. /**
  12528. * Specifies what type of gamepad this represents
  12529. */
  12530. type: number;
  12531. private _leftStick;
  12532. private _rightStick;
  12533. /** @hidden */
  12534. _isConnected: boolean;
  12535. private _leftStickAxisX;
  12536. private _leftStickAxisY;
  12537. private _rightStickAxisX;
  12538. private _rightStickAxisY;
  12539. /**
  12540. * Triggered when the left control stick has been changed
  12541. */
  12542. private _onleftstickchanged;
  12543. /**
  12544. * Triggered when the right control stick has been changed
  12545. */
  12546. private _onrightstickchanged;
  12547. /**
  12548. * Represents a gamepad controller
  12549. */
  12550. static GAMEPAD: number;
  12551. /**
  12552. * Represents a generic controller
  12553. */
  12554. static GENERIC: number;
  12555. /**
  12556. * Represents an XBox controller
  12557. */
  12558. static XBOX: number;
  12559. /**
  12560. * Represents a pose-enabled controller
  12561. */
  12562. static POSE_ENABLED: number;
  12563. /**
  12564. * Represents an Dual Shock controller
  12565. */
  12566. static DUALSHOCK: number;
  12567. /**
  12568. * Specifies whether the left control stick should be Y-inverted
  12569. */
  12570. protected _invertLeftStickY: boolean;
  12571. /**
  12572. * Specifies if the gamepad has been connected
  12573. */
  12574. readonly isConnected: boolean;
  12575. /**
  12576. * Initializes the gamepad
  12577. * @param id The id of the gamepad
  12578. * @param index The index of the gamepad
  12579. * @param browserGamepad The browser gamepad
  12580. * @param leftStickX The x component of the left joystick
  12581. * @param leftStickY The y component of the left joystick
  12582. * @param rightStickX The x component of the right joystick
  12583. * @param rightStickY The y component of the right joystick
  12584. */
  12585. constructor(
  12586. /**
  12587. * The id of the gamepad
  12588. */
  12589. id: string,
  12590. /**
  12591. * The index of the gamepad
  12592. */
  12593. index: number,
  12594. /**
  12595. * The browser gamepad
  12596. */
  12597. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12598. /**
  12599. * Callback triggered when the left joystick has changed
  12600. * @param callback
  12601. */
  12602. onleftstickchanged(callback: (values: StickValues) => void): void;
  12603. /**
  12604. * Callback triggered when the right joystick has changed
  12605. * @param callback
  12606. */
  12607. onrightstickchanged(callback: (values: StickValues) => void): void;
  12608. /**
  12609. * Gets the left joystick
  12610. */
  12611. /**
  12612. * Sets the left joystick values
  12613. */
  12614. leftStick: StickValues;
  12615. /**
  12616. * Gets the right joystick
  12617. */
  12618. /**
  12619. * Sets the right joystick value
  12620. */
  12621. rightStick: StickValues;
  12622. /**
  12623. * Updates the gamepad joystick positions
  12624. */
  12625. update(): void;
  12626. /**
  12627. * Disposes the gamepad
  12628. */
  12629. dispose(): void;
  12630. }
  12631. /**
  12632. * Represents a generic gamepad
  12633. */
  12634. export class GenericPad extends Gamepad {
  12635. private _buttons;
  12636. private _onbuttondown;
  12637. private _onbuttonup;
  12638. /**
  12639. * Observable triggered when a button has been pressed
  12640. */
  12641. onButtonDownObservable: Observable<number>;
  12642. /**
  12643. * Observable triggered when a button has been released
  12644. */
  12645. onButtonUpObservable: Observable<number>;
  12646. /**
  12647. * Callback triggered when a button has been pressed
  12648. * @param callback Called when a button has been pressed
  12649. */
  12650. onbuttondown(callback: (buttonPressed: number) => void): void;
  12651. /**
  12652. * Callback triggered when a button has been released
  12653. * @param callback Called when a button has been released
  12654. */
  12655. onbuttonup(callback: (buttonReleased: number) => void): void;
  12656. /**
  12657. * Initializes the generic gamepad
  12658. * @param id The id of the generic gamepad
  12659. * @param index The index of the generic gamepad
  12660. * @param browserGamepad The browser gamepad
  12661. */
  12662. constructor(id: string, index: number, browserGamepad: any);
  12663. private _setButtonValue;
  12664. /**
  12665. * Updates the generic gamepad
  12666. */
  12667. update(): void;
  12668. /**
  12669. * Disposes the generic gamepad
  12670. */
  12671. dispose(): void;
  12672. }
  12673. }
  12674. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12675. import { Nullable } from "babylonjs/types";
  12676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12677. import { Scene } from "babylonjs/scene";
  12678. module "babylonjs/Engines/engine" {
  12679. interface Engine {
  12680. /**
  12681. * Creates a raw texture
  12682. * @param data defines the data to store in the texture
  12683. * @param width defines the width of the texture
  12684. * @param height defines the height of the texture
  12685. * @param format defines the format of the data
  12686. * @param generateMipMaps defines if the engine should generate the mip levels
  12687. * @param invertY defines if data must be stored with Y axis inverted
  12688. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12689. * @param compression defines the compression used (null by default)
  12690. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12691. * @returns the raw texture inside an InternalTexture
  12692. */
  12693. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12694. /**
  12695. * Update a raw texture
  12696. * @param texture defines the texture to update
  12697. * @param data defines the data to store in the texture
  12698. * @param format defines the format of the data
  12699. * @param invertY defines if data must be stored with Y axis inverted
  12700. */
  12701. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12702. /**
  12703. * Update a raw texture
  12704. * @param texture defines the texture to update
  12705. * @param data defines the data to store in the texture
  12706. * @param format defines the format of the data
  12707. * @param invertY defines if data must be stored with Y axis inverted
  12708. * @param compression defines the compression used (null by default)
  12709. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12710. */
  12711. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12712. /**
  12713. * Creates a new raw cube texture
  12714. * @param data defines the array of data to use to create each face
  12715. * @param size defines the size of the textures
  12716. * @param format defines the format of the data
  12717. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12718. * @param generateMipMaps defines if the engine should generate the mip levels
  12719. * @param invertY defines if data must be stored with Y axis inverted
  12720. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12721. * @param compression defines the compression used (null by default)
  12722. * @returns the cube texture as an InternalTexture
  12723. */
  12724. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12725. /**
  12726. * Update a raw cube texture
  12727. * @param texture defines the texture to udpdate
  12728. * @param data defines the data to store
  12729. * @param format defines the data format
  12730. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12731. * @param invertY defines if data must be stored with Y axis inverted
  12732. */
  12733. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12734. /**
  12735. * Update a raw cube texture
  12736. * @param texture defines the texture to udpdate
  12737. * @param data defines the data to store
  12738. * @param format defines the data format
  12739. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12740. * @param invertY defines if data must be stored with Y axis inverted
  12741. * @param compression defines the compression used (null by default)
  12742. */
  12743. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12744. /**
  12745. * Update a raw cube texture
  12746. * @param texture defines the texture to udpdate
  12747. * @param data defines the data to store
  12748. * @param format defines the data format
  12749. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12750. * @param invertY defines if data must be stored with Y axis inverted
  12751. * @param compression defines the compression used (null by default)
  12752. * @param level defines which level of the texture to update
  12753. */
  12754. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12755. /**
  12756. * Creates a new raw cube texture from a specified url
  12757. * @param url defines the url where the data is located
  12758. * @param scene defines the current scene
  12759. * @param size defines the size of the textures
  12760. * @param format defines the format of the data
  12761. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12762. * @param noMipmap defines if the engine should avoid generating the mip levels
  12763. * @param callback defines a callback used to extract texture data from loaded data
  12764. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12765. * @param onLoad defines a callback called when texture is loaded
  12766. * @param onError defines a callback called if there is an error
  12767. * @returns the cube texture as an InternalTexture
  12768. */
  12769. 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;
  12770. /**
  12771. * Creates a new raw cube texture from a specified url
  12772. * @param url defines the url where the data is located
  12773. * @param scene defines the current scene
  12774. * @param size defines the size of the textures
  12775. * @param format defines the format of the data
  12776. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12777. * @param noMipmap defines if the engine should avoid generating the mip levels
  12778. * @param callback defines a callback used to extract texture data from loaded data
  12779. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12780. * @param onLoad defines a callback called when texture is loaded
  12781. * @param onError defines a callback called if there is an error
  12782. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12783. * @param invertY defines if data must be stored with Y axis inverted
  12784. * @returns the cube texture as an InternalTexture
  12785. */
  12786. 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;
  12787. /**
  12788. * Creates a new raw 3D texture
  12789. * @param data defines the data used to create the texture
  12790. * @param width defines the width of the texture
  12791. * @param height defines the height of the texture
  12792. * @param depth defines the depth of the texture
  12793. * @param format defines the format of the texture
  12794. * @param generateMipMaps defines if the engine must generate mip levels
  12795. * @param invertY defines if data must be stored with Y axis inverted
  12796. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12797. * @param compression defines the compressed used (can be null)
  12798. * @param textureType defines the compressed used (can be null)
  12799. * @returns a new raw 3D texture (stored in an InternalTexture)
  12800. */
  12801. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12802. /**
  12803. * Update a raw 3D texture
  12804. * @param texture defines the texture to update
  12805. * @param data defines the data to store
  12806. * @param format defines the data format
  12807. * @param invertY defines if data must be stored with Y axis inverted
  12808. */
  12809. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12810. /**
  12811. * Update a raw 3D texture
  12812. * @param texture defines the texture to update
  12813. * @param data defines the data to store
  12814. * @param format defines the data format
  12815. * @param invertY defines if data must be stored with Y axis inverted
  12816. * @param compression defines the used compression (can be null)
  12817. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12818. */
  12819. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12820. /**
  12821. * Creates a new raw 2D array texture
  12822. * @param data defines the data used to create the texture
  12823. * @param width defines the width of the texture
  12824. * @param height defines the height of the texture
  12825. * @param depth defines the number of layers of the texture
  12826. * @param format defines the format of the texture
  12827. * @param generateMipMaps defines if the engine must generate mip levels
  12828. * @param invertY defines if data must be stored with Y axis inverted
  12829. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12830. * @param compression defines the compressed used (can be null)
  12831. * @param textureType defines the compressed used (can be null)
  12832. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12833. */
  12834. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12835. /**
  12836. * Update a raw 2D array texture
  12837. * @param texture defines the texture to update
  12838. * @param data defines the data to store
  12839. * @param format defines the data format
  12840. * @param invertY defines if data must be stored with Y axis inverted
  12841. */
  12842. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12843. /**
  12844. * Update a raw 2D array texture
  12845. * @param texture defines the texture to update
  12846. * @param data defines the data to store
  12847. * @param format defines the data format
  12848. * @param invertY defines if data must be stored with Y axis inverted
  12849. * @param compression defines the used compression (can be null)
  12850. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12851. */
  12852. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12853. }
  12854. }
  12855. }
  12856. declare module "babylonjs/Materials/Textures/rawTexture" {
  12857. import { Scene } from "babylonjs/scene";
  12858. import { Texture } from "babylonjs/Materials/Textures/texture";
  12859. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12860. /**
  12861. * Raw texture can help creating a texture directly from an array of data.
  12862. * This can be super useful if you either get the data from an uncompressed source or
  12863. * if you wish to create your texture pixel by pixel.
  12864. */
  12865. export class RawTexture extends Texture {
  12866. /**
  12867. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12868. */
  12869. format: number;
  12870. private _engine;
  12871. /**
  12872. * Instantiates a new RawTexture.
  12873. * Raw texture can help creating a texture directly from an array of data.
  12874. * This can be super useful if you either get the data from an uncompressed source or
  12875. * if you wish to create your texture pixel by pixel.
  12876. * @param data define the array of data to use to create the texture
  12877. * @param width define the width of the texture
  12878. * @param height define the height of the texture
  12879. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12880. * @param scene define the scene the texture belongs to
  12881. * @param generateMipMaps define whether mip maps should be generated or not
  12882. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12883. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12884. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12885. */
  12886. constructor(data: ArrayBufferView, width: number, height: number,
  12887. /**
  12888. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12889. */
  12890. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12891. /**
  12892. * Updates the texture underlying data.
  12893. * @param data Define the new data of the texture
  12894. */
  12895. update(data: ArrayBufferView): void;
  12896. /**
  12897. * Creates a luminance texture from some data.
  12898. * @param data Define the texture data
  12899. * @param width Define the width of the texture
  12900. * @param height Define the height of the texture
  12901. * @param scene Define the scene the texture belongs to
  12902. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12903. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12904. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12905. * @returns the luminance texture
  12906. */
  12907. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12908. /**
  12909. * Creates a luminance alpha texture from some data.
  12910. * @param data Define the texture data
  12911. * @param width Define the width of the texture
  12912. * @param height Define the height of the texture
  12913. * @param scene Define the scene the texture belongs to
  12914. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12915. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12916. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12917. * @returns the luminance alpha texture
  12918. */
  12919. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12920. /**
  12921. * Creates an alpha texture from some data.
  12922. * @param data Define the texture data
  12923. * @param width Define the width of the texture
  12924. * @param height Define the height of the texture
  12925. * @param scene Define the scene the texture belongs to
  12926. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12927. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12928. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12929. * @returns the alpha texture
  12930. */
  12931. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12932. /**
  12933. * Creates a RGB texture from some data.
  12934. * @param data Define the texture data
  12935. * @param width Define the width of the texture
  12936. * @param height Define the height of the texture
  12937. * @param scene Define the scene the texture belongs to
  12938. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12939. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12940. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12941. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12942. * @returns the RGB alpha texture
  12943. */
  12944. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12945. /**
  12946. * Creates a RGBA texture from some data.
  12947. * @param data Define the texture data
  12948. * @param width Define the width of the texture
  12949. * @param height Define the height of the texture
  12950. * @param scene Define the scene the texture belongs to
  12951. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12952. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12953. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12954. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12955. * @returns the RGBA texture
  12956. */
  12957. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12958. /**
  12959. * Creates a R texture from some data.
  12960. * @param data Define the texture data
  12961. * @param width Define the width of the texture
  12962. * @param height Define the height of the texture
  12963. * @param scene Define the scene the texture belongs to
  12964. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12965. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12966. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12967. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12968. * @returns the R texture
  12969. */
  12970. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12971. }
  12972. }
  12973. declare module "babylonjs/Maths/math.size" {
  12974. /**
  12975. * Interface for the size containing width and height
  12976. */
  12977. export interface ISize {
  12978. /**
  12979. * Width
  12980. */
  12981. width: number;
  12982. /**
  12983. * Heighht
  12984. */
  12985. height: number;
  12986. }
  12987. /**
  12988. * Size containing widht and height
  12989. */
  12990. export class Size implements ISize {
  12991. /**
  12992. * Width
  12993. */
  12994. width: number;
  12995. /**
  12996. * Height
  12997. */
  12998. height: number;
  12999. /**
  13000. * Creates a Size object from the given width and height (floats).
  13001. * @param width width of the new size
  13002. * @param height height of the new size
  13003. */
  13004. constructor(width: number, height: number);
  13005. /**
  13006. * Returns a string with the Size width and height
  13007. * @returns a string with the Size width and height
  13008. */
  13009. toString(): string;
  13010. /**
  13011. * "Size"
  13012. * @returns the string "Size"
  13013. */
  13014. getClassName(): string;
  13015. /**
  13016. * Returns the Size hash code.
  13017. * @returns a hash code for a unique width and height
  13018. */
  13019. getHashCode(): number;
  13020. /**
  13021. * Updates the current size from the given one.
  13022. * @param src the given size
  13023. */
  13024. copyFrom(src: Size): void;
  13025. /**
  13026. * Updates in place the current Size from the given floats.
  13027. * @param width width of the new size
  13028. * @param height height of the new size
  13029. * @returns the updated Size.
  13030. */
  13031. copyFromFloats(width: number, height: number): Size;
  13032. /**
  13033. * Updates in place the current Size from the given floats.
  13034. * @param width width to set
  13035. * @param height height to set
  13036. * @returns the updated Size.
  13037. */
  13038. set(width: number, height: number): Size;
  13039. /**
  13040. * Multiplies the width and height by numbers
  13041. * @param w factor to multiple the width by
  13042. * @param h factor to multiple the height by
  13043. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13044. */
  13045. multiplyByFloats(w: number, h: number): Size;
  13046. /**
  13047. * Clones the size
  13048. * @returns a new Size copied from the given one.
  13049. */
  13050. clone(): Size;
  13051. /**
  13052. * True if the current Size and the given one width and height are strictly equal.
  13053. * @param other the other size to compare against
  13054. * @returns True if the current Size and the given one width and height are strictly equal.
  13055. */
  13056. equals(other: Size): boolean;
  13057. /**
  13058. * The surface of the Size : width * height (float).
  13059. */
  13060. readonly surface: number;
  13061. /**
  13062. * Create a new size of zero
  13063. * @returns a new Size set to (0.0, 0.0)
  13064. */
  13065. static Zero(): Size;
  13066. /**
  13067. * Sums the width and height of two sizes
  13068. * @param otherSize size to add to this size
  13069. * @returns a new Size set as the addition result of the current Size and the given one.
  13070. */
  13071. add(otherSize: Size): Size;
  13072. /**
  13073. * Subtracts the width and height of two
  13074. * @param otherSize size to subtract to this size
  13075. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13076. */
  13077. subtract(otherSize: Size): Size;
  13078. /**
  13079. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13080. * @param start starting size to lerp between
  13081. * @param end end size to lerp between
  13082. * @param amount amount to lerp between the start and end values
  13083. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13084. */
  13085. static Lerp(start: Size, end: Size, amount: number): Size;
  13086. }
  13087. }
  13088. declare module "babylonjs/Animations/runtimeAnimation" {
  13089. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13090. import { Animatable } from "babylonjs/Animations/animatable";
  13091. import { Scene } from "babylonjs/scene";
  13092. /**
  13093. * Defines a runtime animation
  13094. */
  13095. export class RuntimeAnimation {
  13096. private _events;
  13097. /**
  13098. * The current frame of the runtime animation
  13099. */
  13100. private _currentFrame;
  13101. /**
  13102. * The animation used by the runtime animation
  13103. */
  13104. private _animation;
  13105. /**
  13106. * The target of the runtime animation
  13107. */
  13108. private _target;
  13109. /**
  13110. * The initiating animatable
  13111. */
  13112. private _host;
  13113. /**
  13114. * The original value of the runtime animation
  13115. */
  13116. private _originalValue;
  13117. /**
  13118. * The original blend value of the runtime animation
  13119. */
  13120. private _originalBlendValue;
  13121. /**
  13122. * The offsets cache of the runtime animation
  13123. */
  13124. private _offsetsCache;
  13125. /**
  13126. * The high limits cache of the runtime animation
  13127. */
  13128. private _highLimitsCache;
  13129. /**
  13130. * Specifies if the runtime animation has been stopped
  13131. */
  13132. private _stopped;
  13133. /**
  13134. * The blending factor of the runtime animation
  13135. */
  13136. private _blendingFactor;
  13137. /**
  13138. * The BabylonJS scene
  13139. */
  13140. private _scene;
  13141. /**
  13142. * The current value of the runtime animation
  13143. */
  13144. private _currentValue;
  13145. /** @hidden */
  13146. _animationState: _IAnimationState;
  13147. /**
  13148. * The active target of the runtime animation
  13149. */
  13150. private _activeTargets;
  13151. private _currentActiveTarget;
  13152. private _directTarget;
  13153. /**
  13154. * The target path of the runtime animation
  13155. */
  13156. private _targetPath;
  13157. /**
  13158. * The weight of the runtime animation
  13159. */
  13160. private _weight;
  13161. /**
  13162. * The ratio offset of the runtime animation
  13163. */
  13164. private _ratioOffset;
  13165. /**
  13166. * The previous delay of the runtime animation
  13167. */
  13168. private _previousDelay;
  13169. /**
  13170. * The previous ratio of the runtime animation
  13171. */
  13172. private _previousRatio;
  13173. private _enableBlending;
  13174. private _keys;
  13175. private _minFrame;
  13176. private _maxFrame;
  13177. private _minValue;
  13178. private _maxValue;
  13179. private _targetIsArray;
  13180. /**
  13181. * Gets the current frame of the runtime animation
  13182. */
  13183. readonly currentFrame: number;
  13184. /**
  13185. * Gets the weight of the runtime animation
  13186. */
  13187. readonly weight: number;
  13188. /**
  13189. * Gets the current value of the runtime animation
  13190. */
  13191. readonly currentValue: any;
  13192. /**
  13193. * Gets the target path of the runtime animation
  13194. */
  13195. readonly targetPath: string;
  13196. /**
  13197. * Gets the actual target of the runtime animation
  13198. */
  13199. readonly target: any;
  13200. /** @hidden */
  13201. _onLoop: () => void;
  13202. /**
  13203. * Create a new RuntimeAnimation object
  13204. * @param target defines the target of the animation
  13205. * @param animation defines the source animation object
  13206. * @param scene defines the hosting scene
  13207. * @param host defines the initiating Animatable
  13208. */
  13209. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13210. private _preparePath;
  13211. /**
  13212. * Gets the animation from the runtime animation
  13213. */
  13214. readonly animation: Animation;
  13215. /**
  13216. * Resets the runtime animation to the beginning
  13217. * @param restoreOriginal defines whether to restore the target property to the original value
  13218. */
  13219. reset(restoreOriginal?: boolean): void;
  13220. /**
  13221. * Specifies if the runtime animation is stopped
  13222. * @returns Boolean specifying if the runtime animation is stopped
  13223. */
  13224. isStopped(): boolean;
  13225. /**
  13226. * Disposes of the runtime animation
  13227. */
  13228. dispose(): void;
  13229. /**
  13230. * Apply the interpolated value to the target
  13231. * @param currentValue defines the value computed by the animation
  13232. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13233. */
  13234. setValue(currentValue: any, weight: number): void;
  13235. private _getOriginalValues;
  13236. private _setValue;
  13237. /**
  13238. * Gets the loop pmode of the runtime animation
  13239. * @returns Loop Mode
  13240. */
  13241. private _getCorrectLoopMode;
  13242. /**
  13243. * Move the current animation to a given frame
  13244. * @param frame defines the frame to move to
  13245. */
  13246. goToFrame(frame: number): void;
  13247. /**
  13248. * @hidden Internal use only
  13249. */
  13250. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13251. /**
  13252. * Execute the current animation
  13253. * @param delay defines the delay to add to the current frame
  13254. * @param from defines the lower bound of the animation range
  13255. * @param to defines the upper bound of the animation range
  13256. * @param loop defines if the current animation must loop
  13257. * @param speedRatio defines the current speed ratio
  13258. * @param weight defines the weight of the animation (default is -1 so no weight)
  13259. * @param onLoop optional callback called when animation loops
  13260. * @returns a boolean indicating if the animation is running
  13261. */
  13262. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13263. }
  13264. }
  13265. declare module "babylonjs/Animations/animatable" {
  13266. import { Animation } from "babylonjs/Animations/animation";
  13267. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13268. import { Nullable } from "babylonjs/types";
  13269. import { Observable } from "babylonjs/Misc/observable";
  13270. import { Scene } from "babylonjs/scene";
  13271. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13272. import { Node } from "babylonjs/node";
  13273. /**
  13274. * Class used to store an actual running animation
  13275. */
  13276. export class Animatable {
  13277. /** defines the target object */
  13278. target: any;
  13279. /** defines the starting frame number (default is 0) */
  13280. fromFrame: number;
  13281. /** defines the ending frame number (default is 100) */
  13282. toFrame: number;
  13283. /** defines if the animation must loop (default is false) */
  13284. loopAnimation: boolean;
  13285. /** defines a callback to call when animation ends if it is not looping */
  13286. onAnimationEnd?: (() => void) | null | undefined;
  13287. /** defines a callback to call when animation loops */
  13288. onAnimationLoop?: (() => void) | null | undefined;
  13289. private _localDelayOffset;
  13290. private _pausedDelay;
  13291. private _runtimeAnimations;
  13292. private _paused;
  13293. private _scene;
  13294. private _speedRatio;
  13295. private _weight;
  13296. private _syncRoot;
  13297. /**
  13298. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13299. * This will only apply for non looping animation (default is true)
  13300. */
  13301. disposeOnEnd: boolean;
  13302. /**
  13303. * Gets a boolean indicating if the animation has started
  13304. */
  13305. animationStarted: boolean;
  13306. /**
  13307. * Observer raised when the animation ends
  13308. */
  13309. onAnimationEndObservable: Observable<Animatable>;
  13310. /**
  13311. * Observer raised when the animation loops
  13312. */
  13313. onAnimationLoopObservable: Observable<Animatable>;
  13314. /**
  13315. * Gets the root Animatable used to synchronize and normalize animations
  13316. */
  13317. readonly syncRoot: Nullable<Animatable>;
  13318. /**
  13319. * Gets the current frame of the first RuntimeAnimation
  13320. * Used to synchronize Animatables
  13321. */
  13322. readonly masterFrame: number;
  13323. /**
  13324. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13325. */
  13326. weight: number;
  13327. /**
  13328. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13329. */
  13330. speedRatio: number;
  13331. /**
  13332. * Creates a new Animatable
  13333. * @param scene defines the hosting scene
  13334. * @param target defines the target object
  13335. * @param fromFrame defines the starting frame number (default is 0)
  13336. * @param toFrame defines the ending frame number (default is 100)
  13337. * @param loopAnimation defines if the animation must loop (default is false)
  13338. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13339. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13340. * @param animations defines a group of animation to add to the new Animatable
  13341. * @param onAnimationLoop defines a callback to call when animation loops
  13342. */
  13343. constructor(scene: Scene,
  13344. /** defines the target object */
  13345. target: any,
  13346. /** defines the starting frame number (default is 0) */
  13347. fromFrame?: number,
  13348. /** defines the ending frame number (default is 100) */
  13349. toFrame?: number,
  13350. /** defines if the animation must loop (default is false) */
  13351. loopAnimation?: boolean, speedRatio?: number,
  13352. /** defines a callback to call when animation ends if it is not looping */
  13353. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13354. /** defines a callback to call when animation loops */
  13355. onAnimationLoop?: (() => void) | null | undefined);
  13356. /**
  13357. * Synchronize and normalize current Animatable with a source Animatable
  13358. * This is useful when using animation weights and when animations are not of the same length
  13359. * @param root defines the root Animatable to synchronize with
  13360. * @returns the current Animatable
  13361. */
  13362. syncWith(root: Animatable): Animatable;
  13363. /**
  13364. * Gets the list of runtime animations
  13365. * @returns an array of RuntimeAnimation
  13366. */
  13367. getAnimations(): RuntimeAnimation[];
  13368. /**
  13369. * Adds more animations to the current animatable
  13370. * @param target defines the target of the animations
  13371. * @param animations defines the new animations to add
  13372. */
  13373. appendAnimations(target: any, animations: Animation[]): void;
  13374. /**
  13375. * Gets the source animation for a specific property
  13376. * @param property defines the propertyu to look for
  13377. * @returns null or the source animation for the given property
  13378. */
  13379. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13380. /**
  13381. * Gets the runtime animation for a specific property
  13382. * @param property defines the propertyu to look for
  13383. * @returns null or the runtime animation for the given property
  13384. */
  13385. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13386. /**
  13387. * Resets the animatable to its original state
  13388. */
  13389. reset(): void;
  13390. /**
  13391. * Allows the animatable to blend with current running animations
  13392. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13393. * @param blendingSpeed defines the blending speed to use
  13394. */
  13395. enableBlending(blendingSpeed: number): void;
  13396. /**
  13397. * Disable animation blending
  13398. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13399. */
  13400. disableBlending(): void;
  13401. /**
  13402. * Jump directly to a given frame
  13403. * @param frame defines the frame to jump to
  13404. */
  13405. goToFrame(frame: number): void;
  13406. /**
  13407. * Pause the animation
  13408. */
  13409. pause(): void;
  13410. /**
  13411. * Restart the animation
  13412. */
  13413. restart(): void;
  13414. private _raiseOnAnimationEnd;
  13415. /**
  13416. * Stop and delete the current animation
  13417. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13418. * @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)
  13419. */
  13420. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13421. /**
  13422. * Wait asynchronously for the animation to end
  13423. * @returns a promise which will be fullfilled when the animation ends
  13424. */
  13425. waitAsync(): Promise<Animatable>;
  13426. /** @hidden */
  13427. _animate(delay: number): boolean;
  13428. }
  13429. module "babylonjs/scene" {
  13430. interface Scene {
  13431. /** @hidden */
  13432. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13433. /** @hidden */
  13434. _processLateAnimationBindingsForMatrices(holder: {
  13435. totalWeight: number;
  13436. animations: RuntimeAnimation[];
  13437. originalValue: Matrix;
  13438. }): any;
  13439. /** @hidden */
  13440. _processLateAnimationBindingsForQuaternions(holder: {
  13441. totalWeight: number;
  13442. animations: RuntimeAnimation[];
  13443. originalValue: Quaternion;
  13444. }, refQuaternion: Quaternion): Quaternion;
  13445. /** @hidden */
  13446. _processLateAnimationBindings(): void;
  13447. /**
  13448. * Will start the animation sequence of a given target
  13449. * @param target defines the target
  13450. * @param from defines from which frame should animation start
  13451. * @param to defines until which frame should animation run.
  13452. * @param weight defines the weight to apply to the animation (1.0 by default)
  13453. * @param loop defines if the animation loops
  13454. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13455. * @param onAnimationEnd defines the function to be executed when the animation ends
  13456. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13457. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13458. * @param onAnimationLoop defines the callback to call when an animation loops
  13459. * @returns the animatable object created for this animation
  13460. */
  13461. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13462. /**
  13463. * Will start the animation sequence of a given target
  13464. * @param target defines the target
  13465. * @param from defines from which frame should animation start
  13466. * @param to defines until which frame should animation run.
  13467. * @param loop defines if the animation loops
  13468. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13469. * @param onAnimationEnd defines the function to be executed when the animation ends
  13470. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13471. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13472. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13473. * @param onAnimationLoop defines the callback to call when an animation loops
  13474. * @returns the animatable object created for this animation
  13475. */
  13476. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13477. /**
  13478. * Will start the animation sequence of a given target and its hierarchy
  13479. * @param target defines the target
  13480. * @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.
  13481. * @param from defines from which frame should animation start
  13482. * @param to defines until which frame should animation run.
  13483. * @param loop defines if the animation loops
  13484. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13485. * @param onAnimationEnd defines the function to be executed when the animation ends
  13486. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13487. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13488. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13489. * @param onAnimationLoop defines the callback to call when an animation loops
  13490. * @returns the list of created animatables
  13491. */
  13492. 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[];
  13493. /**
  13494. * Begin a new animation on a given node
  13495. * @param target defines the target where the animation will take place
  13496. * @param animations defines the list of animations to start
  13497. * @param from defines the initial value
  13498. * @param to defines the final value
  13499. * @param loop defines if you want animation to loop (off by default)
  13500. * @param speedRatio defines the speed ratio to apply to all animations
  13501. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13502. * @param onAnimationLoop defines the callback to call when an animation loops
  13503. * @returns the list of created animatables
  13504. */
  13505. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13506. /**
  13507. * Begin a new animation on a given node and its hierarchy
  13508. * @param target defines the root node where the animation will take place
  13509. * @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.
  13510. * @param animations defines the list of animations to start
  13511. * @param from defines the initial value
  13512. * @param to defines the final value
  13513. * @param loop defines if you want animation to loop (off by default)
  13514. * @param speedRatio defines the speed ratio to apply to all animations
  13515. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13516. * @param onAnimationLoop defines the callback to call when an animation loops
  13517. * @returns the list of animatables created for all nodes
  13518. */
  13519. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13520. /**
  13521. * Gets the animatable associated with a specific target
  13522. * @param target defines the target of the animatable
  13523. * @returns the required animatable if found
  13524. */
  13525. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13526. /**
  13527. * Gets all animatables associated with a given target
  13528. * @param target defines the target to look animatables for
  13529. * @returns an array of Animatables
  13530. */
  13531. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13532. /**
  13533. * Stops and removes all animations that have been applied to the scene
  13534. */
  13535. stopAllAnimations(): void;
  13536. /**
  13537. * Gets the current delta time used by animation engine
  13538. */
  13539. deltaTime: number;
  13540. }
  13541. }
  13542. module "babylonjs/Bones/bone" {
  13543. interface Bone {
  13544. /**
  13545. * Copy an animation range from another bone
  13546. * @param source defines the source bone
  13547. * @param rangeName defines the range name to copy
  13548. * @param frameOffset defines the frame offset
  13549. * @param rescaleAsRequired defines if rescaling must be applied if required
  13550. * @param skelDimensionsRatio defines the scaling ratio
  13551. * @returns true if operation was successful
  13552. */
  13553. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13554. }
  13555. }
  13556. }
  13557. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13558. /**
  13559. * Class used to override all child animations of a given target
  13560. */
  13561. export class AnimationPropertiesOverride {
  13562. /**
  13563. * Gets or sets a value indicating if animation blending must be used
  13564. */
  13565. enableBlending: boolean;
  13566. /**
  13567. * Gets or sets the blending speed to use when enableBlending is true
  13568. */
  13569. blendingSpeed: number;
  13570. /**
  13571. * Gets or sets the default loop mode to use
  13572. */
  13573. loopMode: number;
  13574. }
  13575. }
  13576. declare module "babylonjs/Bones/skeleton" {
  13577. import { Bone } from "babylonjs/Bones/bone";
  13578. import { Observable } from "babylonjs/Misc/observable";
  13579. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13580. import { Scene } from "babylonjs/scene";
  13581. import { Nullable } from "babylonjs/types";
  13582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13583. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13584. import { Animatable } from "babylonjs/Animations/animatable";
  13585. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13586. import { Animation } from "babylonjs/Animations/animation";
  13587. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13588. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13589. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13590. /**
  13591. * Class used to handle skinning animations
  13592. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13593. */
  13594. export class Skeleton implements IAnimatable {
  13595. /** defines the skeleton name */
  13596. name: string;
  13597. /** defines the skeleton Id */
  13598. id: string;
  13599. /**
  13600. * Defines the list of child bones
  13601. */
  13602. bones: Bone[];
  13603. /**
  13604. * Defines an estimate of the dimension of the skeleton at rest
  13605. */
  13606. dimensionsAtRest: Vector3;
  13607. /**
  13608. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13609. */
  13610. needInitialSkinMatrix: boolean;
  13611. /**
  13612. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13613. */
  13614. overrideMesh: Nullable<AbstractMesh>;
  13615. /**
  13616. * Gets the list of animations attached to this skeleton
  13617. */
  13618. animations: Array<Animation>;
  13619. private _scene;
  13620. private _isDirty;
  13621. private _transformMatrices;
  13622. private _transformMatrixTexture;
  13623. private _meshesWithPoseMatrix;
  13624. private _animatables;
  13625. private _identity;
  13626. private _synchronizedWithMesh;
  13627. private _ranges;
  13628. private _lastAbsoluteTransformsUpdateId;
  13629. private _canUseTextureForBones;
  13630. private _uniqueId;
  13631. /** @hidden */
  13632. _numBonesWithLinkedTransformNode: number;
  13633. /** @hidden */
  13634. _hasWaitingData: Nullable<boolean>;
  13635. /**
  13636. * Specifies if the skeleton should be serialized
  13637. */
  13638. doNotSerialize: boolean;
  13639. private _useTextureToStoreBoneMatrices;
  13640. /**
  13641. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13642. * Please note that this option is not available if the hardware does not support it
  13643. */
  13644. useTextureToStoreBoneMatrices: boolean;
  13645. private _animationPropertiesOverride;
  13646. /**
  13647. * Gets or sets the animation properties override
  13648. */
  13649. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13650. /**
  13651. * List of inspectable custom properties (used by the Inspector)
  13652. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13653. */
  13654. inspectableCustomProperties: IInspectable[];
  13655. /**
  13656. * An observable triggered before computing the skeleton's matrices
  13657. */
  13658. onBeforeComputeObservable: Observable<Skeleton>;
  13659. /**
  13660. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13661. */
  13662. readonly isUsingTextureForMatrices: boolean;
  13663. /**
  13664. * Gets the unique ID of this skeleton
  13665. */
  13666. readonly uniqueId: number;
  13667. /**
  13668. * Creates a new skeleton
  13669. * @param name defines the skeleton name
  13670. * @param id defines the skeleton Id
  13671. * @param scene defines the hosting scene
  13672. */
  13673. constructor(
  13674. /** defines the skeleton name */
  13675. name: string,
  13676. /** defines the skeleton Id */
  13677. id: string, scene: Scene);
  13678. /**
  13679. * Gets the current object class name.
  13680. * @return the class name
  13681. */
  13682. getClassName(): string;
  13683. /**
  13684. * Returns an array containing the root bones
  13685. * @returns an array containing the root bones
  13686. */
  13687. getChildren(): Array<Bone>;
  13688. /**
  13689. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13690. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13691. * @returns a Float32Array containing matrices data
  13692. */
  13693. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13694. /**
  13695. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13696. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13697. * @returns a raw texture containing the data
  13698. */
  13699. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13700. /**
  13701. * Gets the current hosting scene
  13702. * @returns a scene object
  13703. */
  13704. getScene(): Scene;
  13705. /**
  13706. * Gets a string representing the current skeleton data
  13707. * @param fullDetails defines a boolean indicating if we want a verbose version
  13708. * @returns a string representing the current skeleton data
  13709. */
  13710. toString(fullDetails?: boolean): string;
  13711. /**
  13712. * Get bone's index searching by name
  13713. * @param name defines bone's name to search for
  13714. * @return the indice of the bone. Returns -1 if not found
  13715. */
  13716. getBoneIndexByName(name: string): number;
  13717. /**
  13718. * Creater a new animation range
  13719. * @param name defines the name of the range
  13720. * @param from defines the start key
  13721. * @param to defines the end key
  13722. */
  13723. createAnimationRange(name: string, from: number, to: number): void;
  13724. /**
  13725. * Delete a specific animation range
  13726. * @param name defines the name of the range
  13727. * @param deleteFrames defines if frames must be removed as well
  13728. */
  13729. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13730. /**
  13731. * Gets a specific animation range
  13732. * @param name defines the name of the range to look for
  13733. * @returns the requested animation range or null if not found
  13734. */
  13735. getAnimationRange(name: string): Nullable<AnimationRange>;
  13736. /**
  13737. * Gets the list of all animation ranges defined on this skeleton
  13738. * @returns an array
  13739. */
  13740. getAnimationRanges(): Nullable<AnimationRange>[];
  13741. /**
  13742. * Copy animation range from a source skeleton.
  13743. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13744. * @param source defines the source skeleton
  13745. * @param name defines the name of the range to copy
  13746. * @param rescaleAsRequired defines if rescaling must be applied if required
  13747. * @returns true if operation was successful
  13748. */
  13749. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13750. /**
  13751. * Forces the skeleton to go to rest pose
  13752. */
  13753. returnToRest(): void;
  13754. private _getHighestAnimationFrame;
  13755. /**
  13756. * Begin a specific animation range
  13757. * @param name defines the name of the range to start
  13758. * @param loop defines if looping must be turned on (false by default)
  13759. * @param speedRatio defines the speed ratio to apply (1 by default)
  13760. * @param onAnimationEnd defines a callback which will be called when animation will end
  13761. * @returns a new animatable
  13762. */
  13763. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13764. /** @hidden */
  13765. _markAsDirty(): void;
  13766. /** @hidden */
  13767. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13768. /** @hidden */
  13769. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13770. private _computeTransformMatrices;
  13771. /**
  13772. * Build all resources required to render a skeleton
  13773. */
  13774. prepare(): void;
  13775. /**
  13776. * Gets the list of animatables currently running for this skeleton
  13777. * @returns an array of animatables
  13778. */
  13779. getAnimatables(): IAnimatable[];
  13780. /**
  13781. * Clone the current skeleton
  13782. * @param name defines the name of the new skeleton
  13783. * @param id defines the id of the new skeleton
  13784. * @returns the new skeleton
  13785. */
  13786. clone(name: string, id?: string): Skeleton;
  13787. /**
  13788. * Enable animation blending for this skeleton
  13789. * @param blendingSpeed defines the blending speed to apply
  13790. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13791. */
  13792. enableBlending(blendingSpeed?: number): void;
  13793. /**
  13794. * Releases all resources associated with the current skeleton
  13795. */
  13796. dispose(): void;
  13797. /**
  13798. * Serialize the skeleton in a JSON object
  13799. * @returns a JSON object
  13800. */
  13801. serialize(): any;
  13802. /**
  13803. * Creates a new skeleton from serialized data
  13804. * @param parsedSkeleton defines the serialized data
  13805. * @param scene defines the hosting scene
  13806. * @returns a new skeleton
  13807. */
  13808. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13809. /**
  13810. * Compute all node absolute transforms
  13811. * @param forceUpdate defines if computation must be done even if cache is up to date
  13812. */
  13813. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13814. /**
  13815. * Gets the root pose matrix
  13816. * @returns a matrix
  13817. */
  13818. getPoseMatrix(): Nullable<Matrix>;
  13819. /**
  13820. * Sorts bones per internal index
  13821. */
  13822. sortBones(): void;
  13823. private _sortBones;
  13824. }
  13825. }
  13826. declare module "babylonjs/Bones/bone" {
  13827. import { Skeleton } from "babylonjs/Bones/skeleton";
  13828. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13829. import { Nullable } from "babylonjs/types";
  13830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13831. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13832. import { Node } from "babylonjs/node";
  13833. import { Space } from "babylonjs/Maths/math.axis";
  13834. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13835. /**
  13836. * Class used to store bone information
  13837. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13838. */
  13839. export class Bone extends Node {
  13840. /**
  13841. * defines the bone name
  13842. */
  13843. name: string;
  13844. private static _tmpVecs;
  13845. private static _tmpQuat;
  13846. private static _tmpMats;
  13847. /**
  13848. * Gets the list of child bones
  13849. */
  13850. children: Bone[];
  13851. /** Gets the animations associated with this bone */
  13852. animations: import("babylonjs/Animations/animation").Animation[];
  13853. /**
  13854. * Gets or sets bone length
  13855. */
  13856. length: number;
  13857. /**
  13858. * @hidden Internal only
  13859. * Set this value to map this bone to a different index in the transform matrices
  13860. * Set this value to -1 to exclude the bone from the transform matrices
  13861. */
  13862. _index: Nullable<number>;
  13863. private _skeleton;
  13864. private _localMatrix;
  13865. private _restPose;
  13866. private _baseMatrix;
  13867. private _absoluteTransform;
  13868. private _invertedAbsoluteTransform;
  13869. private _parent;
  13870. private _scalingDeterminant;
  13871. private _worldTransform;
  13872. private _localScaling;
  13873. private _localRotation;
  13874. private _localPosition;
  13875. private _needToDecompose;
  13876. private _needToCompose;
  13877. /** @hidden */
  13878. _linkedTransformNode: Nullable<TransformNode>;
  13879. /** @hidden */
  13880. _waitingTransformNodeId: Nullable<string>;
  13881. /** @hidden */
  13882. /** @hidden */
  13883. _matrix: Matrix;
  13884. /**
  13885. * Create a new bone
  13886. * @param name defines the bone name
  13887. * @param skeleton defines the parent skeleton
  13888. * @param parentBone defines the parent (can be null if the bone is the root)
  13889. * @param localMatrix defines the local matrix
  13890. * @param restPose defines the rest pose matrix
  13891. * @param baseMatrix defines the base matrix
  13892. * @param index defines index of the bone in the hiearchy
  13893. */
  13894. constructor(
  13895. /**
  13896. * defines the bone name
  13897. */
  13898. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13899. /**
  13900. * Gets the current object class name.
  13901. * @return the class name
  13902. */
  13903. getClassName(): string;
  13904. /**
  13905. * Gets the parent skeleton
  13906. * @returns a skeleton
  13907. */
  13908. getSkeleton(): Skeleton;
  13909. /**
  13910. * Gets parent bone
  13911. * @returns a bone or null if the bone is the root of the bone hierarchy
  13912. */
  13913. getParent(): Nullable<Bone>;
  13914. /**
  13915. * Returns an array containing the root bones
  13916. * @returns an array containing the root bones
  13917. */
  13918. getChildren(): Array<Bone>;
  13919. /**
  13920. * Gets the node index in matrix array generated for rendering
  13921. * @returns the node index
  13922. */
  13923. getIndex(): number;
  13924. /**
  13925. * Sets the parent bone
  13926. * @param parent defines the parent (can be null if the bone is the root)
  13927. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13928. */
  13929. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13930. /**
  13931. * Gets the local matrix
  13932. * @returns a matrix
  13933. */
  13934. getLocalMatrix(): Matrix;
  13935. /**
  13936. * Gets the base matrix (initial matrix which remains unchanged)
  13937. * @returns a matrix
  13938. */
  13939. getBaseMatrix(): Matrix;
  13940. /**
  13941. * Gets the rest pose matrix
  13942. * @returns a matrix
  13943. */
  13944. getRestPose(): Matrix;
  13945. /**
  13946. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13947. */
  13948. getWorldMatrix(): Matrix;
  13949. /**
  13950. * Sets the local matrix to rest pose matrix
  13951. */
  13952. returnToRest(): void;
  13953. /**
  13954. * Gets the inverse of the absolute transform matrix.
  13955. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13956. * @returns a matrix
  13957. */
  13958. getInvertedAbsoluteTransform(): Matrix;
  13959. /**
  13960. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13961. * @returns a matrix
  13962. */
  13963. getAbsoluteTransform(): Matrix;
  13964. /**
  13965. * Links with the given transform node.
  13966. * The local matrix of this bone is copied from the transform node every frame.
  13967. * @param transformNode defines the transform node to link to
  13968. */
  13969. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13970. /**
  13971. * Gets the node used to drive the bone's transformation
  13972. * @returns a transform node or null
  13973. */
  13974. getTransformNode(): Nullable<TransformNode>;
  13975. /** Gets or sets current position (in local space) */
  13976. position: Vector3;
  13977. /** Gets or sets current rotation (in local space) */
  13978. rotation: Vector3;
  13979. /** Gets or sets current rotation quaternion (in local space) */
  13980. rotationQuaternion: Quaternion;
  13981. /** Gets or sets current scaling (in local space) */
  13982. scaling: Vector3;
  13983. /**
  13984. * Gets the animation properties override
  13985. */
  13986. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13987. private _decompose;
  13988. private _compose;
  13989. /**
  13990. * Update the base and local matrices
  13991. * @param matrix defines the new base or local matrix
  13992. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13993. * @param updateLocalMatrix defines if the local matrix should be updated
  13994. */
  13995. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13996. /** @hidden */
  13997. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13998. /**
  13999. * Flag the bone as dirty (Forcing it to update everything)
  14000. */
  14001. markAsDirty(): void;
  14002. /** @hidden */
  14003. _markAsDirtyAndCompose(): void;
  14004. private _markAsDirtyAndDecompose;
  14005. /**
  14006. * Translate the bone in local or world space
  14007. * @param vec The amount to translate the bone
  14008. * @param space The space that the translation is in
  14009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14010. */
  14011. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14012. /**
  14013. * Set the postion of the bone in local or world space
  14014. * @param position The position to set the bone
  14015. * @param space The space that the position is in
  14016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14017. */
  14018. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14019. /**
  14020. * Set the absolute position of the bone (world space)
  14021. * @param position The position to set the bone
  14022. * @param mesh The mesh that this bone is attached to
  14023. */
  14024. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14025. /**
  14026. * Scale the bone on the x, y and z axes (in local space)
  14027. * @param x The amount to scale the bone on the x axis
  14028. * @param y The amount to scale the bone on the y axis
  14029. * @param z The amount to scale the bone on the z axis
  14030. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14031. */
  14032. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14033. /**
  14034. * Set the bone scaling in local space
  14035. * @param scale defines the scaling vector
  14036. */
  14037. setScale(scale: Vector3): void;
  14038. /**
  14039. * Gets the current scaling in local space
  14040. * @returns the current scaling vector
  14041. */
  14042. getScale(): Vector3;
  14043. /**
  14044. * Gets the current scaling in local space and stores it in a target vector
  14045. * @param result defines the target vector
  14046. */
  14047. getScaleToRef(result: Vector3): void;
  14048. /**
  14049. * Set the yaw, pitch, and roll of the bone in local or world space
  14050. * @param yaw The rotation of the bone on the y axis
  14051. * @param pitch The rotation of the bone on the x axis
  14052. * @param roll The rotation of the bone on the z axis
  14053. * @param space The space that the axes of rotation are in
  14054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14055. */
  14056. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14057. /**
  14058. * Add a rotation to the bone on an axis in local or world space
  14059. * @param axis The axis to rotate the bone on
  14060. * @param amount The amount to rotate the bone
  14061. * @param space The space that the axis is in
  14062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14063. */
  14064. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14065. /**
  14066. * Set the rotation of the bone to a particular axis angle in local or world space
  14067. * @param axis The axis to rotate the bone on
  14068. * @param angle The angle that the bone should be rotated to
  14069. * @param space The space that the axis is in
  14070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14071. */
  14072. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14073. /**
  14074. * Set the euler rotation of the bone in local of world space
  14075. * @param rotation The euler rotation that the bone should be set to
  14076. * @param space The space that the rotation is in
  14077. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14078. */
  14079. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14080. /**
  14081. * Set the quaternion rotation of the bone in local of world space
  14082. * @param quat The quaternion rotation that the bone should be set to
  14083. * @param space The space that the rotation is in
  14084. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14085. */
  14086. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14087. /**
  14088. * Set the rotation matrix of the bone in local of world space
  14089. * @param rotMat The rotation matrix that the bone should be set to
  14090. * @param space The space that the rotation is in
  14091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14092. */
  14093. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14094. private _rotateWithMatrix;
  14095. private _getNegativeRotationToRef;
  14096. /**
  14097. * Get the position of the bone in local or world space
  14098. * @param space The space that the returned position is in
  14099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14100. * @returns The position of the bone
  14101. */
  14102. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14103. /**
  14104. * Copy the position of the bone to a vector3 in local or world space
  14105. * @param space The space that the returned position is in
  14106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14107. * @param result The vector3 to copy the position to
  14108. */
  14109. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14110. /**
  14111. * Get the absolute position of the bone (world space)
  14112. * @param mesh The mesh that this bone is attached to
  14113. * @returns The absolute position of the bone
  14114. */
  14115. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14116. /**
  14117. * Copy the absolute position of the bone (world space) to the result param
  14118. * @param mesh The mesh that this bone is attached to
  14119. * @param result The vector3 to copy the absolute position to
  14120. */
  14121. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14122. /**
  14123. * Compute the absolute transforms of this bone and its children
  14124. */
  14125. computeAbsoluteTransforms(): void;
  14126. /**
  14127. * Get the world direction from an axis that is in the local space of the bone
  14128. * @param localAxis The local direction that is used to compute the world direction
  14129. * @param mesh The mesh that this bone is attached to
  14130. * @returns The world direction
  14131. */
  14132. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14133. /**
  14134. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14135. * @param localAxis The local direction that is used to compute the world direction
  14136. * @param mesh The mesh that this bone is attached to
  14137. * @param result The vector3 that the world direction will be copied to
  14138. */
  14139. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14140. /**
  14141. * Get the euler rotation of the bone in local or world space
  14142. * @param space The space that the rotation should be in
  14143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14144. * @returns The euler rotation
  14145. */
  14146. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14147. /**
  14148. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14149. * @param space The space that the rotation should be in
  14150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14151. * @param result The vector3 that the rotation should be copied to
  14152. */
  14153. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14154. /**
  14155. * Get the quaternion rotation of the bone in either local or world space
  14156. * @param space The space that the rotation should be in
  14157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14158. * @returns The quaternion rotation
  14159. */
  14160. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14161. /**
  14162. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14163. * @param space The space that the rotation should be in
  14164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14165. * @param result The quaternion that the rotation should be copied to
  14166. */
  14167. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14168. /**
  14169. * Get the rotation matrix of the bone in local or world space
  14170. * @param space The space that the rotation should be in
  14171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14172. * @returns The rotation matrix
  14173. */
  14174. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14175. /**
  14176. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14177. * @param space The space that the rotation should be in
  14178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14179. * @param result The quaternion that the rotation should be copied to
  14180. */
  14181. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14182. /**
  14183. * Get the world position of a point that is in the local space of the bone
  14184. * @param position The local position
  14185. * @param mesh The mesh that this bone is attached to
  14186. * @returns The world position
  14187. */
  14188. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14189. /**
  14190. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14191. * @param position The local position
  14192. * @param mesh The mesh that this bone is attached to
  14193. * @param result The vector3 that the world position should be copied to
  14194. */
  14195. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14196. /**
  14197. * Get the local position of a point that is in world space
  14198. * @param position The world position
  14199. * @param mesh The mesh that this bone is attached to
  14200. * @returns The local position
  14201. */
  14202. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14203. /**
  14204. * Get the local position of a point that is in world space and copy it to the result param
  14205. * @param position The world position
  14206. * @param mesh The mesh that this bone is attached to
  14207. * @param result The vector3 that the local position should be copied to
  14208. */
  14209. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14210. }
  14211. }
  14212. declare module "babylonjs/Meshes/transformNode" {
  14213. import { DeepImmutable } from "babylonjs/types";
  14214. import { Observable } from "babylonjs/Misc/observable";
  14215. import { Nullable } from "babylonjs/types";
  14216. import { Camera } from "babylonjs/Cameras/camera";
  14217. import { Scene } from "babylonjs/scene";
  14218. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14219. import { Node } from "babylonjs/node";
  14220. import { Bone } from "babylonjs/Bones/bone";
  14221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14222. import { Space } from "babylonjs/Maths/math.axis";
  14223. /**
  14224. * 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.
  14225. * @see https://doc.babylonjs.com/how_to/transformnode
  14226. */
  14227. export class TransformNode extends Node {
  14228. /**
  14229. * Object will not rotate to face the camera
  14230. */
  14231. static BILLBOARDMODE_NONE: number;
  14232. /**
  14233. * Object will rotate to face the camera but only on the x axis
  14234. */
  14235. static BILLBOARDMODE_X: number;
  14236. /**
  14237. * Object will rotate to face the camera but only on the y axis
  14238. */
  14239. static BILLBOARDMODE_Y: number;
  14240. /**
  14241. * Object will rotate to face the camera but only on the z axis
  14242. */
  14243. static BILLBOARDMODE_Z: number;
  14244. /**
  14245. * Object will rotate to face the camera
  14246. */
  14247. static BILLBOARDMODE_ALL: number;
  14248. /**
  14249. * Object will rotate to face the camera's position instead of orientation
  14250. */
  14251. static BILLBOARDMODE_USE_POSITION: number;
  14252. private _forward;
  14253. private _forwardInverted;
  14254. private _up;
  14255. private _right;
  14256. private _rightInverted;
  14257. private _position;
  14258. private _rotation;
  14259. private _rotationQuaternion;
  14260. protected _scaling: Vector3;
  14261. protected _isDirty: boolean;
  14262. private _transformToBoneReferal;
  14263. private _isAbsoluteSynced;
  14264. private _billboardMode;
  14265. /**
  14266. * Gets or sets the billboard mode. Default is 0.
  14267. *
  14268. * | Value | Type | Description |
  14269. * | --- | --- | --- |
  14270. * | 0 | BILLBOARDMODE_NONE | |
  14271. * | 1 | BILLBOARDMODE_X | |
  14272. * | 2 | BILLBOARDMODE_Y | |
  14273. * | 4 | BILLBOARDMODE_Z | |
  14274. * | 7 | BILLBOARDMODE_ALL | |
  14275. *
  14276. */
  14277. billboardMode: number;
  14278. private _preserveParentRotationForBillboard;
  14279. /**
  14280. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14281. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14282. */
  14283. preserveParentRotationForBillboard: boolean;
  14284. /**
  14285. * 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
  14286. */
  14287. scalingDeterminant: number;
  14288. private _infiniteDistance;
  14289. /**
  14290. * Gets or sets the distance of the object to max, often used by skybox
  14291. */
  14292. infiniteDistance: boolean;
  14293. /**
  14294. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14295. * By default the system will update normals to compensate
  14296. */
  14297. ignoreNonUniformScaling: boolean;
  14298. /**
  14299. * 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
  14300. */
  14301. reIntegrateRotationIntoRotationQuaternion: boolean;
  14302. /** @hidden */
  14303. _poseMatrix: Nullable<Matrix>;
  14304. /** @hidden */
  14305. _localMatrix: Matrix;
  14306. private _usePivotMatrix;
  14307. private _absolutePosition;
  14308. private _absoluteScaling;
  14309. private _absoluteRotationQuaternion;
  14310. private _pivotMatrix;
  14311. private _pivotMatrixInverse;
  14312. protected _postMultiplyPivotMatrix: boolean;
  14313. protected _isWorldMatrixFrozen: boolean;
  14314. /** @hidden */
  14315. _indexInSceneTransformNodesArray: number;
  14316. /**
  14317. * An event triggered after the world matrix is updated
  14318. */
  14319. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14320. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14321. /**
  14322. * Gets a string identifying the name of the class
  14323. * @returns "TransformNode" string
  14324. */
  14325. getClassName(): string;
  14326. /**
  14327. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14328. */
  14329. position: Vector3;
  14330. /**
  14331. * 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)).
  14332. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14333. */
  14334. rotation: Vector3;
  14335. /**
  14336. * 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)).
  14337. */
  14338. scaling: Vector3;
  14339. /**
  14340. * 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).
  14341. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14342. */
  14343. rotationQuaternion: Nullable<Quaternion>;
  14344. /**
  14345. * The forward direction of that transform in world space.
  14346. */
  14347. readonly forward: Vector3;
  14348. /**
  14349. * The up direction of that transform in world space.
  14350. */
  14351. readonly up: Vector3;
  14352. /**
  14353. * The right direction of that transform in world space.
  14354. */
  14355. readonly right: Vector3;
  14356. /**
  14357. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14358. * @param matrix the matrix to copy the pose from
  14359. * @returns this TransformNode.
  14360. */
  14361. updatePoseMatrix(matrix: Matrix): TransformNode;
  14362. /**
  14363. * Returns the mesh Pose matrix.
  14364. * @returns the pose matrix
  14365. */
  14366. getPoseMatrix(): Matrix;
  14367. /** @hidden */
  14368. _isSynchronized(): boolean;
  14369. /** @hidden */
  14370. _initCache(): void;
  14371. /**
  14372. * Flag the transform node as dirty (Forcing it to update everything)
  14373. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14374. * @returns this transform node
  14375. */
  14376. markAsDirty(property: string): TransformNode;
  14377. /**
  14378. * Returns the current mesh absolute position.
  14379. * Returns a Vector3.
  14380. */
  14381. readonly absolutePosition: Vector3;
  14382. /**
  14383. * Returns the current mesh absolute scaling.
  14384. * Returns a Vector3.
  14385. */
  14386. readonly absoluteScaling: Vector3;
  14387. /**
  14388. * Returns the current mesh absolute rotation.
  14389. * Returns a Quaternion.
  14390. */
  14391. readonly absoluteRotationQuaternion: Quaternion;
  14392. /**
  14393. * Sets a new matrix to apply before all other transformation
  14394. * @param matrix defines the transform matrix
  14395. * @returns the current TransformNode
  14396. */
  14397. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14398. /**
  14399. * Sets a new pivot matrix to the current node
  14400. * @param matrix defines the new pivot matrix to use
  14401. * @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
  14402. * @returns the current TransformNode
  14403. */
  14404. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14405. /**
  14406. * Returns the mesh pivot matrix.
  14407. * Default : Identity.
  14408. * @returns the matrix
  14409. */
  14410. getPivotMatrix(): Matrix;
  14411. /**
  14412. * Instantiate (when possible) or clone that node with its hierarchy
  14413. * @param newParent defines the new parent to use for the instance (or clone)
  14414. * @param options defines options to configure how copy is done
  14415. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14416. * @returns an instance (or a clone) of the current node with its hiearchy
  14417. */
  14418. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14419. doNotInstantiate: boolean;
  14420. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14421. /**
  14422. * Prevents the World matrix to be computed any longer
  14423. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14424. * @returns the TransformNode.
  14425. */
  14426. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14427. /**
  14428. * Allows back the World matrix computation.
  14429. * @returns the TransformNode.
  14430. */
  14431. unfreezeWorldMatrix(): this;
  14432. /**
  14433. * True if the World matrix has been frozen.
  14434. */
  14435. readonly isWorldMatrixFrozen: boolean;
  14436. /**
  14437. * Retuns the mesh absolute position in the World.
  14438. * @returns a Vector3.
  14439. */
  14440. getAbsolutePosition(): Vector3;
  14441. /**
  14442. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14443. * @param absolutePosition the absolute position to set
  14444. * @returns the TransformNode.
  14445. */
  14446. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14447. /**
  14448. * Sets the mesh position in its local space.
  14449. * @param vector3 the position to set in localspace
  14450. * @returns the TransformNode.
  14451. */
  14452. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14453. /**
  14454. * Returns the mesh position in the local space from the current World matrix values.
  14455. * @returns a new Vector3.
  14456. */
  14457. getPositionExpressedInLocalSpace(): Vector3;
  14458. /**
  14459. * Translates the mesh along the passed Vector3 in its local space.
  14460. * @param vector3 the distance to translate in localspace
  14461. * @returns the TransformNode.
  14462. */
  14463. locallyTranslate(vector3: Vector3): TransformNode;
  14464. private static _lookAtVectorCache;
  14465. /**
  14466. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14467. * @param targetPoint the position (must be in same space as current mesh) to look at
  14468. * @param yawCor optional yaw (y-axis) correction in radians
  14469. * @param pitchCor optional pitch (x-axis) correction in radians
  14470. * @param rollCor optional roll (z-axis) correction in radians
  14471. * @param space the choosen space of the target
  14472. * @returns the TransformNode.
  14473. */
  14474. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14475. /**
  14476. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14477. * This Vector3 is expressed in the World space.
  14478. * @param localAxis axis to rotate
  14479. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14480. */
  14481. getDirection(localAxis: Vector3): Vector3;
  14482. /**
  14483. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14484. * localAxis is expressed in the mesh local space.
  14485. * result is computed in the Wordl space from the mesh World matrix.
  14486. * @param localAxis axis to rotate
  14487. * @param result the resulting transformnode
  14488. * @returns this TransformNode.
  14489. */
  14490. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14491. /**
  14492. * Sets this transform node rotation to the given local axis.
  14493. * @param localAxis the axis in local space
  14494. * @param yawCor optional yaw (y-axis) correction in radians
  14495. * @param pitchCor optional pitch (x-axis) correction in radians
  14496. * @param rollCor optional roll (z-axis) correction in radians
  14497. * @returns this TransformNode
  14498. */
  14499. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14500. /**
  14501. * Sets a new pivot point to the current node
  14502. * @param point defines the new pivot point to use
  14503. * @param space defines if the point is in world or local space (local by default)
  14504. * @returns the current TransformNode
  14505. */
  14506. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14507. /**
  14508. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14509. * @returns the pivot point
  14510. */
  14511. getPivotPoint(): Vector3;
  14512. /**
  14513. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14514. * @param result the vector3 to store the result
  14515. * @returns this TransformNode.
  14516. */
  14517. getPivotPointToRef(result: Vector3): TransformNode;
  14518. /**
  14519. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14520. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14521. */
  14522. getAbsolutePivotPoint(): Vector3;
  14523. /**
  14524. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14525. * @param result vector3 to store the result
  14526. * @returns this TransformNode.
  14527. */
  14528. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14529. /**
  14530. * Defines the passed node as the parent of the current node.
  14531. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14532. * @see https://doc.babylonjs.com/how_to/parenting
  14533. * @param node the node ot set as the parent
  14534. * @returns this TransformNode.
  14535. */
  14536. setParent(node: Nullable<Node>): TransformNode;
  14537. private _nonUniformScaling;
  14538. /**
  14539. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14540. */
  14541. readonly nonUniformScaling: boolean;
  14542. /** @hidden */
  14543. _updateNonUniformScalingState(value: boolean): boolean;
  14544. /**
  14545. * Attach the current TransformNode to another TransformNode associated with a bone
  14546. * @param bone Bone affecting the TransformNode
  14547. * @param affectedTransformNode TransformNode associated with the bone
  14548. * @returns this object
  14549. */
  14550. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14551. /**
  14552. * Detach the transform node if its associated with a bone
  14553. * @returns this object
  14554. */
  14555. detachFromBone(): TransformNode;
  14556. private static _rotationAxisCache;
  14557. /**
  14558. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14559. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14560. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14561. * The passed axis is also normalized.
  14562. * @param axis the axis to rotate around
  14563. * @param amount the amount to rotate in radians
  14564. * @param space Space to rotate in (Default: local)
  14565. * @returns the TransformNode.
  14566. */
  14567. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14568. /**
  14569. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14570. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14571. * The passed axis is also normalized. .
  14572. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14573. * @param point the point to rotate around
  14574. * @param axis the axis to rotate around
  14575. * @param amount the amount to rotate in radians
  14576. * @returns the TransformNode
  14577. */
  14578. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14579. /**
  14580. * Translates the mesh along the axis vector for the passed distance in the given space.
  14581. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14582. * @param axis the axis to translate in
  14583. * @param distance the distance to translate
  14584. * @param space Space to rotate in (Default: local)
  14585. * @returns the TransformNode.
  14586. */
  14587. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14588. /**
  14589. * Adds a rotation step to the mesh current rotation.
  14590. * x, y, z are Euler angles expressed in radians.
  14591. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14592. * This means this rotation is made in the mesh local space only.
  14593. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14594. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14595. * ```javascript
  14596. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14597. * ```
  14598. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14599. * 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.
  14600. * @param x Rotation to add
  14601. * @param y Rotation to add
  14602. * @param z Rotation to add
  14603. * @returns the TransformNode.
  14604. */
  14605. addRotation(x: number, y: number, z: number): TransformNode;
  14606. /**
  14607. * @hidden
  14608. */
  14609. protected _getEffectiveParent(): Nullable<Node>;
  14610. /**
  14611. * Computes the world matrix of the node
  14612. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14613. * @returns the world matrix
  14614. */
  14615. computeWorldMatrix(force?: boolean): Matrix;
  14616. protected _afterComputeWorldMatrix(): void;
  14617. /**
  14618. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14619. * @param func callback function to add
  14620. *
  14621. * @returns the TransformNode.
  14622. */
  14623. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14624. /**
  14625. * Removes a registered callback function.
  14626. * @param func callback function to remove
  14627. * @returns the TransformNode.
  14628. */
  14629. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14630. /**
  14631. * Gets the position of the current mesh in camera space
  14632. * @param camera defines the camera to use
  14633. * @returns a position
  14634. */
  14635. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14636. /**
  14637. * Returns the distance from the mesh to the active camera
  14638. * @param camera defines the camera to use
  14639. * @returns the distance
  14640. */
  14641. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14642. /**
  14643. * Clone the current transform node
  14644. * @param name Name of the new clone
  14645. * @param newParent New parent for the clone
  14646. * @param doNotCloneChildren Do not clone children hierarchy
  14647. * @returns the new transform node
  14648. */
  14649. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14650. /**
  14651. * Serializes the objects information.
  14652. * @param currentSerializationObject defines the object to serialize in
  14653. * @returns the serialized object
  14654. */
  14655. serialize(currentSerializationObject?: any): any;
  14656. /**
  14657. * Returns a new TransformNode object parsed from the source provided.
  14658. * @param parsedTransformNode is the source.
  14659. * @param scene the scne the object belongs to
  14660. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14661. * @returns a new TransformNode object parsed from the source provided.
  14662. */
  14663. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14664. /**
  14665. * Get all child-transformNodes of this node
  14666. * @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
  14667. * @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
  14668. * @returns an array of TransformNode
  14669. */
  14670. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14671. /**
  14672. * Releases resources associated with this transform node.
  14673. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14674. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14675. */
  14676. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14677. /**
  14678. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14679. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14680. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14681. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14682. * @returns the current mesh
  14683. */
  14684. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14685. private _syncAbsoluteScalingAndRotation;
  14686. }
  14687. }
  14688. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14689. import { Observable } from "babylonjs/Misc/observable";
  14690. import { Nullable } from "babylonjs/types";
  14691. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14692. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14694. import { Ray } from "babylonjs/Culling/ray";
  14695. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14696. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14697. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14698. /**
  14699. * Defines the types of pose enabled controllers that are supported
  14700. */
  14701. export enum PoseEnabledControllerType {
  14702. /**
  14703. * HTC Vive
  14704. */
  14705. VIVE = 0,
  14706. /**
  14707. * Oculus Rift
  14708. */
  14709. OCULUS = 1,
  14710. /**
  14711. * Windows mixed reality
  14712. */
  14713. WINDOWS = 2,
  14714. /**
  14715. * Samsung gear VR
  14716. */
  14717. GEAR_VR = 3,
  14718. /**
  14719. * Google Daydream
  14720. */
  14721. DAYDREAM = 4,
  14722. /**
  14723. * Generic
  14724. */
  14725. GENERIC = 5
  14726. }
  14727. /**
  14728. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14729. */
  14730. export interface MutableGamepadButton {
  14731. /**
  14732. * Value of the button/trigger
  14733. */
  14734. value: number;
  14735. /**
  14736. * If the button/trigger is currently touched
  14737. */
  14738. touched: boolean;
  14739. /**
  14740. * If the button/trigger is currently pressed
  14741. */
  14742. pressed: boolean;
  14743. }
  14744. /**
  14745. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14746. * @hidden
  14747. */
  14748. export interface ExtendedGamepadButton extends GamepadButton {
  14749. /**
  14750. * If the button/trigger is currently pressed
  14751. */
  14752. readonly pressed: boolean;
  14753. /**
  14754. * If the button/trigger is currently touched
  14755. */
  14756. readonly touched: boolean;
  14757. /**
  14758. * Value of the button/trigger
  14759. */
  14760. readonly value: number;
  14761. }
  14762. /** @hidden */
  14763. export interface _GamePadFactory {
  14764. /**
  14765. * Returns wether or not the current gamepad can be created for this type of controller.
  14766. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14767. * @returns true if it can be created, otherwise false
  14768. */
  14769. canCreate(gamepadInfo: any): boolean;
  14770. /**
  14771. * Creates a new instance of the Gamepad.
  14772. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14773. * @returns the new gamepad instance
  14774. */
  14775. create(gamepadInfo: any): Gamepad;
  14776. }
  14777. /**
  14778. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14779. */
  14780. export class PoseEnabledControllerHelper {
  14781. /** @hidden */
  14782. static _ControllerFactories: _GamePadFactory[];
  14783. /** @hidden */
  14784. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14785. /**
  14786. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14787. * @param vrGamepad the gamepad to initialized
  14788. * @returns a vr controller of the type the gamepad identified as
  14789. */
  14790. static InitiateController(vrGamepad: any): Gamepad;
  14791. }
  14792. /**
  14793. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14794. */
  14795. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14796. /**
  14797. * If the controller is used in a webXR session
  14798. */
  14799. isXR: boolean;
  14800. private _deviceRoomPosition;
  14801. private _deviceRoomRotationQuaternion;
  14802. /**
  14803. * The device position in babylon space
  14804. */
  14805. devicePosition: Vector3;
  14806. /**
  14807. * The device rotation in babylon space
  14808. */
  14809. deviceRotationQuaternion: Quaternion;
  14810. /**
  14811. * The scale factor of the device in babylon space
  14812. */
  14813. deviceScaleFactor: number;
  14814. /**
  14815. * (Likely devicePosition should be used instead) The device position in its room space
  14816. */
  14817. position: Vector3;
  14818. /**
  14819. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14820. */
  14821. rotationQuaternion: Quaternion;
  14822. /**
  14823. * The type of controller (Eg. Windows mixed reality)
  14824. */
  14825. controllerType: PoseEnabledControllerType;
  14826. protected _calculatedPosition: Vector3;
  14827. private _calculatedRotation;
  14828. /**
  14829. * The raw pose from the device
  14830. */
  14831. rawPose: DevicePose;
  14832. private _trackPosition;
  14833. private _maxRotationDistFromHeadset;
  14834. private _draggedRoomRotation;
  14835. /**
  14836. * @hidden
  14837. */
  14838. _disableTrackPosition(fixedPosition: Vector3): void;
  14839. /**
  14840. * Internal, the mesh attached to the controller
  14841. * @hidden
  14842. */
  14843. _mesh: Nullable<AbstractMesh>;
  14844. private _poseControlledCamera;
  14845. private _leftHandSystemQuaternion;
  14846. /**
  14847. * Internal, matrix used to convert room space to babylon space
  14848. * @hidden
  14849. */
  14850. _deviceToWorld: Matrix;
  14851. /**
  14852. * Node to be used when casting a ray from the controller
  14853. * @hidden
  14854. */
  14855. _pointingPoseNode: Nullable<TransformNode>;
  14856. /**
  14857. * Name of the child mesh that can be used to cast a ray from the controller
  14858. */
  14859. static readonly POINTING_POSE: string;
  14860. /**
  14861. * Creates a new PoseEnabledController from a gamepad
  14862. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14863. */
  14864. constructor(browserGamepad: any);
  14865. private _workingMatrix;
  14866. /**
  14867. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14868. */
  14869. update(): void;
  14870. /**
  14871. * Updates only the pose device and mesh without doing any button event checking
  14872. */
  14873. protected _updatePoseAndMesh(): void;
  14874. /**
  14875. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14876. * @param poseData raw pose fromthe device
  14877. */
  14878. updateFromDevice(poseData: DevicePose): void;
  14879. /**
  14880. * @hidden
  14881. */
  14882. _meshAttachedObservable: Observable<AbstractMesh>;
  14883. /**
  14884. * Attaches a mesh to the controller
  14885. * @param mesh the mesh to be attached
  14886. */
  14887. attachToMesh(mesh: AbstractMesh): void;
  14888. /**
  14889. * Attaches the controllers mesh to a camera
  14890. * @param camera the camera the mesh should be attached to
  14891. */
  14892. attachToPoseControlledCamera(camera: TargetCamera): void;
  14893. /**
  14894. * Disposes of the controller
  14895. */
  14896. dispose(): void;
  14897. /**
  14898. * The mesh that is attached to the controller
  14899. */
  14900. readonly mesh: Nullable<AbstractMesh>;
  14901. /**
  14902. * Gets the ray of the controller in the direction the controller is pointing
  14903. * @param length the length the resulting ray should be
  14904. * @returns a ray in the direction the controller is pointing
  14905. */
  14906. getForwardRay(length?: number): Ray;
  14907. }
  14908. }
  14909. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14910. import { Observable } from "babylonjs/Misc/observable";
  14911. import { Scene } from "babylonjs/scene";
  14912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14913. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14914. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14915. import { Nullable } from "babylonjs/types";
  14916. /**
  14917. * Defines the WebVRController object that represents controllers tracked in 3D space
  14918. */
  14919. export abstract class WebVRController extends PoseEnabledController {
  14920. /**
  14921. * Internal, the default controller model for the controller
  14922. */
  14923. protected _defaultModel: Nullable<AbstractMesh>;
  14924. /**
  14925. * Fired when the trigger state has changed
  14926. */
  14927. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14928. /**
  14929. * Fired when the main button state has changed
  14930. */
  14931. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14932. /**
  14933. * Fired when the secondary button state has changed
  14934. */
  14935. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14936. /**
  14937. * Fired when the pad state has changed
  14938. */
  14939. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14940. /**
  14941. * Fired when controllers stick values have changed
  14942. */
  14943. onPadValuesChangedObservable: Observable<StickValues>;
  14944. /**
  14945. * Array of button availible on the controller
  14946. */
  14947. protected _buttons: Array<MutableGamepadButton>;
  14948. private _onButtonStateChange;
  14949. /**
  14950. * Fired when a controller button's state has changed
  14951. * @param callback the callback containing the button that was modified
  14952. */
  14953. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14954. /**
  14955. * X and Y axis corresponding to the controllers joystick
  14956. */
  14957. pad: StickValues;
  14958. /**
  14959. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14960. */
  14961. hand: string;
  14962. /**
  14963. * The default controller model for the controller
  14964. */
  14965. readonly defaultModel: Nullable<AbstractMesh>;
  14966. /**
  14967. * Creates a new WebVRController from a gamepad
  14968. * @param vrGamepad the gamepad that the WebVRController should be created from
  14969. */
  14970. constructor(vrGamepad: any);
  14971. /**
  14972. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14973. */
  14974. update(): void;
  14975. /**
  14976. * Function to be called when a button is modified
  14977. */
  14978. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14979. /**
  14980. * Loads a mesh and attaches it to the controller
  14981. * @param scene the scene the mesh should be added to
  14982. * @param meshLoaded callback for when the mesh has been loaded
  14983. */
  14984. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14985. private _setButtonValue;
  14986. private _changes;
  14987. private _checkChanges;
  14988. /**
  14989. * Disposes of th webVRCOntroller
  14990. */
  14991. dispose(): void;
  14992. }
  14993. }
  14994. declare module "babylonjs/Lights/hemisphericLight" {
  14995. import { Nullable } from "babylonjs/types";
  14996. import { Scene } from "babylonjs/scene";
  14997. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14998. import { Color3 } from "babylonjs/Maths/math.color";
  14999. import { Effect } from "babylonjs/Materials/effect";
  15000. import { Light } from "babylonjs/Lights/light";
  15001. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15002. /**
  15003. * The HemisphericLight simulates the ambient environment light,
  15004. * so the passed direction is the light reflection direction, not the incoming direction.
  15005. */
  15006. export class HemisphericLight extends Light {
  15007. /**
  15008. * The groundColor is the light in the opposite direction to the one specified during creation.
  15009. * 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.
  15010. */
  15011. groundColor: Color3;
  15012. /**
  15013. * The light reflection direction, not the incoming direction.
  15014. */
  15015. direction: Vector3;
  15016. /**
  15017. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15018. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15019. * The HemisphericLight can't cast shadows.
  15020. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15021. * @param name The friendly name of the light
  15022. * @param direction The direction of the light reflection
  15023. * @param scene The scene the light belongs to
  15024. */
  15025. constructor(name: string, direction: Vector3, scene: Scene);
  15026. protected _buildUniformLayout(): void;
  15027. /**
  15028. * Returns the string "HemisphericLight".
  15029. * @return The class name
  15030. */
  15031. getClassName(): string;
  15032. /**
  15033. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15034. * Returns the updated direction.
  15035. * @param target The target the direction should point to
  15036. * @return The computed direction
  15037. */
  15038. setDirectionToTarget(target: Vector3): Vector3;
  15039. /**
  15040. * Returns the shadow generator associated to the light.
  15041. * @returns Always null for hemispheric lights because it does not support shadows.
  15042. */
  15043. getShadowGenerator(): Nullable<IShadowGenerator>;
  15044. /**
  15045. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15046. * @param effect The effect to update
  15047. * @param lightIndex The index of the light in the effect to update
  15048. * @returns The hemispheric light
  15049. */
  15050. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15051. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15052. /**
  15053. * Computes the world matrix of the node
  15054. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15055. * @param useWasUpdatedFlag defines a reserved property
  15056. * @returns the world matrix
  15057. */
  15058. computeWorldMatrix(): Matrix;
  15059. /**
  15060. * Returns the integer 3.
  15061. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15062. */
  15063. getTypeID(): number;
  15064. /**
  15065. * Prepares the list of defines specific to the light type.
  15066. * @param defines the list of defines
  15067. * @param lightIndex defines the index of the light for the effect
  15068. */
  15069. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15070. }
  15071. }
  15072. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15073. /** @hidden */
  15074. export var vrMultiviewToSingleviewPixelShader: {
  15075. name: string;
  15076. shader: string;
  15077. };
  15078. }
  15079. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15080. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15081. import { Scene } from "babylonjs/scene";
  15082. /**
  15083. * Renders to multiple views with a single draw call
  15084. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15085. */
  15086. export class MultiviewRenderTarget extends RenderTargetTexture {
  15087. /**
  15088. * Creates a multiview render target
  15089. * @param scene scene used with the render target
  15090. * @param size the size of the render target (used for each view)
  15091. */
  15092. constructor(scene: Scene, size?: number | {
  15093. width: number;
  15094. height: number;
  15095. } | {
  15096. ratio: number;
  15097. });
  15098. /**
  15099. * @hidden
  15100. * @param faceIndex the face index, if its a cube texture
  15101. */
  15102. _bindFrameBuffer(faceIndex?: number): void;
  15103. /**
  15104. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15105. * @returns the view count
  15106. */
  15107. getViewCount(): number;
  15108. }
  15109. }
  15110. declare module "babylonjs/Maths/math.frustum" {
  15111. import { Matrix } from "babylonjs/Maths/math.vector";
  15112. import { DeepImmutable } from "babylonjs/types";
  15113. import { Plane } from "babylonjs/Maths/math.plane";
  15114. /**
  15115. * Represents a camera frustum
  15116. */
  15117. export class Frustum {
  15118. /**
  15119. * Gets the planes representing the frustum
  15120. * @param transform matrix to be applied to the returned planes
  15121. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15122. */
  15123. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15124. /**
  15125. * Gets the near frustum plane transformed by the transform matrix
  15126. * @param transform transformation matrix to be applied to the resulting frustum plane
  15127. * @param frustumPlane the resuling frustum plane
  15128. */
  15129. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15130. /**
  15131. * Gets the far frustum plane transformed by the transform matrix
  15132. * @param transform transformation matrix to be applied to the resulting frustum plane
  15133. * @param frustumPlane the resuling frustum plane
  15134. */
  15135. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15136. /**
  15137. * Gets the left frustum plane transformed by the transform matrix
  15138. * @param transform transformation matrix to be applied to the resulting frustum plane
  15139. * @param frustumPlane the resuling frustum plane
  15140. */
  15141. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15142. /**
  15143. * Gets the right frustum plane transformed by the transform matrix
  15144. * @param transform transformation matrix to be applied to the resulting frustum plane
  15145. * @param frustumPlane the resuling frustum plane
  15146. */
  15147. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15148. /**
  15149. * Gets the top frustum plane transformed by the transform matrix
  15150. * @param transform transformation matrix to be applied to the resulting frustum plane
  15151. * @param frustumPlane the resuling frustum plane
  15152. */
  15153. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15154. /**
  15155. * Gets the bottom frustum plane transformed by the transform matrix
  15156. * @param transform transformation matrix to be applied to the resulting frustum plane
  15157. * @param frustumPlane the resuling frustum plane
  15158. */
  15159. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15160. /**
  15161. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15162. * @param transform transformation matrix to be applied to the resulting frustum planes
  15163. * @param frustumPlanes the resuling frustum planes
  15164. */
  15165. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15166. }
  15167. }
  15168. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15169. import { Camera } from "babylonjs/Cameras/camera";
  15170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15171. import { Nullable } from "babylonjs/types";
  15172. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15173. import { Matrix } from "babylonjs/Maths/math.vector";
  15174. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15175. module "babylonjs/Engines/engine" {
  15176. interface Engine {
  15177. /**
  15178. * Creates a new multiview render target
  15179. * @param width defines the width of the texture
  15180. * @param height defines the height of the texture
  15181. * @returns the created multiview texture
  15182. */
  15183. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15184. /**
  15185. * Binds a multiview framebuffer to be drawn to
  15186. * @param multiviewTexture texture to bind
  15187. */
  15188. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15189. }
  15190. }
  15191. module "babylonjs/Cameras/camera" {
  15192. interface Camera {
  15193. /**
  15194. * @hidden
  15195. * 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)
  15196. */
  15197. _useMultiviewToSingleView: boolean;
  15198. /**
  15199. * @hidden
  15200. * 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)
  15201. */
  15202. _multiviewTexture: Nullable<RenderTargetTexture>;
  15203. /**
  15204. * @hidden
  15205. * ensures the multiview texture of the camera exists and has the specified width/height
  15206. * @param width height to set on the multiview texture
  15207. * @param height width to set on the multiview texture
  15208. */
  15209. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15210. }
  15211. }
  15212. module "babylonjs/scene" {
  15213. interface Scene {
  15214. /** @hidden */
  15215. _transformMatrixR: Matrix;
  15216. /** @hidden */
  15217. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15218. /** @hidden */
  15219. _createMultiviewUbo(): void;
  15220. /** @hidden */
  15221. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15222. /** @hidden */
  15223. _renderMultiviewToSingleView(camera: Camera): void;
  15224. }
  15225. }
  15226. }
  15227. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15228. import { Camera } from "babylonjs/Cameras/camera";
  15229. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15230. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15231. import "babylonjs/Engines/Extensions/engine.multiview";
  15232. /**
  15233. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15234. * This will not be used for webXR as it supports displaying texture arrays directly
  15235. */
  15236. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15237. /**
  15238. * Initializes a VRMultiviewToSingleview
  15239. * @param name name of the post process
  15240. * @param camera camera to be applied to
  15241. * @param scaleFactor scaling factor to the size of the output texture
  15242. */
  15243. constructor(name: string, camera: Camera, scaleFactor: number);
  15244. }
  15245. }
  15246. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15247. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15248. import { Nullable } from "babylonjs/types";
  15249. import { Size } from "babylonjs/Maths/math.size";
  15250. import { Observable } from "babylonjs/Misc/observable";
  15251. /**
  15252. * Interface used to define additional presentation attributes
  15253. */
  15254. export interface IVRPresentationAttributes {
  15255. /**
  15256. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15257. */
  15258. highRefreshRate: boolean;
  15259. /**
  15260. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15261. */
  15262. foveationLevel: number;
  15263. }
  15264. module "babylonjs/Engines/engine" {
  15265. interface Engine {
  15266. /** @hidden */
  15267. _vrDisplay: any;
  15268. /** @hidden */
  15269. _vrSupported: boolean;
  15270. /** @hidden */
  15271. _oldSize: Size;
  15272. /** @hidden */
  15273. _oldHardwareScaleFactor: number;
  15274. /** @hidden */
  15275. _vrExclusivePointerMode: boolean;
  15276. /** @hidden */
  15277. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15278. /** @hidden */
  15279. _onVRDisplayPointerRestricted: () => void;
  15280. /** @hidden */
  15281. _onVRDisplayPointerUnrestricted: () => void;
  15282. /** @hidden */
  15283. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15284. /** @hidden */
  15285. _onVrDisplayDisconnect: Nullable<() => void>;
  15286. /** @hidden */
  15287. _onVrDisplayPresentChange: Nullable<() => void>;
  15288. /**
  15289. * Observable signaled when VR display mode changes
  15290. */
  15291. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15292. /**
  15293. * Observable signaled when VR request present is complete
  15294. */
  15295. onVRRequestPresentComplete: Observable<boolean>;
  15296. /**
  15297. * Observable signaled when VR request present starts
  15298. */
  15299. onVRRequestPresentStart: Observable<Engine>;
  15300. /**
  15301. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15302. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15303. */
  15304. isInVRExclusivePointerMode: boolean;
  15305. /**
  15306. * Gets a boolean indicating if a webVR device was detected
  15307. * @returns true if a webVR device was detected
  15308. */
  15309. isVRDevicePresent(): boolean;
  15310. /**
  15311. * Gets the current webVR device
  15312. * @returns the current webVR device (or null)
  15313. */
  15314. getVRDevice(): any;
  15315. /**
  15316. * Initializes a webVR display and starts listening to display change events
  15317. * The onVRDisplayChangedObservable will be notified upon these changes
  15318. * @returns A promise containing a VRDisplay and if vr is supported
  15319. */
  15320. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15321. /** @hidden */
  15322. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15323. /**
  15324. * Gets or sets the presentation attributes used to configure VR rendering
  15325. */
  15326. vrPresentationAttributes?: IVRPresentationAttributes;
  15327. /**
  15328. * Call this function to switch to webVR mode
  15329. * Will do nothing if webVR is not supported or if there is no webVR device
  15330. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15331. */
  15332. enableVR(): void;
  15333. /** @hidden */
  15334. _onVRFullScreenTriggered(): void;
  15335. }
  15336. }
  15337. }
  15338. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15339. import { Nullable } from "babylonjs/types";
  15340. import { Observable } from "babylonjs/Misc/observable";
  15341. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15342. import { Scene } from "babylonjs/scene";
  15343. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15344. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15345. import { Node } from "babylonjs/node";
  15346. import { Ray } from "babylonjs/Culling/ray";
  15347. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15348. import "babylonjs/Engines/Extensions/engine.webVR";
  15349. /**
  15350. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15351. * IMPORTANT!! The data is right-hand data.
  15352. * @export
  15353. * @interface DevicePose
  15354. */
  15355. export interface DevicePose {
  15356. /**
  15357. * The position of the device, values in array are [x,y,z].
  15358. */
  15359. readonly position: Nullable<Float32Array>;
  15360. /**
  15361. * The linearVelocity of the device, values in array are [x,y,z].
  15362. */
  15363. readonly linearVelocity: Nullable<Float32Array>;
  15364. /**
  15365. * The linearAcceleration of the device, values in array are [x,y,z].
  15366. */
  15367. readonly linearAcceleration: Nullable<Float32Array>;
  15368. /**
  15369. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15370. */
  15371. readonly orientation: Nullable<Float32Array>;
  15372. /**
  15373. * The angularVelocity of the device, values in array are [x,y,z].
  15374. */
  15375. readonly angularVelocity: Nullable<Float32Array>;
  15376. /**
  15377. * The angularAcceleration of the device, values in array are [x,y,z].
  15378. */
  15379. readonly angularAcceleration: Nullable<Float32Array>;
  15380. }
  15381. /**
  15382. * Interface representing a pose controlled object in Babylon.
  15383. * A pose controlled object has both regular pose values as well as pose values
  15384. * from an external device such as a VR head mounted display
  15385. */
  15386. export interface PoseControlled {
  15387. /**
  15388. * The position of the object in babylon space.
  15389. */
  15390. position: Vector3;
  15391. /**
  15392. * The rotation quaternion of the object in babylon space.
  15393. */
  15394. rotationQuaternion: Quaternion;
  15395. /**
  15396. * The position of the device in babylon space.
  15397. */
  15398. devicePosition?: Vector3;
  15399. /**
  15400. * The rotation quaternion of the device in babylon space.
  15401. */
  15402. deviceRotationQuaternion: Quaternion;
  15403. /**
  15404. * The raw pose coming from the device.
  15405. */
  15406. rawPose: Nullable<DevicePose>;
  15407. /**
  15408. * The scale of the device to be used when translating from device space to babylon space.
  15409. */
  15410. deviceScaleFactor: number;
  15411. /**
  15412. * Updates the poseControlled values based on the input device pose.
  15413. * @param poseData the pose data to update the object with
  15414. */
  15415. updateFromDevice(poseData: DevicePose): void;
  15416. }
  15417. /**
  15418. * Set of options to customize the webVRCamera
  15419. */
  15420. export interface WebVROptions {
  15421. /**
  15422. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15423. */
  15424. trackPosition?: boolean;
  15425. /**
  15426. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15427. */
  15428. positionScale?: number;
  15429. /**
  15430. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15431. */
  15432. displayName?: string;
  15433. /**
  15434. * Should the native controller meshes be initialized. (default: true)
  15435. */
  15436. controllerMeshes?: boolean;
  15437. /**
  15438. * Creating a default HemiLight only on controllers. (default: true)
  15439. */
  15440. defaultLightingOnControllers?: boolean;
  15441. /**
  15442. * If you don't want to use the default VR button of the helper. (default: false)
  15443. */
  15444. useCustomVRButton?: boolean;
  15445. /**
  15446. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15447. */
  15448. customVRButton?: HTMLButtonElement;
  15449. /**
  15450. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15451. */
  15452. rayLength?: number;
  15453. /**
  15454. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15455. */
  15456. defaultHeight?: number;
  15457. /**
  15458. * If multiview should be used if availible (default: false)
  15459. */
  15460. useMultiview?: boolean;
  15461. }
  15462. /**
  15463. * This represents a WebVR camera.
  15464. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15465. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15466. */
  15467. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15468. private webVROptions;
  15469. /**
  15470. * @hidden
  15471. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15472. */
  15473. _vrDevice: any;
  15474. /**
  15475. * The rawPose of the vrDevice.
  15476. */
  15477. rawPose: Nullable<DevicePose>;
  15478. private _onVREnabled;
  15479. private _specsVersion;
  15480. private _attached;
  15481. private _frameData;
  15482. protected _descendants: Array<Node>;
  15483. private _deviceRoomPosition;
  15484. /** @hidden */
  15485. _deviceRoomRotationQuaternion: Quaternion;
  15486. private _standingMatrix;
  15487. /**
  15488. * Represents device position in babylon space.
  15489. */
  15490. devicePosition: Vector3;
  15491. /**
  15492. * Represents device rotation in babylon space.
  15493. */
  15494. deviceRotationQuaternion: Quaternion;
  15495. /**
  15496. * The scale of the device to be used when translating from device space to babylon space.
  15497. */
  15498. deviceScaleFactor: number;
  15499. private _deviceToWorld;
  15500. private _worldToDevice;
  15501. /**
  15502. * References to the webVR controllers for the vrDevice.
  15503. */
  15504. controllers: Array<WebVRController>;
  15505. /**
  15506. * Emits an event when a controller is attached.
  15507. */
  15508. onControllersAttachedObservable: Observable<WebVRController[]>;
  15509. /**
  15510. * Emits an event when a controller's mesh has been loaded;
  15511. */
  15512. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15513. /**
  15514. * Emits an event when the HMD's pose has been updated.
  15515. */
  15516. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15517. private _poseSet;
  15518. /**
  15519. * If the rig cameras be used as parent instead of this camera.
  15520. */
  15521. rigParenting: boolean;
  15522. private _lightOnControllers;
  15523. private _defaultHeight?;
  15524. /**
  15525. * Instantiates a WebVRFreeCamera.
  15526. * @param name The name of the WebVRFreeCamera
  15527. * @param position The starting anchor position for the camera
  15528. * @param scene The scene the camera belongs to
  15529. * @param webVROptions a set of customizable options for the webVRCamera
  15530. */
  15531. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15532. /**
  15533. * Gets the device distance from the ground in meters.
  15534. * @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.
  15535. */
  15536. deviceDistanceToRoomGround(): number;
  15537. /**
  15538. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15539. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15540. */
  15541. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15542. /**
  15543. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15544. * @returns A promise with a boolean set to if the standing matrix is supported.
  15545. */
  15546. useStandingMatrixAsync(): Promise<boolean>;
  15547. /**
  15548. * Disposes the camera
  15549. */
  15550. dispose(): void;
  15551. /**
  15552. * Gets a vrController by name.
  15553. * @param name The name of the controller to retreive
  15554. * @returns the controller matching the name specified or null if not found
  15555. */
  15556. getControllerByName(name: string): Nullable<WebVRController>;
  15557. private _leftController;
  15558. /**
  15559. * The controller corresponding to the users left hand.
  15560. */
  15561. readonly leftController: Nullable<WebVRController>;
  15562. private _rightController;
  15563. /**
  15564. * The controller corresponding to the users right hand.
  15565. */
  15566. readonly rightController: Nullable<WebVRController>;
  15567. /**
  15568. * Casts a ray forward from the vrCamera's gaze.
  15569. * @param length Length of the ray (default: 100)
  15570. * @returns the ray corresponding to the gaze
  15571. */
  15572. getForwardRay(length?: number): Ray;
  15573. /**
  15574. * @hidden
  15575. * Updates the camera based on device's frame data
  15576. */
  15577. _checkInputs(): void;
  15578. /**
  15579. * Updates the poseControlled values based on the input device pose.
  15580. * @param poseData Pose coming from the device
  15581. */
  15582. updateFromDevice(poseData: DevicePose): void;
  15583. private _htmlElementAttached;
  15584. private _detachIfAttached;
  15585. /**
  15586. * WebVR's attach control will start broadcasting frames to the device.
  15587. * Note that in certain browsers (chrome for example) this function must be called
  15588. * within a user-interaction callback. Example:
  15589. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15590. *
  15591. * @param element html element to attach the vrDevice to
  15592. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15593. */
  15594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15595. /**
  15596. * Detaches the camera from the html element and disables VR
  15597. *
  15598. * @param element html element to detach from
  15599. */
  15600. detachControl(element: HTMLElement): void;
  15601. /**
  15602. * @returns the name of this class
  15603. */
  15604. getClassName(): string;
  15605. /**
  15606. * Calls resetPose on the vrDisplay
  15607. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15608. */
  15609. resetToCurrentRotation(): void;
  15610. /**
  15611. * @hidden
  15612. * Updates the rig cameras (left and right eye)
  15613. */
  15614. _updateRigCameras(): void;
  15615. private _workingVector;
  15616. private _oneVector;
  15617. private _workingMatrix;
  15618. private updateCacheCalled;
  15619. private _correctPositionIfNotTrackPosition;
  15620. /**
  15621. * @hidden
  15622. * Updates the cached values of the camera
  15623. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15624. */
  15625. _updateCache(ignoreParentClass?: boolean): void;
  15626. /**
  15627. * @hidden
  15628. * Get current device position in babylon world
  15629. */
  15630. _computeDevicePosition(): void;
  15631. /**
  15632. * Updates the current device position and rotation in the babylon world
  15633. */
  15634. update(): void;
  15635. /**
  15636. * @hidden
  15637. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15638. * @returns an identity matrix
  15639. */
  15640. _getViewMatrix(): Matrix;
  15641. private _tmpMatrix;
  15642. /**
  15643. * This function is called by the two RIG cameras.
  15644. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15645. * @hidden
  15646. */
  15647. _getWebVRViewMatrix(): Matrix;
  15648. /** @hidden */
  15649. _getWebVRProjectionMatrix(): Matrix;
  15650. private _onGamepadConnectedObserver;
  15651. private _onGamepadDisconnectedObserver;
  15652. private _updateCacheWhenTrackingDisabledObserver;
  15653. /**
  15654. * Initializes the controllers and their meshes
  15655. */
  15656. initControllers(): void;
  15657. }
  15658. }
  15659. declare module "babylonjs/PostProcesses/postProcess" {
  15660. import { Nullable } from "babylonjs/types";
  15661. import { SmartArray } from "babylonjs/Misc/smartArray";
  15662. import { Observable } from "babylonjs/Misc/observable";
  15663. import { Vector2 } from "babylonjs/Maths/math.vector";
  15664. import { Camera } from "babylonjs/Cameras/camera";
  15665. import { Effect } from "babylonjs/Materials/effect";
  15666. import "babylonjs/Shaders/postprocess.vertex";
  15667. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15668. import { Engine } from "babylonjs/Engines/engine";
  15669. import { Color4 } from "babylonjs/Maths/math.color";
  15670. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15671. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15672. /**
  15673. * Size options for a post process
  15674. */
  15675. export type PostProcessOptions = {
  15676. width: number;
  15677. height: number;
  15678. };
  15679. /**
  15680. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15681. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15682. */
  15683. export class PostProcess {
  15684. /** Name of the PostProcess. */
  15685. name: string;
  15686. /**
  15687. * Gets or sets the unique id of the post process
  15688. */
  15689. uniqueId: number;
  15690. /**
  15691. * Width of the texture to apply the post process on
  15692. */
  15693. width: number;
  15694. /**
  15695. * Height of the texture to apply the post process on
  15696. */
  15697. height: number;
  15698. /**
  15699. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15700. * @hidden
  15701. */
  15702. _outputTexture: Nullable<InternalTexture>;
  15703. /**
  15704. * Sampling mode used by the shader
  15705. * See https://doc.babylonjs.com/classes/3.1/texture
  15706. */
  15707. renderTargetSamplingMode: number;
  15708. /**
  15709. * Clear color to use when screen clearing
  15710. */
  15711. clearColor: Color4;
  15712. /**
  15713. * If the buffer needs to be cleared before applying the post process. (default: true)
  15714. * Should be set to false if shader will overwrite all previous pixels.
  15715. */
  15716. autoClear: boolean;
  15717. /**
  15718. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15719. */
  15720. alphaMode: number;
  15721. /**
  15722. * Sets the setAlphaBlendConstants of the babylon engine
  15723. */
  15724. alphaConstants: Color4;
  15725. /**
  15726. * Animations to be used for the post processing
  15727. */
  15728. animations: import("babylonjs/Animations/animation").Animation[];
  15729. /**
  15730. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15731. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15732. */
  15733. enablePixelPerfectMode: boolean;
  15734. /**
  15735. * Force the postprocess to be applied without taking in account viewport
  15736. */
  15737. forceFullscreenViewport: boolean;
  15738. /**
  15739. * List of inspectable custom properties (used by the Inspector)
  15740. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15741. */
  15742. inspectableCustomProperties: IInspectable[];
  15743. /**
  15744. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15745. *
  15746. * | Value | Type | Description |
  15747. * | ----- | ----------------------------------- | ----------- |
  15748. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15749. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15750. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15751. *
  15752. */
  15753. scaleMode: number;
  15754. /**
  15755. * Force textures to be a power of two (default: false)
  15756. */
  15757. alwaysForcePOT: boolean;
  15758. private _samples;
  15759. /**
  15760. * Number of sample textures (default: 1)
  15761. */
  15762. samples: number;
  15763. /**
  15764. * Modify the scale of the post process to be the same as the viewport (default: false)
  15765. */
  15766. adaptScaleToCurrentViewport: boolean;
  15767. private _camera;
  15768. private _scene;
  15769. private _engine;
  15770. private _options;
  15771. private _reusable;
  15772. private _textureType;
  15773. /**
  15774. * Smart array of input and output textures for the post process.
  15775. * @hidden
  15776. */
  15777. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15778. /**
  15779. * The index in _textures that corresponds to the output texture.
  15780. * @hidden
  15781. */
  15782. _currentRenderTextureInd: number;
  15783. private _effect;
  15784. private _samplers;
  15785. private _fragmentUrl;
  15786. private _vertexUrl;
  15787. private _parameters;
  15788. private _scaleRatio;
  15789. protected _indexParameters: any;
  15790. private _shareOutputWithPostProcess;
  15791. private _texelSize;
  15792. private _forcedOutputTexture;
  15793. /**
  15794. * Returns the fragment url or shader name used in the post process.
  15795. * @returns the fragment url or name in the shader store.
  15796. */
  15797. getEffectName(): string;
  15798. /**
  15799. * An event triggered when the postprocess is activated.
  15800. */
  15801. onActivateObservable: Observable<Camera>;
  15802. private _onActivateObserver;
  15803. /**
  15804. * A function that is added to the onActivateObservable
  15805. */
  15806. onActivate: Nullable<(camera: Camera) => void>;
  15807. /**
  15808. * An event triggered when the postprocess changes its size.
  15809. */
  15810. onSizeChangedObservable: Observable<PostProcess>;
  15811. private _onSizeChangedObserver;
  15812. /**
  15813. * A function that is added to the onSizeChangedObservable
  15814. */
  15815. onSizeChanged: (postProcess: PostProcess) => void;
  15816. /**
  15817. * An event triggered when the postprocess applies its effect.
  15818. */
  15819. onApplyObservable: Observable<Effect>;
  15820. private _onApplyObserver;
  15821. /**
  15822. * A function that is added to the onApplyObservable
  15823. */
  15824. onApply: (effect: Effect) => void;
  15825. /**
  15826. * An event triggered before rendering the postprocess
  15827. */
  15828. onBeforeRenderObservable: Observable<Effect>;
  15829. private _onBeforeRenderObserver;
  15830. /**
  15831. * A function that is added to the onBeforeRenderObservable
  15832. */
  15833. onBeforeRender: (effect: Effect) => void;
  15834. /**
  15835. * An event triggered after rendering the postprocess
  15836. */
  15837. onAfterRenderObservable: Observable<Effect>;
  15838. private _onAfterRenderObserver;
  15839. /**
  15840. * A function that is added to the onAfterRenderObservable
  15841. */
  15842. onAfterRender: (efect: Effect) => void;
  15843. /**
  15844. * 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
  15845. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15846. */
  15847. inputTexture: InternalTexture;
  15848. /**
  15849. * Gets the camera which post process is applied to.
  15850. * @returns The camera the post process is applied to.
  15851. */
  15852. getCamera(): Camera;
  15853. /**
  15854. * Gets the texel size of the postprocess.
  15855. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15856. */
  15857. readonly texelSize: Vector2;
  15858. /**
  15859. * Creates a new instance PostProcess
  15860. * @param name The name of the PostProcess.
  15861. * @param fragmentUrl The url of the fragment shader to be used.
  15862. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15863. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15864. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15865. * @param camera The camera to apply the render pass to.
  15866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15867. * @param engine The engine which the post process will be applied. (default: current engine)
  15868. * @param reusable If the post process can be reused on the same frame. (default: false)
  15869. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15870. * @param textureType Type of textures used when performing the post process. (default: 0)
  15871. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15872. * @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
  15873. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15874. */
  15875. constructor(
  15876. /** Name of the PostProcess. */
  15877. 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);
  15878. /**
  15879. * Gets a string idenfifying the name of the class
  15880. * @returns "PostProcess" string
  15881. */
  15882. getClassName(): string;
  15883. /**
  15884. * Gets the engine which this post process belongs to.
  15885. * @returns The engine the post process was enabled with.
  15886. */
  15887. getEngine(): Engine;
  15888. /**
  15889. * The effect that is created when initializing the post process.
  15890. * @returns The created effect corresponding the the postprocess.
  15891. */
  15892. getEffect(): Effect;
  15893. /**
  15894. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15895. * @param postProcess The post process to share the output with.
  15896. * @returns This post process.
  15897. */
  15898. shareOutputWith(postProcess: PostProcess): PostProcess;
  15899. /**
  15900. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15901. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15902. */
  15903. useOwnOutput(): void;
  15904. /**
  15905. * Updates the effect with the current post process compile time values and recompiles the shader.
  15906. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15907. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15908. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15909. * @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
  15910. * @param onCompiled Called when the shader has been compiled.
  15911. * @param onError Called if there is an error when compiling a shader.
  15912. */
  15913. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15914. /**
  15915. * The post process is reusable if it can be used multiple times within one frame.
  15916. * @returns If the post process is reusable
  15917. */
  15918. isReusable(): boolean;
  15919. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15920. markTextureDirty(): void;
  15921. /**
  15922. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15923. * 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.
  15924. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15925. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15926. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15927. * @returns The target texture that was bound to be written to.
  15928. */
  15929. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15930. /**
  15931. * If the post process is supported.
  15932. */
  15933. readonly isSupported: boolean;
  15934. /**
  15935. * The aspect ratio of the output texture.
  15936. */
  15937. readonly aspectRatio: number;
  15938. /**
  15939. * Get a value indicating if the post-process is ready to be used
  15940. * @returns true if the post-process is ready (shader is compiled)
  15941. */
  15942. isReady(): boolean;
  15943. /**
  15944. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15945. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15946. */
  15947. apply(): Nullable<Effect>;
  15948. private _disposeTextures;
  15949. /**
  15950. * Disposes the post process.
  15951. * @param camera The camera to dispose the post process on.
  15952. */
  15953. dispose(camera?: Camera): void;
  15954. }
  15955. }
  15956. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15957. /** @hidden */
  15958. export var kernelBlurVaryingDeclaration: {
  15959. name: string;
  15960. shader: string;
  15961. };
  15962. }
  15963. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15964. /** @hidden */
  15965. export var kernelBlurFragment: {
  15966. name: string;
  15967. shader: string;
  15968. };
  15969. }
  15970. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15971. /** @hidden */
  15972. export var kernelBlurFragment2: {
  15973. name: string;
  15974. shader: string;
  15975. };
  15976. }
  15977. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15978. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15979. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15980. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15981. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15982. /** @hidden */
  15983. export var kernelBlurPixelShader: {
  15984. name: string;
  15985. shader: string;
  15986. };
  15987. }
  15988. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15989. /** @hidden */
  15990. export var kernelBlurVertex: {
  15991. name: string;
  15992. shader: string;
  15993. };
  15994. }
  15995. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15996. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15997. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15998. /** @hidden */
  15999. export var kernelBlurVertexShader: {
  16000. name: string;
  16001. shader: string;
  16002. };
  16003. }
  16004. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16005. import { Vector2 } from "babylonjs/Maths/math.vector";
  16006. import { Nullable } from "babylonjs/types";
  16007. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16008. import { Camera } from "babylonjs/Cameras/camera";
  16009. import { Effect } from "babylonjs/Materials/effect";
  16010. import { Engine } from "babylonjs/Engines/engine";
  16011. import "babylonjs/Shaders/kernelBlur.fragment";
  16012. import "babylonjs/Shaders/kernelBlur.vertex";
  16013. /**
  16014. * The Blur Post Process which blurs an image based on a kernel and direction.
  16015. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16016. */
  16017. export class BlurPostProcess extends PostProcess {
  16018. /** The direction in which to blur the image. */
  16019. direction: Vector2;
  16020. private blockCompilation;
  16021. protected _kernel: number;
  16022. protected _idealKernel: number;
  16023. protected _packedFloat: boolean;
  16024. private _staticDefines;
  16025. /**
  16026. * Sets the length in pixels of the blur sample region
  16027. */
  16028. /**
  16029. * Gets the length in pixels of the blur sample region
  16030. */
  16031. kernel: number;
  16032. /**
  16033. * Sets wether or not the blur needs to unpack/repack floats
  16034. */
  16035. /**
  16036. * Gets wether or not the blur is unpacking/repacking floats
  16037. */
  16038. packedFloat: boolean;
  16039. /**
  16040. * Creates a new instance BlurPostProcess
  16041. * @param name The name of the effect.
  16042. * @param direction The direction in which to blur the image.
  16043. * @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.
  16044. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16045. * @param camera The camera to apply the render pass to.
  16046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16047. * @param engine The engine which the post process will be applied. (default: current engine)
  16048. * @param reusable If the post process can be reused on the same frame. (default: false)
  16049. * @param textureType Type of textures used when performing the post process. (default: 0)
  16050. * @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)
  16051. */
  16052. constructor(name: string,
  16053. /** The direction in which to blur the image. */
  16054. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16055. /**
  16056. * Updates the effect with the current post process compile time values and recompiles the shader.
  16057. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16058. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16059. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16060. * @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
  16061. * @param onCompiled Called when the shader has been compiled.
  16062. * @param onError Called if there is an error when compiling a shader.
  16063. */
  16064. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16065. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16066. /**
  16067. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16068. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16069. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16070. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16071. * The gaps between physical kernels are compensated for in the weighting of the samples
  16072. * @param idealKernel Ideal blur kernel.
  16073. * @return Nearest best kernel.
  16074. */
  16075. protected _nearestBestKernel(idealKernel: number): number;
  16076. /**
  16077. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16078. * @param x The point on the Gaussian distribution to sample.
  16079. * @return the value of the Gaussian function at x.
  16080. */
  16081. protected _gaussianWeight(x: number): number;
  16082. /**
  16083. * Generates a string that can be used as a floating point number in GLSL.
  16084. * @param x Value to print.
  16085. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16086. * @return GLSL float string.
  16087. */
  16088. protected _glslFloat(x: number, decimalFigures?: number): string;
  16089. }
  16090. }
  16091. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16092. import { Scene } from "babylonjs/scene";
  16093. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16094. import { Plane } from "babylonjs/Maths/math.plane";
  16095. /**
  16096. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16097. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16098. * You can then easily use it as a reflectionTexture on a flat surface.
  16099. * In case the surface is not a plane, please consider relying on reflection probes.
  16100. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16101. */
  16102. export class MirrorTexture extends RenderTargetTexture {
  16103. private scene;
  16104. /**
  16105. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16106. * 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.
  16107. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16108. */
  16109. mirrorPlane: Plane;
  16110. /**
  16111. * Define the blur ratio used to blur the reflection if needed.
  16112. */
  16113. blurRatio: number;
  16114. /**
  16115. * Define the adaptive blur kernel used to blur the reflection if needed.
  16116. * This will autocompute the closest best match for the `blurKernel`
  16117. */
  16118. adaptiveBlurKernel: number;
  16119. /**
  16120. * Define the blur kernel used to blur the reflection if needed.
  16121. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16122. */
  16123. blurKernel: number;
  16124. /**
  16125. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16126. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16127. */
  16128. blurKernelX: number;
  16129. /**
  16130. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16131. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16132. */
  16133. blurKernelY: number;
  16134. private _autoComputeBlurKernel;
  16135. protected _onRatioRescale(): void;
  16136. private _updateGammaSpace;
  16137. private _imageProcessingConfigChangeObserver;
  16138. private _transformMatrix;
  16139. private _mirrorMatrix;
  16140. private _savedViewMatrix;
  16141. private _blurX;
  16142. private _blurY;
  16143. private _adaptiveBlurKernel;
  16144. private _blurKernelX;
  16145. private _blurKernelY;
  16146. private _blurRatio;
  16147. /**
  16148. * Instantiates a Mirror Texture.
  16149. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16150. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16151. * You can then easily use it as a reflectionTexture on a flat surface.
  16152. * In case the surface is not a plane, please consider relying on reflection probes.
  16153. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16154. * @param name
  16155. * @param size
  16156. * @param scene
  16157. * @param generateMipMaps
  16158. * @param type
  16159. * @param samplingMode
  16160. * @param generateDepthBuffer
  16161. */
  16162. constructor(name: string, size: number | {
  16163. width: number;
  16164. height: number;
  16165. } | {
  16166. ratio: number;
  16167. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16168. private _preparePostProcesses;
  16169. /**
  16170. * Clone the mirror texture.
  16171. * @returns the cloned texture
  16172. */
  16173. clone(): MirrorTexture;
  16174. /**
  16175. * Serialize the texture to a JSON representation you could use in Parse later on
  16176. * @returns the serialized JSON representation
  16177. */
  16178. serialize(): any;
  16179. /**
  16180. * Dispose the texture and release its associated resources.
  16181. */
  16182. dispose(): void;
  16183. }
  16184. }
  16185. declare module "babylonjs/Materials/Textures/texture" {
  16186. import { Observable } from "babylonjs/Misc/observable";
  16187. import { Nullable } from "babylonjs/types";
  16188. import { Matrix } from "babylonjs/Maths/math.vector";
  16189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16190. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16191. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16192. import { Scene } from "babylonjs/scene";
  16193. /**
  16194. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16195. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16196. */
  16197. export class Texture extends BaseTexture {
  16198. /**
  16199. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16200. */
  16201. static SerializeBuffers: boolean;
  16202. /** @hidden */
  16203. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16204. /** @hidden */
  16205. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16206. /** @hidden */
  16207. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16208. /** nearest is mag = nearest and min = nearest and mip = linear */
  16209. static readonly NEAREST_SAMPLINGMODE: number;
  16210. /** nearest is mag = nearest and min = nearest and mip = linear */
  16211. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16212. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16213. static readonly BILINEAR_SAMPLINGMODE: number;
  16214. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16215. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16216. /** Trilinear is mag = linear and min = linear and mip = linear */
  16217. static readonly TRILINEAR_SAMPLINGMODE: number;
  16218. /** Trilinear is mag = linear and min = linear and mip = linear */
  16219. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16220. /** mag = nearest and min = nearest and mip = nearest */
  16221. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16222. /** mag = nearest and min = linear and mip = nearest */
  16223. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16224. /** mag = nearest and min = linear and mip = linear */
  16225. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16226. /** mag = nearest and min = linear and mip = none */
  16227. static readonly NEAREST_LINEAR: number;
  16228. /** mag = nearest and min = nearest and mip = none */
  16229. static readonly NEAREST_NEAREST: number;
  16230. /** mag = linear and min = nearest and mip = nearest */
  16231. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16232. /** mag = linear and min = nearest and mip = linear */
  16233. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16234. /** mag = linear and min = linear and mip = none */
  16235. static readonly LINEAR_LINEAR: number;
  16236. /** mag = linear and min = nearest and mip = none */
  16237. static readonly LINEAR_NEAREST: number;
  16238. /** Explicit coordinates mode */
  16239. static readonly EXPLICIT_MODE: number;
  16240. /** Spherical coordinates mode */
  16241. static readonly SPHERICAL_MODE: number;
  16242. /** Planar coordinates mode */
  16243. static readonly PLANAR_MODE: number;
  16244. /** Cubic coordinates mode */
  16245. static readonly CUBIC_MODE: number;
  16246. /** Projection coordinates mode */
  16247. static readonly PROJECTION_MODE: number;
  16248. /** Inverse Cubic coordinates mode */
  16249. static readonly SKYBOX_MODE: number;
  16250. /** Inverse Cubic coordinates mode */
  16251. static readonly INVCUBIC_MODE: number;
  16252. /** Equirectangular coordinates mode */
  16253. static readonly EQUIRECTANGULAR_MODE: number;
  16254. /** Equirectangular Fixed coordinates mode */
  16255. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16256. /** Equirectangular Fixed Mirrored coordinates mode */
  16257. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16258. /** Texture is not repeating outside of 0..1 UVs */
  16259. static readonly CLAMP_ADDRESSMODE: number;
  16260. /** Texture is repeating outside of 0..1 UVs */
  16261. static readonly WRAP_ADDRESSMODE: number;
  16262. /** Texture is repeating and mirrored */
  16263. static readonly MIRROR_ADDRESSMODE: number;
  16264. /**
  16265. * 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
  16266. */
  16267. static UseSerializedUrlIfAny: boolean;
  16268. /**
  16269. * Define the url of the texture.
  16270. */
  16271. url: Nullable<string>;
  16272. /**
  16273. * Define an offset on the texture to offset the u coordinates of the UVs
  16274. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16275. */
  16276. uOffset: number;
  16277. /**
  16278. * Define an offset on the texture to offset the v coordinates of the UVs
  16279. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16280. */
  16281. vOffset: number;
  16282. /**
  16283. * Define an offset on the texture to scale the u coordinates of the UVs
  16284. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16285. */
  16286. uScale: number;
  16287. /**
  16288. * Define an offset on the texture to scale the v coordinates of the UVs
  16289. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16290. */
  16291. vScale: number;
  16292. /**
  16293. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16294. * @see http://doc.babylonjs.com/how_to/more_materials
  16295. */
  16296. uAng: number;
  16297. /**
  16298. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16299. * @see http://doc.babylonjs.com/how_to/more_materials
  16300. */
  16301. vAng: number;
  16302. /**
  16303. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16304. * @see http://doc.babylonjs.com/how_to/more_materials
  16305. */
  16306. wAng: number;
  16307. /**
  16308. * Defines the center of rotation (U)
  16309. */
  16310. uRotationCenter: number;
  16311. /**
  16312. * Defines the center of rotation (V)
  16313. */
  16314. vRotationCenter: number;
  16315. /**
  16316. * Defines the center of rotation (W)
  16317. */
  16318. wRotationCenter: number;
  16319. /**
  16320. * Are mip maps generated for this texture or not.
  16321. */
  16322. readonly noMipmap: boolean;
  16323. /**
  16324. * List of inspectable custom properties (used by the Inspector)
  16325. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16326. */
  16327. inspectableCustomProperties: Nullable<IInspectable[]>;
  16328. private _noMipmap;
  16329. /** @hidden */
  16330. _invertY: boolean;
  16331. private _rowGenerationMatrix;
  16332. private _cachedTextureMatrix;
  16333. private _projectionModeMatrix;
  16334. private _t0;
  16335. private _t1;
  16336. private _t2;
  16337. private _cachedUOffset;
  16338. private _cachedVOffset;
  16339. private _cachedUScale;
  16340. private _cachedVScale;
  16341. private _cachedUAng;
  16342. private _cachedVAng;
  16343. private _cachedWAng;
  16344. private _cachedProjectionMatrixId;
  16345. private _cachedCoordinatesMode;
  16346. /** @hidden */
  16347. protected _initialSamplingMode: number;
  16348. /** @hidden */
  16349. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16350. private _deleteBuffer;
  16351. protected _format: Nullable<number>;
  16352. private _delayedOnLoad;
  16353. private _delayedOnError;
  16354. private _mimeType?;
  16355. /**
  16356. * Observable triggered once the texture has been loaded.
  16357. */
  16358. onLoadObservable: Observable<Texture>;
  16359. protected _isBlocking: boolean;
  16360. /**
  16361. * Is the texture preventing material to render while loading.
  16362. * If false, a default texture will be used instead of the loading one during the preparation step.
  16363. */
  16364. isBlocking: boolean;
  16365. /**
  16366. * Get the current sampling mode associated with the texture.
  16367. */
  16368. readonly samplingMode: number;
  16369. /**
  16370. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16371. */
  16372. readonly invertY: boolean;
  16373. /**
  16374. * Instantiates a new texture.
  16375. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16376. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16377. * @param url defines the url of the picture to load as a texture
  16378. * @param scene defines the scene or engine the texture will belong to
  16379. * @param noMipmap defines if the texture will require mip maps or not
  16380. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16381. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16382. * @param onLoad defines a callback triggered when the texture has been loaded
  16383. * @param onError defines a callback triggered when an error occurred during the loading session
  16384. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16385. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16386. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16387. * @param mimeType defines an optional mime type information
  16388. */
  16389. 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);
  16390. /**
  16391. * Update the url (and optional buffer) of this texture if url was null during construction.
  16392. * @param url the url of the texture
  16393. * @param buffer the buffer of the texture (defaults to null)
  16394. * @param onLoad callback called when the texture is loaded (defaults to null)
  16395. */
  16396. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16397. /**
  16398. * Finish the loading sequence of a texture flagged as delayed load.
  16399. * @hidden
  16400. */
  16401. delayLoad(): void;
  16402. private _prepareRowForTextureGeneration;
  16403. /**
  16404. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16405. * @returns the transform matrix of the texture.
  16406. */
  16407. getTextureMatrix(): Matrix;
  16408. /**
  16409. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16410. * @returns The reflection texture transform
  16411. */
  16412. getReflectionTextureMatrix(): Matrix;
  16413. /**
  16414. * Clones the texture.
  16415. * @returns the cloned texture
  16416. */
  16417. clone(): Texture;
  16418. /**
  16419. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16420. * @returns The JSON representation of the texture
  16421. */
  16422. serialize(): any;
  16423. /**
  16424. * Get the current class name of the texture useful for serialization or dynamic coding.
  16425. * @returns "Texture"
  16426. */
  16427. getClassName(): string;
  16428. /**
  16429. * Dispose the texture and release its associated resources.
  16430. */
  16431. dispose(): void;
  16432. /**
  16433. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16434. * @param parsedTexture Define the JSON representation of the texture
  16435. * @param scene Define the scene the parsed texture should be instantiated in
  16436. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16437. * @returns The parsed texture if successful
  16438. */
  16439. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16440. /**
  16441. * Creates a texture from its base 64 representation.
  16442. * @param data Define the base64 payload without the data: prefix
  16443. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16444. * @param scene Define the scene the texture should belong to
  16445. * @param noMipmap Forces the texture to not create mip map information if true
  16446. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16447. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16448. * @param onLoad define a callback triggered when the texture has been loaded
  16449. * @param onError define a callback triggered when an error occurred during the loading session
  16450. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16451. * @returns the created texture
  16452. */
  16453. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16454. /**
  16455. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16456. * @param data Define the base64 payload without the data: prefix
  16457. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16458. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16459. * @param scene Define the scene the texture should belong to
  16460. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16461. * @param noMipmap Forces the texture to not create mip map information if true
  16462. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16463. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16464. * @param onLoad define a callback triggered when the texture has been loaded
  16465. * @param onError define a callback triggered when an error occurred during the loading session
  16466. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16467. * @returns the created texture
  16468. */
  16469. 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;
  16470. }
  16471. }
  16472. declare module "babylonjs/PostProcesses/postProcessManager" {
  16473. import { Nullable } from "babylonjs/types";
  16474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16475. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16476. import { Scene } from "babylonjs/scene";
  16477. /**
  16478. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16479. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16480. */
  16481. export class PostProcessManager {
  16482. private _scene;
  16483. private _indexBuffer;
  16484. private _vertexBuffers;
  16485. /**
  16486. * Creates a new instance PostProcess
  16487. * @param scene The scene that the post process is associated with.
  16488. */
  16489. constructor(scene: Scene);
  16490. private _prepareBuffers;
  16491. private _buildIndexBuffer;
  16492. /**
  16493. * Rebuilds the vertex buffers of the manager.
  16494. * @hidden
  16495. */
  16496. _rebuild(): void;
  16497. /**
  16498. * Prepares a frame to be run through a post process.
  16499. * @param sourceTexture The input texture to the post procesess. (default: null)
  16500. * @param postProcesses An array of post processes to be run. (default: null)
  16501. * @returns True if the post processes were able to be run.
  16502. * @hidden
  16503. */
  16504. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16505. /**
  16506. * Manually render a set of post processes to a texture.
  16507. * @param postProcesses An array of post processes to be run.
  16508. * @param targetTexture The target texture to render to.
  16509. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16510. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16511. * @param lodLevel defines which lod of the texture to render to
  16512. */
  16513. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16514. /**
  16515. * Finalize the result of the output of the postprocesses.
  16516. * @param doNotPresent If true the result will not be displayed to the screen.
  16517. * @param targetTexture The target texture to render to.
  16518. * @param faceIndex The index of the face to bind the target texture to.
  16519. * @param postProcesses The array of post processes to render.
  16520. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16521. * @hidden
  16522. */
  16523. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16524. /**
  16525. * Disposes of the post process manager.
  16526. */
  16527. dispose(): void;
  16528. }
  16529. }
  16530. declare module "babylonjs/Misc/gradients" {
  16531. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16532. /** Interface used by value gradients (color, factor, ...) */
  16533. export interface IValueGradient {
  16534. /**
  16535. * Gets or sets the gradient value (between 0 and 1)
  16536. */
  16537. gradient: number;
  16538. }
  16539. /** Class used to store color4 gradient */
  16540. export class ColorGradient implements IValueGradient {
  16541. /**
  16542. * Gets or sets the gradient value (between 0 and 1)
  16543. */
  16544. gradient: number;
  16545. /**
  16546. * Gets or sets first associated color
  16547. */
  16548. color1: Color4;
  16549. /**
  16550. * Gets or sets second associated color
  16551. */
  16552. color2?: Color4;
  16553. /**
  16554. * Will get a color picked randomly between color1 and color2.
  16555. * If color2 is undefined then color1 will be used
  16556. * @param result defines the target Color4 to store the result in
  16557. */
  16558. getColorToRef(result: Color4): void;
  16559. }
  16560. /** Class used to store color 3 gradient */
  16561. export class Color3Gradient implements IValueGradient {
  16562. /**
  16563. * Gets or sets the gradient value (between 0 and 1)
  16564. */
  16565. gradient: number;
  16566. /**
  16567. * Gets or sets the associated color
  16568. */
  16569. color: Color3;
  16570. }
  16571. /** Class used to store factor gradient */
  16572. export class FactorGradient implements IValueGradient {
  16573. /**
  16574. * Gets or sets the gradient value (between 0 and 1)
  16575. */
  16576. gradient: number;
  16577. /**
  16578. * Gets or sets first associated factor
  16579. */
  16580. factor1: number;
  16581. /**
  16582. * Gets or sets second associated factor
  16583. */
  16584. factor2?: number;
  16585. /**
  16586. * Will get a number picked randomly between factor1 and factor2.
  16587. * If factor2 is undefined then factor1 will be used
  16588. * @returns the picked number
  16589. */
  16590. getFactor(): number;
  16591. }
  16592. /**
  16593. * Helper used to simplify some generic gradient tasks
  16594. */
  16595. export class GradientHelper {
  16596. /**
  16597. * Gets the current gradient from an array of IValueGradient
  16598. * @param ratio defines the current ratio to get
  16599. * @param gradients defines the array of IValueGradient
  16600. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16601. */
  16602. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16603. }
  16604. }
  16605. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16606. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16607. import { Nullable } from "babylonjs/types";
  16608. module "babylonjs/Engines/thinEngine" {
  16609. interface ThinEngine {
  16610. /**
  16611. * Creates a dynamic texture
  16612. * @param width defines the width of the texture
  16613. * @param height defines the height of the texture
  16614. * @param generateMipMaps defines if the engine should generate the mip levels
  16615. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16616. * @returns the dynamic texture inside an InternalTexture
  16617. */
  16618. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16619. /**
  16620. * Update the content of a dynamic texture
  16621. * @param texture defines the texture to update
  16622. * @param canvas defines the canvas containing the source
  16623. * @param invertY defines if data must be stored with Y axis inverted
  16624. * @param premulAlpha defines if alpha is stored as premultiplied
  16625. * @param format defines the format of the data
  16626. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16627. */
  16628. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16629. }
  16630. }
  16631. }
  16632. declare module "babylonjs/Misc/canvasGenerator" {
  16633. /**
  16634. * Helper class used to generate a canvas to manipulate images
  16635. */
  16636. export class CanvasGenerator {
  16637. /**
  16638. * Create a new canvas (or offscreen canvas depending on the context)
  16639. * @param width defines the expected width
  16640. * @param height defines the expected height
  16641. * @return a new canvas or offscreen canvas
  16642. */
  16643. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16644. }
  16645. }
  16646. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16647. import { Scene } from "babylonjs/scene";
  16648. import { Texture } from "babylonjs/Materials/Textures/texture";
  16649. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16650. /**
  16651. * A class extending Texture allowing drawing on a texture
  16652. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16653. */
  16654. export class DynamicTexture extends Texture {
  16655. private _generateMipMaps;
  16656. private _canvas;
  16657. private _context;
  16658. private _engine;
  16659. /**
  16660. * Creates a DynamicTexture
  16661. * @param name defines the name of the texture
  16662. * @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
  16663. * @param scene defines the scene where you want the texture
  16664. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16665. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16666. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16667. */
  16668. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16669. /**
  16670. * Get the current class name of the texture useful for serialization or dynamic coding.
  16671. * @returns "DynamicTexture"
  16672. */
  16673. getClassName(): string;
  16674. /**
  16675. * Gets the current state of canRescale
  16676. */
  16677. readonly canRescale: boolean;
  16678. private _recreate;
  16679. /**
  16680. * Scales the texture
  16681. * @param ratio the scale factor to apply to both width and height
  16682. */
  16683. scale(ratio: number): void;
  16684. /**
  16685. * Resizes the texture
  16686. * @param width the new width
  16687. * @param height the new height
  16688. */
  16689. scaleTo(width: number, height: number): void;
  16690. /**
  16691. * Gets the context of the canvas used by the texture
  16692. * @returns the canvas context of the dynamic texture
  16693. */
  16694. getContext(): CanvasRenderingContext2D;
  16695. /**
  16696. * Clears the texture
  16697. */
  16698. clear(): void;
  16699. /**
  16700. * Updates the texture
  16701. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16702. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16703. */
  16704. update(invertY?: boolean, premulAlpha?: boolean): void;
  16705. /**
  16706. * Draws text onto the texture
  16707. * @param text defines the text to be drawn
  16708. * @param x defines the placement of the text from the left
  16709. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16710. * @param font defines the font to be used with font-style, font-size, font-name
  16711. * @param color defines the color used for the text
  16712. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16713. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16714. * @param update defines whether texture is immediately update (default is true)
  16715. */
  16716. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16717. /**
  16718. * Clones the texture
  16719. * @returns the clone of the texture.
  16720. */
  16721. clone(): DynamicTexture;
  16722. /**
  16723. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16724. * @returns a serialized dynamic texture object
  16725. */
  16726. serialize(): any;
  16727. /** @hidden */
  16728. _rebuild(): void;
  16729. }
  16730. }
  16731. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16732. import { Scene } from "babylonjs/scene";
  16733. import { ISceneComponent } from "babylonjs/sceneComponent";
  16734. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16735. module "babylonjs/abstractScene" {
  16736. interface AbstractScene {
  16737. /**
  16738. * The list of procedural textures added to the scene
  16739. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16740. */
  16741. proceduralTextures: Array<ProceduralTexture>;
  16742. }
  16743. }
  16744. /**
  16745. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16746. * in a given scene.
  16747. */
  16748. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16749. /**
  16750. * The component name helpfull to identify the component in the list of scene components.
  16751. */
  16752. readonly name: string;
  16753. /**
  16754. * The scene the component belongs to.
  16755. */
  16756. scene: Scene;
  16757. /**
  16758. * Creates a new instance of the component for the given scene
  16759. * @param scene Defines the scene to register the component in
  16760. */
  16761. constructor(scene: Scene);
  16762. /**
  16763. * Registers the component in a given scene
  16764. */
  16765. register(): void;
  16766. /**
  16767. * Rebuilds the elements related to this component in case of
  16768. * context lost for instance.
  16769. */
  16770. rebuild(): void;
  16771. /**
  16772. * Disposes the component and the associated ressources.
  16773. */
  16774. dispose(): void;
  16775. private _beforeClear;
  16776. }
  16777. }
  16778. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16779. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16780. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16781. module "babylonjs/Engines/thinEngine" {
  16782. interface ThinEngine {
  16783. /**
  16784. * Creates a new render target cube texture
  16785. * @param size defines the size of the texture
  16786. * @param options defines the options used to create the texture
  16787. * @returns a new render target cube texture stored in an InternalTexture
  16788. */
  16789. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16790. }
  16791. }
  16792. }
  16793. declare module "babylonjs/Shaders/procedural.vertex" {
  16794. /** @hidden */
  16795. export var proceduralVertexShader: {
  16796. name: string;
  16797. shader: string;
  16798. };
  16799. }
  16800. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16801. import { Observable } from "babylonjs/Misc/observable";
  16802. import { Nullable } from "babylonjs/types";
  16803. import { Scene } from "babylonjs/scene";
  16804. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16805. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16806. import { Effect } from "babylonjs/Materials/effect";
  16807. import { Texture } from "babylonjs/Materials/Textures/texture";
  16808. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16809. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16810. import "babylonjs/Shaders/procedural.vertex";
  16811. /**
  16812. * 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.
  16813. * This is the base class of any Procedural texture and contains most of the shareable code.
  16814. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16815. */
  16816. export class ProceduralTexture extends Texture {
  16817. isCube: boolean;
  16818. /**
  16819. * Define if the texture is enabled or not (disabled texture will not render)
  16820. */
  16821. isEnabled: boolean;
  16822. /**
  16823. * Define if the texture must be cleared before rendering (default is true)
  16824. */
  16825. autoClear: boolean;
  16826. /**
  16827. * Callback called when the texture is generated
  16828. */
  16829. onGenerated: () => void;
  16830. /**
  16831. * Event raised when the texture is generated
  16832. */
  16833. onGeneratedObservable: Observable<ProceduralTexture>;
  16834. /** @hidden */
  16835. _generateMipMaps: boolean;
  16836. /** @hidden **/
  16837. _effect: Effect;
  16838. /** @hidden */
  16839. _textures: {
  16840. [key: string]: Texture;
  16841. };
  16842. private _size;
  16843. private _currentRefreshId;
  16844. private _refreshRate;
  16845. private _vertexBuffers;
  16846. private _indexBuffer;
  16847. private _uniforms;
  16848. private _samplers;
  16849. private _fragment;
  16850. private _floats;
  16851. private _ints;
  16852. private _floatsArrays;
  16853. private _colors3;
  16854. private _colors4;
  16855. private _vectors2;
  16856. private _vectors3;
  16857. private _matrices;
  16858. private _fallbackTexture;
  16859. private _fallbackTextureUsed;
  16860. private _engine;
  16861. private _cachedDefines;
  16862. private _contentUpdateId;
  16863. private _contentData;
  16864. /**
  16865. * Instantiates a new procedural texture.
  16866. * 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.
  16867. * This is the base class of any Procedural texture and contains most of the shareable code.
  16868. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16869. * @param name Define the name of the texture
  16870. * @param size Define the size of the texture to create
  16871. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16872. * @param scene Define the scene the texture belongs to
  16873. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16874. * @param generateMipMaps Define if the texture should creates mip maps or not
  16875. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16876. */
  16877. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16878. /**
  16879. * The effect that is created when initializing the post process.
  16880. * @returns The created effect corresponding the the postprocess.
  16881. */
  16882. getEffect(): Effect;
  16883. /**
  16884. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16885. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16886. */
  16887. getContent(): Nullable<ArrayBufferView>;
  16888. private _createIndexBuffer;
  16889. /** @hidden */
  16890. _rebuild(): void;
  16891. /**
  16892. * Resets the texture in order to recreate its associated resources.
  16893. * This can be called in case of context loss
  16894. */
  16895. reset(): void;
  16896. protected _getDefines(): string;
  16897. /**
  16898. * Is the texture ready to be used ? (rendered at least once)
  16899. * @returns true if ready, otherwise, false.
  16900. */
  16901. isReady(): boolean;
  16902. /**
  16903. * Resets the refresh counter of the texture and start bak from scratch.
  16904. * Could be useful to regenerate the texture if it is setup to render only once.
  16905. */
  16906. resetRefreshCounter(): void;
  16907. /**
  16908. * Set the fragment shader to use in order to render the texture.
  16909. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16910. */
  16911. setFragment(fragment: any): void;
  16912. /**
  16913. * Define the refresh rate of the texture or the rendering frequency.
  16914. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16915. */
  16916. refreshRate: number;
  16917. /** @hidden */
  16918. _shouldRender(): boolean;
  16919. /**
  16920. * Get the size the texture is rendering at.
  16921. * @returns the size (texture is always squared)
  16922. */
  16923. getRenderSize(): number;
  16924. /**
  16925. * Resize the texture to new value.
  16926. * @param size Define the new size the texture should have
  16927. * @param generateMipMaps Define whether the new texture should create mip maps
  16928. */
  16929. resize(size: number, generateMipMaps: boolean): void;
  16930. private _checkUniform;
  16931. /**
  16932. * Set a texture in the shader program used to render.
  16933. * @param name Define the name of the uniform samplers as defined in the shader
  16934. * @param texture Define the texture to bind to this sampler
  16935. * @return the texture itself allowing "fluent" like uniform updates
  16936. */
  16937. setTexture(name: string, texture: Texture): ProceduralTexture;
  16938. /**
  16939. * Set a float in the shader.
  16940. * @param name Define the name of the uniform as defined in the shader
  16941. * @param value Define the value to give to the uniform
  16942. * @return the texture itself allowing "fluent" like uniform updates
  16943. */
  16944. setFloat(name: string, value: number): ProceduralTexture;
  16945. /**
  16946. * Set a int in the shader.
  16947. * @param name Define the name of the uniform as defined in the shader
  16948. * @param value Define the value to give to the uniform
  16949. * @return the texture itself allowing "fluent" like uniform updates
  16950. */
  16951. setInt(name: string, value: number): ProceduralTexture;
  16952. /**
  16953. * Set an array of floats in the shader.
  16954. * @param name Define the name of the uniform as defined in the shader
  16955. * @param value Define the value to give to the uniform
  16956. * @return the texture itself allowing "fluent" like uniform updates
  16957. */
  16958. setFloats(name: string, value: number[]): ProceduralTexture;
  16959. /**
  16960. * Set a vec3 in the shader from a Color3.
  16961. * @param name Define the name of the uniform as defined in the shader
  16962. * @param value Define the value to give to the uniform
  16963. * @return the texture itself allowing "fluent" like uniform updates
  16964. */
  16965. setColor3(name: string, value: Color3): ProceduralTexture;
  16966. /**
  16967. * Set a vec4 in the shader from a Color4.
  16968. * @param name Define the name of the uniform as defined in the shader
  16969. * @param value Define the value to give to the uniform
  16970. * @return the texture itself allowing "fluent" like uniform updates
  16971. */
  16972. setColor4(name: string, value: Color4): ProceduralTexture;
  16973. /**
  16974. * Set a vec2 in the shader from a Vector2.
  16975. * @param name Define the name of the uniform as defined in the shader
  16976. * @param value Define the value to give to the uniform
  16977. * @return the texture itself allowing "fluent" like uniform updates
  16978. */
  16979. setVector2(name: string, value: Vector2): ProceduralTexture;
  16980. /**
  16981. * Set a vec3 in the shader from a Vector3.
  16982. * @param name Define the name of the uniform as defined in the shader
  16983. * @param value Define the value to give to the uniform
  16984. * @return the texture itself allowing "fluent" like uniform updates
  16985. */
  16986. setVector3(name: string, value: Vector3): ProceduralTexture;
  16987. /**
  16988. * Set a mat4 in the shader from a MAtrix.
  16989. * @param name Define the name of the uniform as defined in the shader
  16990. * @param value Define the value to give to the uniform
  16991. * @return the texture itself allowing "fluent" like uniform updates
  16992. */
  16993. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16994. /**
  16995. * Render the texture to its associated render target.
  16996. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16997. */
  16998. render(useCameraPostProcess?: boolean): void;
  16999. /**
  17000. * Clone the texture.
  17001. * @returns the cloned texture
  17002. */
  17003. clone(): ProceduralTexture;
  17004. /**
  17005. * Dispose the texture and release its asoociated resources.
  17006. */
  17007. dispose(): void;
  17008. }
  17009. }
  17010. declare module "babylonjs/Particles/baseParticleSystem" {
  17011. import { Nullable } from "babylonjs/types";
  17012. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17014. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17015. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17016. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17017. import { Scene } from "babylonjs/scene";
  17018. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17019. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17020. import { Texture } from "babylonjs/Materials/Textures/texture";
  17021. import { Color4 } from "babylonjs/Maths/math.color";
  17022. import { Animation } from "babylonjs/Animations/animation";
  17023. /**
  17024. * This represents the base class for particle system in Babylon.
  17025. * 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.
  17026. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17027. * @example https://doc.babylonjs.com/babylon101/particles
  17028. */
  17029. export class BaseParticleSystem {
  17030. /**
  17031. * Source color is added to the destination color without alpha affecting the result
  17032. */
  17033. static BLENDMODE_ONEONE: number;
  17034. /**
  17035. * Blend current color and particle color using particle’s alpha
  17036. */
  17037. static BLENDMODE_STANDARD: number;
  17038. /**
  17039. * Add current color and particle color multiplied by particle’s alpha
  17040. */
  17041. static BLENDMODE_ADD: number;
  17042. /**
  17043. * Multiply current color with particle color
  17044. */
  17045. static BLENDMODE_MULTIPLY: number;
  17046. /**
  17047. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17048. */
  17049. static BLENDMODE_MULTIPLYADD: number;
  17050. /**
  17051. * List of animations used by the particle system.
  17052. */
  17053. animations: Animation[];
  17054. /**
  17055. * The id of the Particle system.
  17056. */
  17057. id: string;
  17058. /**
  17059. * The friendly name of the Particle system.
  17060. */
  17061. name: string;
  17062. /**
  17063. * The rendering group used by the Particle system to chose when to render.
  17064. */
  17065. renderingGroupId: number;
  17066. /**
  17067. * The emitter represents the Mesh or position we are attaching the particle system to.
  17068. */
  17069. emitter: Nullable<AbstractMesh | Vector3>;
  17070. /**
  17071. * The maximum number of particles to emit per frame
  17072. */
  17073. emitRate: number;
  17074. /**
  17075. * If you want to launch only a few particles at once, that can be done, as well.
  17076. */
  17077. manualEmitCount: number;
  17078. /**
  17079. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17080. */
  17081. updateSpeed: number;
  17082. /**
  17083. * The amount of time the particle system is running (depends of the overall update speed).
  17084. */
  17085. targetStopDuration: number;
  17086. /**
  17087. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17088. */
  17089. disposeOnStop: boolean;
  17090. /**
  17091. * Minimum power of emitting particles.
  17092. */
  17093. minEmitPower: number;
  17094. /**
  17095. * Maximum power of emitting particles.
  17096. */
  17097. maxEmitPower: number;
  17098. /**
  17099. * Minimum life time of emitting particles.
  17100. */
  17101. minLifeTime: number;
  17102. /**
  17103. * Maximum life time of emitting particles.
  17104. */
  17105. maxLifeTime: number;
  17106. /**
  17107. * Minimum Size of emitting particles.
  17108. */
  17109. minSize: number;
  17110. /**
  17111. * Maximum Size of emitting particles.
  17112. */
  17113. maxSize: number;
  17114. /**
  17115. * Minimum scale of emitting particles on X axis.
  17116. */
  17117. minScaleX: number;
  17118. /**
  17119. * Maximum scale of emitting particles on X axis.
  17120. */
  17121. maxScaleX: number;
  17122. /**
  17123. * Minimum scale of emitting particles on Y axis.
  17124. */
  17125. minScaleY: number;
  17126. /**
  17127. * Maximum scale of emitting particles on Y axis.
  17128. */
  17129. maxScaleY: number;
  17130. /**
  17131. * Gets or sets the minimal initial rotation in radians.
  17132. */
  17133. minInitialRotation: number;
  17134. /**
  17135. * Gets or sets the maximal initial rotation in radians.
  17136. */
  17137. maxInitialRotation: number;
  17138. /**
  17139. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17140. */
  17141. minAngularSpeed: number;
  17142. /**
  17143. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17144. */
  17145. maxAngularSpeed: number;
  17146. /**
  17147. * The texture used to render each particle. (this can be a spritesheet)
  17148. */
  17149. particleTexture: Nullable<Texture>;
  17150. /**
  17151. * The layer mask we are rendering the particles through.
  17152. */
  17153. layerMask: number;
  17154. /**
  17155. * This can help using your own shader to render the particle system.
  17156. * The according effect will be created
  17157. */
  17158. customShader: any;
  17159. /**
  17160. * By default particle system starts as soon as they are created. This prevents the
  17161. * automatic start to happen and let you decide when to start emitting particles.
  17162. */
  17163. preventAutoStart: boolean;
  17164. private _noiseTexture;
  17165. /**
  17166. * Gets or sets a texture used to add random noise to particle positions
  17167. */
  17168. noiseTexture: Nullable<ProceduralTexture>;
  17169. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17170. noiseStrength: Vector3;
  17171. /**
  17172. * Callback triggered when the particle animation is ending.
  17173. */
  17174. onAnimationEnd: Nullable<() => void>;
  17175. /**
  17176. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17177. */
  17178. blendMode: number;
  17179. /**
  17180. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17181. * to override the particles.
  17182. */
  17183. forceDepthWrite: boolean;
  17184. /** 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 */
  17185. preWarmCycles: number;
  17186. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17187. preWarmStepOffset: number;
  17188. /**
  17189. * 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)
  17190. */
  17191. spriteCellChangeSpeed: number;
  17192. /**
  17193. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17194. */
  17195. startSpriteCellID: number;
  17196. /**
  17197. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17198. */
  17199. endSpriteCellID: number;
  17200. /**
  17201. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17202. */
  17203. spriteCellWidth: number;
  17204. /**
  17205. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17206. */
  17207. spriteCellHeight: number;
  17208. /**
  17209. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17210. */
  17211. spriteRandomStartCell: boolean;
  17212. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17213. translationPivot: Vector2;
  17214. /** @hidden */
  17215. protected _isAnimationSheetEnabled: boolean;
  17216. /**
  17217. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17218. */
  17219. beginAnimationOnStart: boolean;
  17220. /**
  17221. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17222. */
  17223. beginAnimationFrom: number;
  17224. /**
  17225. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17226. */
  17227. beginAnimationTo: number;
  17228. /**
  17229. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17230. */
  17231. beginAnimationLoop: boolean;
  17232. /**
  17233. * Gets or sets a world offset applied to all particles
  17234. */
  17235. worldOffset: Vector3;
  17236. /**
  17237. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17238. */
  17239. isAnimationSheetEnabled: boolean;
  17240. /**
  17241. * Get hosting scene
  17242. * @returns the scene
  17243. */
  17244. getScene(): Scene;
  17245. /**
  17246. * You can use gravity if you want to give an orientation to your particles.
  17247. */
  17248. gravity: Vector3;
  17249. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17250. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17251. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17252. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17253. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17254. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17255. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17256. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17257. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17258. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17259. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17260. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17261. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17262. /**
  17263. * Defines the delay in milliseconds before starting the system (0 by default)
  17264. */
  17265. startDelay: number;
  17266. /**
  17267. * Gets the current list of drag gradients.
  17268. * You must use addDragGradient and removeDragGradient to udpate this list
  17269. * @returns the list of drag gradients
  17270. */
  17271. getDragGradients(): Nullable<Array<FactorGradient>>;
  17272. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17273. limitVelocityDamping: number;
  17274. /**
  17275. * Gets the current list of limit velocity gradients.
  17276. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17277. * @returns the list of limit velocity gradients
  17278. */
  17279. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17280. /**
  17281. * Gets the current list of color gradients.
  17282. * You must use addColorGradient and removeColorGradient to udpate this list
  17283. * @returns the list of color gradients
  17284. */
  17285. getColorGradients(): Nullable<Array<ColorGradient>>;
  17286. /**
  17287. * Gets the current list of size gradients.
  17288. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17289. * @returns the list of size gradients
  17290. */
  17291. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17292. /**
  17293. * Gets the current list of color remap gradients.
  17294. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17295. * @returns the list of color remap gradients
  17296. */
  17297. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17298. /**
  17299. * Gets the current list of alpha remap gradients.
  17300. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17301. * @returns the list of alpha remap gradients
  17302. */
  17303. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17304. /**
  17305. * Gets the current list of life time gradients.
  17306. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17307. * @returns the list of life time gradients
  17308. */
  17309. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17310. /**
  17311. * Gets the current list of angular speed gradients.
  17312. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17313. * @returns the list of angular speed gradients
  17314. */
  17315. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17316. /**
  17317. * Gets the current list of velocity gradients.
  17318. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17319. * @returns the list of velocity gradients
  17320. */
  17321. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17322. /**
  17323. * Gets the current list of start size gradients.
  17324. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17325. * @returns the list of start size gradients
  17326. */
  17327. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17328. /**
  17329. * Gets the current list of emit rate gradients.
  17330. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17331. * @returns the list of emit rate gradients
  17332. */
  17333. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17334. /**
  17335. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17336. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17337. */
  17338. direction1: Vector3;
  17339. /**
  17340. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17341. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17342. */
  17343. direction2: Vector3;
  17344. /**
  17345. * 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.
  17346. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17347. */
  17348. minEmitBox: Vector3;
  17349. /**
  17350. * 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.
  17351. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17352. */
  17353. maxEmitBox: Vector3;
  17354. /**
  17355. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17356. */
  17357. color1: Color4;
  17358. /**
  17359. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17360. */
  17361. color2: Color4;
  17362. /**
  17363. * Color the particle will have at the end of its lifetime
  17364. */
  17365. colorDead: Color4;
  17366. /**
  17367. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17368. */
  17369. textureMask: Color4;
  17370. /**
  17371. * The particle emitter type defines the emitter used by the particle system.
  17372. * It can be for example box, sphere, or cone...
  17373. */
  17374. particleEmitterType: IParticleEmitterType;
  17375. /** @hidden */
  17376. _isSubEmitter: boolean;
  17377. /**
  17378. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17379. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17380. */
  17381. billboardMode: number;
  17382. protected _isBillboardBased: boolean;
  17383. /**
  17384. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17385. */
  17386. isBillboardBased: boolean;
  17387. /**
  17388. * The scene the particle system belongs to.
  17389. */
  17390. protected _scene: Scene;
  17391. /**
  17392. * Local cache of defines for image processing.
  17393. */
  17394. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17395. /**
  17396. * Default configuration related to image processing available in the standard Material.
  17397. */
  17398. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17399. /**
  17400. * Gets the image processing configuration used either in this material.
  17401. */
  17402. /**
  17403. * Sets the Default image processing configuration used either in the this material.
  17404. *
  17405. * If sets to null, the scene one is in use.
  17406. */
  17407. imageProcessingConfiguration: ImageProcessingConfiguration;
  17408. /**
  17409. * Attaches a new image processing configuration to the Standard Material.
  17410. * @param configuration
  17411. */
  17412. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17413. /** @hidden */
  17414. protected _reset(): void;
  17415. /** @hidden */
  17416. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17417. /**
  17418. * Instantiates a particle system.
  17419. * 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.
  17420. * @param name The name of the particle system
  17421. */
  17422. constructor(name: string);
  17423. /**
  17424. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17425. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17426. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17427. * @returns the emitter
  17428. */
  17429. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17430. /**
  17431. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17432. * @param radius The radius of the hemisphere to emit from
  17433. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17434. * @returns the emitter
  17435. */
  17436. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17437. /**
  17438. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17439. * @param radius The radius of the sphere to emit from
  17440. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17441. * @returns the emitter
  17442. */
  17443. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17444. /**
  17445. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17446. * @param radius The radius of the sphere to emit from
  17447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17449. * @returns the emitter
  17450. */
  17451. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17452. /**
  17453. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17454. * @param radius The radius of the emission cylinder
  17455. * @param height The height of the emission cylinder
  17456. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17457. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17458. * @returns the emitter
  17459. */
  17460. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17461. /**
  17462. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17463. * @param radius The radius of the cylinder to emit from
  17464. * @param height The height of the emission cylinder
  17465. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17468. * @returns the emitter
  17469. */
  17470. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17471. /**
  17472. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17473. * @param radius The radius of the cone to emit from
  17474. * @param angle The base angle of the cone
  17475. * @returns the emitter
  17476. */
  17477. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17478. /**
  17479. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17480. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17481. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17482. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17483. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17484. * @returns the emitter
  17485. */
  17486. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17487. }
  17488. }
  17489. declare module "babylonjs/Particles/subEmitter" {
  17490. import { Scene } from "babylonjs/scene";
  17491. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17492. /**
  17493. * Type of sub emitter
  17494. */
  17495. export enum SubEmitterType {
  17496. /**
  17497. * Attached to the particle over it's lifetime
  17498. */
  17499. ATTACHED = 0,
  17500. /**
  17501. * Created when the particle dies
  17502. */
  17503. END = 1
  17504. }
  17505. /**
  17506. * Sub emitter class used to emit particles from an existing particle
  17507. */
  17508. export class SubEmitter {
  17509. /**
  17510. * the particle system to be used by the sub emitter
  17511. */
  17512. particleSystem: ParticleSystem;
  17513. /**
  17514. * Type of the submitter (Default: END)
  17515. */
  17516. type: SubEmitterType;
  17517. /**
  17518. * 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)
  17519. * Note: This only is supported when using an emitter of type Mesh
  17520. */
  17521. inheritDirection: boolean;
  17522. /**
  17523. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17524. */
  17525. inheritedVelocityAmount: number;
  17526. /**
  17527. * Creates a sub emitter
  17528. * @param particleSystem the particle system to be used by the sub emitter
  17529. */
  17530. constructor(
  17531. /**
  17532. * the particle system to be used by the sub emitter
  17533. */
  17534. particleSystem: ParticleSystem);
  17535. /**
  17536. * Clones the sub emitter
  17537. * @returns the cloned sub emitter
  17538. */
  17539. clone(): SubEmitter;
  17540. /**
  17541. * Serialize current object to a JSON object
  17542. * @returns the serialized object
  17543. */
  17544. serialize(): any;
  17545. /** @hidden */
  17546. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17547. /**
  17548. * Creates a new SubEmitter from a serialized JSON version
  17549. * @param serializationObject defines the JSON object to read from
  17550. * @param scene defines the hosting scene
  17551. * @param rootUrl defines the rootUrl for data loading
  17552. * @returns a new SubEmitter
  17553. */
  17554. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17555. /** Release associated resources */
  17556. dispose(): void;
  17557. }
  17558. }
  17559. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17560. /** @hidden */
  17561. export var clipPlaneFragmentDeclaration: {
  17562. name: string;
  17563. shader: string;
  17564. };
  17565. }
  17566. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17567. /** @hidden */
  17568. export var imageProcessingDeclaration: {
  17569. name: string;
  17570. shader: string;
  17571. };
  17572. }
  17573. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17574. /** @hidden */
  17575. export var imageProcessingFunctions: {
  17576. name: string;
  17577. shader: string;
  17578. };
  17579. }
  17580. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17581. /** @hidden */
  17582. export var clipPlaneFragment: {
  17583. name: string;
  17584. shader: string;
  17585. };
  17586. }
  17587. declare module "babylonjs/Shaders/particles.fragment" {
  17588. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17589. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17590. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17591. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17592. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17593. /** @hidden */
  17594. export var particlesPixelShader: {
  17595. name: string;
  17596. shader: string;
  17597. };
  17598. }
  17599. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17600. /** @hidden */
  17601. export var clipPlaneVertexDeclaration: {
  17602. name: string;
  17603. shader: string;
  17604. };
  17605. }
  17606. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17607. /** @hidden */
  17608. export var clipPlaneVertex: {
  17609. name: string;
  17610. shader: string;
  17611. };
  17612. }
  17613. declare module "babylonjs/Shaders/particles.vertex" {
  17614. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17615. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17616. /** @hidden */
  17617. export var particlesVertexShader: {
  17618. name: string;
  17619. shader: string;
  17620. };
  17621. }
  17622. declare module "babylonjs/Particles/particleSystem" {
  17623. import { Nullable } from "babylonjs/types";
  17624. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17625. import { Observable } from "babylonjs/Misc/observable";
  17626. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17627. import { Effect } from "babylonjs/Materials/effect";
  17628. import { Scene, IDisposable } from "babylonjs/scene";
  17629. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17630. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17631. import { Particle } from "babylonjs/Particles/particle";
  17632. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17633. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17634. import "babylonjs/Shaders/particles.fragment";
  17635. import "babylonjs/Shaders/particles.vertex";
  17636. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17637. /**
  17638. * This represents a particle system in Babylon.
  17639. * 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.
  17640. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17641. * @example https://doc.babylonjs.com/babylon101/particles
  17642. */
  17643. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17644. /**
  17645. * Billboard mode will only apply to Y axis
  17646. */
  17647. static readonly BILLBOARDMODE_Y: number;
  17648. /**
  17649. * Billboard mode will apply to all axes
  17650. */
  17651. static readonly BILLBOARDMODE_ALL: number;
  17652. /**
  17653. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17654. */
  17655. static readonly BILLBOARDMODE_STRETCHED: number;
  17656. /**
  17657. * This function can be defined to provide custom update for active particles.
  17658. * This function will be called instead of regular update (age, position, color, etc.).
  17659. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17660. */
  17661. updateFunction: (particles: Particle[]) => void;
  17662. private _emitterWorldMatrix;
  17663. /**
  17664. * This function can be defined to specify initial direction for every new particle.
  17665. * It by default use the emitterType defined function
  17666. */
  17667. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17668. /**
  17669. * This function can be defined to specify initial position for every new particle.
  17670. * It by default use the emitterType defined function
  17671. */
  17672. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17673. /**
  17674. * @hidden
  17675. */
  17676. _inheritedVelocityOffset: Vector3;
  17677. /**
  17678. * An event triggered when the system is disposed
  17679. */
  17680. onDisposeObservable: Observable<ParticleSystem>;
  17681. private _onDisposeObserver;
  17682. /**
  17683. * Sets a callback that will be triggered when the system is disposed
  17684. */
  17685. onDispose: () => void;
  17686. private _particles;
  17687. private _epsilon;
  17688. private _capacity;
  17689. private _stockParticles;
  17690. private _newPartsExcess;
  17691. private _vertexData;
  17692. private _vertexBuffer;
  17693. private _vertexBuffers;
  17694. private _spriteBuffer;
  17695. private _indexBuffer;
  17696. private _effect;
  17697. private _customEffect;
  17698. private _cachedDefines;
  17699. private _scaledColorStep;
  17700. private _colorDiff;
  17701. private _scaledDirection;
  17702. private _scaledGravity;
  17703. private _currentRenderId;
  17704. private _alive;
  17705. private _useInstancing;
  17706. private _started;
  17707. private _stopped;
  17708. private _actualFrame;
  17709. private _scaledUpdateSpeed;
  17710. private _vertexBufferSize;
  17711. /** @hidden */
  17712. _currentEmitRateGradient: Nullable<FactorGradient>;
  17713. /** @hidden */
  17714. _currentEmitRate1: number;
  17715. /** @hidden */
  17716. _currentEmitRate2: number;
  17717. /** @hidden */
  17718. _currentStartSizeGradient: Nullable<FactorGradient>;
  17719. /** @hidden */
  17720. _currentStartSize1: number;
  17721. /** @hidden */
  17722. _currentStartSize2: number;
  17723. private readonly _rawTextureWidth;
  17724. private _rampGradientsTexture;
  17725. private _useRampGradients;
  17726. /** Gets or sets a boolean indicating that ramp gradients must be used
  17727. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17728. */
  17729. useRampGradients: boolean;
  17730. /**
  17731. * 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.
  17732. * 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: [])
  17733. */
  17734. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17735. private _subEmitters;
  17736. /**
  17737. * @hidden
  17738. * If the particle systems emitter should be disposed when the particle system is disposed
  17739. */
  17740. _disposeEmitterOnDispose: boolean;
  17741. /**
  17742. * The current active Sub-systems, this property is used by the root particle system only.
  17743. */
  17744. activeSubSystems: Array<ParticleSystem>;
  17745. private _rootParticleSystem;
  17746. /**
  17747. * Gets the current list of active particles
  17748. */
  17749. readonly particles: Particle[];
  17750. /**
  17751. * Returns the string "ParticleSystem"
  17752. * @returns a string containing the class name
  17753. */
  17754. getClassName(): string;
  17755. /**
  17756. * Instantiates a particle system.
  17757. * 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.
  17758. * @param name The name of the particle system
  17759. * @param capacity The max number of particles alive at the same time
  17760. * @param scene The scene the particle system belongs to
  17761. * @param customEffect a custom effect used to change the way particles are rendered by default
  17762. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17763. * @param epsilon Offset used to render the particles
  17764. */
  17765. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17766. private _addFactorGradient;
  17767. private _removeFactorGradient;
  17768. /**
  17769. * Adds a new life time gradient
  17770. * @param gradient defines the gradient to use (between 0 and 1)
  17771. * @param factor defines the life time factor to affect to the specified gradient
  17772. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17773. * @returns the current particle system
  17774. */
  17775. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17776. /**
  17777. * Remove a specific life time gradient
  17778. * @param gradient defines the gradient to remove
  17779. * @returns the current particle system
  17780. */
  17781. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17782. /**
  17783. * Adds a new size gradient
  17784. * @param gradient defines the gradient to use (between 0 and 1)
  17785. * @param factor defines the size factor to affect to the specified gradient
  17786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17787. * @returns the current particle system
  17788. */
  17789. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17790. /**
  17791. * Remove a specific size gradient
  17792. * @param gradient defines the gradient to remove
  17793. * @returns the current particle system
  17794. */
  17795. removeSizeGradient(gradient: number): IParticleSystem;
  17796. /**
  17797. * Adds a new color remap gradient
  17798. * @param gradient defines the gradient to use (between 0 and 1)
  17799. * @param min defines the color remap minimal range
  17800. * @param max defines the color remap maximal range
  17801. * @returns the current particle system
  17802. */
  17803. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17804. /**
  17805. * Remove a specific color remap gradient
  17806. * @param gradient defines the gradient to remove
  17807. * @returns the current particle system
  17808. */
  17809. removeColorRemapGradient(gradient: number): IParticleSystem;
  17810. /**
  17811. * Adds a new alpha remap gradient
  17812. * @param gradient defines the gradient to use (between 0 and 1)
  17813. * @param min defines the alpha remap minimal range
  17814. * @param max defines the alpha remap maximal range
  17815. * @returns the current particle system
  17816. */
  17817. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17818. /**
  17819. * Remove a specific alpha remap gradient
  17820. * @param gradient defines the gradient to remove
  17821. * @returns the current particle system
  17822. */
  17823. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17824. /**
  17825. * Adds a new angular speed gradient
  17826. * @param gradient defines the gradient to use (between 0 and 1)
  17827. * @param factor defines the angular speed to affect to the specified gradient
  17828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17829. * @returns the current particle system
  17830. */
  17831. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17832. /**
  17833. * Remove a specific angular speed gradient
  17834. * @param gradient defines the gradient to remove
  17835. * @returns the current particle system
  17836. */
  17837. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17838. /**
  17839. * Adds a new velocity gradient
  17840. * @param gradient defines the gradient to use (between 0 and 1)
  17841. * @param factor defines the velocity to affect to the specified gradient
  17842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17843. * @returns the current particle system
  17844. */
  17845. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17846. /**
  17847. * Remove a specific velocity gradient
  17848. * @param gradient defines the gradient to remove
  17849. * @returns the current particle system
  17850. */
  17851. removeVelocityGradient(gradient: number): IParticleSystem;
  17852. /**
  17853. * Adds a new limit velocity gradient
  17854. * @param gradient defines the gradient to use (between 0 and 1)
  17855. * @param factor defines the limit velocity value to affect to the specified gradient
  17856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17857. * @returns the current particle system
  17858. */
  17859. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17860. /**
  17861. * Remove a specific limit velocity gradient
  17862. * @param gradient defines the gradient to remove
  17863. * @returns the current particle system
  17864. */
  17865. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17866. /**
  17867. * Adds a new drag gradient
  17868. * @param gradient defines the gradient to use (between 0 and 1)
  17869. * @param factor defines the drag value to affect to the specified gradient
  17870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17871. * @returns the current particle system
  17872. */
  17873. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17874. /**
  17875. * Remove a specific drag gradient
  17876. * @param gradient defines the gradient to remove
  17877. * @returns the current particle system
  17878. */
  17879. removeDragGradient(gradient: number): IParticleSystem;
  17880. /**
  17881. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17882. * @param gradient defines the gradient to use (between 0 and 1)
  17883. * @param factor defines the emit rate value to affect to the specified gradient
  17884. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17885. * @returns the current particle system
  17886. */
  17887. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17888. /**
  17889. * Remove a specific emit rate gradient
  17890. * @param gradient defines the gradient to remove
  17891. * @returns the current particle system
  17892. */
  17893. removeEmitRateGradient(gradient: number): IParticleSystem;
  17894. /**
  17895. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17896. * @param gradient defines the gradient to use (between 0 and 1)
  17897. * @param factor defines the start size value to affect to the specified gradient
  17898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17899. * @returns the current particle system
  17900. */
  17901. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17902. /**
  17903. * Remove a specific start size gradient
  17904. * @param gradient defines the gradient to remove
  17905. * @returns the current particle system
  17906. */
  17907. removeStartSizeGradient(gradient: number): IParticleSystem;
  17908. private _createRampGradientTexture;
  17909. /**
  17910. * Gets the current list of ramp gradients.
  17911. * You must use addRampGradient and removeRampGradient to udpate this list
  17912. * @returns the list of ramp gradients
  17913. */
  17914. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17915. /**
  17916. * Adds a new ramp gradient used to remap particle colors
  17917. * @param gradient defines the gradient to use (between 0 and 1)
  17918. * @param color defines the color to affect to the specified gradient
  17919. * @returns the current particle system
  17920. */
  17921. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17922. /**
  17923. * Remove a specific ramp gradient
  17924. * @param gradient defines the gradient to remove
  17925. * @returns the current particle system
  17926. */
  17927. removeRampGradient(gradient: number): ParticleSystem;
  17928. /**
  17929. * Adds a new color gradient
  17930. * @param gradient defines the gradient to use (between 0 and 1)
  17931. * @param color1 defines the color to affect to the specified gradient
  17932. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17933. * @returns this particle system
  17934. */
  17935. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17936. /**
  17937. * Remove a specific color gradient
  17938. * @param gradient defines the gradient to remove
  17939. * @returns this particle system
  17940. */
  17941. removeColorGradient(gradient: number): IParticleSystem;
  17942. private _fetchR;
  17943. protected _reset(): void;
  17944. private _resetEffect;
  17945. private _createVertexBuffers;
  17946. private _createIndexBuffer;
  17947. /**
  17948. * Gets the maximum number of particles active at the same time.
  17949. * @returns The max number of active particles.
  17950. */
  17951. getCapacity(): number;
  17952. /**
  17953. * Gets whether there are still active particles in the system.
  17954. * @returns True if it is alive, otherwise false.
  17955. */
  17956. isAlive(): boolean;
  17957. /**
  17958. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17959. * @returns True if it has been started, otherwise false.
  17960. */
  17961. isStarted(): boolean;
  17962. private _prepareSubEmitterInternalArray;
  17963. /**
  17964. * Starts the particle system and begins to emit
  17965. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17966. */
  17967. start(delay?: number): void;
  17968. /**
  17969. * Stops the particle system.
  17970. * @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.
  17971. */
  17972. stop(stopSubEmitters?: boolean): void;
  17973. /**
  17974. * Remove all active particles
  17975. */
  17976. reset(): void;
  17977. /**
  17978. * @hidden (for internal use only)
  17979. */
  17980. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17981. /**
  17982. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17983. * Its lifetime will start back at 0.
  17984. */
  17985. recycleParticle: (particle: Particle) => void;
  17986. private _stopSubEmitters;
  17987. private _createParticle;
  17988. private _removeFromRoot;
  17989. private _emitFromParticle;
  17990. private _update;
  17991. /** @hidden */
  17992. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17993. /** @hidden */
  17994. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17995. /** @hidden */
  17996. private _getEffect;
  17997. /**
  17998. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17999. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18000. */
  18001. animate(preWarmOnly?: boolean): void;
  18002. private _appendParticleVertices;
  18003. /**
  18004. * Rebuilds the particle system.
  18005. */
  18006. rebuild(): void;
  18007. /**
  18008. * Is this system ready to be used/rendered
  18009. * @return true if the system is ready
  18010. */
  18011. isReady(): boolean;
  18012. private _render;
  18013. /**
  18014. * Renders the particle system in its current state.
  18015. * @returns the current number of particles
  18016. */
  18017. render(): number;
  18018. /**
  18019. * Disposes the particle system and free the associated resources
  18020. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18021. */
  18022. dispose(disposeTexture?: boolean): void;
  18023. /**
  18024. * Clones the particle system.
  18025. * @param name The name of the cloned object
  18026. * @param newEmitter The new emitter to use
  18027. * @returns the cloned particle system
  18028. */
  18029. clone(name: string, newEmitter: any): ParticleSystem;
  18030. /**
  18031. * Serializes the particle system to a JSON object.
  18032. * @returns the JSON object
  18033. */
  18034. serialize(): any;
  18035. /** @hidden */
  18036. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18037. /** @hidden */
  18038. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18039. /**
  18040. * Parses a JSON object to create a particle system.
  18041. * @param parsedParticleSystem The JSON object to parse
  18042. * @param scene The scene to create the particle system in
  18043. * @param rootUrl The root url to use to load external dependencies like texture
  18044. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18045. * @returns the Parsed particle system
  18046. */
  18047. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18048. }
  18049. }
  18050. declare module "babylonjs/Particles/particle" {
  18051. import { Nullable } from "babylonjs/types";
  18052. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18053. import { Color4 } from "babylonjs/Maths/math.color";
  18054. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18055. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18056. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18057. /**
  18058. * A particle represents one of the element emitted by a particle system.
  18059. * This is mainly define by its coordinates, direction, velocity and age.
  18060. */
  18061. export class Particle {
  18062. /**
  18063. * The particle system the particle belongs to.
  18064. */
  18065. particleSystem: ParticleSystem;
  18066. private static _Count;
  18067. /**
  18068. * Unique ID of the particle
  18069. */
  18070. id: number;
  18071. /**
  18072. * The world position of the particle in the scene.
  18073. */
  18074. position: Vector3;
  18075. /**
  18076. * The world direction of the particle in the scene.
  18077. */
  18078. direction: Vector3;
  18079. /**
  18080. * The color of the particle.
  18081. */
  18082. color: Color4;
  18083. /**
  18084. * The color change of the particle per step.
  18085. */
  18086. colorStep: Color4;
  18087. /**
  18088. * Defines how long will the life of the particle be.
  18089. */
  18090. lifeTime: number;
  18091. /**
  18092. * The current age of the particle.
  18093. */
  18094. age: number;
  18095. /**
  18096. * The current size of the particle.
  18097. */
  18098. size: number;
  18099. /**
  18100. * The current scale of the particle.
  18101. */
  18102. scale: Vector2;
  18103. /**
  18104. * The current angle of the particle.
  18105. */
  18106. angle: number;
  18107. /**
  18108. * Defines how fast is the angle changing.
  18109. */
  18110. angularSpeed: number;
  18111. /**
  18112. * Defines the cell index used by the particle to be rendered from a sprite.
  18113. */
  18114. cellIndex: number;
  18115. /**
  18116. * The information required to support color remapping
  18117. */
  18118. remapData: Vector4;
  18119. /** @hidden */
  18120. _randomCellOffset?: number;
  18121. /** @hidden */
  18122. _initialDirection: Nullable<Vector3>;
  18123. /** @hidden */
  18124. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18125. /** @hidden */
  18126. _initialStartSpriteCellID: number;
  18127. /** @hidden */
  18128. _initialEndSpriteCellID: number;
  18129. /** @hidden */
  18130. _currentColorGradient: Nullable<ColorGradient>;
  18131. /** @hidden */
  18132. _currentColor1: Color4;
  18133. /** @hidden */
  18134. _currentColor2: Color4;
  18135. /** @hidden */
  18136. _currentSizeGradient: Nullable<FactorGradient>;
  18137. /** @hidden */
  18138. _currentSize1: number;
  18139. /** @hidden */
  18140. _currentSize2: number;
  18141. /** @hidden */
  18142. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18143. /** @hidden */
  18144. _currentAngularSpeed1: number;
  18145. /** @hidden */
  18146. _currentAngularSpeed2: number;
  18147. /** @hidden */
  18148. _currentVelocityGradient: Nullable<FactorGradient>;
  18149. /** @hidden */
  18150. _currentVelocity1: number;
  18151. /** @hidden */
  18152. _currentVelocity2: number;
  18153. /** @hidden */
  18154. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18155. /** @hidden */
  18156. _currentLimitVelocity1: number;
  18157. /** @hidden */
  18158. _currentLimitVelocity2: number;
  18159. /** @hidden */
  18160. _currentDragGradient: Nullable<FactorGradient>;
  18161. /** @hidden */
  18162. _currentDrag1: number;
  18163. /** @hidden */
  18164. _currentDrag2: number;
  18165. /** @hidden */
  18166. _randomNoiseCoordinates1: Vector3;
  18167. /** @hidden */
  18168. _randomNoiseCoordinates2: Vector3;
  18169. /**
  18170. * Creates a new instance Particle
  18171. * @param particleSystem the particle system the particle belongs to
  18172. */
  18173. constructor(
  18174. /**
  18175. * The particle system the particle belongs to.
  18176. */
  18177. particleSystem: ParticleSystem);
  18178. private updateCellInfoFromSystem;
  18179. /**
  18180. * Defines how the sprite cell index is updated for the particle
  18181. */
  18182. updateCellIndex(): void;
  18183. /** @hidden */
  18184. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18185. /** @hidden */
  18186. _inheritParticleInfoToSubEmitters(): void;
  18187. /** @hidden */
  18188. _reset(): void;
  18189. /**
  18190. * Copy the properties of particle to another one.
  18191. * @param other the particle to copy the information to.
  18192. */
  18193. copyTo(other: Particle): void;
  18194. }
  18195. }
  18196. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18197. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18198. import { Effect } from "babylonjs/Materials/effect";
  18199. import { Particle } from "babylonjs/Particles/particle";
  18200. /**
  18201. * Particle emitter represents a volume emitting particles.
  18202. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18203. */
  18204. export interface IParticleEmitterType {
  18205. /**
  18206. * Called by the particle System when the direction is computed for the created particle.
  18207. * @param worldMatrix is the world matrix of the particle system
  18208. * @param directionToUpdate is the direction vector to update with the result
  18209. * @param particle is the particle we are computed the direction for
  18210. */
  18211. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18212. /**
  18213. * Called by the particle System when the position is computed for the created particle.
  18214. * @param worldMatrix is the world matrix of the particle system
  18215. * @param positionToUpdate is the position vector to update with the result
  18216. * @param particle is the particle we are computed the position for
  18217. */
  18218. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18219. /**
  18220. * Clones the current emitter and returns a copy of it
  18221. * @returns the new emitter
  18222. */
  18223. clone(): IParticleEmitterType;
  18224. /**
  18225. * Called by the GPUParticleSystem to setup the update shader
  18226. * @param effect defines the update shader
  18227. */
  18228. applyToShader(effect: Effect): void;
  18229. /**
  18230. * Returns a string to use to update the GPU particles update shader
  18231. * @returns the effect defines string
  18232. */
  18233. getEffectDefines(): string;
  18234. /**
  18235. * Returns a string representing the class name
  18236. * @returns a string containing the class name
  18237. */
  18238. getClassName(): string;
  18239. /**
  18240. * Serializes the particle system to a JSON object.
  18241. * @returns the JSON object
  18242. */
  18243. serialize(): any;
  18244. /**
  18245. * Parse properties from a JSON object
  18246. * @param serializationObject defines the JSON object
  18247. */
  18248. parse(serializationObject: any): void;
  18249. }
  18250. }
  18251. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18252. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18253. import { Effect } from "babylonjs/Materials/effect";
  18254. import { Particle } from "babylonjs/Particles/particle";
  18255. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18256. /**
  18257. * Particle emitter emitting particles from the inside of a box.
  18258. * It emits the particles randomly between 2 given directions.
  18259. */
  18260. export class BoxParticleEmitter implements IParticleEmitterType {
  18261. /**
  18262. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18263. */
  18264. direction1: Vector3;
  18265. /**
  18266. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18267. */
  18268. direction2: Vector3;
  18269. /**
  18270. * 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.
  18271. */
  18272. minEmitBox: Vector3;
  18273. /**
  18274. * 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.
  18275. */
  18276. maxEmitBox: Vector3;
  18277. /**
  18278. * Creates a new instance BoxParticleEmitter
  18279. */
  18280. constructor();
  18281. /**
  18282. * Called by the particle System when the direction is computed for the created particle.
  18283. * @param worldMatrix is the world matrix of the particle system
  18284. * @param directionToUpdate is the direction vector to update with the result
  18285. * @param particle is the particle we are computed the direction for
  18286. */
  18287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18288. /**
  18289. * Called by the particle System when the position is computed for the created particle.
  18290. * @param worldMatrix is the world matrix of the particle system
  18291. * @param positionToUpdate is the position vector to update with the result
  18292. * @param particle is the particle we are computed the position for
  18293. */
  18294. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18295. /**
  18296. * Clones the current emitter and returns a copy of it
  18297. * @returns the new emitter
  18298. */
  18299. clone(): BoxParticleEmitter;
  18300. /**
  18301. * Called by the GPUParticleSystem to setup the update shader
  18302. * @param effect defines the update shader
  18303. */
  18304. applyToShader(effect: Effect): void;
  18305. /**
  18306. * Returns a string to use to update the GPU particles update shader
  18307. * @returns a string containng the defines string
  18308. */
  18309. getEffectDefines(): string;
  18310. /**
  18311. * Returns the string "BoxParticleEmitter"
  18312. * @returns a string containing the class name
  18313. */
  18314. getClassName(): string;
  18315. /**
  18316. * Serializes the particle system to a JSON object.
  18317. * @returns the JSON object
  18318. */
  18319. serialize(): any;
  18320. /**
  18321. * Parse properties from a JSON object
  18322. * @param serializationObject defines the JSON object
  18323. */
  18324. parse(serializationObject: any): void;
  18325. }
  18326. }
  18327. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18328. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18329. import { Effect } from "babylonjs/Materials/effect";
  18330. import { Particle } from "babylonjs/Particles/particle";
  18331. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18332. /**
  18333. * Particle emitter emitting particles from the inside of a cone.
  18334. * It emits the particles alongside the cone volume from the base to the particle.
  18335. * The emission direction might be randomized.
  18336. */
  18337. export class ConeParticleEmitter implements IParticleEmitterType {
  18338. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18339. directionRandomizer: number;
  18340. private _radius;
  18341. private _angle;
  18342. private _height;
  18343. /**
  18344. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18345. */
  18346. radiusRange: number;
  18347. /**
  18348. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18349. */
  18350. heightRange: number;
  18351. /**
  18352. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18353. */
  18354. emitFromSpawnPointOnly: boolean;
  18355. /**
  18356. * Gets or sets the radius of the emission cone
  18357. */
  18358. radius: number;
  18359. /**
  18360. * Gets or sets the angle of the emission cone
  18361. */
  18362. angle: number;
  18363. private _buildHeight;
  18364. /**
  18365. * Creates a new instance ConeParticleEmitter
  18366. * @param radius the radius of the emission cone (1 by default)
  18367. * @param angle the cone base angle (PI by default)
  18368. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18369. */
  18370. constructor(radius?: number, angle?: number,
  18371. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18372. directionRandomizer?: number);
  18373. /**
  18374. * Called by the particle System when the direction is computed for the created particle.
  18375. * @param worldMatrix is the world matrix of the particle system
  18376. * @param directionToUpdate is the direction vector to update with the result
  18377. * @param particle is the particle we are computed the direction for
  18378. */
  18379. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18380. /**
  18381. * Called by the particle System when the position is computed for the created particle.
  18382. * @param worldMatrix is the world matrix of the particle system
  18383. * @param positionToUpdate is the position vector to update with the result
  18384. * @param particle is the particle we are computed the position for
  18385. */
  18386. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18387. /**
  18388. * Clones the current emitter and returns a copy of it
  18389. * @returns the new emitter
  18390. */
  18391. clone(): ConeParticleEmitter;
  18392. /**
  18393. * Called by the GPUParticleSystem to setup the update shader
  18394. * @param effect defines the update shader
  18395. */
  18396. applyToShader(effect: Effect): void;
  18397. /**
  18398. * Returns a string to use to update the GPU particles update shader
  18399. * @returns a string containng the defines string
  18400. */
  18401. getEffectDefines(): string;
  18402. /**
  18403. * Returns the string "ConeParticleEmitter"
  18404. * @returns a string containing the class name
  18405. */
  18406. getClassName(): string;
  18407. /**
  18408. * Serializes the particle system to a JSON object.
  18409. * @returns the JSON object
  18410. */
  18411. serialize(): any;
  18412. /**
  18413. * Parse properties from a JSON object
  18414. * @param serializationObject defines the JSON object
  18415. */
  18416. parse(serializationObject: any): void;
  18417. }
  18418. }
  18419. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18420. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18421. import { Effect } from "babylonjs/Materials/effect";
  18422. import { Particle } from "babylonjs/Particles/particle";
  18423. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18424. /**
  18425. * Particle emitter emitting particles from the inside of a cylinder.
  18426. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18427. */
  18428. export class CylinderParticleEmitter implements IParticleEmitterType {
  18429. /**
  18430. * The radius of the emission cylinder.
  18431. */
  18432. radius: number;
  18433. /**
  18434. * The height of the emission cylinder.
  18435. */
  18436. height: number;
  18437. /**
  18438. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18439. */
  18440. radiusRange: number;
  18441. /**
  18442. * How much to randomize the particle direction [0-1].
  18443. */
  18444. directionRandomizer: number;
  18445. /**
  18446. * Creates a new instance CylinderParticleEmitter
  18447. * @param radius the radius of the emission cylinder (1 by default)
  18448. * @param height the height of the emission cylinder (1 by default)
  18449. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18450. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18451. */
  18452. constructor(
  18453. /**
  18454. * The radius of the emission cylinder.
  18455. */
  18456. radius?: number,
  18457. /**
  18458. * The height of the emission cylinder.
  18459. */
  18460. height?: number,
  18461. /**
  18462. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18463. */
  18464. radiusRange?: number,
  18465. /**
  18466. * How much to randomize the particle direction [0-1].
  18467. */
  18468. directionRandomizer?: number);
  18469. /**
  18470. * Called by the particle System when the direction is computed for the created particle.
  18471. * @param worldMatrix is the world matrix of the particle system
  18472. * @param directionToUpdate is the direction vector to update with the result
  18473. * @param particle is the particle we are computed the direction for
  18474. */
  18475. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18476. /**
  18477. * Called by the particle System when the position is computed for the created particle.
  18478. * @param worldMatrix is the world matrix of the particle system
  18479. * @param positionToUpdate is the position vector to update with the result
  18480. * @param particle is the particle we are computed the position for
  18481. */
  18482. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18483. /**
  18484. * Clones the current emitter and returns a copy of it
  18485. * @returns the new emitter
  18486. */
  18487. clone(): CylinderParticleEmitter;
  18488. /**
  18489. * Called by the GPUParticleSystem to setup the update shader
  18490. * @param effect defines the update shader
  18491. */
  18492. applyToShader(effect: Effect): void;
  18493. /**
  18494. * Returns a string to use to update the GPU particles update shader
  18495. * @returns a string containng the defines string
  18496. */
  18497. getEffectDefines(): string;
  18498. /**
  18499. * Returns the string "CylinderParticleEmitter"
  18500. * @returns a string containing the class name
  18501. */
  18502. getClassName(): string;
  18503. /**
  18504. * Serializes the particle system to a JSON object.
  18505. * @returns the JSON object
  18506. */
  18507. serialize(): any;
  18508. /**
  18509. * Parse properties from a JSON object
  18510. * @param serializationObject defines the JSON object
  18511. */
  18512. parse(serializationObject: any): void;
  18513. }
  18514. /**
  18515. * Particle emitter emitting particles from the inside of a cylinder.
  18516. * It emits the particles randomly between two vectors.
  18517. */
  18518. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18519. /**
  18520. * The min limit of the emission direction.
  18521. */
  18522. direction1: Vector3;
  18523. /**
  18524. * The max limit of the emission direction.
  18525. */
  18526. direction2: Vector3;
  18527. /**
  18528. * Creates a new instance CylinderDirectedParticleEmitter
  18529. * @param radius the radius of the emission cylinder (1 by default)
  18530. * @param height the height of the emission cylinder (1 by default)
  18531. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18532. * @param direction1 the min limit of the emission direction (up vector by default)
  18533. * @param direction2 the max limit of the emission direction (up vector by default)
  18534. */
  18535. constructor(radius?: number, height?: number, radiusRange?: number,
  18536. /**
  18537. * The min limit of the emission direction.
  18538. */
  18539. direction1?: Vector3,
  18540. /**
  18541. * The max limit of the emission direction.
  18542. */
  18543. direction2?: Vector3);
  18544. /**
  18545. * Called by the particle System when the direction is computed for the created particle.
  18546. * @param worldMatrix is the world matrix of the particle system
  18547. * @param directionToUpdate is the direction vector to update with the result
  18548. * @param particle is the particle we are computed the direction for
  18549. */
  18550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18551. /**
  18552. * Clones the current emitter and returns a copy of it
  18553. * @returns the new emitter
  18554. */
  18555. clone(): CylinderDirectedParticleEmitter;
  18556. /**
  18557. * Called by the GPUParticleSystem to setup the update shader
  18558. * @param effect defines the update shader
  18559. */
  18560. applyToShader(effect: Effect): void;
  18561. /**
  18562. * Returns a string to use to update the GPU particles update shader
  18563. * @returns a string containng the defines string
  18564. */
  18565. getEffectDefines(): string;
  18566. /**
  18567. * Returns the string "CylinderDirectedParticleEmitter"
  18568. * @returns a string containing the class name
  18569. */
  18570. getClassName(): string;
  18571. /**
  18572. * Serializes the particle system to a JSON object.
  18573. * @returns the JSON object
  18574. */
  18575. serialize(): any;
  18576. /**
  18577. * Parse properties from a JSON object
  18578. * @param serializationObject defines the JSON object
  18579. */
  18580. parse(serializationObject: any): void;
  18581. }
  18582. }
  18583. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18584. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18585. import { Effect } from "babylonjs/Materials/effect";
  18586. import { Particle } from "babylonjs/Particles/particle";
  18587. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18588. /**
  18589. * Particle emitter emitting particles from the inside of a hemisphere.
  18590. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18591. */
  18592. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18593. /**
  18594. * The radius of the emission hemisphere.
  18595. */
  18596. radius: number;
  18597. /**
  18598. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18599. */
  18600. radiusRange: number;
  18601. /**
  18602. * How much to randomize the particle direction [0-1].
  18603. */
  18604. directionRandomizer: number;
  18605. /**
  18606. * Creates a new instance HemisphericParticleEmitter
  18607. * @param radius the radius of the emission hemisphere (1 by default)
  18608. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18609. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18610. */
  18611. constructor(
  18612. /**
  18613. * The radius of the emission hemisphere.
  18614. */
  18615. radius?: number,
  18616. /**
  18617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18618. */
  18619. radiusRange?: number,
  18620. /**
  18621. * How much to randomize the particle direction [0-1].
  18622. */
  18623. directionRandomizer?: number);
  18624. /**
  18625. * Called by the particle System when the direction is computed for the created particle.
  18626. * @param worldMatrix is the world matrix of the particle system
  18627. * @param directionToUpdate is the direction vector to update with the result
  18628. * @param particle is the particle we are computed the direction for
  18629. */
  18630. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18631. /**
  18632. * Called by the particle System when the position is computed for the created particle.
  18633. * @param worldMatrix is the world matrix of the particle system
  18634. * @param positionToUpdate is the position vector to update with the result
  18635. * @param particle is the particle we are computed the position for
  18636. */
  18637. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18638. /**
  18639. * Clones the current emitter and returns a copy of it
  18640. * @returns the new emitter
  18641. */
  18642. clone(): HemisphericParticleEmitter;
  18643. /**
  18644. * Called by the GPUParticleSystem to setup the update shader
  18645. * @param effect defines the update shader
  18646. */
  18647. applyToShader(effect: Effect): void;
  18648. /**
  18649. * Returns a string to use to update the GPU particles update shader
  18650. * @returns a string containng the defines string
  18651. */
  18652. getEffectDefines(): string;
  18653. /**
  18654. * Returns the string "HemisphericParticleEmitter"
  18655. * @returns a string containing the class name
  18656. */
  18657. getClassName(): string;
  18658. /**
  18659. * Serializes the particle system to a JSON object.
  18660. * @returns the JSON object
  18661. */
  18662. serialize(): any;
  18663. /**
  18664. * Parse properties from a JSON object
  18665. * @param serializationObject defines the JSON object
  18666. */
  18667. parse(serializationObject: any): void;
  18668. }
  18669. }
  18670. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18671. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18672. import { Effect } from "babylonjs/Materials/effect";
  18673. import { Particle } from "babylonjs/Particles/particle";
  18674. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18675. /**
  18676. * Particle emitter emitting particles from a point.
  18677. * It emits the particles randomly between 2 given directions.
  18678. */
  18679. export class PointParticleEmitter implements IParticleEmitterType {
  18680. /**
  18681. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18682. */
  18683. direction1: Vector3;
  18684. /**
  18685. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18686. */
  18687. direction2: Vector3;
  18688. /**
  18689. * Creates a new instance PointParticleEmitter
  18690. */
  18691. constructor();
  18692. /**
  18693. * Called by the particle System when the direction is computed for the created particle.
  18694. * @param worldMatrix is the world matrix of the particle system
  18695. * @param directionToUpdate is the direction vector to update with the result
  18696. * @param particle is the particle we are computed the direction for
  18697. */
  18698. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18699. /**
  18700. * Called by the particle System when the position is computed for the created particle.
  18701. * @param worldMatrix is the world matrix of the particle system
  18702. * @param positionToUpdate is the position vector to update with the result
  18703. * @param particle is the particle we are computed the position for
  18704. */
  18705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18706. /**
  18707. * Clones the current emitter and returns a copy of it
  18708. * @returns the new emitter
  18709. */
  18710. clone(): PointParticleEmitter;
  18711. /**
  18712. * Called by the GPUParticleSystem to setup the update shader
  18713. * @param effect defines the update shader
  18714. */
  18715. applyToShader(effect: Effect): void;
  18716. /**
  18717. * Returns a string to use to update the GPU particles update shader
  18718. * @returns a string containng the defines string
  18719. */
  18720. getEffectDefines(): string;
  18721. /**
  18722. * Returns the string "PointParticleEmitter"
  18723. * @returns a string containing the class name
  18724. */
  18725. getClassName(): string;
  18726. /**
  18727. * Serializes the particle system to a JSON object.
  18728. * @returns the JSON object
  18729. */
  18730. serialize(): any;
  18731. /**
  18732. * Parse properties from a JSON object
  18733. * @param serializationObject defines the JSON object
  18734. */
  18735. parse(serializationObject: any): void;
  18736. }
  18737. }
  18738. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18739. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18740. import { Effect } from "babylonjs/Materials/effect";
  18741. import { Particle } from "babylonjs/Particles/particle";
  18742. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18743. /**
  18744. * Particle emitter emitting particles from the inside of a sphere.
  18745. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18746. */
  18747. export class SphereParticleEmitter implements IParticleEmitterType {
  18748. /**
  18749. * The radius of the emission sphere.
  18750. */
  18751. radius: number;
  18752. /**
  18753. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18754. */
  18755. radiusRange: number;
  18756. /**
  18757. * How much to randomize the particle direction [0-1].
  18758. */
  18759. directionRandomizer: number;
  18760. /**
  18761. * Creates a new instance SphereParticleEmitter
  18762. * @param radius the radius of the emission sphere (1 by default)
  18763. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18764. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18765. */
  18766. constructor(
  18767. /**
  18768. * The radius of the emission sphere.
  18769. */
  18770. radius?: number,
  18771. /**
  18772. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18773. */
  18774. radiusRange?: number,
  18775. /**
  18776. * How much to randomize the particle direction [0-1].
  18777. */
  18778. directionRandomizer?: number);
  18779. /**
  18780. * Called by the particle System when the direction is computed for the created particle.
  18781. * @param worldMatrix is the world matrix of the particle system
  18782. * @param directionToUpdate is the direction vector to update with the result
  18783. * @param particle is the particle we are computed the direction for
  18784. */
  18785. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18786. /**
  18787. * Called by the particle System when the position is computed for the created particle.
  18788. * @param worldMatrix is the world matrix of the particle system
  18789. * @param positionToUpdate is the position vector to update with the result
  18790. * @param particle is the particle we are computed the position for
  18791. */
  18792. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18793. /**
  18794. * Clones the current emitter and returns a copy of it
  18795. * @returns the new emitter
  18796. */
  18797. clone(): SphereParticleEmitter;
  18798. /**
  18799. * Called by the GPUParticleSystem to setup the update shader
  18800. * @param effect defines the update shader
  18801. */
  18802. applyToShader(effect: Effect): void;
  18803. /**
  18804. * Returns a string to use to update the GPU particles update shader
  18805. * @returns a string containng the defines string
  18806. */
  18807. getEffectDefines(): string;
  18808. /**
  18809. * Returns the string "SphereParticleEmitter"
  18810. * @returns a string containing the class name
  18811. */
  18812. getClassName(): string;
  18813. /**
  18814. * Serializes the particle system to a JSON object.
  18815. * @returns the JSON object
  18816. */
  18817. serialize(): any;
  18818. /**
  18819. * Parse properties from a JSON object
  18820. * @param serializationObject defines the JSON object
  18821. */
  18822. parse(serializationObject: any): void;
  18823. }
  18824. /**
  18825. * Particle emitter emitting particles from the inside of a sphere.
  18826. * It emits the particles randomly between two vectors.
  18827. */
  18828. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18829. /**
  18830. * The min limit of the emission direction.
  18831. */
  18832. direction1: Vector3;
  18833. /**
  18834. * The max limit of the emission direction.
  18835. */
  18836. direction2: Vector3;
  18837. /**
  18838. * Creates a new instance SphereDirectedParticleEmitter
  18839. * @param radius the radius of the emission sphere (1 by default)
  18840. * @param direction1 the min limit of the emission direction (up vector by default)
  18841. * @param direction2 the max limit of the emission direction (up vector by default)
  18842. */
  18843. constructor(radius?: number,
  18844. /**
  18845. * The min limit of the emission direction.
  18846. */
  18847. direction1?: Vector3,
  18848. /**
  18849. * The max limit of the emission direction.
  18850. */
  18851. direction2?: Vector3);
  18852. /**
  18853. * Called by the particle System when the direction is computed for the created particle.
  18854. * @param worldMatrix is the world matrix of the particle system
  18855. * @param directionToUpdate is the direction vector to update with the result
  18856. * @param particle is the particle we are computed the direction for
  18857. */
  18858. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18859. /**
  18860. * Clones the current emitter and returns a copy of it
  18861. * @returns the new emitter
  18862. */
  18863. clone(): SphereDirectedParticleEmitter;
  18864. /**
  18865. * Called by the GPUParticleSystem to setup the update shader
  18866. * @param effect defines the update shader
  18867. */
  18868. applyToShader(effect: Effect): void;
  18869. /**
  18870. * Returns a string to use to update the GPU particles update shader
  18871. * @returns a string containng the defines string
  18872. */
  18873. getEffectDefines(): string;
  18874. /**
  18875. * Returns the string "SphereDirectedParticleEmitter"
  18876. * @returns a string containing the class name
  18877. */
  18878. getClassName(): string;
  18879. /**
  18880. * Serializes the particle system to a JSON object.
  18881. * @returns the JSON object
  18882. */
  18883. serialize(): any;
  18884. /**
  18885. * Parse properties from a JSON object
  18886. * @param serializationObject defines the JSON object
  18887. */
  18888. parse(serializationObject: any): void;
  18889. }
  18890. }
  18891. declare module "babylonjs/Particles/EmitterTypes/index" {
  18892. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18893. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18894. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18895. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18896. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18897. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18898. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18899. }
  18900. declare module "babylonjs/Particles/IParticleSystem" {
  18901. import { Nullable } from "babylonjs/types";
  18902. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18903. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18906. import { Texture } from "babylonjs/Materials/Textures/texture";
  18907. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18908. import { Scene } from "babylonjs/scene";
  18909. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18910. import { Animation } from "babylonjs/Animations/animation";
  18911. /**
  18912. * Interface representing a particle system in Babylon.js.
  18913. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18914. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18915. */
  18916. export interface IParticleSystem {
  18917. /**
  18918. * List of animations used by the particle system.
  18919. */
  18920. animations: Animation[];
  18921. /**
  18922. * The id of the Particle system.
  18923. */
  18924. id: string;
  18925. /**
  18926. * The name of the Particle system.
  18927. */
  18928. name: string;
  18929. /**
  18930. * The emitter represents the Mesh or position we are attaching the particle system to.
  18931. */
  18932. emitter: Nullable<AbstractMesh | Vector3>;
  18933. /**
  18934. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18935. */
  18936. isBillboardBased: boolean;
  18937. /**
  18938. * The rendering group used by the Particle system to chose when to render.
  18939. */
  18940. renderingGroupId: number;
  18941. /**
  18942. * The layer mask we are rendering the particles through.
  18943. */
  18944. layerMask: number;
  18945. /**
  18946. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18947. */
  18948. updateSpeed: number;
  18949. /**
  18950. * The amount of time the particle system is running (depends of the overall update speed).
  18951. */
  18952. targetStopDuration: number;
  18953. /**
  18954. * The texture used to render each particle. (this can be a spritesheet)
  18955. */
  18956. particleTexture: Nullable<Texture>;
  18957. /**
  18958. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18959. */
  18960. blendMode: number;
  18961. /**
  18962. * Minimum life time of emitting particles.
  18963. */
  18964. minLifeTime: number;
  18965. /**
  18966. * Maximum life time of emitting particles.
  18967. */
  18968. maxLifeTime: number;
  18969. /**
  18970. * Minimum Size of emitting particles.
  18971. */
  18972. minSize: number;
  18973. /**
  18974. * Maximum Size of emitting particles.
  18975. */
  18976. maxSize: number;
  18977. /**
  18978. * Minimum scale of emitting particles on X axis.
  18979. */
  18980. minScaleX: number;
  18981. /**
  18982. * Maximum scale of emitting particles on X axis.
  18983. */
  18984. maxScaleX: number;
  18985. /**
  18986. * Minimum scale of emitting particles on Y axis.
  18987. */
  18988. minScaleY: number;
  18989. /**
  18990. * Maximum scale of emitting particles on Y axis.
  18991. */
  18992. maxScaleY: number;
  18993. /**
  18994. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18995. */
  18996. color1: Color4;
  18997. /**
  18998. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18999. */
  19000. color2: Color4;
  19001. /**
  19002. * Color the particle will have at the end of its lifetime.
  19003. */
  19004. colorDead: Color4;
  19005. /**
  19006. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19007. */
  19008. emitRate: number;
  19009. /**
  19010. * You can use gravity if you want to give an orientation to your particles.
  19011. */
  19012. gravity: Vector3;
  19013. /**
  19014. * Minimum power of emitting particles.
  19015. */
  19016. minEmitPower: number;
  19017. /**
  19018. * Maximum power of emitting particles.
  19019. */
  19020. maxEmitPower: number;
  19021. /**
  19022. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19023. */
  19024. minAngularSpeed: number;
  19025. /**
  19026. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19027. */
  19028. maxAngularSpeed: number;
  19029. /**
  19030. * Gets or sets the minimal initial rotation in radians.
  19031. */
  19032. minInitialRotation: number;
  19033. /**
  19034. * Gets or sets the maximal initial rotation in radians.
  19035. */
  19036. maxInitialRotation: number;
  19037. /**
  19038. * The particle emitter type defines the emitter used by the particle system.
  19039. * It can be for example box, sphere, or cone...
  19040. */
  19041. particleEmitterType: Nullable<IParticleEmitterType>;
  19042. /**
  19043. * Defines the delay in milliseconds before starting the system (0 by default)
  19044. */
  19045. startDelay: number;
  19046. /**
  19047. * 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
  19048. */
  19049. preWarmCycles: number;
  19050. /**
  19051. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19052. */
  19053. preWarmStepOffset: number;
  19054. /**
  19055. * 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)
  19056. */
  19057. spriteCellChangeSpeed: number;
  19058. /**
  19059. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19060. */
  19061. startSpriteCellID: number;
  19062. /**
  19063. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19064. */
  19065. endSpriteCellID: number;
  19066. /**
  19067. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19068. */
  19069. spriteCellWidth: number;
  19070. /**
  19071. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19072. */
  19073. spriteCellHeight: number;
  19074. /**
  19075. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19076. */
  19077. spriteRandomStartCell: boolean;
  19078. /**
  19079. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19080. */
  19081. isAnimationSheetEnabled: boolean;
  19082. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19083. translationPivot: Vector2;
  19084. /**
  19085. * Gets or sets a texture used to add random noise to particle positions
  19086. */
  19087. noiseTexture: Nullable<BaseTexture>;
  19088. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19089. noiseStrength: Vector3;
  19090. /**
  19091. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19092. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19093. */
  19094. billboardMode: number;
  19095. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19096. limitVelocityDamping: number;
  19097. /**
  19098. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19099. */
  19100. beginAnimationOnStart: boolean;
  19101. /**
  19102. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19103. */
  19104. beginAnimationFrom: number;
  19105. /**
  19106. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19107. */
  19108. beginAnimationTo: number;
  19109. /**
  19110. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19111. */
  19112. beginAnimationLoop: boolean;
  19113. /**
  19114. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19115. */
  19116. disposeOnStop: boolean;
  19117. /**
  19118. * Gets the maximum number of particles active at the same time.
  19119. * @returns The max number of active particles.
  19120. */
  19121. getCapacity(): number;
  19122. /**
  19123. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19124. * @returns True if it has been started, otherwise false.
  19125. */
  19126. isStarted(): boolean;
  19127. /**
  19128. * Animates the particle system for this frame.
  19129. */
  19130. animate(): void;
  19131. /**
  19132. * Renders the particle system in its current state.
  19133. * @returns the current number of particles
  19134. */
  19135. render(): number;
  19136. /**
  19137. * Dispose the particle system and frees its associated resources.
  19138. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19139. */
  19140. dispose(disposeTexture?: boolean): void;
  19141. /**
  19142. * Clones the particle system.
  19143. * @param name The name of the cloned object
  19144. * @param newEmitter The new emitter to use
  19145. * @returns the cloned particle system
  19146. */
  19147. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19148. /**
  19149. * Serializes the particle system to a JSON object.
  19150. * @returns the JSON object
  19151. */
  19152. serialize(): any;
  19153. /**
  19154. * Rebuild the particle system
  19155. */
  19156. rebuild(): void;
  19157. /**
  19158. * Starts the particle system and begins to emit
  19159. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19160. */
  19161. start(delay?: number): void;
  19162. /**
  19163. * Stops the particle system.
  19164. */
  19165. stop(): void;
  19166. /**
  19167. * Remove all active particles
  19168. */
  19169. reset(): void;
  19170. /**
  19171. * Is this system ready to be used/rendered
  19172. * @return true if the system is ready
  19173. */
  19174. isReady(): boolean;
  19175. /**
  19176. * Adds a new color gradient
  19177. * @param gradient defines the gradient to use (between 0 and 1)
  19178. * @param color1 defines the color to affect to the specified gradient
  19179. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19180. * @returns the current particle system
  19181. */
  19182. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19183. /**
  19184. * Remove a specific color gradient
  19185. * @param gradient defines the gradient to remove
  19186. * @returns the current particle system
  19187. */
  19188. removeColorGradient(gradient: number): IParticleSystem;
  19189. /**
  19190. * Adds a new size gradient
  19191. * @param gradient defines the gradient to use (between 0 and 1)
  19192. * @param factor defines the size factor to affect to the specified gradient
  19193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19194. * @returns the current particle system
  19195. */
  19196. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19197. /**
  19198. * Remove a specific size gradient
  19199. * @param gradient defines the gradient to remove
  19200. * @returns the current particle system
  19201. */
  19202. removeSizeGradient(gradient: number): IParticleSystem;
  19203. /**
  19204. * Gets the current list of color gradients.
  19205. * You must use addColorGradient and removeColorGradient to udpate this list
  19206. * @returns the list of color gradients
  19207. */
  19208. getColorGradients(): Nullable<Array<ColorGradient>>;
  19209. /**
  19210. * Gets the current list of size gradients.
  19211. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19212. * @returns the list of size gradients
  19213. */
  19214. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19215. /**
  19216. * Gets the current list of angular speed gradients.
  19217. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19218. * @returns the list of angular speed gradients
  19219. */
  19220. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19221. /**
  19222. * Adds a new angular speed gradient
  19223. * @param gradient defines the gradient to use (between 0 and 1)
  19224. * @param factor defines the angular speed to affect to the specified gradient
  19225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19226. * @returns the current particle system
  19227. */
  19228. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19229. /**
  19230. * Remove a specific angular speed gradient
  19231. * @param gradient defines the gradient to remove
  19232. * @returns the current particle system
  19233. */
  19234. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19235. /**
  19236. * Gets the current list of velocity gradients.
  19237. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19238. * @returns the list of velocity gradients
  19239. */
  19240. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19241. /**
  19242. * Adds a new velocity gradient
  19243. * @param gradient defines the gradient to use (between 0 and 1)
  19244. * @param factor defines the velocity to affect to the specified gradient
  19245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19246. * @returns the current particle system
  19247. */
  19248. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19249. /**
  19250. * Remove a specific velocity gradient
  19251. * @param gradient defines the gradient to remove
  19252. * @returns the current particle system
  19253. */
  19254. removeVelocityGradient(gradient: number): IParticleSystem;
  19255. /**
  19256. * Gets the current list of limit velocity gradients.
  19257. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19258. * @returns the list of limit velocity gradients
  19259. */
  19260. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19261. /**
  19262. * Adds a new limit velocity gradient
  19263. * @param gradient defines the gradient to use (between 0 and 1)
  19264. * @param factor defines the limit velocity to affect to the specified gradient
  19265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19266. * @returns the current particle system
  19267. */
  19268. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19269. /**
  19270. * Remove a specific limit velocity gradient
  19271. * @param gradient defines the gradient to remove
  19272. * @returns the current particle system
  19273. */
  19274. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19275. /**
  19276. * Adds a new drag gradient
  19277. * @param gradient defines the gradient to use (between 0 and 1)
  19278. * @param factor defines the drag to affect to the specified gradient
  19279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19280. * @returns the current particle system
  19281. */
  19282. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19283. /**
  19284. * Remove a specific drag gradient
  19285. * @param gradient defines the gradient to remove
  19286. * @returns the current particle system
  19287. */
  19288. removeDragGradient(gradient: number): IParticleSystem;
  19289. /**
  19290. * Gets the current list of drag gradients.
  19291. * You must use addDragGradient and removeDragGradient to udpate this list
  19292. * @returns the list of drag gradients
  19293. */
  19294. getDragGradients(): Nullable<Array<FactorGradient>>;
  19295. /**
  19296. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19297. * @param gradient defines the gradient to use (between 0 and 1)
  19298. * @param factor defines the emit rate to affect to the specified gradient
  19299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19300. * @returns the current particle system
  19301. */
  19302. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19303. /**
  19304. * Remove a specific emit rate gradient
  19305. * @param gradient defines the gradient to remove
  19306. * @returns the current particle system
  19307. */
  19308. removeEmitRateGradient(gradient: number): IParticleSystem;
  19309. /**
  19310. * Gets the current list of emit rate gradients.
  19311. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19312. * @returns the list of emit rate gradients
  19313. */
  19314. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19315. /**
  19316. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19317. * @param gradient defines the gradient to use (between 0 and 1)
  19318. * @param factor defines the start size to affect to the specified gradient
  19319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19320. * @returns the current particle system
  19321. */
  19322. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19323. /**
  19324. * Remove a specific start size gradient
  19325. * @param gradient defines the gradient to remove
  19326. * @returns the current particle system
  19327. */
  19328. removeStartSizeGradient(gradient: number): IParticleSystem;
  19329. /**
  19330. * Gets the current list of start size gradients.
  19331. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19332. * @returns the list of start size gradients
  19333. */
  19334. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19335. /**
  19336. * Adds a new life time gradient
  19337. * @param gradient defines the gradient to use (between 0 and 1)
  19338. * @param factor defines the life time factor to affect to the specified gradient
  19339. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19340. * @returns the current particle system
  19341. */
  19342. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19343. /**
  19344. * Remove a specific life time gradient
  19345. * @param gradient defines the gradient to remove
  19346. * @returns the current particle system
  19347. */
  19348. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19349. /**
  19350. * Gets the current list of life time gradients.
  19351. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19352. * @returns the list of life time gradients
  19353. */
  19354. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19355. /**
  19356. * Gets the current list of color gradients.
  19357. * You must use addColorGradient and removeColorGradient to udpate this list
  19358. * @returns the list of color gradients
  19359. */
  19360. getColorGradients(): Nullable<Array<ColorGradient>>;
  19361. /**
  19362. * Adds a new ramp gradient used to remap particle colors
  19363. * @param gradient defines the gradient to use (between 0 and 1)
  19364. * @param color defines the color to affect to the specified gradient
  19365. * @returns the current particle system
  19366. */
  19367. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19368. /**
  19369. * Gets the current list of ramp gradients.
  19370. * You must use addRampGradient and removeRampGradient to udpate this list
  19371. * @returns the list of ramp gradients
  19372. */
  19373. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19374. /** Gets or sets a boolean indicating that ramp gradients must be used
  19375. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19376. */
  19377. useRampGradients: boolean;
  19378. /**
  19379. * Adds a new color remap gradient
  19380. * @param gradient defines the gradient to use (between 0 and 1)
  19381. * @param min defines the color remap minimal range
  19382. * @param max defines the color remap maximal range
  19383. * @returns the current particle system
  19384. */
  19385. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19386. /**
  19387. * Gets the current list of color remap gradients.
  19388. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19389. * @returns the list of color remap gradients
  19390. */
  19391. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19392. /**
  19393. * Adds a new alpha remap gradient
  19394. * @param gradient defines the gradient to use (between 0 and 1)
  19395. * @param min defines the alpha remap minimal range
  19396. * @param max defines the alpha remap maximal range
  19397. * @returns the current particle system
  19398. */
  19399. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19400. /**
  19401. * Gets the current list of alpha remap gradients.
  19402. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19403. * @returns the list of alpha remap gradients
  19404. */
  19405. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19406. /**
  19407. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19410. * @returns the emitter
  19411. */
  19412. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19413. /**
  19414. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19415. * @param radius The radius of the hemisphere to emit from
  19416. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19417. * @returns the emitter
  19418. */
  19419. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19420. /**
  19421. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19422. * @param radius The radius of the sphere to emit from
  19423. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19424. * @returns the emitter
  19425. */
  19426. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19427. /**
  19428. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19429. * @param radius The radius of the sphere to emit from
  19430. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19431. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19432. * @returns the emitter
  19433. */
  19434. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19435. /**
  19436. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19437. * @param radius The radius of the emission cylinder
  19438. * @param height The height of the emission cylinder
  19439. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19440. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19441. * @returns the emitter
  19442. */
  19443. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19444. /**
  19445. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19446. * @param radius The radius of the cylinder to emit from
  19447. * @param height The height of the emission cylinder
  19448. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19449. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19450. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19451. * @returns the emitter
  19452. */
  19453. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19454. /**
  19455. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19456. * @param radius The radius of the cone to emit from
  19457. * @param angle The base angle of the cone
  19458. * @returns the emitter
  19459. */
  19460. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19461. /**
  19462. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19463. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19464. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19465. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19466. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19467. * @returns the emitter
  19468. */
  19469. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19470. /**
  19471. * Get hosting scene
  19472. * @returns the scene
  19473. */
  19474. getScene(): Scene;
  19475. }
  19476. }
  19477. declare module "babylonjs/Meshes/instancedMesh" {
  19478. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19479. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19480. import { Camera } from "babylonjs/Cameras/camera";
  19481. import { Node } from "babylonjs/node";
  19482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19483. import { Mesh } from "babylonjs/Meshes/mesh";
  19484. import { Material } from "babylonjs/Materials/material";
  19485. import { Skeleton } from "babylonjs/Bones/skeleton";
  19486. import { Light } from "babylonjs/Lights/light";
  19487. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19488. /**
  19489. * Creates an instance based on a source mesh.
  19490. */
  19491. export class InstancedMesh extends AbstractMesh {
  19492. private _sourceMesh;
  19493. private _currentLOD;
  19494. /** @hidden */
  19495. _indexInSourceMeshInstanceArray: number;
  19496. constructor(name: string, source: Mesh);
  19497. /**
  19498. * Returns the string "InstancedMesh".
  19499. */
  19500. getClassName(): string;
  19501. /** Gets the list of lights affecting that mesh */
  19502. readonly lightSources: Light[];
  19503. _resyncLightSources(): void;
  19504. _resyncLighSource(light: Light): void;
  19505. _removeLightSource(light: Light, dispose: boolean): void;
  19506. /**
  19507. * If the source mesh receives shadows
  19508. */
  19509. readonly receiveShadows: boolean;
  19510. /**
  19511. * The material of the source mesh
  19512. */
  19513. readonly material: Nullable<Material>;
  19514. /**
  19515. * Visibility of the source mesh
  19516. */
  19517. readonly visibility: number;
  19518. /**
  19519. * Skeleton of the source mesh
  19520. */
  19521. readonly skeleton: Nullable<Skeleton>;
  19522. /**
  19523. * Rendering ground id of the source mesh
  19524. */
  19525. renderingGroupId: number;
  19526. /**
  19527. * Returns the total number of vertices (integer).
  19528. */
  19529. getTotalVertices(): number;
  19530. /**
  19531. * Returns a positive integer : the total number of indices in this mesh geometry.
  19532. * @returns the numner of indices or zero if the mesh has no geometry.
  19533. */
  19534. getTotalIndices(): number;
  19535. /**
  19536. * The source mesh of the instance
  19537. */
  19538. readonly sourceMesh: Mesh;
  19539. /**
  19540. * Is this node ready to be used/rendered
  19541. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19542. * @return {boolean} is it ready
  19543. */
  19544. isReady(completeCheck?: boolean): boolean;
  19545. /**
  19546. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19547. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19548. * @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.
  19549. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19550. */
  19551. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19552. /**
  19553. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19554. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19555. * The `data` are either a numeric array either a Float32Array.
  19556. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19557. * 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).
  19558. * Note that a new underlying VertexBuffer object is created each call.
  19559. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19560. *
  19561. * Possible `kind` values :
  19562. * - VertexBuffer.PositionKind
  19563. * - VertexBuffer.UVKind
  19564. * - VertexBuffer.UV2Kind
  19565. * - VertexBuffer.UV3Kind
  19566. * - VertexBuffer.UV4Kind
  19567. * - VertexBuffer.UV5Kind
  19568. * - VertexBuffer.UV6Kind
  19569. * - VertexBuffer.ColorKind
  19570. * - VertexBuffer.MatricesIndicesKind
  19571. * - VertexBuffer.MatricesIndicesExtraKind
  19572. * - VertexBuffer.MatricesWeightsKind
  19573. * - VertexBuffer.MatricesWeightsExtraKind
  19574. *
  19575. * Returns the Mesh.
  19576. */
  19577. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19578. /**
  19579. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19580. * If the mesh has no geometry, it is simply returned as it is.
  19581. * The `data` are either a numeric array either a Float32Array.
  19582. * No new underlying VertexBuffer object is created.
  19583. * 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.
  19584. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19585. *
  19586. * Possible `kind` values :
  19587. * - VertexBuffer.PositionKind
  19588. * - VertexBuffer.UVKind
  19589. * - VertexBuffer.UV2Kind
  19590. * - VertexBuffer.UV3Kind
  19591. * - VertexBuffer.UV4Kind
  19592. * - VertexBuffer.UV5Kind
  19593. * - VertexBuffer.UV6Kind
  19594. * - VertexBuffer.ColorKind
  19595. * - VertexBuffer.MatricesIndicesKind
  19596. * - VertexBuffer.MatricesIndicesExtraKind
  19597. * - VertexBuffer.MatricesWeightsKind
  19598. * - VertexBuffer.MatricesWeightsExtraKind
  19599. *
  19600. * Returns the Mesh.
  19601. */
  19602. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19603. /**
  19604. * Sets the mesh indices.
  19605. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19606. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19607. * This method creates a new index buffer each call.
  19608. * Returns the Mesh.
  19609. */
  19610. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19611. /**
  19612. * Boolean : True if the mesh owns the requested kind of data.
  19613. */
  19614. isVerticesDataPresent(kind: string): boolean;
  19615. /**
  19616. * Returns an array of indices (IndicesArray).
  19617. */
  19618. getIndices(): Nullable<IndicesArray>;
  19619. readonly _positions: Nullable<Vector3[]>;
  19620. /**
  19621. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19622. * This means the mesh underlying bounding box and sphere are recomputed.
  19623. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19624. * @returns the current mesh
  19625. */
  19626. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19627. /** @hidden */
  19628. _preActivate(): InstancedMesh;
  19629. /** @hidden */
  19630. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19631. /** @hidden */
  19632. _postActivate(): void;
  19633. getWorldMatrix(): Matrix;
  19634. readonly isAnInstance: boolean;
  19635. /**
  19636. * Returns the current associated LOD AbstractMesh.
  19637. */
  19638. getLOD(camera: Camera): AbstractMesh;
  19639. /** @hidden */
  19640. _syncSubMeshes(): InstancedMesh;
  19641. /** @hidden */
  19642. _generatePointsArray(): boolean;
  19643. /**
  19644. * Creates a new InstancedMesh from the current mesh.
  19645. * - name (string) : the cloned mesh name
  19646. * - newParent (optional Node) : the optional Node to parent the clone to.
  19647. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19648. *
  19649. * Returns the clone.
  19650. */
  19651. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19652. /**
  19653. * Disposes the InstancedMesh.
  19654. * Returns nothing.
  19655. */
  19656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19657. }
  19658. module "babylonjs/Meshes/mesh" {
  19659. interface Mesh {
  19660. /**
  19661. * Register a custom buffer that will be instanced
  19662. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19663. * @param kind defines the buffer kind
  19664. * @param stride defines the stride in floats
  19665. */
  19666. registerInstancedBuffer(kind: string, stride: number): void;
  19667. /** @hidden */
  19668. _userInstancedBuffersStorage: {
  19669. data: {
  19670. [key: string]: Float32Array;
  19671. };
  19672. sizes: {
  19673. [key: string]: number;
  19674. };
  19675. vertexBuffers: {
  19676. [key: string]: Nullable<VertexBuffer>;
  19677. };
  19678. strides: {
  19679. [key: string]: number;
  19680. };
  19681. };
  19682. }
  19683. }
  19684. module "babylonjs/Meshes/abstractMesh" {
  19685. interface AbstractMesh {
  19686. /**
  19687. * Object used to store instanced buffers defined by user
  19688. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19689. */
  19690. instancedBuffers: {
  19691. [key: string]: any;
  19692. };
  19693. }
  19694. }
  19695. }
  19696. declare module "babylonjs/Materials/shaderMaterial" {
  19697. import { Scene } from "babylonjs/scene";
  19698. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19700. import { Mesh } from "babylonjs/Meshes/mesh";
  19701. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19703. import { Texture } from "babylonjs/Materials/Textures/texture";
  19704. import { Material } from "babylonjs/Materials/material";
  19705. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19706. /**
  19707. * Defines the options associated with the creation of a shader material.
  19708. */
  19709. export interface IShaderMaterialOptions {
  19710. /**
  19711. * Does the material work in alpha blend mode
  19712. */
  19713. needAlphaBlending: boolean;
  19714. /**
  19715. * Does the material work in alpha test mode
  19716. */
  19717. needAlphaTesting: boolean;
  19718. /**
  19719. * The list of attribute names used in the shader
  19720. */
  19721. attributes: string[];
  19722. /**
  19723. * The list of unifrom names used in the shader
  19724. */
  19725. uniforms: string[];
  19726. /**
  19727. * The list of UBO names used in the shader
  19728. */
  19729. uniformBuffers: string[];
  19730. /**
  19731. * The list of sampler names used in the shader
  19732. */
  19733. samplers: string[];
  19734. /**
  19735. * The list of defines used in the shader
  19736. */
  19737. defines: string[];
  19738. }
  19739. /**
  19740. * 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.
  19741. *
  19742. * This returned material effects how the mesh will look based on the code in the shaders.
  19743. *
  19744. * @see http://doc.babylonjs.com/how_to/shader_material
  19745. */
  19746. export class ShaderMaterial extends Material {
  19747. private _shaderPath;
  19748. private _options;
  19749. private _textures;
  19750. private _textureArrays;
  19751. private _floats;
  19752. private _ints;
  19753. private _floatsArrays;
  19754. private _colors3;
  19755. private _colors3Arrays;
  19756. private _colors4;
  19757. private _colors4Arrays;
  19758. private _vectors2;
  19759. private _vectors3;
  19760. private _vectors4;
  19761. private _matrices;
  19762. private _matrixArrays;
  19763. private _matrices3x3;
  19764. private _matrices2x2;
  19765. private _vectors2Arrays;
  19766. private _vectors3Arrays;
  19767. private _vectors4Arrays;
  19768. private _cachedWorldViewMatrix;
  19769. private _cachedWorldViewProjectionMatrix;
  19770. private _renderId;
  19771. private _multiview;
  19772. /**
  19773. * Instantiate a new shader material.
  19774. * 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.
  19775. * This returned material effects how the mesh will look based on the code in the shaders.
  19776. * @see http://doc.babylonjs.com/how_to/shader_material
  19777. * @param name Define the name of the material in the scene
  19778. * @param scene Define the scene the material belongs to
  19779. * @param shaderPath Defines the route to the shader code in one of three ways:
  19780. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19781. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19782. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19783. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19784. * @param options Define the options used to create the shader
  19785. */
  19786. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19787. /**
  19788. * Gets the shader path used to define the shader code
  19789. * It can be modified to trigger a new compilation
  19790. */
  19791. /**
  19792. * Sets the shader path used to define the shader code
  19793. * It can be modified to trigger a new compilation
  19794. */
  19795. shaderPath: any;
  19796. /**
  19797. * Gets the options used to compile the shader.
  19798. * They can be modified to trigger a new compilation
  19799. */
  19800. readonly options: IShaderMaterialOptions;
  19801. /**
  19802. * Gets the current class name of the material e.g. "ShaderMaterial"
  19803. * Mainly use in serialization.
  19804. * @returns the class name
  19805. */
  19806. getClassName(): string;
  19807. /**
  19808. * Specifies if the material will require alpha blending
  19809. * @returns a boolean specifying if alpha blending is needed
  19810. */
  19811. needAlphaBlending(): boolean;
  19812. /**
  19813. * Specifies if this material should be rendered in alpha test mode
  19814. * @returns a boolean specifying if an alpha test is needed.
  19815. */
  19816. needAlphaTesting(): boolean;
  19817. private _checkUniform;
  19818. /**
  19819. * Set a texture in the shader.
  19820. * @param name Define the name of the uniform samplers as defined in the shader
  19821. * @param texture Define the texture to bind to this sampler
  19822. * @return the material itself allowing "fluent" like uniform updates
  19823. */
  19824. setTexture(name: string, texture: Texture): ShaderMaterial;
  19825. /**
  19826. * Set a texture array in the shader.
  19827. * @param name Define the name of the uniform sampler array as defined in the shader
  19828. * @param textures Define the list of textures to bind to this sampler
  19829. * @return the material itself allowing "fluent" like uniform updates
  19830. */
  19831. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19832. /**
  19833. * Set a float in the shader.
  19834. * @param name Define the name of the uniform as defined in the shader
  19835. * @param value Define the value to give to the uniform
  19836. * @return the material itself allowing "fluent" like uniform updates
  19837. */
  19838. setFloat(name: string, value: number): ShaderMaterial;
  19839. /**
  19840. * Set a int in the shader.
  19841. * @param name Define the name of the uniform as defined in the shader
  19842. * @param value Define the value to give to the uniform
  19843. * @return the material itself allowing "fluent" like uniform updates
  19844. */
  19845. setInt(name: string, value: number): ShaderMaterial;
  19846. /**
  19847. * Set an array of floats in the shader.
  19848. * @param name Define the name of the uniform as defined in the shader
  19849. * @param value Define the value to give to the uniform
  19850. * @return the material itself allowing "fluent" like uniform updates
  19851. */
  19852. setFloats(name: string, value: number[]): ShaderMaterial;
  19853. /**
  19854. * Set a vec3 in the shader from a Color3.
  19855. * @param name Define the name of the uniform as defined in the shader
  19856. * @param value Define the value to give to the uniform
  19857. * @return the material itself allowing "fluent" like uniform updates
  19858. */
  19859. setColor3(name: string, value: Color3): ShaderMaterial;
  19860. /**
  19861. * Set a vec3 array in the shader from a Color3 array.
  19862. * @param name Define the name of the uniform as defined in the shader
  19863. * @param value Define the value to give to the uniform
  19864. * @return the material itself allowing "fluent" like uniform updates
  19865. */
  19866. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19867. /**
  19868. * Set a vec4 in the shader from a Color4.
  19869. * @param name Define the name of the uniform as defined in the shader
  19870. * @param value Define the value to give to the uniform
  19871. * @return the material itself allowing "fluent" like uniform updates
  19872. */
  19873. setColor4(name: string, value: Color4): ShaderMaterial;
  19874. /**
  19875. * Set a vec4 array in the shader from a Color4 array.
  19876. * @param name Define the name of the uniform as defined in the shader
  19877. * @param value Define the value to give to the uniform
  19878. * @return the material itself allowing "fluent" like uniform updates
  19879. */
  19880. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19881. /**
  19882. * Set a vec2 in the shader from a Vector2.
  19883. * @param name Define the name of the uniform as defined in the shader
  19884. * @param value Define the value to give to the uniform
  19885. * @return the material itself allowing "fluent" like uniform updates
  19886. */
  19887. setVector2(name: string, value: Vector2): ShaderMaterial;
  19888. /**
  19889. * Set a vec3 in the shader from a Vector3.
  19890. * @param name Define the name of the uniform as defined in the shader
  19891. * @param value Define the value to give to the uniform
  19892. * @return the material itself allowing "fluent" like uniform updates
  19893. */
  19894. setVector3(name: string, value: Vector3): ShaderMaterial;
  19895. /**
  19896. * Set a vec4 in the shader from a Vector4.
  19897. * @param name Define the name of the uniform as defined in the shader
  19898. * @param value Define the value to give to the uniform
  19899. * @return the material itself allowing "fluent" like uniform updates
  19900. */
  19901. setVector4(name: string, value: Vector4): ShaderMaterial;
  19902. /**
  19903. * Set a mat4 in the shader from a Matrix.
  19904. * @param name Define the name of the uniform as defined in the shader
  19905. * @param value Define the value to give to the uniform
  19906. * @return the material itself allowing "fluent" like uniform updates
  19907. */
  19908. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19909. /**
  19910. * Set a float32Array in the shader from a matrix array.
  19911. * @param name Define the name of the uniform as defined in the shader
  19912. * @param value Define the value to give to the uniform
  19913. * @return the material itself allowing "fluent" like uniform updates
  19914. */
  19915. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19916. /**
  19917. * Set a mat3 in the shader from a Float32Array.
  19918. * @param name Define the name of the uniform as defined in the shader
  19919. * @param value Define the value to give to the uniform
  19920. * @return the material itself allowing "fluent" like uniform updates
  19921. */
  19922. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19923. /**
  19924. * Set a mat2 in the shader from a Float32Array.
  19925. * @param name Define the name of the uniform as defined in the shader
  19926. * @param value Define the value to give to the uniform
  19927. * @return the material itself allowing "fluent" like uniform updates
  19928. */
  19929. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19930. /**
  19931. * Set a vec2 array in the shader from a number array.
  19932. * @param name Define the name of the uniform as defined in the shader
  19933. * @param value Define the value to give to the uniform
  19934. * @return the material itself allowing "fluent" like uniform updates
  19935. */
  19936. setArray2(name: string, value: number[]): ShaderMaterial;
  19937. /**
  19938. * Set a vec3 array in the shader from a number array.
  19939. * @param name Define the name of the uniform as defined in the shader
  19940. * @param value Define the value to give to the uniform
  19941. * @return the material itself allowing "fluent" like uniform updates
  19942. */
  19943. setArray3(name: string, value: number[]): ShaderMaterial;
  19944. /**
  19945. * Set a vec4 array in the shader from a number array.
  19946. * @param name Define the name of the uniform as defined in the shader
  19947. * @param value Define the value to give to the uniform
  19948. * @return the material itself allowing "fluent" like uniform updates
  19949. */
  19950. setArray4(name: string, value: number[]): ShaderMaterial;
  19951. private _checkCache;
  19952. /**
  19953. * Specifies that the submesh is ready to be used
  19954. * @param mesh defines the mesh to check
  19955. * @param subMesh defines which submesh to check
  19956. * @param useInstances specifies that instances should be used
  19957. * @returns a boolean indicating that the submesh is ready or not
  19958. */
  19959. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19960. /**
  19961. * Checks if the material is ready to render the requested mesh
  19962. * @param mesh Define the mesh to render
  19963. * @param useInstances Define whether or not the material is used with instances
  19964. * @returns true if ready, otherwise false
  19965. */
  19966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19967. /**
  19968. * Binds the world matrix to the material
  19969. * @param world defines the world transformation matrix
  19970. */
  19971. bindOnlyWorldMatrix(world: Matrix): void;
  19972. /**
  19973. * Binds the material to the mesh
  19974. * @param world defines the world transformation matrix
  19975. * @param mesh defines the mesh to bind the material to
  19976. */
  19977. bind(world: Matrix, mesh?: Mesh): void;
  19978. /**
  19979. * Gets the active textures from the material
  19980. * @returns an array of textures
  19981. */
  19982. getActiveTextures(): BaseTexture[];
  19983. /**
  19984. * Specifies if the material uses a texture
  19985. * @param texture defines the texture to check against the material
  19986. * @returns a boolean specifying if the material uses the texture
  19987. */
  19988. hasTexture(texture: BaseTexture): boolean;
  19989. /**
  19990. * Makes a duplicate of the material, and gives it a new name
  19991. * @param name defines the new name for the duplicated material
  19992. * @returns the cloned material
  19993. */
  19994. clone(name: string): ShaderMaterial;
  19995. /**
  19996. * Disposes the material
  19997. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19998. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19999. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20000. */
  20001. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20002. /**
  20003. * Serializes this material in a JSON representation
  20004. * @returns the serialized material object
  20005. */
  20006. serialize(): any;
  20007. /**
  20008. * Creates a shader material from parsed shader material data
  20009. * @param source defines the JSON represnetation of the material
  20010. * @param scene defines the hosting scene
  20011. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20012. * @returns a new material
  20013. */
  20014. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20015. }
  20016. }
  20017. declare module "babylonjs/Shaders/color.fragment" {
  20018. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20019. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20020. /** @hidden */
  20021. export var colorPixelShader: {
  20022. name: string;
  20023. shader: string;
  20024. };
  20025. }
  20026. declare module "babylonjs/Shaders/color.vertex" {
  20027. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20028. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20029. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20030. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20031. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20032. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20033. /** @hidden */
  20034. export var colorVertexShader: {
  20035. name: string;
  20036. shader: string;
  20037. };
  20038. }
  20039. declare module "babylonjs/Meshes/linesMesh" {
  20040. import { Nullable } from "babylonjs/types";
  20041. import { Scene } from "babylonjs/scene";
  20042. import { Color3 } from "babylonjs/Maths/math.color";
  20043. import { Node } from "babylonjs/node";
  20044. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20045. import { Mesh } from "babylonjs/Meshes/mesh";
  20046. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20047. import { Effect } from "babylonjs/Materials/effect";
  20048. import { Material } from "babylonjs/Materials/material";
  20049. import "babylonjs/Shaders/color.fragment";
  20050. import "babylonjs/Shaders/color.vertex";
  20051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20052. /**
  20053. * Line mesh
  20054. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20055. */
  20056. export class LinesMesh extends Mesh {
  20057. /**
  20058. * If vertex color should be applied to the mesh
  20059. */
  20060. readonly useVertexColor?: boolean | undefined;
  20061. /**
  20062. * If vertex alpha should be applied to the mesh
  20063. */
  20064. readonly useVertexAlpha?: boolean | undefined;
  20065. /**
  20066. * Color of the line (Default: White)
  20067. */
  20068. color: Color3;
  20069. /**
  20070. * Alpha of the line (Default: 1)
  20071. */
  20072. alpha: number;
  20073. /**
  20074. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20075. * This margin is expressed in world space coordinates, so its value may vary.
  20076. * Default value is 0.1
  20077. */
  20078. intersectionThreshold: number;
  20079. private _colorShader;
  20080. private color4;
  20081. /**
  20082. * Creates a new LinesMesh
  20083. * @param name defines the name
  20084. * @param scene defines the hosting scene
  20085. * @param parent defines the parent mesh if any
  20086. * @param source defines the optional source LinesMesh used to clone data from
  20087. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20088. * When false, achieved by calling a clone(), also passing False.
  20089. * This will make creation of children, recursive.
  20090. * @param useVertexColor defines if this LinesMesh supports vertex color
  20091. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20092. */
  20093. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20094. /**
  20095. * If vertex color should be applied to the mesh
  20096. */
  20097. useVertexColor?: boolean | undefined,
  20098. /**
  20099. * If vertex alpha should be applied to the mesh
  20100. */
  20101. useVertexAlpha?: boolean | undefined);
  20102. private _addClipPlaneDefine;
  20103. private _removeClipPlaneDefine;
  20104. isReady(): boolean;
  20105. /**
  20106. * Returns the string "LineMesh"
  20107. */
  20108. getClassName(): string;
  20109. /**
  20110. * @hidden
  20111. */
  20112. /**
  20113. * @hidden
  20114. */
  20115. material: Material;
  20116. /**
  20117. * @hidden
  20118. */
  20119. readonly checkCollisions: boolean;
  20120. /** @hidden */
  20121. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20122. /** @hidden */
  20123. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20124. /**
  20125. * Disposes of the line mesh
  20126. * @param doNotRecurse If children should be disposed
  20127. */
  20128. dispose(doNotRecurse?: boolean): void;
  20129. /**
  20130. * Returns a new LineMesh object cloned from the current one.
  20131. */
  20132. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20133. /**
  20134. * Creates a new InstancedLinesMesh object from the mesh model.
  20135. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20136. * @param name defines the name of the new instance
  20137. * @returns a new InstancedLinesMesh
  20138. */
  20139. createInstance(name: string): InstancedLinesMesh;
  20140. }
  20141. /**
  20142. * Creates an instance based on a source LinesMesh
  20143. */
  20144. export class InstancedLinesMesh extends InstancedMesh {
  20145. /**
  20146. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20147. * This margin is expressed in world space coordinates, so its value may vary.
  20148. * Initilized with the intersectionThreshold value of the source LinesMesh
  20149. */
  20150. intersectionThreshold: number;
  20151. constructor(name: string, source: LinesMesh);
  20152. /**
  20153. * Returns the string "InstancedLinesMesh".
  20154. */
  20155. getClassName(): string;
  20156. }
  20157. }
  20158. declare module "babylonjs/Shaders/line.fragment" {
  20159. /** @hidden */
  20160. export var linePixelShader: {
  20161. name: string;
  20162. shader: string;
  20163. };
  20164. }
  20165. declare module "babylonjs/Shaders/line.vertex" {
  20166. /** @hidden */
  20167. export var lineVertexShader: {
  20168. name: string;
  20169. shader: string;
  20170. };
  20171. }
  20172. declare module "babylonjs/Rendering/edgesRenderer" {
  20173. import { Nullable } from "babylonjs/types";
  20174. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20176. import { Vector3 } from "babylonjs/Maths/math.vector";
  20177. import { IDisposable } from "babylonjs/scene";
  20178. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20179. import "babylonjs/Shaders/line.fragment";
  20180. import "babylonjs/Shaders/line.vertex";
  20181. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20182. module "babylonjs/Meshes/abstractMesh" {
  20183. interface AbstractMesh {
  20184. /**
  20185. * Gets the edgesRenderer associated with the mesh
  20186. */
  20187. edgesRenderer: Nullable<EdgesRenderer>;
  20188. }
  20189. }
  20190. module "babylonjs/Meshes/linesMesh" {
  20191. interface LinesMesh {
  20192. /**
  20193. * Enables the edge rendering mode on the mesh.
  20194. * This mode makes the mesh edges visible
  20195. * @param epsilon defines the maximal distance between two angles to detect a face
  20196. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20197. * @returns the currentAbstractMesh
  20198. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20199. */
  20200. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20201. }
  20202. }
  20203. module "babylonjs/Meshes/linesMesh" {
  20204. interface InstancedLinesMesh {
  20205. /**
  20206. * Enables the edge rendering mode on the mesh.
  20207. * This mode makes the mesh edges visible
  20208. * @param epsilon defines the maximal distance between two angles to detect a face
  20209. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20210. * @returns the current InstancedLinesMesh
  20211. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20212. */
  20213. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20214. }
  20215. }
  20216. /**
  20217. * Defines the minimum contract an Edges renderer should follow.
  20218. */
  20219. export interface IEdgesRenderer extends IDisposable {
  20220. /**
  20221. * Gets or sets a boolean indicating if the edgesRenderer is active
  20222. */
  20223. isEnabled: boolean;
  20224. /**
  20225. * Renders the edges of the attached mesh,
  20226. */
  20227. render(): void;
  20228. /**
  20229. * Checks wether or not the edges renderer is ready to render.
  20230. * @return true if ready, otherwise false.
  20231. */
  20232. isReady(): boolean;
  20233. }
  20234. /**
  20235. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20236. */
  20237. export class EdgesRenderer implements IEdgesRenderer {
  20238. /**
  20239. * Define the size of the edges with an orthographic camera
  20240. */
  20241. edgesWidthScalerForOrthographic: number;
  20242. /**
  20243. * Define the size of the edges with a perspective camera
  20244. */
  20245. edgesWidthScalerForPerspective: number;
  20246. protected _source: AbstractMesh;
  20247. protected _linesPositions: number[];
  20248. protected _linesNormals: number[];
  20249. protected _linesIndices: number[];
  20250. protected _epsilon: number;
  20251. protected _indicesCount: number;
  20252. protected _lineShader: ShaderMaterial;
  20253. protected _ib: DataBuffer;
  20254. protected _buffers: {
  20255. [key: string]: Nullable<VertexBuffer>;
  20256. };
  20257. protected _checkVerticesInsteadOfIndices: boolean;
  20258. private _meshRebuildObserver;
  20259. private _meshDisposeObserver;
  20260. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20261. isEnabled: boolean;
  20262. /**
  20263. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20264. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20265. * @param source Mesh used to create edges
  20266. * @param epsilon sum of angles in adjacency to check for edge
  20267. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20268. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20269. */
  20270. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20271. protected _prepareRessources(): void;
  20272. /** @hidden */
  20273. _rebuild(): void;
  20274. /**
  20275. * Releases the required resources for the edges renderer
  20276. */
  20277. dispose(): void;
  20278. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20279. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20280. /**
  20281. * Checks if the pair of p0 and p1 is en edge
  20282. * @param faceIndex
  20283. * @param edge
  20284. * @param faceNormals
  20285. * @param p0
  20286. * @param p1
  20287. * @private
  20288. */
  20289. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20290. /**
  20291. * push line into the position, normal and index buffer
  20292. * @protected
  20293. */
  20294. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20295. /**
  20296. * Generates lines edges from adjacencjes
  20297. * @private
  20298. */
  20299. _generateEdgesLines(): void;
  20300. /**
  20301. * Checks wether or not the edges renderer is ready to render.
  20302. * @return true if ready, otherwise false.
  20303. */
  20304. isReady(): boolean;
  20305. /**
  20306. * Renders the edges of the attached mesh,
  20307. */
  20308. render(): void;
  20309. }
  20310. /**
  20311. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20312. */
  20313. export class LineEdgesRenderer extends EdgesRenderer {
  20314. /**
  20315. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20316. * @param source LineMesh used to generate edges
  20317. * @param epsilon not important (specified angle for edge detection)
  20318. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20319. */
  20320. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20321. /**
  20322. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20323. */
  20324. _generateEdgesLines(): void;
  20325. }
  20326. }
  20327. declare module "babylonjs/Rendering/renderingGroup" {
  20328. import { SmartArray } from "babylonjs/Misc/smartArray";
  20329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20331. import { Nullable } from "babylonjs/types";
  20332. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20333. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20334. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20335. import { Material } from "babylonjs/Materials/material";
  20336. import { Scene } from "babylonjs/scene";
  20337. /**
  20338. * This represents the object necessary to create a rendering group.
  20339. * This is exclusively used and created by the rendering manager.
  20340. * To modify the behavior, you use the available helpers in your scene or meshes.
  20341. * @hidden
  20342. */
  20343. export class RenderingGroup {
  20344. index: number;
  20345. private static _zeroVector;
  20346. private _scene;
  20347. private _opaqueSubMeshes;
  20348. private _transparentSubMeshes;
  20349. private _alphaTestSubMeshes;
  20350. private _depthOnlySubMeshes;
  20351. private _particleSystems;
  20352. private _spriteManagers;
  20353. private _opaqueSortCompareFn;
  20354. private _alphaTestSortCompareFn;
  20355. private _transparentSortCompareFn;
  20356. private _renderOpaque;
  20357. private _renderAlphaTest;
  20358. private _renderTransparent;
  20359. /** @hidden */
  20360. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20361. onBeforeTransparentRendering: () => void;
  20362. /**
  20363. * Set the opaque sort comparison function.
  20364. * If null the sub meshes will be render in the order they were created
  20365. */
  20366. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20367. /**
  20368. * Set the alpha test sort comparison function.
  20369. * If null the sub meshes will be render in the order they were created
  20370. */
  20371. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20372. /**
  20373. * Set the transparent sort comparison function.
  20374. * If null the sub meshes will be render in the order they were created
  20375. */
  20376. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20377. /**
  20378. * Creates a new rendering group.
  20379. * @param index The rendering group index
  20380. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20381. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20382. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20383. */
  20384. 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>);
  20385. /**
  20386. * Render all the sub meshes contained in the group.
  20387. * @param customRenderFunction Used to override the default render behaviour of the group.
  20388. * @returns true if rendered some submeshes.
  20389. */
  20390. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20391. /**
  20392. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20393. * @param subMeshes The submeshes to render
  20394. */
  20395. private renderOpaqueSorted;
  20396. /**
  20397. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20398. * @param subMeshes The submeshes to render
  20399. */
  20400. private renderAlphaTestSorted;
  20401. /**
  20402. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20403. * @param subMeshes The submeshes to render
  20404. */
  20405. private renderTransparentSorted;
  20406. /**
  20407. * Renders the submeshes in a specified order.
  20408. * @param subMeshes The submeshes to sort before render
  20409. * @param sortCompareFn The comparison function use to sort
  20410. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20411. * @param transparent Specifies to activate blending if true
  20412. */
  20413. private static renderSorted;
  20414. /**
  20415. * Renders the submeshes in the order they were dispatched (no sort applied).
  20416. * @param subMeshes The submeshes to render
  20417. */
  20418. private static renderUnsorted;
  20419. /**
  20420. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20421. * are rendered back to front if in the same alpha index.
  20422. *
  20423. * @param a The first submesh
  20424. * @param b The second submesh
  20425. * @returns The result of the comparison
  20426. */
  20427. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20428. /**
  20429. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20430. * are rendered back to front.
  20431. *
  20432. * @param a The first submesh
  20433. * @param b The second submesh
  20434. * @returns The result of the comparison
  20435. */
  20436. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20437. /**
  20438. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20439. * are rendered front to back (prevent overdraw).
  20440. *
  20441. * @param a The first submesh
  20442. * @param b The second submesh
  20443. * @returns The result of the comparison
  20444. */
  20445. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20446. /**
  20447. * Resets the different lists of submeshes to prepare a new frame.
  20448. */
  20449. prepare(): void;
  20450. dispose(): void;
  20451. /**
  20452. * Inserts the submesh in its correct queue depending on its material.
  20453. * @param subMesh The submesh to dispatch
  20454. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20455. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20456. */
  20457. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20458. dispatchSprites(spriteManager: ISpriteManager): void;
  20459. dispatchParticles(particleSystem: IParticleSystem): void;
  20460. private _renderParticles;
  20461. private _renderSprites;
  20462. }
  20463. }
  20464. declare module "babylonjs/Rendering/renderingManager" {
  20465. import { Nullable } from "babylonjs/types";
  20466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20467. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20468. import { SmartArray } from "babylonjs/Misc/smartArray";
  20469. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20470. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20471. import { Material } from "babylonjs/Materials/material";
  20472. import { Scene } from "babylonjs/scene";
  20473. import { Camera } from "babylonjs/Cameras/camera";
  20474. /**
  20475. * Interface describing the different options available in the rendering manager
  20476. * regarding Auto Clear between groups.
  20477. */
  20478. export interface IRenderingManagerAutoClearSetup {
  20479. /**
  20480. * Defines whether or not autoclear is enable.
  20481. */
  20482. autoClear: boolean;
  20483. /**
  20484. * Defines whether or not to autoclear the depth buffer.
  20485. */
  20486. depth: boolean;
  20487. /**
  20488. * Defines whether or not to autoclear the stencil buffer.
  20489. */
  20490. stencil: boolean;
  20491. }
  20492. /**
  20493. * This class is used by the onRenderingGroupObservable
  20494. */
  20495. export class RenderingGroupInfo {
  20496. /**
  20497. * The Scene that being rendered
  20498. */
  20499. scene: Scene;
  20500. /**
  20501. * The camera currently used for the rendering pass
  20502. */
  20503. camera: Nullable<Camera>;
  20504. /**
  20505. * The ID of the renderingGroup being processed
  20506. */
  20507. renderingGroupId: number;
  20508. }
  20509. /**
  20510. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20511. * It is enable to manage the different groups as well as the different necessary sort functions.
  20512. * This should not be used directly aside of the few static configurations
  20513. */
  20514. export class RenderingManager {
  20515. /**
  20516. * The max id used for rendering groups (not included)
  20517. */
  20518. static MAX_RENDERINGGROUPS: number;
  20519. /**
  20520. * The min id used for rendering groups (included)
  20521. */
  20522. static MIN_RENDERINGGROUPS: number;
  20523. /**
  20524. * Used to globally prevent autoclearing scenes.
  20525. */
  20526. static AUTOCLEAR: boolean;
  20527. /**
  20528. * @hidden
  20529. */
  20530. _useSceneAutoClearSetup: boolean;
  20531. private _scene;
  20532. private _renderingGroups;
  20533. private _depthStencilBufferAlreadyCleaned;
  20534. private _autoClearDepthStencil;
  20535. private _customOpaqueSortCompareFn;
  20536. private _customAlphaTestSortCompareFn;
  20537. private _customTransparentSortCompareFn;
  20538. private _renderingGroupInfo;
  20539. /**
  20540. * Instantiates a new rendering group for a particular scene
  20541. * @param scene Defines the scene the groups belongs to
  20542. */
  20543. constructor(scene: Scene);
  20544. private _clearDepthStencilBuffer;
  20545. /**
  20546. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20547. * @hidden
  20548. */
  20549. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20550. /**
  20551. * Resets the different information of the group to prepare a new frame
  20552. * @hidden
  20553. */
  20554. reset(): void;
  20555. /**
  20556. * Dispose and release the group and its associated resources.
  20557. * @hidden
  20558. */
  20559. dispose(): void;
  20560. /**
  20561. * Clear the info related to rendering groups preventing retention points during dispose.
  20562. */
  20563. freeRenderingGroups(): void;
  20564. private _prepareRenderingGroup;
  20565. /**
  20566. * Add a sprite manager to the rendering manager in order to render it this frame.
  20567. * @param spriteManager Define the sprite manager to render
  20568. */
  20569. dispatchSprites(spriteManager: ISpriteManager): void;
  20570. /**
  20571. * Add a particle system to the rendering manager in order to render it this frame.
  20572. * @param particleSystem Define the particle system to render
  20573. */
  20574. dispatchParticles(particleSystem: IParticleSystem): void;
  20575. /**
  20576. * Add a submesh to the manager in order to render it this frame
  20577. * @param subMesh The submesh to dispatch
  20578. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20579. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20580. */
  20581. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20582. /**
  20583. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20584. * This allowed control for front to back rendering or reversly depending of the special needs.
  20585. *
  20586. * @param renderingGroupId The rendering group id corresponding to its index
  20587. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20588. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20589. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20590. */
  20591. 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;
  20592. /**
  20593. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20594. *
  20595. * @param renderingGroupId The rendering group id corresponding to its index
  20596. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20597. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20598. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20599. */
  20600. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20601. /**
  20602. * Gets the current auto clear configuration for one rendering group of the rendering
  20603. * manager.
  20604. * @param index the rendering group index to get the information for
  20605. * @returns The auto clear setup for the requested rendering group
  20606. */
  20607. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20608. }
  20609. }
  20610. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20611. import { Observable } from "babylonjs/Misc/observable";
  20612. import { SmartArray } from "babylonjs/Misc/smartArray";
  20613. import { Nullable } from "babylonjs/types";
  20614. import { Camera } from "babylonjs/Cameras/camera";
  20615. import { Scene } from "babylonjs/scene";
  20616. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20617. import { Color4 } from "babylonjs/Maths/math.color";
  20618. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20620. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20622. import { Texture } from "babylonjs/Materials/Textures/texture";
  20623. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20624. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20625. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20626. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20627. import { Engine } from "babylonjs/Engines/engine";
  20628. /**
  20629. * This Helps creating a texture that will be created from a camera in your scene.
  20630. * It is basically a dynamic texture that could be used to create special effects for instance.
  20631. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20632. */
  20633. export class RenderTargetTexture extends Texture {
  20634. isCube: boolean;
  20635. /**
  20636. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20637. */
  20638. static readonly REFRESHRATE_RENDER_ONCE: number;
  20639. /**
  20640. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20641. */
  20642. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20643. /**
  20644. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20645. * the central point of your effect and can save a lot of performances.
  20646. */
  20647. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20648. /**
  20649. * Use this predicate to dynamically define the list of mesh you want to render.
  20650. * If set, the renderList property will be overwritten.
  20651. */
  20652. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20653. private _renderList;
  20654. /**
  20655. * Use this list to define the list of mesh you want to render.
  20656. */
  20657. renderList: Nullable<Array<AbstractMesh>>;
  20658. private _hookArray;
  20659. /**
  20660. * Define if particles should be rendered in your texture.
  20661. */
  20662. renderParticles: boolean;
  20663. /**
  20664. * Define if sprites should be rendered in your texture.
  20665. */
  20666. renderSprites: boolean;
  20667. /**
  20668. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20669. */
  20670. coordinatesMode: number;
  20671. /**
  20672. * Define the camera used to render the texture.
  20673. */
  20674. activeCamera: Nullable<Camera>;
  20675. /**
  20676. * Override the render function of the texture with your own one.
  20677. */
  20678. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20679. /**
  20680. * Define if camera post processes should be use while rendering the texture.
  20681. */
  20682. useCameraPostProcesses: boolean;
  20683. /**
  20684. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20685. */
  20686. ignoreCameraViewport: boolean;
  20687. private _postProcessManager;
  20688. private _postProcesses;
  20689. private _resizeObserver;
  20690. /**
  20691. * An event triggered when the texture is unbind.
  20692. */
  20693. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20694. /**
  20695. * An event triggered when the texture is unbind.
  20696. */
  20697. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20698. private _onAfterUnbindObserver;
  20699. /**
  20700. * Set a after unbind callback in the texture.
  20701. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20702. */
  20703. onAfterUnbind: () => void;
  20704. /**
  20705. * An event triggered before rendering the texture
  20706. */
  20707. onBeforeRenderObservable: Observable<number>;
  20708. private _onBeforeRenderObserver;
  20709. /**
  20710. * Set a before render callback in the texture.
  20711. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20712. */
  20713. onBeforeRender: (faceIndex: number) => void;
  20714. /**
  20715. * An event triggered after rendering the texture
  20716. */
  20717. onAfterRenderObservable: Observable<number>;
  20718. private _onAfterRenderObserver;
  20719. /**
  20720. * Set a after render callback in the texture.
  20721. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20722. */
  20723. onAfterRender: (faceIndex: number) => void;
  20724. /**
  20725. * An event triggered after the texture clear
  20726. */
  20727. onClearObservable: Observable<Engine>;
  20728. private _onClearObserver;
  20729. /**
  20730. * Set a clear callback in the texture.
  20731. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20732. */
  20733. onClear: (Engine: Engine) => void;
  20734. /**
  20735. * An event triggered when the texture is resized.
  20736. */
  20737. onResizeObservable: Observable<RenderTargetTexture>;
  20738. /**
  20739. * Define the clear color of the Render Target if it should be different from the scene.
  20740. */
  20741. clearColor: Color4;
  20742. protected _size: number | {
  20743. width: number;
  20744. height: number;
  20745. };
  20746. protected _initialSizeParameter: number | {
  20747. width: number;
  20748. height: number;
  20749. } | {
  20750. ratio: number;
  20751. };
  20752. protected _sizeRatio: Nullable<number>;
  20753. /** @hidden */
  20754. _generateMipMaps: boolean;
  20755. protected _renderingManager: RenderingManager;
  20756. /** @hidden */
  20757. _waitingRenderList: string[];
  20758. protected _doNotChangeAspectRatio: boolean;
  20759. protected _currentRefreshId: number;
  20760. protected _refreshRate: number;
  20761. protected _textureMatrix: Matrix;
  20762. protected _samples: number;
  20763. protected _renderTargetOptions: RenderTargetCreationOptions;
  20764. /**
  20765. * Gets render target creation options that were used.
  20766. */
  20767. readonly renderTargetOptions: RenderTargetCreationOptions;
  20768. protected _engine: Engine;
  20769. protected _onRatioRescale(): void;
  20770. /**
  20771. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20772. * It must define where the camera used to render the texture is set
  20773. */
  20774. boundingBoxPosition: Vector3;
  20775. private _boundingBoxSize;
  20776. /**
  20777. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20778. * When defined, the cubemap will switch to local mode
  20779. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20780. * @example https://www.babylonjs-playground.com/#RNASML
  20781. */
  20782. boundingBoxSize: Vector3;
  20783. /**
  20784. * In case the RTT has been created with a depth texture, get the associated
  20785. * depth texture.
  20786. * Otherwise, return null.
  20787. */
  20788. depthStencilTexture: Nullable<InternalTexture>;
  20789. /**
  20790. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20791. * or used a shadow, depth texture...
  20792. * @param name The friendly name of the texture
  20793. * @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)
  20794. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20795. * @param generateMipMaps True if mip maps need to be generated after render.
  20796. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20797. * @param type The type of the buffer in the RTT (int, half float, float...)
  20798. * @param isCube True if a cube texture needs to be created
  20799. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20800. * @param generateDepthBuffer True to generate a depth buffer
  20801. * @param generateStencilBuffer True to generate a stencil buffer
  20802. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20803. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20804. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20805. */
  20806. constructor(name: string, size: number | {
  20807. width: number;
  20808. height: number;
  20809. } | {
  20810. ratio: number;
  20811. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20812. /**
  20813. * Creates a depth stencil texture.
  20814. * This is only available in WebGL 2 or with the depth texture extension available.
  20815. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20816. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20817. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20818. */
  20819. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20820. private _processSizeParameter;
  20821. /**
  20822. * Define the number of samples to use in case of MSAA.
  20823. * It defaults to one meaning no MSAA has been enabled.
  20824. */
  20825. samples: number;
  20826. /**
  20827. * Resets the refresh counter of the texture and start bak from scratch.
  20828. * Could be useful to regenerate the texture if it is setup to render only once.
  20829. */
  20830. resetRefreshCounter(): void;
  20831. /**
  20832. * Define the refresh rate of the texture or the rendering frequency.
  20833. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20834. */
  20835. refreshRate: number;
  20836. /**
  20837. * Adds a post process to the render target rendering passes.
  20838. * @param postProcess define the post process to add
  20839. */
  20840. addPostProcess(postProcess: PostProcess): void;
  20841. /**
  20842. * Clear all the post processes attached to the render target
  20843. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20844. */
  20845. clearPostProcesses(dispose?: boolean): void;
  20846. /**
  20847. * Remove one of the post process from the list of attached post processes to the texture
  20848. * @param postProcess define the post process to remove from the list
  20849. */
  20850. removePostProcess(postProcess: PostProcess): void;
  20851. /** @hidden */
  20852. _shouldRender(): boolean;
  20853. /**
  20854. * Gets the actual render size of the texture.
  20855. * @returns the width of the render size
  20856. */
  20857. getRenderSize(): number;
  20858. /**
  20859. * Gets the actual render width of the texture.
  20860. * @returns the width of the render size
  20861. */
  20862. getRenderWidth(): number;
  20863. /**
  20864. * Gets the actual render height of the texture.
  20865. * @returns the height of the render size
  20866. */
  20867. getRenderHeight(): number;
  20868. /**
  20869. * Get if the texture can be rescaled or not.
  20870. */
  20871. readonly canRescale: boolean;
  20872. /**
  20873. * Resize the texture using a ratio.
  20874. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20875. */
  20876. scale(ratio: number): void;
  20877. /**
  20878. * Get the texture reflection matrix used to rotate/transform the reflection.
  20879. * @returns the reflection matrix
  20880. */
  20881. getReflectionTextureMatrix(): Matrix;
  20882. /**
  20883. * Resize the texture to a new desired size.
  20884. * Be carrefull as it will recreate all the data in the new texture.
  20885. * @param size Define the new size. It can be:
  20886. * - a number for squared texture,
  20887. * - an object containing { width: number, height: number }
  20888. * - or an object containing a ratio { ratio: number }
  20889. */
  20890. resize(size: number | {
  20891. width: number;
  20892. height: number;
  20893. } | {
  20894. ratio: number;
  20895. }): void;
  20896. /**
  20897. * Renders all the objects from the render list into the texture.
  20898. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20899. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20900. */
  20901. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20902. private _bestReflectionRenderTargetDimension;
  20903. /**
  20904. * @hidden
  20905. * @param faceIndex face index to bind to if this is a cubetexture
  20906. */
  20907. _bindFrameBuffer(faceIndex?: number): void;
  20908. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20909. private renderToTarget;
  20910. /**
  20911. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20912. * This allowed control for front to back rendering or reversly depending of the special needs.
  20913. *
  20914. * @param renderingGroupId The rendering group id corresponding to its index
  20915. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20916. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20917. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20918. */
  20919. 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;
  20920. /**
  20921. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20922. *
  20923. * @param renderingGroupId The rendering group id corresponding to its index
  20924. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20925. */
  20926. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20927. /**
  20928. * Clones the texture.
  20929. * @returns the cloned texture
  20930. */
  20931. clone(): RenderTargetTexture;
  20932. /**
  20933. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20934. * @returns The JSON representation of the texture
  20935. */
  20936. serialize(): any;
  20937. /**
  20938. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20939. */
  20940. disposeFramebufferObjects(): void;
  20941. /**
  20942. * Dispose the texture and release its associated resources.
  20943. */
  20944. dispose(): void;
  20945. /** @hidden */
  20946. _rebuild(): void;
  20947. /**
  20948. * Clear the info related to rendering groups preventing retention point in material dispose.
  20949. */
  20950. freeRenderingGroups(): void;
  20951. /**
  20952. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20953. * @returns the view count
  20954. */
  20955. getViewCount(): number;
  20956. }
  20957. }
  20958. declare module "babylonjs/Materials/material" {
  20959. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20960. import { SmartArray } from "babylonjs/Misc/smartArray";
  20961. import { Observable } from "babylonjs/Misc/observable";
  20962. import { Nullable } from "babylonjs/types";
  20963. import { Scene } from "babylonjs/scene";
  20964. import { Matrix } from "babylonjs/Maths/math.vector";
  20965. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20967. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20968. import { Effect } from "babylonjs/Materials/effect";
  20969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20970. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20971. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20972. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20973. import { Mesh } from "babylonjs/Meshes/mesh";
  20974. import { Animation } from "babylonjs/Animations/animation";
  20975. /**
  20976. * Options for compiling materials.
  20977. */
  20978. export interface IMaterialCompilationOptions {
  20979. /**
  20980. * Defines whether clip planes are enabled.
  20981. */
  20982. clipPlane: boolean;
  20983. /**
  20984. * Defines whether instances are enabled.
  20985. */
  20986. useInstances: boolean;
  20987. }
  20988. /**
  20989. * Base class for the main features of a material in Babylon.js
  20990. */
  20991. export class Material implements IAnimatable {
  20992. /**
  20993. * Returns the triangle fill mode
  20994. */
  20995. static readonly TriangleFillMode: number;
  20996. /**
  20997. * Returns the wireframe mode
  20998. */
  20999. static readonly WireFrameFillMode: number;
  21000. /**
  21001. * Returns the point fill mode
  21002. */
  21003. static readonly PointFillMode: number;
  21004. /**
  21005. * Returns the point list draw mode
  21006. */
  21007. static readonly PointListDrawMode: number;
  21008. /**
  21009. * Returns the line list draw mode
  21010. */
  21011. static readonly LineListDrawMode: number;
  21012. /**
  21013. * Returns the line loop draw mode
  21014. */
  21015. static readonly LineLoopDrawMode: number;
  21016. /**
  21017. * Returns the line strip draw mode
  21018. */
  21019. static readonly LineStripDrawMode: number;
  21020. /**
  21021. * Returns the triangle strip draw mode
  21022. */
  21023. static readonly TriangleStripDrawMode: number;
  21024. /**
  21025. * Returns the triangle fan draw mode
  21026. */
  21027. static readonly TriangleFanDrawMode: number;
  21028. /**
  21029. * Stores the clock-wise side orientation
  21030. */
  21031. static readonly ClockWiseSideOrientation: number;
  21032. /**
  21033. * Stores the counter clock-wise side orientation
  21034. */
  21035. static readonly CounterClockWiseSideOrientation: number;
  21036. /**
  21037. * The dirty texture flag value
  21038. */
  21039. static readonly TextureDirtyFlag: number;
  21040. /**
  21041. * The dirty light flag value
  21042. */
  21043. static readonly LightDirtyFlag: number;
  21044. /**
  21045. * The dirty fresnel flag value
  21046. */
  21047. static readonly FresnelDirtyFlag: number;
  21048. /**
  21049. * The dirty attribute flag value
  21050. */
  21051. static readonly AttributesDirtyFlag: number;
  21052. /**
  21053. * The dirty misc flag value
  21054. */
  21055. static readonly MiscDirtyFlag: number;
  21056. /**
  21057. * The all dirty flag value
  21058. */
  21059. static readonly AllDirtyFlag: number;
  21060. /**
  21061. * The ID of the material
  21062. */
  21063. id: string;
  21064. /**
  21065. * Gets or sets the unique id of the material
  21066. */
  21067. uniqueId: number;
  21068. /**
  21069. * The name of the material
  21070. */
  21071. name: string;
  21072. /**
  21073. * Gets or sets user defined metadata
  21074. */
  21075. metadata: any;
  21076. /**
  21077. * For internal use only. Please do not use.
  21078. */
  21079. reservedDataStore: any;
  21080. /**
  21081. * Specifies if the ready state should be checked on each call
  21082. */
  21083. checkReadyOnEveryCall: boolean;
  21084. /**
  21085. * Specifies if the ready state should be checked once
  21086. */
  21087. checkReadyOnlyOnce: boolean;
  21088. /**
  21089. * The state of the material
  21090. */
  21091. state: string;
  21092. /**
  21093. * The alpha value of the material
  21094. */
  21095. protected _alpha: number;
  21096. /**
  21097. * List of inspectable custom properties (used by the Inspector)
  21098. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21099. */
  21100. inspectableCustomProperties: IInspectable[];
  21101. /**
  21102. * Sets the alpha value of the material
  21103. */
  21104. /**
  21105. * Gets the alpha value of the material
  21106. */
  21107. alpha: number;
  21108. /**
  21109. * Specifies if back face culling is enabled
  21110. */
  21111. protected _backFaceCulling: boolean;
  21112. /**
  21113. * Sets the back-face culling state
  21114. */
  21115. /**
  21116. * Gets the back-face culling state
  21117. */
  21118. backFaceCulling: boolean;
  21119. /**
  21120. * Stores the value for side orientation
  21121. */
  21122. sideOrientation: number;
  21123. /**
  21124. * Callback triggered when the material is compiled
  21125. */
  21126. onCompiled: Nullable<(effect: Effect) => void>;
  21127. /**
  21128. * Callback triggered when an error occurs
  21129. */
  21130. onError: Nullable<(effect: Effect, errors: string) => void>;
  21131. /**
  21132. * Callback triggered to get the render target textures
  21133. */
  21134. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21135. /**
  21136. * Gets a boolean indicating that current material needs to register RTT
  21137. */
  21138. readonly hasRenderTargetTextures: boolean;
  21139. /**
  21140. * Specifies if the material should be serialized
  21141. */
  21142. doNotSerialize: boolean;
  21143. /**
  21144. * @hidden
  21145. */
  21146. _storeEffectOnSubMeshes: boolean;
  21147. /**
  21148. * Stores the animations for the material
  21149. */
  21150. animations: Nullable<Array<Animation>>;
  21151. /**
  21152. * An event triggered when the material is disposed
  21153. */
  21154. onDisposeObservable: Observable<Material>;
  21155. /**
  21156. * An observer which watches for dispose events
  21157. */
  21158. private _onDisposeObserver;
  21159. private _onUnBindObservable;
  21160. /**
  21161. * Called during a dispose event
  21162. */
  21163. onDispose: () => void;
  21164. private _onBindObservable;
  21165. /**
  21166. * An event triggered when the material is bound
  21167. */
  21168. readonly onBindObservable: Observable<AbstractMesh>;
  21169. /**
  21170. * An observer which watches for bind events
  21171. */
  21172. private _onBindObserver;
  21173. /**
  21174. * Called during a bind event
  21175. */
  21176. onBind: (Mesh: AbstractMesh) => void;
  21177. /**
  21178. * An event triggered when the material is unbound
  21179. */
  21180. readonly onUnBindObservable: Observable<Material>;
  21181. /**
  21182. * Stores the value of the alpha mode
  21183. */
  21184. private _alphaMode;
  21185. /**
  21186. * Sets the value of the alpha mode.
  21187. *
  21188. * | Value | Type | Description |
  21189. * | --- | --- | --- |
  21190. * | 0 | ALPHA_DISABLE | |
  21191. * | 1 | ALPHA_ADD | |
  21192. * | 2 | ALPHA_COMBINE | |
  21193. * | 3 | ALPHA_SUBTRACT | |
  21194. * | 4 | ALPHA_MULTIPLY | |
  21195. * | 5 | ALPHA_MAXIMIZED | |
  21196. * | 6 | ALPHA_ONEONE | |
  21197. * | 7 | ALPHA_PREMULTIPLIED | |
  21198. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21199. * | 9 | ALPHA_INTERPOLATE | |
  21200. * | 10 | ALPHA_SCREENMODE | |
  21201. *
  21202. */
  21203. /**
  21204. * Gets the value of the alpha mode
  21205. */
  21206. alphaMode: number;
  21207. /**
  21208. * Stores the state of the need depth pre-pass value
  21209. */
  21210. private _needDepthPrePass;
  21211. /**
  21212. * Sets the need depth pre-pass value
  21213. */
  21214. /**
  21215. * Gets the depth pre-pass value
  21216. */
  21217. needDepthPrePass: boolean;
  21218. /**
  21219. * Specifies if depth writing should be disabled
  21220. */
  21221. disableDepthWrite: boolean;
  21222. /**
  21223. * Specifies if depth writing should be forced
  21224. */
  21225. forceDepthWrite: boolean;
  21226. /**
  21227. * Specifies the depth function that should be used. 0 means the default engine function
  21228. */
  21229. depthFunction: number;
  21230. /**
  21231. * Specifies if there should be a separate pass for culling
  21232. */
  21233. separateCullingPass: boolean;
  21234. /**
  21235. * Stores the state specifing if fog should be enabled
  21236. */
  21237. private _fogEnabled;
  21238. /**
  21239. * Sets the state for enabling fog
  21240. */
  21241. /**
  21242. * Gets the value of the fog enabled state
  21243. */
  21244. fogEnabled: boolean;
  21245. /**
  21246. * Stores the size of points
  21247. */
  21248. pointSize: number;
  21249. /**
  21250. * Stores the z offset value
  21251. */
  21252. zOffset: number;
  21253. /**
  21254. * Gets a value specifying if wireframe mode is enabled
  21255. */
  21256. /**
  21257. * Sets the state of wireframe mode
  21258. */
  21259. wireframe: boolean;
  21260. /**
  21261. * Gets the value specifying if point clouds are enabled
  21262. */
  21263. /**
  21264. * Sets the state of point cloud mode
  21265. */
  21266. pointsCloud: boolean;
  21267. /**
  21268. * Gets the material fill mode
  21269. */
  21270. /**
  21271. * Sets the material fill mode
  21272. */
  21273. fillMode: number;
  21274. /**
  21275. * @hidden
  21276. * Stores the effects for the material
  21277. */
  21278. _effect: Nullable<Effect>;
  21279. /**
  21280. * @hidden
  21281. * Specifies if the material was previously ready
  21282. */
  21283. _wasPreviouslyReady: boolean;
  21284. /**
  21285. * Specifies if uniform buffers should be used
  21286. */
  21287. private _useUBO;
  21288. /**
  21289. * Stores a reference to the scene
  21290. */
  21291. private _scene;
  21292. /**
  21293. * Stores the fill mode state
  21294. */
  21295. private _fillMode;
  21296. /**
  21297. * Specifies if the depth write state should be cached
  21298. */
  21299. private _cachedDepthWriteState;
  21300. /**
  21301. * Specifies if the depth function state should be cached
  21302. */
  21303. private _cachedDepthFunctionState;
  21304. /**
  21305. * Stores the uniform buffer
  21306. */
  21307. protected _uniformBuffer: UniformBuffer;
  21308. /** @hidden */
  21309. _indexInSceneMaterialArray: number;
  21310. /** @hidden */
  21311. meshMap: Nullable<{
  21312. [id: string]: AbstractMesh | undefined;
  21313. }>;
  21314. /**
  21315. * Creates a material instance
  21316. * @param name defines the name of the material
  21317. * @param scene defines the scene to reference
  21318. * @param doNotAdd specifies if the material should be added to the scene
  21319. */
  21320. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21321. /**
  21322. * Returns a string representation of the current material
  21323. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21324. * @returns a string with material information
  21325. */
  21326. toString(fullDetails?: boolean): string;
  21327. /**
  21328. * Gets the class name of the material
  21329. * @returns a string with the class name of the material
  21330. */
  21331. getClassName(): string;
  21332. /**
  21333. * Specifies if updates for the material been locked
  21334. */
  21335. readonly isFrozen: boolean;
  21336. /**
  21337. * Locks updates for the material
  21338. */
  21339. freeze(): void;
  21340. /**
  21341. * Unlocks updates for the material
  21342. */
  21343. unfreeze(): void;
  21344. /**
  21345. * Specifies if the material is ready to be used
  21346. * @param mesh defines the mesh to check
  21347. * @param useInstances specifies if instances should be used
  21348. * @returns a boolean indicating if the material is ready to be used
  21349. */
  21350. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21351. /**
  21352. * Specifies that the submesh is ready to be used
  21353. * @param mesh defines the mesh to check
  21354. * @param subMesh defines which submesh to check
  21355. * @param useInstances specifies that instances should be used
  21356. * @returns a boolean indicating that the submesh is ready or not
  21357. */
  21358. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21359. /**
  21360. * Returns the material effect
  21361. * @returns the effect associated with the material
  21362. */
  21363. getEffect(): Nullable<Effect>;
  21364. /**
  21365. * Returns the current scene
  21366. * @returns a Scene
  21367. */
  21368. getScene(): Scene;
  21369. /**
  21370. * Specifies if the material will require alpha blending
  21371. * @returns a boolean specifying if alpha blending is needed
  21372. */
  21373. needAlphaBlending(): boolean;
  21374. /**
  21375. * Specifies if the mesh will require alpha blending
  21376. * @param mesh defines the mesh to check
  21377. * @returns a boolean specifying if alpha blending is needed for the mesh
  21378. */
  21379. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21380. /**
  21381. * Specifies if this material should be rendered in alpha test mode
  21382. * @returns a boolean specifying if an alpha test is needed.
  21383. */
  21384. needAlphaTesting(): boolean;
  21385. /**
  21386. * Gets the texture used for the alpha test
  21387. * @returns the texture to use for alpha testing
  21388. */
  21389. getAlphaTestTexture(): Nullable<BaseTexture>;
  21390. /**
  21391. * Marks the material to indicate that it needs to be re-calculated
  21392. */
  21393. markDirty(): void;
  21394. /** @hidden */
  21395. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21396. /**
  21397. * Binds the material to the mesh
  21398. * @param world defines the world transformation matrix
  21399. * @param mesh defines the mesh to bind the material to
  21400. */
  21401. bind(world: Matrix, mesh?: Mesh): void;
  21402. /**
  21403. * Binds the submesh to the material
  21404. * @param world defines the world transformation matrix
  21405. * @param mesh defines the mesh containing the submesh
  21406. * @param subMesh defines the submesh to bind the material to
  21407. */
  21408. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21409. /**
  21410. * Binds the world matrix to the material
  21411. * @param world defines the world transformation matrix
  21412. */
  21413. bindOnlyWorldMatrix(world: Matrix): void;
  21414. /**
  21415. * Binds the scene's uniform buffer to the effect.
  21416. * @param effect defines the effect to bind to the scene uniform buffer
  21417. * @param sceneUbo defines the uniform buffer storing scene data
  21418. */
  21419. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21420. /**
  21421. * Binds the view matrix to the effect
  21422. * @param effect defines the effect to bind the view matrix to
  21423. */
  21424. bindView(effect: Effect): void;
  21425. /**
  21426. * Binds the view projection matrix to the effect
  21427. * @param effect defines the effect to bind the view projection matrix to
  21428. */
  21429. bindViewProjection(effect: Effect): void;
  21430. /**
  21431. * Specifies if material alpha testing should be turned on for the mesh
  21432. * @param mesh defines the mesh to check
  21433. */
  21434. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21435. /**
  21436. * Processes to execute after binding the material to a mesh
  21437. * @param mesh defines the rendered mesh
  21438. */
  21439. protected _afterBind(mesh?: Mesh): void;
  21440. /**
  21441. * Unbinds the material from the mesh
  21442. */
  21443. unbind(): void;
  21444. /**
  21445. * Gets the active textures from the material
  21446. * @returns an array of textures
  21447. */
  21448. getActiveTextures(): BaseTexture[];
  21449. /**
  21450. * Specifies if the material uses a texture
  21451. * @param texture defines the texture to check against the material
  21452. * @returns a boolean specifying if the material uses the texture
  21453. */
  21454. hasTexture(texture: BaseTexture): boolean;
  21455. /**
  21456. * Makes a duplicate of the material, and gives it a new name
  21457. * @param name defines the new name for the duplicated material
  21458. * @returns the cloned material
  21459. */
  21460. clone(name: string): Nullable<Material>;
  21461. /**
  21462. * Gets the meshes bound to the material
  21463. * @returns an array of meshes bound to the material
  21464. */
  21465. getBindedMeshes(): AbstractMesh[];
  21466. /**
  21467. * Force shader compilation
  21468. * @param mesh defines the mesh associated with this material
  21469. * @param onCompiled defines a function to execute once the material is compiled
  21470. * @param options defines the options to configure the compilation
  21471. * @param onError defines a function to execute if the material fails compiling
  21472. */
  21473. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21474. /**
  21475. * Force shader compilation
  21476. * @param mesh defines the mesh that will use this material
  21477. * @param options defines additional options for compiling the shaders
  21478. * @returns a promise that resolves when the compilation completes
  21479. */
  21480. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21481. private static readonly _AllDirtyCallBack;
  21482. private static readonly _ImageProcessingDirtyCallBack;
  21483. private static readonly _TextureDirtyCallBack;
  21484. private static readonly _FresnelDirtyCallBack;
  21485. private static readonly _MiscDirtyCallBack;
  21486. private static readonly _LightsDirtyCallBack;
  21487. private static readonly _AttributeDirtyCallBack;
  21488. private static _FresnelAndMiscDirtyCallBack;
  21489. private static _TextureAndMiscDirtyCallBack;
  21490. private static readonly _DirtyCallbackArray;
  21491. private static readonly _RunDirtyCallBacks;
  21492. /**
  21493. * Marks a define in the material to indicate that it needs to be re-computed
  21494. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21495. */
  21496. markAsDirty(flag: number): void;
  21497. /**
  21498. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21499. * @param func defines a function which checks material defines against the submeshes
  21500. */
  21501. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21502. /**
  21503. * Indicates that we need to re-calculated for all submeshes
  21504. */
  21505. protected _markAllSubMeshesAsAllDirty(): void;
  21506. /**
  21507. * Indicates that image processing needs to be re-calculated for all submeshes
  21508. */
  21509. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21510. /**
  21511. * Indicates that textures need to be re-calculated for all submeshes
  21512. */
  21513. protected _markAllSubMeshesAsTexturesDirty(): void;
  21514. /**
  21515. * Indicates that fresnel needs to be re-calculated for all submeshes
  21516. */
  21517. protected _markAllSubMeshesAsFresnelDirty(): void;
  21518. /**
  21519. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21520. */
  21521. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21522. /**
  21523. * Indicates that lights need to be re-calculated for all submeshes
  21524. */
  21525. protected _markAllSubMeshesAsLightsDirty(): void;
  21526. /**
  21527. * Indicates that attributes need to be re-calculated for all submeshes
  21528. */
  21529. protected _markAllSubMeshesAsAttributesDirty(): void;
  21530. /**
  21531. * Indicates that misc needs to be re-calculated for all submeshes
  21532. */
  21533. protected _markAllSubMeshesAsMiscDirty(): void;
  21534. /**
  21535. * Indicates that textures and misc need to be re-calculated for all submeshes
  21536. */
  21537. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21538. /**
  21539. * Disposes the material
  21540. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21541. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21542. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21543. */
  21544. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21545. /** @hidden */
  21546. private releaseVertexArrayObject;
  21547. /**
  21548. * Serializes this material
  21549. * @returns the serialized material object
  21550. */
  21551. serialize(): any;
  21552. /**
  21553. * Creates a material from parsed material data
  21554. * @param parsedMaterial defines parsed material data
  21555. * @param scene defines the hosting scene
  21556. * @param rootUrl defines the root URL to use to load textures
  21557. * @returns a new material
  21558. */
  21559. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21560. }
  21561. }
  21562. declare module "babylonjs/Materials/multiMaterial" {
  21563. import { Nullable } from "babylonjs/types";
  21564. import { Scene } from "babylonjs/scene";
  21565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21566. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21568. import { Material } from "babylonjs/Materials/material";
  21569. /**
  21570. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21571. * separate meshes. This can be use to improve performances.
  21572. * @see http://doc.babylonjs.com/how_to/multi_materials
  21573. */
  21574. export class MultiMaterial extends Material {
  21575. private _subMaterials;
  21576. /**
  21577. * Gets or Sets the list of Materials used within the multi material.
  21578. * They need to be ordered according to the submeshes order in the associated mesh
  21579. */
  21580. subMaterials: Nullable<Material>[];
  21581. /**
  21582. * Function used to align with Node.getChildren()
  21583. * @returns the list of Materials used within the multi material
  21584. */
  21585. getChildren(): Nullable<Material>[];
  21586. /**
  21587. * Instantiates a new Multi Material
  21588. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21589. * separate meshes. This can be use to improve performances.
  21590. * @see http://doc.babylonjs.com/how_to/multi_materials
  21591. * @param name Define the name in the scene
  21592. * @param scene Define the scene the material belongs to
  21593. */
  21594. constructor(name: string, scene: Scene);
  21595. private _hookArray;
  21596. /**
  21597. * Get one of the submaterial by its index in the submaterials array
  21598. * @param index The index to look the sub material at
  21599. * @returns The Material if the index has been defined
  21600. */
  21601. getSubMaterial(index: number): Nullable<Material>;
  21602. /**
  21603. * Get the list of active textures for the whole sub materials list.
  21604. * @returns All the textures that will be used during the rendering
  21605. */
  21606. getActiveTextures(): BaseTexture[];
  21607. /**
  21608. * Gets the current class name of the material e.g. "MultiMaterial"
  21609. * Mainly use in serialization.
  21610. * @returns the class name
  21611. */
  21612. getClassName(): string;
  21613. /**
  21614. * Checks if the material is ready to render the requested sub mesh
  21615. * @param mesh Define the mesh the submesh belongs to
  21616. * @param subMesh Define the sub mesh to look readyness for
  21617. * @param useInstances Define whether or not the material is used with instances
  21618. * @returns true if ready, otherwise false
  21619. */
  21620. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21621. /**
  21622. * Clones the current material and its related sub materials
  21623. * @param name Define the name of the newly cloned material
  21624. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21625. * @returns the cloned material
  21626. */
  21627. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21628. /**
  21629. * Serializes the materials into a JSON representation.
  21630. * @returns the JSON representation
  21631. */
  21632. serialize(): any;
  21633. /**
  21634. * Dispose the material and release its associated resources
  21635. * @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)
  21636. * @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)
  21637. * @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)
  21638. */
  21639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21640. /**
  21641. * Creates a MultiMaterial from parsed MultiMaterial data.
  21642. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21643. * @param scene defines the hosting scene
  21644. * @returns a new MultiMaterial
  21645. */
  21646. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21647. }
  21648. }
  21649. declare module "babylonjs/Meshes/subMesh" {
  21650. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21651. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21652. import { Engine } from "babylonjs/Engines/engine";
  21653. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21654. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21655. import { Effect } from "babylonjs/Materials/effect";
  21656. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21657. import { Plane } from "babylonjs/Maths/math.plane";
  21658. import { Collider } from "babylonjs/Collisions/collider";
  21659. import { Material } from "babylonjs/Materials/material";
  21660. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21662. import { Mesh } from "babylonjs/Meshes/mesh";
  21663. import { Ray } from "babylonjs/Culling/ray";
  21664. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21665. /**
  21666. * Base class for submeshes
  21667. */
  21668. export class BaseSubMesh {
  21669. /** @hidden */
  21670. _materialDefines: Nullable<MaterialDefines>;
  21671. /** @hidden */
  21672. _materialEffect: Nullable<Effect>;
  21673. /**
  21674. * Gets associated effect
  21675. */
  21676. readonly effect: Nullable<Effect>;
  21677. /**
  21678. * Sets associated effect (effect used to render this submesh)
  21679. * @param effect defines the effect to associate with
  21680. * @param defines defines the set of defines used to compile this effect
  21681. */
  21682. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21683. }
  21684. /**
  21685. * Defines a subdivision inside a mesh
  21686. */
  21687. export class SubMesh extends BaseSubMesh implements ICullable {
  21688. /** the material index to use */
  21689. materialIndex: number;
  21690. /** vertex index start */
  21691. verticesStart: number;
  21692. /** vertices count */
  21693. verticesCount: number;
  21694. /** index start */
  21695. indexStart: number;
  21696. /** indices count */
  21697. indexCount: number;
  21698. /** @hidden */
  21699. _linesIndexCount: number;
  21700. private _mesh;
  21701. private _renderingMesh;
  21702. private _boundingInfo;
  21703. private _linesIndexBuffer;
  21704. /** @hidden */
  21705. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21706. /** @hidden */
  21707. _trianglePlanes: Plane[];
  21708. /** @hidden */
  21709. _lastColliderTransformMatrix: Nullable<Matrix>;
  21710. /** @hidden */
  21711. _renderId: number;
  21712. /** @hidden */
  21713. _alphaIndex: number;
  21714. /** @hidden */
  21715. _distanceToCamera: number;
  21716. /** @hidden */
  21717. _id: number;
  21718. private _currentMaterial;
  21719. /**
  21720. * Add a new submesh to a mesh
  21721. * @param materialIndex defines the material index to use
  21722. * @param verticesStart defines vertex index start
  21723. * @param verticesCount defines vertices count
  21724. * @param indexStart defines index start
  21725. * @param indexCount defines indices count
  21726. * @param mesh defines the parent mesh
  21727. * @param renderingMesh defines an optional rendering mesh
  21728. * @param createBoundingBox defines if bounding box should be created for this submesh
  21729. * @returns the new submesh
  21730. */
  21731. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21732. /**
  21733. * Creates a new submesh
  21734. * @param materialIndex defines the material index to use
  21735. * @param verticesStart defines vertex index start
  21736. * @param verticesCount defines vertices count
  21737. * @param indexStart defines index start
  21738. * @param indexCount defines indices count
  21739. * @param mesh defines the parent mesh
  21740. * @param renderingMesh defines an optional rendering mesh
  21741. * @param createBoundingBox defines if bounding box should be created for this submesh
  21742. */
  21743. constructor(
  21744. /** the material index to use */
  21745. materialIndex: number,
  21746. /** vertex index start */
  21747. verticesStart: number,
  21748. /** vertices count */
  21749. verticesCount: number,
  21750. /** index start */
  21751. indexStart: number,
  21752. /** indices count */
  21753. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21754. /**
  21755. * Returns true if this submesh covers the entire parent mesh
  21756. * @ignorenaming
  21757. */
  21758. readonly IsGlobal: boolean;
  21759. /**
  21760. * Returns the submesh BoudingInfo object
  21761. * @returns current bounding info (or mesh's one if the submesh is global)
  21762. */
  21763. getBoundingInfo(): BoundingInfo;
  21764. /**
  21765. * Sets the submesh BoundingInfo
  21766. * @param boundingInfo defines the new bounding info to use
  21767. * @returns the SubMesh
  21768. */
  21769. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21770. /**
  21771. * Returns the mesh of the current submesh
  21772. * @return the parent mesh
  21773. */
  21774. getMesh(): AbstractMesh;
  21775. /**
  21776. * Returns the rendering mesh of the submesh
  21777. * @returns the rendering mesh (could be different from parent mesh)
  21778. */
  21779. getRenderingMesh(): Mesh;
  21780. /**
  21781. * Returns the submesh material
  21782. * @returns null or the current material
  21783. */
  21784. getMaterial(): Nullable<Material>;
  21785. /**
  21786. * Sets a new updated BoundingInfo object to the submesh
  21787. * @param data defines an optional position array to use to determine the bounding info
  21788. * @returns the SubMesh
  21789. */
  21790. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21791. /** @hidden */
  21792. _checkCollision(collider: Collider): boolean;
  21793. /**
  21794. * Updates the submesh BoundingInfo
  21795. * @param world defines the world matrix to use to update the bounding info
  21796. * @returns the submesh
  21797. */
  21798. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21799. /**
  21800. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21801. * @param frustumPlanes defines the frustum planes
  21802. * @returns true if the submesh is intersecting with the frustum
  21803. */
  21804. isInFrustum(frustumPlanes: Plane[]): boolean;
  21805. /**
  21806. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21807. * @param frustumPlanes defines the frustum planes
  21808. * @returns true if the submesh is inside the frustum
  21809. */
  21810. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21811. /**
  21812. * Renders the submesh
  21813. * @param enableAlphaMode defines if alpha needs to be used
  21814. * @returns the submesh
  21815. */
  21816. render(enableAlphaMode: boolean): SubMesh;
  21817. /**
  21818. * @hidden
  21819. */
  21820. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21821. /**
  21822. * Checks if the submesh intersects with a ray
  21823. * @param ray defines the ray to test
  21824. * @returns true is the passed ray intersects the submesh bounding box
  21825. */
  21826. canIntersects(ray: Ray): boolean;
  21827. /**
  21828. * Intersects current submesh with a ray
  21829. * @param ray defines the ray to test
  21830. * @param positions defines mesh's positions array
  21831. * @param indices defines mesh's indices array
  21832. * @param fastCheck defines if only bounding info should be used
  21833. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21834. * @returns intersection info or null if no intersection
  21835. */
  21836. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21837. /** @hidden */
  21838. private _intersectLines;
  21839. /** @hidden */
  21840. private _intersectUnIndexedLines;
  21841. /** @hidden */
  21842. private _intersectTriangles;
  21843. /** @hidden */
  21844. private _intersectUnIndexedTriangles;
  21845. /** @hidden */
  21846. _rebuild(): void;
  21847. /**
  21848. * Creates a new submesh from the passed mesh
  21849. * @param newMesh defines the new hosting mesh
  21850. * @param newRenderingMesh defines an optional rendering mesh
  21851. * @returns the new submesh
  21852. */
  21853. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21854. /**
  21855. * Release associated resources
  21856. */
  21857. dispose(): void;
  21858. /**
  21859. * Gets the class name
  21860. * @returns the string "SubMesh".
  21861. */
  21862. getClassName(): string;
  21863. /**
  21864. * Creates a new submesh from indices data
  21865. * @param materialIndex the index of the main mesh material
  21866. * @param startIndex the index where to start the copy in the mesh indices array
  21867. * @param indexCount the number of indices to copy then from the startIndex
  21868. * @param mesh the main mesh to create the submesh from
  21869. * @param renderingMesh the optional rendering mesh
  21870. * @returns a new submesh
  21871. */
  21872. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21873. }
  21874. }
  21875. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21876. /**
  21877. * Class used to represent data loading progression
  21878. */
  21879. export class SceneLoaderFlags {
  21880. private static _ForceFullSceneLoadingForIncremental;
  21881. private static _ShowLoadingScreen;
  21882. private static _CleanBoneMatrixWeights;
  21883. private static _loggingLevel;
  21884. /**
  21885. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21886. */
  21887. static ForceFullSceneLoadingForIncremental: boolean;
  21888. /**
  21889. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21890. */
  21891. static ShowLoadingScreen: boolean;
  21892. /**
  21893. * Defines the current logging level (while loading the scene)
  21894. * @ignorenaming
  21895. */
  21896. static loggingLevel: number;
  21897. /**
  21898. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21899. */
  21900. static CleanBoneMatrixWeights: boolean;
  21901. }
  21902. }
  21903. declare module "babylonjs/Meshes/geometry" {
  21904. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21905. import { Scene } from "babylonjs/scene";
  21906. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21907. import { Engine } from "babylonjs/Engines/engine";
  21908. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21909. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21910. import { Effect } from "babylonjs/Materials/effect";
  21911. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21912. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21913. import { Mesh } from "babylonjs/Meshes/mesh";
  21914. /**
  21915. * Class used to store geometry data (vertex buffers + index buffer)
  21916. */
  21917. export class Geometry implements IGetSetVerticesData {
  21918. /**
  21919. * Gets or sets the ID of the geometry
  21920. */
  21921. id: string;
  21922. /**
  21923. * Gets or sets the unique ID of the geometry
  21924. */
  21925. uniqueId: number;
  21926. /**
  21927. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21928. */
  21929. delayLoadState: number;
  21930. /**
  21931. * Gets the file containing the data to load when running in delay load state
  21932. */
  21933. delayLoadingFile: Nullable<string>;
  21934. /**
  21935. * Callback called when the geometry is updated
  21936. */
  21937. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21938. private _scene;
  21939. private _engine;
  21940. private _meshes;
  21941. private _totalVertices;
  21942. /** @hidden */
  21943. _indices: IndicesArray;
  21944. /** @hidden */
  21945. _vertexBuffers: {
  21946. [key: string]: VertexBuffer;
  21947. };
  21948. private _isDisposed;
  21949. private _extend;
  21950. private _boundingBias;
  21951. /** @hidden */
  21952. _delayInfo: Array<string>;
  21953. private _indexBuffer;
  21954. private _indexBufferIsUpdatable;
  21955. /** @hidden */
  21956. _boundingInfo: Nullable<BoundingInfo>;
  21957. /** @hidden */
  21958. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21959. /** @hidden */
  21960. _softwareSkinningFrameId: number;
  21961. private _vertexArrayObjects;
  21962. private _updatable;
  21963. /** @hidden */
  21964. _positions: Nullable<Vector3[]>;
  21965. /**
  21966. * 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
  21967. */
  21968. /**
  21969. * 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
  21970. */
  21971. boundingBias: Vector2;
  21972. /**
  21973. * Static function used to attach a new empty geometry to a mesh
  21974. * @param mesh defines the mesh to attach the geometry to
  21975. * @returns the new Geometry
  21976. */
  21977. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21978. /**
  21979. * Creates a new geometry
  21980. * @param id defines the unique ID
  21981. * @param scene defines the hosting scene
  21982. * @param vertexData defines the VertexData used to get geometry data
  21983. * @param updatable defines if geometry must be updatable (false by default)
  21984. * @param mesh defines the mesh that will be associated with the geometry
  21985. */
  21986. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21987. /**
  21988. * Gets the current extend of the geometry
  21989. */
  21990. readonly extend: {
  21991. minimum: Vector3;
  21992. maximum: Vector3;
  21993. };
  21994. /**
  21995. * Gets the hosting scene
  21996. * @returns the hosting Scene
  21997. */
  21998. getScene(): Scene;
  21999. /**
  22000. * Gets the hosting engine
  22001. * @returns the hosting Engine
  22002. */
  22003. getEngine(): Engine;
  22004. /**
  22005. * Defines if the geometry is ready to use
  22006. * @returns true if the geometry is ready to be used
  22007. */
  22008. isReady(): boolean;
  22009. /**
  22010. * Gets a value indicating that the geometry should not be serialized
  22011. */
  22012. readonly doNotSerialize: boolean;
  22013. /** @hidden */
  22014. _rebuild(): void;
  22015. /**
  22016. * Affects all geometry data in one call
  22017. * @param vertexData defines the geometry data
  22018. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22019. */
  22020. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22021. /**
  22022. * Set specific vertex data
  22023. * @param kind defines the data kind (Position, normal, etc...)
  22024. * @param data defines the vertex data to use
  22025. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22026. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22027. */
  22028. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22029. /**
  22030. * Removes a specific vertex data
  22031. * @param kind defines the data kind (Position, normal, etc...)
  22032. */
  22033. removeVerticesData(kind: string): void;
  22034. /**
  22035. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22036. * @param buffer defines the vertex buffer to use
  22037. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22038. */
  22039. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22040. /**
  22041. * Update a specific vertex buffer
  22042. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22043. * It will do nothing if the buffer is not updatable
  22044. * @param kind defines the data kind (Position, normal, etc...)
  22045. * @param data defines the data to use
  22046. * @param offset defines the offset in the target buffer where to store the data
  22047. * @param useBytes set to true if the offset is in bytes
  22048. */
  22049. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22050. /**
  22051. * Update a specific vertex buffer
  22052. * This function will create a new buffer if the current one is not updatable
  22053. * @param kind defines the data kind (Position, normal, etc...)
  22054. * @param data defines the data to use
  22055. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22056. */
  22057. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22058. private _updateBoundingInfo;
  22059. /** @hidden */
  22060. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22061. /**
  22062. * Gets total number of vertices
  22063. * @returns the total number of vertices
  22064. */
  22065. getTotalVertices(): number;
  22066. /**
  22067. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22068. * @param kind defines the data kind (Position, normal, etc...)
  22069. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22070. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22071. * @returns a float array containing vertex data
  22072. */
  22073. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22074. /**
  22075. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22076. * @param kind defines the data kind (Position, normal, etc...)
  22077. * @returns true if the vertex buffer with the specified kind is updatable
  22078. */
  22079. isVertexBufferUpdatable(kind: string): boolean;
  22080. /**
  22081. * Gets a specific vertex buffer
  22082. * @param kind defines the data kind (Position, normal, etc...)
  22083. * @returns a VertexBuffer
  22084. */
  22085. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22086. /**
  22087. * Returns all vertex buffers
  22088. * @return an object holding all vertex buffers indexed by kind
  22089. */
  22090. getVertexBuffers(): Nullable<{
  22091. [key: string]: VertexBuffer;
  22092. }>;
  22093. /**
  22094. * Gets a boolean indicating if specific vertex buffer is present
  22095. * @param kind defines the data kind (Position, normal, etc...)
  22096. * @returns true if data is present
  22097. */
  22098. isVerticesDataPresent(kind: string): boolean;
  22099. /**
  22100. * Gets a list of all attached data kinds (Position, normal, etc...)
  22101. * @returns a list of string containing all kinds
  22102. */
  22103. getVerticesDataKinds(): string[];
  22104. /**
  22105. * Update index buffer
  22106. * @param indices defines the indices to store in the index buffer
  22107. * @param offset defines the offset in the target buffer where to store the data
  22108. * @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)
  22109. */
  22110. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22111. /**
  22112. * Creates a new index buffer
  22113. * @param indices defines the indices to store in the index buffer
  22114. * @param totalVertices defines the total number of vertices (could be null)
  22115. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22116. */
  22117. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22118. /**
  22119. * Return the total number of indices
  22120. * @returns the total number of indices
  22121. */
  22122. getTotalIndices(): number;
  22123. /**
  22124. * Gets the index buffer array
  22125. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22126. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22127. * @returns the index buffer array
  22128. */
  22129. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22130. /**
  22131. * Gets the index buffer
  22132. * @return the index buffer
  22133. */
  22134. getIndexBuffer(): Nullable<DataBuffer>;
  22135. /** @hidden */
  22136. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22137. /**
  22138. * Release the associated resources for a specific mesh
  22139. * @param mesh defines the source mesh
  22140. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22141. */
  22142. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22143. /**
  22144. * Apply current geometry to a given mesh
  22145. * @param mesh defines the mesh to apply geometry to
  22146. */
  22147. applyToMesh(mesh: Mesh): void;
  22148. private _updateExtend;
  22149. private _applyToMesh;
  22150. private notifyUpdate;
  22151. /**
  22152. * Load the geometry if it was flagged as delay loaded
  22153. * @param scene defines the hosting scene
  22154. * @param onLoaded defines a callback called when the geometry is loaded
  22155. */
  22156. load(scene: Scene, onLoaded?: () => void): void;
  22157. private _queueLoad;
  22158. /**
  22159. * Invert the geometry to move from a right handed system to a left handed one.
  22160. */
  22161. toLeftHanded(): void;
  22162. /** @hidden */
  22163. _resetPointsArrayCache(): void;
  22164. /** @hidden */
  22165. _generatePointsArray(): boolean;
  22166. /**
  22167. * Gets a value indicating if the geometry is disposed
  22168. * @returns true if the geometry was disposed
  22169. */
  22170. isDisposed(): boolean;
  22171. private _disposeVertexArrayObjects;
  22172. /**
  22173. * Free all associated resources
  22174. */
  22175. dispose(): void;
  22176. /**
  22177. * Clone the current geometry into a new geometry
  22178. * @param id defines the unique ID of the new geometry
  22179. * @returns a new geometry object
  22180. */
  22181. copy(id: string): Geometry;
  22182. /**
  22183. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22184. * @return a JSON representation of the current geometry data (without the vertices data)
  22185. */
  22186. serialize(): any;
  22187. private toNumberArray;
  22188. /**
  22189. * Serialize all vertices data into a JSON oject
  22190. * @returns a JSON representation of the current geometry data
  22191. */
  22192. serializeVerticeData(): any;
  22193. /**
  22194. * Extracts a clone of a mesh geometry
  22195. * @param mesh defines the source mesh
  22196. * @param id defines the unique ID of the new geometry object
  22197. * @returns the new geometry object
  22198. */
  22199. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22200. /**
  22201. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22202. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22203. * Be aware Math.random() could cause collisions, but:
  22204. * "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"
  22205. * @returns a string containing a new GUID
  22206. */
  22207. static RandomId(): string;
  22208. /** @hidden */
  22209. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22210. private static _CleanMatricesWeights;
  22211. /**
  22212. * Create a new geometry from persisted data (Using .babylon file format)
  22213. * @param parsedVertexData defines the persisted data
  22214. * @param scene defines the hosting scene
  22215. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22216. * @returns the new geometry object
  22217. */
  22218. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22219. }
  22220. }
  22221. declare module "babylonjs/Meshes/mesh.vertexData" {
  22222. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22223. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22224. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22225. import { Geometry } from "babylonjs/Meshes/geometry";
  22226. import { Mesh } from "babylonjs/Meshes/mesh";
  22227. /**
  22228. * Define an interface for all classes that will get and set the data on vertices
  22229. */
  22230. export interface IGetSetVerticesData {
  22231. /**
  22232. * Gets a boolean indicating if specific vertex data is present
  22233. * @param kind defines the vertex data kind to use
  22234. * @returns true is data kind is present
  22235. */
  22236. isVerticesDataPresent(kind: string): boolean;
  22237. /**
  22238. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22239. * @param kind defines the data kind (Position, normal, etc...)
  22240. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22241. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22242. * @returns a float array containing vertex data
  22243. */
  22244. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22245. /**
  22246. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22247. * @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.
  22248. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22249. * @returns the indices array or an empty array if the mesh has no geometry
  22250. */
  22251. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22252. /**
  22253. * Set specific vertex data
  22254. * @param kind defines the data kind (Position, normal, etc...)
  22255. * @param data defines the vertex data to use
  22256. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22257. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22258. */
  22259. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22260. /**
  22261. * Update a specific associated vertex buffer
  22262. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22263. * - VertexBuffer.PositionKind
  22264. * - VertexBuffer.UVKind
  22265. * - VertexBuffer.UV2Kind
  22266. * - VertexBuffer.UV3Kind
  22267. * - VertexBuffer.UV4Kind
  22268. * - VertexBuffer.UV5Kind
  22269. * - VertexBuffer.UV6Kind
  22270. * - VertexBuffer.ColorKind
  22271. * - VertexBuffer.MatricesIndicesKind
  22272. * - VertexBuffer.MatricesIndicesExtraKind
  22273. * - VertexBuffer.MatricesWeightsKind
  22274. * - VertexBuffer.MatricesWeightsExtraKind
  22275. * @param data defines the data source
  22276. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22277. * @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)
  22278. */
  22279. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22280. /**
  22281. * Creates a new index buffer
  22282. * @param indices defines the indices to store in the index buffer
  22283. * @param totalVertices defines the total number of vertices (could be null)
  22284. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22285. */
  22286. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22287. }
  22288. /**
  22289. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22290. */
  22291. export class VertexData {
  22292. /**
  22293. * Mesh side orientation : usually the external or front surface
  22294. */
  22295. static readonly FRONTSIDE: number;
  22296. /**
  22297. * Mesh side orientation : usually the internal or back surface
  22298. */
  22299. static readonly BACKSIDE: number;
  22300. /**
  22301. * Mesh side orientation : both internal and external or front and back surfaces
  22302. */
  22303. static readonly DOUBLESIDE: number;
  22304. /**
  22305. * Mesh side orientation : by default, `FRONTSIDE`
  22306. */
  22307. static readonly DEFAULTSIDE: number;
  22308. /**
  22309. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22310. */
  22311. positions: Nullable<FloatArray>;
  22312. /**
  22313. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22314. */
  22315. normals: Nullable<FloatArray>;
  22316. /**
  22317. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22318. */
  22319. tangents: Nullable<FloatArray>;
  22320. /**
  22321. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22322. */
  22323. uvs: Nullable<FloatArray>;
  22324. /**
  22325. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22326. */
  22327. uvs2: Nullable<FloatArray>;
  22328. /**
  22329. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22330. */
  22331. uvs3: Nullable<FloatArray>;
  22332. /**
  22333. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22334. */
  22335. uvs4: Nullable<FloatArray>;
  22336. /**
  22337. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22338. */
  22339. uvs5: Nullable<FloatArray>;
  22340. /**
  22341. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22342. */
  22343. uvs6: Nullable<FloatArray>;
  22344. /**
  22345. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22346. */
  22347. colors: Nullable<FloatArray>;
  22348. /**
  22349. * 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).
  22350. */
  22351. matricesIndices: Nullable<FloatArray>;
  22352. /**
  22353. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22354. */
  22355. matricesWeights: Nullable<FloatArray>;
  22356. /**
  22357. * An array extending the number of possible indices
  22358. */
  22359. matricesIndicesExtra: Nullable<FloatArray>;
  22360. /**
  22361. * An array extending the number of possible weights when the number of indices is extended
  22362. */
  22363. matricesWeightsExtra: Nullable<FloatArray>;
  22364. /**
  22365. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22366. */
  22367. indices: Nullable<IndicesArray>;
  22368. /**
  22369. * Uses the passed data array to set the set the values for the specified kind of data
  22370. * @param data a linear array of floating numbers
  22371. * @param kind the type of data that is being set, eg positions, colors etc
  22372. */
  22373. set(data: FloatArray, kind: string): void;
  22374. /**
  22375. * Associates the vertexData to the passed Mesh.
  22376. * Sets it as updatable or not (default `false`)
  22377. * @param mesh the mesh the vertexData is applied to
  22378. * @param updatable when used and having the value true allows new data to update the vertexData
  22379. * @returns the VertexData
  22380. */
  22381. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22382. /**
  22383. * Associates the vertexData to the passed Geometry.
  22384. * Sets it as updatable or not (default `false`)
  22385. * @param geometry the geometry the vertexData is applied to
  22386. * @param updatable when used and having the value true allows new data to update the vertexData
  22387. * @returns VertexData
  22388. */
  22389. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22390. /**
  22391. * Updates the associated mesh
  22392. * @param mesh the mesh to be updated
  22393. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22394. * @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
  22395. * @returns VertexData
  22396. */
  22397. updateMesh(mesh: Mesh): VertexData;
  22398. /**
  22399. * Updates the associated geometry
  22400. * @param geometry the geometry to be updated
  22401. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22402. * @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
  22403. * @returns VertexData.
  22404. */
  22405. updateGeometry(geometry: Geometry): VertexData;
  22406. private _applyTo;
  22407. private _update;
  22408. /**
  22409. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22410. * @param matrix the transforming matrix
  22411. * @returns the VertexData
  22412. */
  22413. transform(matrix: Matrix): VertexData;
  22414. /**
  22415. * Merges the passed VertexData into the current one
  22416. * @param other the VertexData to be merged into the current one
  22417. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22418. * @returns the modified VertexData
  22419. */
  22420. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22421. private _mergeElement;
  22422. private _validate;
  22423. /**
  22424. * Serializes the VertexData
  22425. * @returns a serialized object
  22426. */
  22427. serialize(): any;
  22428. /**
  22429. * Extracts the vertexData from a mesh
  22430. * @param mesh the mesh from which to extract the VertexData
  22431. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22432. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22433. * @returns the object VertexData associated to the passed mesh
  22434. */
  22435. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22436. /**
  22437. * Extracts the vertexData from the geometry
  22438. * @param geometry the geometry from which to extract the VertexData
  22439. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22440. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22441. * @returns the object VertexData associated to the passed mesh
  22442. */
  22443. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22444. private static _ExtractFrom;
  22445. /**
  22446. * Creates the VertexData for a Ribbon
  22447. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22448. * * pathArray array of paths, each of which an array of successive Vector3
  22449. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22450. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22451. * * 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
  22452. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22453. * * 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)
  22454. * * 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)
  22455. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22456. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22457. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22458. * @returns the VertexData of the ribbon
  22459. */
  22460. static CreateRibbon(options: {
  22461. pathArray: Vector3[][];
  22462. closeArray?: boolean;
  22463. closePath?: boolean;
  22464. offset?: number;
  22465. sideOrientation?: number;
  22466. frontUVs?: Vector4;
  22467. backUVs?: Vector4;
  22468. invertUV?: boolean;
  22469. uvs?: Vector2[];
  22470. colors?: Color4[];
  22471. }): VertexData;
  22472. /**
  22473. * Creates the VertexData for a box
  22474. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22475. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22476. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22477. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22478. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22479. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22480. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22482. * * 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)
  22483. * * 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)
  22484. * @returns the VertexData of the box
  22485. */
  22486. static CreateBox(options: {
  22487. size?: number;
  22488. width?: number;
  22489. height?: number;
  22490. depth?: number;
  22491. faceUV?: Vector4[];
  22492. faceColors?: Color4[];
  22493. sideOrientation?: number;
  22494. frontUVs?: Vector4;
  22495. backUVs?: Vector4;
  22496. }): VertexData;
  22497. /**
  22498. * Creates the VertexData for a tiled box
  22499. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22500. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22501. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22502. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22503. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22504. * @returns the VertexData of the box
  22505. */
  22506. static CreateTiledBox(options: {
  22507. pattern?: number;
  22508. width?: number;
  22509. height?: number;
  22510. depth?: number;
  22511. tileSize?: number;
  22512. tileWidth?: number;
  22513. tileHeight?: number;
  22514. alignHorizontal?: number;
  22515. alignVertical?: number;
  22516. faceUV?: Vector4[];
  22517. faceColors?: Color4[];
  22518. sideOrientation?: number;
  22519. }): VertexData;
  22520. /**
  22521. * Creates the VertexData for a tiled plane
  22522. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22523. * * pattern a limited pattern arrangement depending on the number
  22524. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22525. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22526. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22528. * * 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)
  22529. * * 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)
  22530. * @returns the VertexData of the tiled plane
  22531. */
  22532. static CreateTiledPlane(options: {
  22533. pattern?: number;
  22534. tileSize?: number;
  22535. tileWidth?: number;
  22536. tileHeight?: number;
  22537. size?: number;
  22538. width?: number;
  22539. height?: number;
  22540. alignHorizontal?: number;
  22541. alignVertical?: number;
  22542. sideOrientation?: number;
  22543. frontUVs?: Vector4;
  22544. backUVs?: Vector4;
  22545. }): VertexData;
  22546. /**
  22547. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22548. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22549. * * segments sets the number of horizontal strips optional, default 32
  22550. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22551. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22552. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22553. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22554. * * 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
  22555. * * 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
  22556. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22557. * * 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)
  22558. * * 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)
  22559. * @returns the VertexData of the ellipsoid
  22560. */
  22561. static CreateSphere(options: {
  22562. segments?: number;
  22563. diameter?: number;
  22564. diameterX?: number;
  22565. diameterY?: number;
  22566. diameterZ?: number;
  22567. arc?: number;
  22568. slice?: number;
  22569. sideOrientation?: number;
  22570. frontUVs?: Vector4;
  22571. backUVs?: Vector4;
  22572. }): VertexData;
  22573. /**
  22574. * Creates the VertexData for a cylinder, cone or prism
  22575. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22576. * * height sets the height (y direction) of the cylinder, optional, default 2
  22577. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22578. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22579. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22580. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22581. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22582. * * 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
  22583. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22584. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22585. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22586. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22588. * * 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)
  22589. * * 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)
  22590. * @returns the VertexData of the cylinder, cone or prism
  22591. */
  22592. static CreateCylinder(options: {
  22593. height?: number;
  22594. diameterTop?: number;
  22595. diameterBottom?: number;
  22596. diameter?: number;
  22597. tessellation?: number;
  22598. subdivisions?: number;
  22599. arc?: number;
  22600. faceColors?: Color4[];
  22601. faceUV?: Vector4[];
  22602. hasRings?: boolean;
  22603. enclose?: boolean;
  22604. sideOrientation?: number;
  22605. frontUVs?: Vector4;
  22606. backUVs?: Vector4;
  22607. }): VertexData;
  22608. /**
  22609. * Creates the VertexData for a torus
  22610. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22611. * * diameter the diameter of the torus, optional default 1
  22612. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22613. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22614. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22615. * * 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)
  22616. * * 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)
  22617. * @returns the VertexData of the torus
  22618. */
  22619. static CreateTorus(options: {
  22620. diameter?: number;
  22621. thickness?: number;
  22622. tessellation?: number;
  22623. sideOrientation?: number;
  22624. frontUVs?: Vector4;
  22625. backUVs?: Vector4;
  22626. }): VertexData;
  22627. /**
  22628. * Creates the VertexData of the LineSystem
  22629. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22630. * - lines an array of lines, each line being an array of successive Vector3
  22631. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22632. * @returns the VertexData of the LineSystem
  22633. */
  22634. static CreateLineSystem(options: {
  22635. lines: Vector3[][];
  22636. colors?: Nullable<Color4[][]>;
  22637. }): VertexData;
  22638. /**
  22639. * Create the VertexData for a DashedLines
  22640. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22641. * - points an array successive Vector3
  22642. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22643. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22644. * - dashNb the intended total number of dashes, optional, default 200
  22645. * @returns the VertexData for the DashedLines
  22646. */
  22647. static CreateDashedLines(options: {
  22648. points: Vector3[];
  22649. dashSize?: number;
  22650. gapSize?: number;
  22651. dashNb?: number;
  22652. }): VertexData;
  22653. /**
  22654. * Creates the VertexData for a Ground
  22655. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22656. * - width the width (x direction) of the ground, optional, default 1
  22657. * - height the height (z direction) of the ground, optional, default 1
  22658. * - subdivisions the number of subdivisions per side, optional, default 1
  22659. * @returns the VertexData of the Ground
  22660. */
  22661. static CreateGround(options: {
  22662. width?: number;
  22663. height?: number;
  22664. subdivisions?: number;
  22665. subdivisionsX?: number;
  22666. subdivisionsY?: number;
  22667. }): VertexData;
  22668. /**
  22669. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22670. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22671. * * xmin the ground minimum X coordinate, optional, default -1
  22672. * * zmin the ground minimum Z coordinate, optional, default -1
  22673. * * xmax the ground maximum X coordinate, optional, default 1
  22674. * * zmax the ground maximum Z coordinate, optional, default 1
  22675. * * 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}
  22676. * * 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}
  22677. * @returns the VertexData of the TiledGround
  22678. */
  22679. static CreateTiledGround(options: {
  22680. xmin: number;
  22681. zmin: number;
  22682. xmax: number;
  22683. zmax: number;
  22684. subdivisions?: {
  22685. w: number;
  22686. h: number;
  22687. };
  22688. precision?: {
  22689. w: number;
  22690. h: number;
  22691. };
  22692. }): VertexData;
  22693. /**
  22694. * Creates the VertexData of the Ground designed from a heightmap
  22695. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22696. * * width the width (x direction) of the ground
  22697. * * height the height (z direction) of the ground
  22698. * * subdivisions the number of subdivisions per side
  22699. * * minHeight the minimum altitude on the ground, optional, default 0
  22700. * * maxHeight the maximum altitude on the ground, optional default 1
  22701. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22702. * * buffer the array holding the image color data
  22703. * * bufferWidth the width of image
  22704. * * bufferHeight the height of image
  22705. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22706. * @returns the VertexData of the Ground designed from a heightmap
  22707. */
  22708. static CreateGroundFromHeightMap(options: {
  22709. width: number;
  22710. height: number;
  22711. subdivisions: number;
  22712. minHeight: number;
  22713. maxHeight: number;
  22714. colorFilter: Color3;
  22715. buffer: Uint8Array;
  22716. bufferWidth: number;
  22717. bufferHeight: number;
  22718. alphaFilter: number;
  22719. }): VertexData;
  22720. /**
  22721. * Creates the VertexData for a Plane
  22722. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22723. * * size sets the width and height of the plane to the value of size, optional default 1
  22724. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22725. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22726. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22727. * * 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)
  22728. * * 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)
  22729. * @returns the VertexData of the box
  22730. */
  22731. static CreatePlane(options: {
  22732. size?: number;
  22733. width?: number;
  22734. height?: number;
  22735. sideOrientation?: number;
  22736. frontUVs?: Vector4;
  22737. backUVs?: Vector4;
  22738. }): VertexData;
  22739. /**
  22740. * Creates the VertexData of the Disc or regular Polygon
  22741. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22742. * * radius the radius of the disc, optional default 0.5
  22743. * * tessellation the number of polygon sides, optional, default 64
  22744. * * 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
  22745. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22746. * * 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)
  22747. * * 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)
  22748. * @returns the VertexData of the box
  22749. */
  22750. static CreateDisc(options: {
  22751. radius?: number;
  22752. tessellation?: number;
  22753. arc?: number;
  22754. sideOrientation?: number;
  22755. frontUVs?: Vector4;
  22756. backUVs?: Vector4;
  22757. }): VertexData;
  22758. /**
  22759. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22760. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22761. * @param polygon a mesh built from polygonTriangulation.build()
  22762. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22763. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22764. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22765. * @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)
  22766. * @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)
  22767. * @returns the VertexData of the Polygon
  22768. */
  22769. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22770. /**
  22771. * Creates the VertexData of the IcoSphere
  22772. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22773. * * radius the radius of the IcoSphere, optional default 1
  22774. * * radiusX allows stretching in the x direction, optional, default radius
  22775. * * radiusY allows stretching in the y direction, optional, default radius
  22776. * * radiusZ allows stretching in the z direction, optional, default radius
  22777. * * flat when true creates a flat shaded mesh, optional, default true
  22778. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22779. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22780. * * 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)
  22781. * * 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)
  22782. * @returns the VertexData of the IcoSphere
  22783. */
  22784. static CreateIcoSphere(options: {
  22785. radius?: number;
  22786. radiusX?: number;
  22787. radiusY?: number;
  22788. radiusZ?: number;
  22789. flat?: boolean;
  22790. subdivisions?: number;
  22791. sideOrientation?: number;
  22792. frontUVs?: Vector4;
  22793. backUVs?: Vector4;
  22794. }): VertexData;
  22795. /**
  22796. * Creates the VertexData for a Polyhedron
  22797. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22798. * * type provided types are:
  22799. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22800. * * 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)
  22801. * * size the size of the IcoSphere, optional default 1
  22802. * * sizeX allows stretching in the x direction, optional, default size
  22803. * * sizeY allows stretching in the y direction, optional, default size
  22804. * * sizeZ allows stretching in the z direction, optional, default size
  22805. * * 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
  22806. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22807. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22808. * * flat when true creates a flat shaded mesh, optional, default true
  22809. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22810. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22811. * * 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)
  22812. * * 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)
  22813. * @returns the VertexData of the Polyhedron
  22814. */
  22815. static CreatePolyhedron(options: {
  22816. type?: number;
  22817. size?: number;
  22818. sizeX?: number;
  22819. sizeY?: number;
  22820. sizeZ?: number;
  22821. custom?: any;
  22822. faceUV?: Vector4[];
  22823. faceColors?: Color4[];
  22824. flat?: boolean;
  22825. sideOrientation?: number;
  22826. frontUVs?: Vector4;
  22827. backUVs?: Vector4;
  22828. }): VertexData;
  22829. /**
  22830. * Creates the VertexData for a TorusKnot
  22831. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22832. * * radius the radius of the torus knot, optional, default 2
  22833. * * tube the thickness of the tube, optional, default 0.5
  22834. * * radialSegments the number of sides on each tube segments, optional, default 32
  22835. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22836. * * p the number of windings around the z axis, optional, default 2
  22837. * * q the number of windings around the x axis, optional, default 3
  22838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22839. * * 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)
  22840. * * 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)
  22841. * @returns the VertexData of the Torus Knot
  22842. */
  22843. static CreateTorusKnot(options: {
  22844. radius?: number;
  22845. tube?: number;
  22846. radialSegments?: number;
  22847. tubularSegments?: number;
  22848. p?: number;
  22849. q?: number;
  22850. sideOrientation?: number;
  22851. frontUVs?: Vector4;
  22852. backUVs?: Vector4;
  22853. }): VertexData;
  22854. /**
  22855. * Compute normals for given positions and indices
  22856. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22857. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22858. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22859. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22860. * * facetNormals : optional array of facet normals (vector3)
  22861. * * facetPositions : optional array of facet positions (vector3)
  22862. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22863. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22864. * * bInfo : optional bounding info, required for facetPartitioning computation
  22865. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22866. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22867. * * useRightHandedSystem: optional boolean to for right handed system computation
  22868. * * depthSort : optional boolean to enable the facet depth sort computation
  22869. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22870. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22871. */
  22872. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22873. facetNormals?: any;
  22874. facetPositions?: any;
  22875. facetPartitioning?: any;
  22876. ratio?: number;
  22877. bInfo?: any;
  22878. bbSize?: Vector3;
  22879. subDiv?: any;
  22880. useRightHandedSystem?: boolean;
  22881. depthSort?: boolean;
  22882. distanceTo?: Vector3;
  22883. depthSortedFacets?: any;
  22884. }): void;
  22885. /** @hidden */
  22886. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22887. /**
  22888. * Applies VertexData created from the imported parameters to the geometry
  22889. * @param parsedVertexData the parsed data from an imported file
  22890. * @param geometry the geometry to apply the VertexData to
  22891. */
  22892. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22893. }
  22894. }
  22895. declare module "babylonjs/Morph/morphTarget" {
  22896. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22897. import { Observable } from "babylonjs/Misc/observable";
  22898. import { Nullable, FloatArray } from "babylonjs/types";
  22899. import { Scene } from "babylonjs/scene";
  22900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22901. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22902. /**
  22903. * Defines a target to use with MorphTargetManager
  22904. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22905. */
  22906. export class MorphTarget implements IAnimatable {
  22907. /** defines the name of the target */
  22908. name: string;
  22909. /**
  22910. * Gets or sets the list of animations
  22911. */
  22912. animations: import("babylonjs/Animations/animation").Animation[];
  22913. private _scene;
  22914. private _positions;
  22915. private _normals;
  22916. private _tangents;
  22917. private _uvs;
  22918. private _influence;
  22919. private _uniqueId;
  22920. /**
  22921. * Observable raised when the influence changes
  22922. */
  22923. onInfluenceChanged: Observable<boolean>;
  22924. /** @hidden */
  22925. _onDataLayoutChanged: Observable<void>;
  22926. /**
  22927. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22928. */
  22929. influence: number;
  22930. /**
  22931. * Gets or sets the id of the morph Target
  22932. */
  22933. id: string;
  22934. private _animationPropertiesOverride;
  22935. /**
  22936. * Gets or sets the animation properties override
  22937. */
  22938. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22939. /**
  22940. * Creates a new MorphTarget
  22941. * @param name defines the name of the target
  22942. * @param influence defines the influence to use
  22943. * @param scene defines the scene the morphtarget belongs to
  22944. */
  22945. constructor(
  22946. /** defines the name of the target */
  22947. name: string, influence?: number, scene?: Nullable<Scene>);
  22948. /**
  22949. * Gets the unique ID of this manager
  22950. */
  22951. readonly uniqueId: number;
  22952. /**
  22953. * Gets a boolean defining if the target contains position data
  22954. */
  22955. readonly hasPositions: boolean;
  22956. /**
  22957. * Gets a boolean defining if the target contains normal data
  22958. */
  22959. readonly hasNormals: boolean;
  22960. /**
  22961. * Gets a boolean defining if the target contains tangent data
  22962. */
  22963. readonly hasTangents: boolean;
  22964. /**
  22965. * Gets a boolean defining if the target contains texture coordinates data
  22966. */
  22967. readonly hasUVs: boolean;
  22968. /**
  22969. * Affects position data to this target
  22970. * @param data defines the position data to use
  22971. */
  22972. setPositions(data: Nullable<FloatArray>): void;
  22973. /**
  22974. * Gets the position data stored in this target
  22975. * @returns a FloatArray containing the position data (or null if not present)
  22976. */
  22977. getPositions(): Nullable<FloatArray>;
  22978. /**
  22979. * Affects normal data to this target
  22980. * @param data defines the normal data to use
  22981. */
  22982. setNormals(data: Nullable<FloatArray>): void;
  22983. /**
  22984. * Gets the normal data stored in this target
  22985. * @returns a FloatArray containing the normal data (or null if not present)
  22986. */
  22987. getNormals(): Nullable<FloatArray>;
  22988. /**
  22989. * Affects tangent data to this target
  22990. * @param data defines the tangent data to use
  22991. */
  22992. setTangents(data: Nullable<FloatArray>): void;
  22993. /**
  22994. * Gets the tangent data stored in this target
  22995. * @returns a FloatArray containing the tangent data (or null if not present)
  22996. */
  22997. getTangents(): Nullable<FloatArray>;
  22998. /**
  22999. * Affects texture coordinates data to this target
  23000. * @param data defines the texture coordinates data to use
  23001. */
  23002. setUVs(data: Nullable<FloatArray>): void;
  23003. /**
  23004. * Gets the texture coordinates data stored in this target
  23005. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23006. */
  23007. getUVs(): Nullable<FloatArray>;
  23008. /**
  23009. * Clone the current target
  23010. * @returns a new MorphTarget
  23011. */
  23012. clone(): MorphTarget;
  23013. /**
  23014. * Serializes the current target into a Serialization object
  23015. * @returns the serialized object
  23016. */
  23017. serialize(): any;
  23018. /**
  23019. * Returns the string "MorphTarget"
  23020. * @returns "MorphTarget"
  23021. */
  23022. getClassName(): string;
  23023. /**
  23024. * Creates a new target from serialized data
  23025. * @param serializationObject defines the serialized data to use
  23026. * @returns a new MorphTarget
  23027. */
  23028. static Parse(serializationObject: any): MorphTarget;
  23029. /**
  23030. * Creates a MorphTarget from mesh data
  23031. * @param mesh defines the source mesh
  23032. * @param name defines the name to use for the new target
  23033. * @param influence defines the influence to attach to the target
  23034. * @returns a new MorphTarget
  23035. */
  23036. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23037. }
  23038. }
  23039. declare module "babylonjs/Morph/morphTargetManager" {
  23040. import { Nullable } from "babylonjs/types";
  23041. import { Scene } from "babylonjs/scene";
  23042. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23043. /**
  23044. * This class is used to deform meshes using morphing between different targets
  23045. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23046. */
  23047. export class MorphTargetManager {
  23048. private _targets;
  23049. private _targetInfluenceChangedObservers;
  23050. private _targetDataLayoutChangedObservers;
  23051. private _activeTargets;
  23052. private _scene;
  23053. private _influences;
  23054. private _supportsNormals;
  23055. private _supportsTangents;
  23056. private _supportsUVs;
  23057. private _vertexCount;
  23058. private _uniqueId;
  23059. private _tempInfluences;
  23060. /**
  23061. * Gets or sets a boolean indicating if normals must be morphed
  23062. */
  23063. enableNormalMorphing: boolean;
  23064. /**
  23065. * Gets or sets a boolean indicating if tangents must be morphed
  23066. */
  23067. enableTangentMorphing: boolean;
  23068. /**
  23069. * Gets or sets a boolean indicating if UV must be morphed
  23070. */
  23071. enableUVMorphing: boolean;
  23072. /**
  23073. * Creates a new MorphTargetManager
  23074. * @param scene defines the current scene
  23075. */
  23076. constructor(scene?: Nullable<Scene>);
  23077. /**
  23078. * Gets the unique ID of this manager
  23079. */
  23080. readonly uniqueId: number;
  23081. /**
  23082. * Gets the number of vertices handled by this manager
  23083. */
  23084. readonly vertexCount: number;
  23085. /**
  23086. * Gets a boolean indicating if this manager supports morphing of normals
  23087. */
  23088. readonly supportsNormals: boolean;
  23089. /**
  23090. * Gets a boolean indicating if this manager supports morphing of tangents
  23091. */
  23092. readonly supportsTangents: boolean;
  23093. /**
  23094. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23095. */
  23096. readonly supportsUVs: boolean;
  23097. /**
  23098. * Gets the number of targets stored in this manager
  23099. */
  23100. readonly numTargets: number;
  23101. /**
  23102. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23103. */
  23104. readonly numInfluencers: number;
  23105. /**
  23106. * Gets the list of influences (one per target)
  23107. */
  23108. readonly influences: Float32Array;
  23109. /**
  23110. * Gets the active target at specified index. An active target is a target with an influence > 0
  23111. * @param index defines the index to check
  23112. * @returns the requested target
  23113. */
  23114. getActiveTarget(index: number): MorphTarget;
  23115. /**
  23116. * Gets the target at specified index
  23117. * @param index defines the index to check
  23118. * @returns the requested target
  23119. */
  23120. getTarget(index: number): MorphTarget;
  23121. /**
  23122. * Add a new target to this manager
  23123. * @param target defines the target to add
  23124. */
  23125. addTarget(target: MorphTarget): void;
  23126. /**
  23127. * Removes a target from the manager
  23128. * @param target defines the target to remove
  23129. */
  23130. removeTarget(target: MorphTarget): void;
  23131. /**
  23132. * Clone the current manager
  23133. * @returns a new MorphTargetManager
  23134. */
  23135. clone(): MorphTargetManager;
  23136. /**
  23137. * Serializes the current manager into a Serialization object
  23138. * @returns the serialized object
  23139. */
  23140. serialize(): any;
  23141. private _syncActiveTargets;
  23142. /**
  23143. * Syncrhonize the targets with all the meshes using this morph target manager
  23144. */
  23145. synchronize(): void;
  23146. /**
  23147. * Creates a new MorphTargetManager from serialized data
  23148. * @param serializationObject defines the serialized data
  23149. * @param scene defines the hosting scene
  23150. * @returns the new MorphTargetManager
  23151. */
  23152. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23153. }
  23154. }
  23155. declare module "babylonjs/Meshes/meshLODLevel" {
  23156. import { Mesh } from "babylonjs/Meshes/mesh";
  23157. import { Nullable } from "babylonjs/types";
  23158. /**
  23159. * Class used to represent a specific level of detail of a mesh
  23160. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23161. */
  23162. export class MeshLODLevel {
  23163. /** Defines the distance where this level should start being displayed */
  23164. distance: number;
  23165. /** Defines the mesh to use to render this level */
  23166. mesh: Nullable<Mesh>;
  23167. /**
  23168. * Creates a new LOD level
  23169. * @param distance defines the distance where this level should star being displayed
  23170. * @param mesh defines the mesh to use to render this level
  23171. */
  23172. constructor(
  23173. /** Defines the distance where this level should start being displayed */
  23174. distance: number,
  23175. /** Defines the mesh to use to render this level */
  23176. mesh: Nullable<Mesh>);
  23177. }
  23178. }
  23179. declare module "babylonjs/Meshes/groundMesh" {
  23180. import { Scene } from "babylonjs/scene";
  23181. import { Vector3 } from "babylonjs/Maths/math.vector";
  23182. import { Mesh } from "babylonjs/Meshes/mesh";
  23183. /**
  23184. * Mesh representing the gorund
  23185. */
  23186. export class GroundMesh extends Mesh {
  23187. /** If octree should be generated */
  23188. generateOctree: boolean;
  23189. private _heightQuads;
  23190. /** @hidden */
  23191. _subdivisionsX: number;
  23192. /** @hidden */
  23193. _subdivisionsY: number;
  23194. /** @hidden */
  23195. _width: number;
  23196. /** @hidden */
  23197. _height: number;
  23198. /** @hidden */
  23199. _minX: number;
  23200. /** @hidden */
  23201. _maxX: number;
  23202. /** @hidden */
  23203. _minZ: number;
  23204. /** @hidden */
  23205. _maxZ: number;
  23206. constructor(name: string, scene: Scene);
  23207. /**
  23208. * "GroundMesh"
  23209. * @returns "GroundMesh"
  23210. */
  23211. getClassName(): string;
  23212. /**
  23213. * The minimum of x and y subdivisions
  23214. */
  23215. readonly subdivisions: number;
  23216. /**
  23217. * X subdivisions
  23218. */
  23219. readonly subdivisionsX: number;
  23220. /**
  23221. * Y subdivisions
  23222. */
  23223. readonly subdivisionsY: number;
  23224. /**
  23225. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23226. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23227. * @param chunksCount the number of subdivisions for x and y
  23228. * @param octreeBlocksSize (Default: 32)
  23229. */
  23230. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23231. /**
  23232. * Returns a height (y) value in the Worl system :
  23233. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23234. * @param x x coordinate
  23235. * @param z z coordinate
  23236. * @returns the ground y position if (x, z) are outside the ground surface.
  23237. */
  23238. getHeightAtCoordinates(x: number, z: number): number;
  23239. /**
  23240. * Returns a normalized vector (Vector3) orthogonal to the ground
  23241. * at the ground coordinates (x, z) expressed in the World system.
  23242. * @param x x coordinate
  23243. * @param z z coordinate
  23244. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23245. */
  23246. getNormalAtCoordinates(x: number, z: number): Vector3;
  23247. /**
  23248. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23249. * at the ground coordinates (x, z) expressed in the World system.
  23250. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23251. * @param x x coordinate
  23252. * @param z z coordinate
  23253. * @param ref vector to store the result
  23254. * @returns the GroundMesh.
  23255. */
  23256. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23257. /**
  23258. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23259. * if the ground has been updated.
  23260. * This can be used in the render loop.
  23261. * @returns the GroundMesh.
  23262. */
  23263. updateCoordinateHeights(): GroundMesh;
  23264. private _getFacetAt;
  23265. private _initHeightQuads;
  23266. private _computeHeightQuads;
  23267. /**
  23268. * Serializes this ground mesh
  23269. * @param serializationObject object to write serialization to
  23270. */
  23271. serialize(serializationObject: any): void;
  23272. /**
  23273. * Parses a serialized ground mesh
  23274. * @param parsedMesh the serialized mesh
  23275. * @param scene the scene to create the ground mesh in
  23276. * @returns the created ground mesh
  23277. */
  23278. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23279. }
  23280. }
  23281. declare module "babylonjs/Physics/physicsJoint" {
  23282. import { Vector3 } from "babylonjs/Maths/math.vector";
  23283. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23284. /**
  23285. * Interface for Physics-Joint data
  23286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23287. */
  23288. export interface PhysicsJointData {
  23289. /**
  23290. * The main pivot of the joint
  23291. */
  23292. mainPivot?: Vector3;
  23293. /**
  23294. * The connected pivot of the joint
  23295. */
  23296. connectedPivot?: Vector3;
  23297. /**
  23298. * The main axis of the joint
  23299. */
  23300. mainAxis?: Vector3;
  23301. /**
  23302. * The connected axis of the joint
  23303. */
  23304. connectedAxis?: Vector3;
  23305. /**
  23306. * The collision of the joint
  23307. */
  23308. collision?: boolean;
  23309. /**
  23310. * Native Oimo/Cannon/Energy data
  23311. */
  23312. nativeParams?: any;
  23313. }
  23314. /**
  23315. * This is a holder class for the physics joint created by the physics plugin
  23316. * It holds a set of functions to control the underlying joint
  23317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23318. */
  23319. export class PhysicsJoint {
  23320. /**
  23321. * The type of the physics joint
  23322. */
  23323. type: number;
  23324. /**
  23325. * The data for the physics joint
  23326. */
  23327. jointData: PhysicsJointData;
  23328. private _physicsJoint;
  23329. protected _physicsPlugin: IPhysicsEnginePlugin;
  23330. /**
  23331. * Initializes the physics joint
  23332. * @param type The type of the physics joint
  23333. * @param jointData The data for the physics joint
  23334. */
  23335. constructor(
  23336. /**
  23337. * The type of the physics joint
  23338. */
  23339. type: number,
  23340. /**
  23341. * The data for the physics joint
  23342. */
  23343. jointData: PhysicsJointData);
  23344. /**
  23345. * Gets the physics joint
  23346. */
  23347. /**
  23348. * Sets the physics joint
  23349. */
  23350. physicsJoint: any;
  23351. /**
  23352. * Sets the physics plugin
  23353. */
  23354. physicsPlugin: IPhysicsEnginePlugin;
  23355. /**
  23356. * Execute a function that is physics-plugin specific.
  23357. * @param {Function} func the function that will be executed.
  23358. * It accepts two parameters: the physics world and the physics joint
  23359. */
  23360. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23361. /**
  23362. * Distance-Joint type
  23363. */
  23364. static DistanceJoint: number;
  23365. /**
  23366. * Hinge-Joint type
  23367. */
  23368. static HingeJoint: number;
  23369. /**
  23370. * Ball-and-Socket joint type
  23371. */
  23372. static BallAndSocketJoint: number;
  23373. /**
  23374. * Wheel-Joint type
  23375. */
  23376. static WheelJoint: number;
  23377. /**
  23378. * Slider-Joint type
  23379. */
  23380. static SliderJoint: number;
  23381. /**
  23382. * Prismatic-Joint type
  23383. */
  23384. static PrismaticJoint: number;
  23385. /**
  23386. * Universal-Joint type
  23387. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23388. */
  23389. static UniversalJoint: number;
  23390. /**
  23391. * Hinge-Joint 2 type
  23392. */
  23393. static Hinge2Joint: number;
  23394. /**
  23395. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23396. */
  23397. static PointToPointJoint: number;
  23398. /**
  23399. * Spring-Joint type
  23400. */
  23401. static SpringJoint: number;
  23402. /**
  23403. * Lock-Joint type
  23404. */
  23405. static LockJoint: number;
  23406. }
  23407. /**
  23408. * A class representing a physics distance joint
  23409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23410. */
  23411. export class DistanceJoint extends PhysicsJoint {
  23412. /**
  23413. *
  23414. * @param jointData The data for the Distance-Joint
  23415. */
  23416. constructor(jointData: DistanceJointData);
  23417. /**
  23418. * Update the predefined distance.
  23419. * @param maxDistance The maximum preferred distance
  23420. * @param minDistance The minimum preferred distance
  23421. */
  23422. updateDistance(maxDistance: number, minDistance?: number): void;
  23423. }
  23424. /**
  23425. * Represents a Motor-Enabled Joint
  23426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23427. */
  23428. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23429. /**
  23430. * Initializes the Motor-Enabled Joint
  23431. * @param type The type of the joint
  23432. * @param jointData The physica joint data for the joint
  23433. */
  23434. constructor(type: number, jointData: PhysicsJointData);
  23435. /**
  23436. * Set the motor values.
  23437. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23438. * @param force the force to apply
  23439. * @param maxForce max force for this motor.
  23440. */
  23441. setMotor(force?: number, maxForce?: number): void;
  23442. /**
  23443. * Set the motor's limits.
  23444. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23445. * @param upperLimit The upper limit of the motor
  23446. * @param lowerLimit The lower limit of the motor
  23447. */
  23448. setLimit(upperLimit: number, lowerLimit?: number): void;
  23449. }
  23450. /**
  23451. * This class represents a single physics Hinge-Joint
  23452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23453. */
  23454. export class HingeJoint extends MotorEnabledJoint {
  23455. /**
  23456. * Initializes the Hinge-Joint
  23457. * @param jointData The joint data for the Hinge-Joint
  23458. */
  23459. constructor(jointData: PhysicsJointData);
  23460. /**
  23461. * Set the motor values.
  23462. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23463. * @param {number} force the force to apply
  23464. * @param {number} maxForce max force for this motor.
  23465. */
  23466. setMotor(force?: number, maxForce?: number): void;
  23467. /**
  23468. * Set the motor's limits.
  23469. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23470. * @param upperLimit The upper limit of the motor
  23471. * @param lowerLimit The lower limit of the motor
  23472. */
  23473. setLimit(upperLimit: number, lowerLimit?: number): void;
  23474. }
  23475. /**
  23476. * This class represents a dual hinge physics joint (same as wheel joint)
  23477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23478. */
  23479. export class Hinge2Joint extends MotorEnabledJoint {
  23480. /**
  23481. * Initializes the Hinge2-Joint
  23482. * @param jointData The joint data for the Hinge2-Joint
  23483. */
  23484. constructor(jointData: PhysicsJointData);
  23485. /**
  23486. * Set the motor values.
  23487. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23488. * @param {number} targetSpeed the speed the motor is to reach
  23489. * @param {number} maxForce max force for this motor.
  23490. * @param {motorIndex} the motor's index, 0 or 1.
  23491. */
  23492. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23493. /**
  23494. * Set the motor limits.
  23495. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23496. * @param {number} upperLimit the upper limit
  23497. * @param {number} lowerLimit lower limit
  23498. * @param {motorIndex} the motor's index, 0 or 1.
  23499. */
  23500. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23501. }
  23502. /**
  23503. * Interface for a motor enabled joint
  23504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23505. */
  23506. export interface IMotorEnabledJoint {
  23507. /**
  23508. * Physics joint
  23509. */
  23510. physicsJoint: any;
  23511. /**
  23512. * Sets the motor of the motor-enabled joint
  23513. * @param force The force of the motor
  23514. * @param maxForce The maximum force of the motor
  23515. * @param motorIndex The index of the motor
  23516. */
  23517. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23518. /**
  23519. * Sets the limit of the motor
  23520. * @param upperLimit The upper limit of the motor
  23521. * @param lowerLimit The lower limit of the motor
  23522. * @param motorIndex The index of the motor
  23523. */
  23524. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23525. }
  23526. /**
  23527. * Joint data for a Distance-Joint
  23528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23529. */
  23530. export interface DistanceJointData extends PhysicsJointData {
  23531. /**
  23532. * Max distance the 2 joint objects can be apart
  23533. */
  23534. maxDistance: number;
  23535. }
  23536. /**
  23537. * Joint data from a spring joint
  23538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23539. */
  23540. export interface SpringJointData extends PhysicsJointData {
  23541. /**
  23542. * Length of the spring
  23543. */
  23544. length: number;
  23545. /**
  23546. * Stiffness of the spring
  23547. */
  23548. stiffness: number;
  23549. /**
  23550. * Damping of the spring
  23551. */
  23552. damping: number;
  23553. /** this callback will be called when applying the force to the impostors. */
  23554. forceApplicationCallback: () => void;
  23555. }
  23556. }
  23557. declare module "babylonjs/Physics/physicsRaycastResult" {
  23558. import { Vector3 } from "babylonjs/Maths/math.vector";
  23559. /**
  23560. * Holds the data for the raycast result
  23561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23562. */
  23563. export class PhysicsRaycastResult {
  23564. private _hasHit;
  23565. private _hitDistance;
  23566. private _hitNormalWorld;
  23567. private _hitPointWorld;
  23568. private _rayFromWorld;
  23569. private _rayToWorld;
  23570. /**
  23571. * Gets if there was a hit
  23572. */
  23573. readonly hasHit: boolean;
  23574. /**
  23575. * Gets the distance from the hit
  23576. */
  23577. readonly hitDistance: number;
  23578. /**
  23579. * Gets the hit normal/direction in the world
  23580. */
  23581. readonly hitNormalWorld: Vector3;
  23582. /**
  23583. * Gets the hit point in the world
  23584. */
  23585. readonly hitPointWorld: Vector3;
  23586. /**
  23587. * Gets the ray "start point" of the ray in the world
  23588. */
  23589. readonly rayFromWorld: Vector3;
  23590. /**
  23591. * Gets the ray "end point" of the ray in the world
  23592. */
  23593. readonly rayToWorld: Vector3;
  23594. /**
  23595. * Sets the hit data (normal & point in world space)
  23596. * @param hitNormalWorld defines the normal in world space
  23597. * @param hitPointWorld defines the point in world space
  23598. */
  23599. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23600. /**
  23601. * Sets the distance from the start point to the hit point
  23602. * @param distance
  23603. */
  23604. setHitDistance(distance: number): void;
  23605. /**
  23606. * Calculates the distance manually
  23607. */
  23608. calculateHitDistance(): void;
  23609. /**
  23610. * Resets all the values to default
  23611. * @param from The from point on world space
  23612. * @param to The to point on world space
  23613. */
  23614. reset(from?: Vector3, to?: Vector3): void;
  23615. }
  23616. /**
  23617. * Interface for the size containing width and height
  23618. */
  23619. interface IXYZ {
  23620. /**
  23621. * X
  23622. */
  23623. x: number;
  23624. /**
  23625. * Y
  23626. */
  23627. y: number;
  23628. /**
  23629. * Z
  23630. */
  23631. z: number;
  23632. }
  23633. }
  23634. declare module "babylonjs/Physics/IPhysicsEngine" {
  23635. import { Nullable } from "babylonjs/types";
  23636. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23638. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23639. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23640. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23641. /**
  23642. * Interface used to describe a physics joint
  23643. */
  23644. export interface PhysicsImpostorJoint {
  23645. /** Defines the main impostor to which the joint is linked */
  23646. mainImpostor: PhysicsImpostor;
  23647. /** Defines the impostor that is connected to the main impostor using this joint */
  23648. connectedImpostor: PhysicsImpostor;
  23649. /** Defines the joint itself */
  23650. joint: PhysicsJoint;
  23651. }
  23652. /** @hidden */
  23653. export interface IPhysicsEnginePlugin {
  23654. world: any;
  23655. name: string;
  23656. setGravity(gravity: Vector3): void;
  23657. setTimeStep(timeStep: number): void;
  23658. getTimeStep(): number;
  23659. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23660. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23661. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23662. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23663. removePhysicsBody(impostor: PhysicsImpostor): void;
  23664. generateJoint(joint: PhysicsImpostorJoint): void;
  23665. removeJoint(joint: PhysicsImpostorJoint): void;
  23666. isSupported(): boolean;
  23667. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23668. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23669. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23670. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23671. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23672. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23673. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23674. getBodyMass(impostor: PhysicsImpostor): number;
  23675. getBodyFriction(impostor: PhysicsImpostor): number;
  23676. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23677. getBodyRestitution(impostor: PhysicsImpostor): number;
  23678. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23679. getBodyPressure?(impostor: PhysicsImpostor): number;
  23680. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23681. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23682. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23683. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23684. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23685. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23686. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23687. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23688. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23689. sleepBody(impostor: PhysicsImpostor): void;
  23690. wakeUpBody(impostor: PhysicsImpostor): void;
  23691. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23692. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23693. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23694. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23695. getRadius(impostor: PhysicsImpostor): number;
  23696. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23697. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23698. dispose(): void;
  23699. }
  23700. /**
  23701. * Interface used to define a physics engine
  23702. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23703. */
  23704. export interface IPhysicsEngine {
  23705. /**
  23706. * Gets the gravity vector used by the simulation
  23707. */
  23708. gravity: Vector3;
  23709. /**
  23710. * Sets the gravity vector used by the simulation
  23711. * @param gravity defines the gravity vector to use
  23712. */
  23713. setGravity(gravity: Vector3): void;
  23714. /**
  23715. * Set the time step of the physics engine.
  23716. * Default is 1/60.
  23717. * To slow it down, enter 1/600 for example.
  23718. * To speed it up, 1/30
  23719. * @param newTimeStep the new timestep to apply to this world.
  23720. */
  23721. setTimeStep(newTimeStep: number): void;
  23722. /**
  23723. * Get the time step of the physics engine.
  23724. * @returns the current time step
  23725. */
  23726. getTimeStep(): number;
  23727. /**
  23728. * Release all resources
  23729. */
  23730. dispose(): void;
  23731. /**
  23732. * Gets the name of the current physics plugin
  23733. * @returns the name of the plugin
  23734. */
  23735. getPhysicsPluginName(): string;
  23736. /**
  23737. * Adding a new impostor for the impostor tracking.
  23738. * This will be done by the impostor itself.
  23739. * @param impostor the impostor to add
  23740. */
  23741. addImpostor(impostor: PhysicsImpostor): void;
  23742. /**
  23743. * Remove an impostor from the engine.
  23744. * This impostor and its mesh will not longer be updated by the physics engine.
  23745. * @param impostor the impostor to remove
  23746. */
  23747. removeImpostor(impostor: PhysicsImpostor): void;
  23748. /**
  23749. * Add a joint to the physics engine
  23750. * @param mainImpostor defines the main impostor to which the joint is added.
  23751. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23752. * @param joint defines the joint that will connect both impostors.
  23753. */
  23754. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23755. /**
  23756. * Removes a joint from the simulation
  23757. * @param mainImpostor defines the impostor used with the joint
  23758. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23759. * @param joint defines the joint to remove
  23760. */
  23761. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23762. /**
  23763. * Gets the current plugin used to run the simulation
  23764. * @returns current plugin
  23765. */
  23766. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23767. /**
  23768. * Gets the list of physic impostors
  23769. * @returns an array of PhysicsImpostor
  23770. */
  23771. getImpostors(): Array<PhysicsImpostor>;
  23772. /**
  23773. * Gets the impostor for a physics enabled object
  23774. * @param object defines the object impersonated by the impostor
  23775. * @returns the PhysicsImpostor or null if not found
  23776. */
  23777. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23778. /**
  23779. * Gets the impostor for a physics body object
  23780. * @param body defines physics body used by the impostor
  23781. * @returns the PhysicsImpostor or null if not found
  23782. */
  23783. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23784. /**
  23785. * Does a raycast in the physics world
  23786. * @param from when should the ray start?
  23787. * @param to when should the ray end?
  23788. * @returns PhysicsRaycastResult
  23789. */
  23790. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23791. /**
  23792. * Called by the scene. No need to call it.
  23793. * @param delta defines the timespam between frames
  23794. */
  23795. _step(delta: number): void;
  23796. }
  23797. }
  23798. declare module "babylonjs/Physics/physicsImpostor" {
  23799. import { Nullable, IndicesArray } from "babylonjs/types";
  23800. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23801. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23803. import { Scene } from "babylonjs/scene";
  23804. import { Bone } from "babylonjs/Bones/bone";
  23805. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23806. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23807. import { Space } from "babylonjs/Maths/math.axis";
  23808. /**
  23809. * The interface for the physics imposter parameters
  23810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23811. */
  23812. export interface PhysicsImpostorParameters {
  23813. /**
  23814. * The mass of the physics imposter
  23815. */
  23816. mass: number;
  23817. /**
  23818. * The friction of the physics imposter
  23819. */
  23820. friction?: number;
  23821. /**
  23822. * The coefficient of restitution of the physics imposter
  23823. */
  23824. restitution?: number;
  23825. /**
  23826. * The native options of the physics imposter
  23827. */
  23828. nativeOptions?: any;
  23829. /**
  23830. * Specifies if the parent should be ignored
  23831. */
  23832. ignoreParent?: boolean;
  23833. /**
  23834. * Specifies if bi-directional transformations should be disabled
  23835. */
  23836. disableBidirectionalTransformation?: boolean;
  23837. /**
  23838. * The pressure inside the physics imposter, soft object only
  23839. */
  23840. pressure?: number;
  23841. /**
  23842. * The stiffness the physics imposter, soft object only
  23843. */
  23844. stiffness?: number;
  23845. /**
  23846. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23847. */
  23848. velocityIterations?: number;
  23849. /**
  23850. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23851. */
  23852. positionIterations?: number;
  23853. /**
  23854. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23855. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23856. * Add to fix multiple points
  23857. */
  23858. fixedPoints?: number;
  23859. /**
  23860. * The collision margin around a soft object
  23861. */
  23862. margin?: number;
  23863. /**
  23864. * The collision margin around a soft object
  23865. */
  23866. damping?: number;
  23867. /**
  23868. * The path for a rope based on an extrusion
  23869. */
  23870. path?: any;
  23871. /**
  23872. * The shape of an extrusion used for a rope based on an extrusion
  23873. */
  23874. shape?: any;
  23875. }
  23876. /**
  23877. * Interface for a physics-enabled object
  23878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23879. */
  23880. export interface IPhysicsEnabledObject {
  23881. /**
  23882. * The position of the physics-enabled object
  23883. */
  23884. position: Vector3;
  23885. /**
  23886. * The rotation of the physics-enabled object
  23887. */
  23888. rotationQuaternion: Nullable<Quaternion>;
  23889. /**
  23890. * The scale of the physics-enabled object
  23891. */
  23892. scaling: Vector3;
  23893. /**
  23894. * The rotation of the physics-enabled object
  23895. */
  23896. rotation?: Vector3;
  23897. /**
  23898. * The parent of the physics-enabled object
  23899. */
  23900. parent?: any;
  23901. /**
  23902. * The bounding info of the physics-enabled object
  23903. * @returns The bounding info of the physics-enabled object
  23904. */
  23905. getBoundingInfo(): BoundingInfo;
  23906. /**
  23907. * Computes the world matrix
  23908. * @param force Specifies if the world matrix should be computed by force
  23909. * @returns A world matrix
  23910. */
  23911. computeWorldMatrix(force: boolean): Matrix;
  23912. /**
  23913. * Gets the world matrix
  23914. * @returns A world matrix
  23915. */
  23916. getWorldMatrix?(): Matrix;
  23917. /**
  23918. * Gets the child meshes
  23919. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23920. * @returns An array of abstract meshes
  23921. */
  23922. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23923. /**
  23924. * Gets the vertex data
  23925. * @param kind The type of vertex data
  23926. * @returns A nullable array of numbers, or a float32 array
  23927. */
  23928. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23929. /**
  23930. * Gets the indices from the mesh
  23931. * @returns A nullable array of index arrays
  23932. */
  23933. getIndices?(): Nullable<IndicesArray>;
  23934. /**
  23935. * Gets the scene from the mesh
  23936. * @returns the indices array or null
  23937. */
  23938. getScene?(): Scene;
  23939. /**
  23940. * Gets the absolute position from the mesh
  23941. * @returns the absolute position
  23942. */
  23943. getAbsolutePosition(): Vector3;
  23944. /**
  23945. * Gets the absolute pivot point from the mesh
  23946. * @returns the absolute pivot point
  23947. */
  23948. getAbsolutePivotPoint(): Vector3;
  23949. /**
  23950. * Rotates the mesh
  23951. * @param axis The axis of rotation
  23952. * @param amount The amount of rotation
  23953. * @param space The space of the rotation
  23954. * @returns The rotation transform node
  23955. */
  23956. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23957. /**
  23958. * Translates the mesh
  23959. * @param axis The axis of translation
  23960. * @param distance The distance of translation
  23961. * @param space The space of the translation
  23962. * @returns The transform node
  23963. */
  23964. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23965. /**
  23966. * Sets the absolute position of the mesh
  23967. * @param absolutePosition The absolute position of the mesh
  23968. * @returns The transform node
  23969. */
  23970. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23971. /**
  23972. * Gets the class name of the mesh
  23973. * @returns The class name
  23974. */
  23975. getClassName(): string;
  23976. }
  23977. /**
  23978. * Represents a physics imposter
  23979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23980. */
  23981. export class PhysicsImpostor {
  23982. /**
  23983. * The physics-enabled object used as the physics imposter
  23984. */
  23985. object: IPhysicsEnabledObject;
  23986. /**
  23987. * The type of the physics imposter
  23988. */
  23989. type: number;
  23990. private _options;
  23991. private _scene?;
  23992. /**
  23993. * The default object size of the imposter
  23994. */
  23995. static DEFAULT_OBJECT_SIZE: Vector3;
  23996. /**
  23997. * The identity quaternion of the imposter
  23998. */
  23999. static IDENTITY_QUATERNION: Quaternion;
  24000. /** @hidden */
  24001. _pluginData: any;
  24002. private _physicsEngine;
  24003. private _physicsBody;
  24004. private _bodyUpdateRequired;
  24005. private _onBeforePhysicsStepCallbacks;
  24006. private _onAfterPhysicsStepCallbacks;
  24007. /** @hidden */
  24008. _onPhysicsCollideCallbacks: Array<{
  24009. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24010. otherImpostors: Array<PhysicsImpostor>;
  24011. }>;
  24012. private _deltaPosition;
  24013. private _deltaRotation;
  24014. private _deltaRotationConjugated;
  24015. /** @hidden */
  24016. _isFromLine: boolean;
  24017. private _parent;
  24018. private _isDisposed;
  24019. private static _tmpVecs;
  24020. private static _tmpQuat;
  24021. /**
  24022. * Specifies if the physics imposter is disposed
  24023. */
  24024. readonly isDisposed: boolean;
  24025. /**
  24026. * Gets the mass of the physics imposter
  24027. */
  24028. mass: number;
  24029. /**
  24030. * Gets the coefficient of friction
  24031. */
  24032. /**
  24033. * Sets the coefficient of friction
  24034. */
  24035. friction: number;
  24036. /**
  24037. * Gets the coefficient of restitution
  24038. */
  24039. /**
  24040. * Sets the coefficient of restitution
  24041. */
  24042. restitution: number;
  24043. /**
  24044. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24045. */
  24046. /**
  24047. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24048. */
  24049. pressure: number;
  24050. /**
  24051. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24052. */
  24053. /**
  24054. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24055. */
  24056. stiffness: number;
  24057. /**
  24058. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24059. */
  24060. /**
  24061. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24062. */
  24063. velocityIterations: number;
  24064. /**
  24065. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24066. */
  24067. /**
  24068. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24069. */
  24070. positionIterations: number;
  24071. /**
  24072. * The unique id of the physics imposter
  24073. * set by the physics engine when adding this impostor to the array
  24074. */
  24075. uniqueId: number;
  24076. /**
  24077. * @hidden
  24078. */
  24079. soft: boolean;
  24080. /**
  24081. * @hidden
  24082. */
  24083. segments: number;
  24084. private _joints;
  24085. /**
  24086. * Initializes the physics imposter
  24087. * @param object The physics-enabled object used as the physics imposter
  24088. * @param type The type of the physics imposter
  24089. * @param _options The options for the physics imposter
  24090. * @param _scene The Babylon scene
  24091. */
  24092. constructor(
  24093. /**
  24094. * The physics-enabled object used as the physics imposter
  24095. */
  24096. object: IPhysicsEnabledObject,
  24097. /**
  24098. * The type of the physics imposter
  24099. */
  24100. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24101. /**
  24102. * This function will completly initialize this impostor.
  24103. * It will create a new body - but only if this mesh has no parent.
  24104. * If it has, this impostor will not be used other than to define the impostor
  24105. * of the child mesh.
  24106. * @hidden
  24107. */
  24108. _init(): void;
  24109. private _getPhysicsParent;
  24110. /**
  24111. * Should a new body be generated.
  24112. * @returns boolean specifying if body initialization is required
  24113. */
  24114. isBodyInitRequired(): boolean;
  24115. /**
  24116. * Sets the updated scaling
  24117. * @param updated Specifies if the scaling is updated
  24118. */
  24119. setScalingUpdated(): void;
  24120. /**
  24121. * Force a regeneration of this or the parent's impostor's body.
  24122. * Use under cautious - This will remove all joints already implemented.
  24123. */
  24124. forceUpdate(): void;
  24125. /**
  24126. * Gets the body that holds this impostor. Either its own, or its parent.
  24127. */
  24128. /**
  24129. * Set the physics body. Used mainly by the physics engine/plugin
  24130. */
  24131. physicsBody: any;
  24132. /**
  24133. * Get the parent of the physics imposter
  24134. * @returns Physics imposter or null
  24135. */
  24136. /**
  24137. * Sets the parent of the physics imposter
  24138. */
  24139. parent: Nullable<PhysicsImpostor>;
  24140. /**
  24141. * Resets the update flags
  24142. */
  24143. resetUpdateFlags(): void;
  24144. /**
  24145. * Gets the object extend size
  24146. * @returns the object extend size
  24147. */
  24148. getObjectExtendSize(): Vector3;
  24149. /**
  24150. * Gets the object center
  24151. * @returns The object center
  24152. */
  24153. getObjectCenter(): Vector3;
  24154. /**
  24155. * Get a specific parametes from the options parameter
  24156. * @param paramName The object parameter name
  24157. * @returns The object parameter
  24158. */
  24159. getParam(paramName: string): any;
  24160. /**
  24161. * Sets a specific parameter in the options given to the physics plugin
  24162. * @param paramName The parameter name
  24163. * @param value The value of the parameter
  24164. */
  24165. setParam(paramName: string, value: number): void;
  24166. /**
  24167. * Specifically change the body's mass option. Won't recreate the physics body object
  24168. * @param mass The mass of the physics imposter
  24169. */
  24170. setMass(mass: number): void;
  24171. /**
  24172. * Gets the linear velocity
  24173. * @returns linear velocity or null
  24174. */
  24175. getLinearVelocity(): Nullable<Vector3>;
  24176. /**
  24177. * Sets the linear velocity
  24178. * @param velocity linear velocity or null
  24179. */
  24180. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24181. /**
  24182. * Gets the angular velocity
  24183. * @returns angular velocity or null
  24184. */
  24185. getAngularVelocity(): Nullable<Vector3>;
  24186. /**
  24187. * Sets the angular velocity
  24188. * @param velocity The velocity or null
  24189. */
  24190. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24191. /**
  24192. * Execute a function with the physics plugin native code
  24193. * Provide a function the will have two variables - the world object and the physics body object
  24194. * @param func The function to execute with the physics plugin native code
  24195. */
  24196. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24197. /**
  24198. * Register a function that will be executed before the physics world is stepping forward
  24199. * @param func The function to execute before the physics world is stepped forward
  24200. */
  24201. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24202. /**
  24203. * Unregister a function that will be executed before the physics world is stepping forward
  24204. * @param func The function to execute before the physics world is stepped forward
  24205. */
  24206. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24207. /**
  24208. * Register a function that will be executed after the physics step
  24209. * @param func The function to execute after physics step
  24210. */
  24211. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24212. /**
  24213. * Unregisters a function that will be executed after the physics step
  24214. * @param func The function to execute after physics step
  24215. */
  24216. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24217. /**
  24218. * register a function that will be executed when this impostor collides against a different body
  24219. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24220. * @param func Callback that is executed on collision
  24221. */
  24222. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24223. /**
  24224. * Unregisters the physics imposter on contact
  24225. * @param collideAgainst The physics object to collide against
  24226. * @param func Callback to execute on collision
  24227. */
  24228. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24229. private _tmpQuat;
  24230. private _tmpQuat2;
  24231. /**
  24232. * Get the parent rotation
  24233. * @returns The parent rotation
  24234. */
  24235. getParentsRotation(): Quaternion;
  24236. /**
  24237. * this function is executed by the physics engine.
  24238. */
  24239. beforeStep: () => void;
  24240. /**
  24241. * this function is executed by the physics engine
  24242. */
  24243. afterStep: () => void;
  24244. /**
  24245. * Legacy collision detection event support
  24246. */
  24247. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24248. /**
  24249. * event and body object due to cannon's event-based architecture.
  24250. */
  24251. onCollide: (e: {
  24252. body: any;
  24253. }) => void;
  24254. /**
  24255. * Apply a force
  24256. * @param force The force to apply
  24257. * @param contactPoint The contact point for the force
  24258. * @returns The physics imposter
  24259. */
  24260. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24261. /**
  24262. * Apply an impulse
  24263. * @param force The impulse force
  24264. * @param contactPoint The contact point for the impulse force
  24265. * @returns The physics imposter
  24266. */
  24267. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24268. /**
  24269. * A help function to create a joint
  24270. * @param otherImpostor A physics imposter used to create a joint
  24271. * @param jointType The type of joint
  24272. * @param jointData The data for the joint
  24273. * @returns The physics imposter
  24274. */
  24275. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24276. /**
  24277. * Add a joint to this impostor with a different impostor
  24278. * @param otherImpostor A physics imposter used to add a joint
  24279. * @param joint The joint to add
  24280. * @returns The physics imposter
  24281. */
  24282. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24283. /**
  24284. * Add an anchor to a cloth impostor
  24285. * @param otherImpostor rigid impostor to anchor to
  24286. * @param width ratio across width from 0 to 1
  24287. * @param height ratio up height from 0 to 1
  24288. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24289. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24290. * @returns impostor the soft imposter
  24291. */
  24292. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24293. /**
  24294. * Add a hook to a rope impostor
  24295. * @param otherImpostor rigid impostor to anchor to
  24296. * @param length ratio across rope from 0 to 1
  24297. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24298. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24299. * @returns impostor the rope imposter
  24300. */
  24301. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24302. /**
  24303. * Will keep this body still, in a sleep mode.
  24304. * @returns the physics imposter
  24305. */
  24306. sleep(): PhysicsImpostor;
  24307. /**
  24308. * Wake the body up.
  24309. * @returns The physics imposter
  24310. */
  24311. wakeUp(): PhysicsImpostor;
  24312. /**
  24313. * Clones the physics imposter
  24314. * @param newObject The physics imposter clones to this physics-enabled object
  24315. * @returns A nullable physics imposter
  24316. */
  24317. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24318. /**
  24319. * Disposes the physics imposter
  24320. */
  24321. dispose(): void;
  24322. /**
  24323. * Sets the delta position
  24324. * @param position The delta position amount
  24325. */
  24326. setDeltaPosition(position: Vector3): void;
  24327. /**
  24328. * Sets the delta rotation
  24329. * @param rotation The delta rotation amount
  24330. */
  24331. setDeltaRotation(rotation: Quaternion): void;
  24332. /**
  24333. * Gets the box size of the physics imposter and stores the result in the input parameter
  24334. * @param result Stores the box size
  24335. * @returns The physics imposter
  24336. */
  24337. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24338. /**
  24339. * Gets the radius of the physics imposter
  24340. * @returns Radius of the physics imposter
  24341. */
  24342. getRadius(): number;
  24343. /**
  24344. * Sync a bone with this impostor
  24345. * @param bone The bone to sync to the impostor.
  24346. * @param boneMesh The mesh that the bone is influencing.
  24347. * @param jointPivot The pivot of the joint / bone in local space.
  24348. * @param distToJoint Optional distance from the impostor to the joint.
  24349. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24350. */
  24351. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24352. /**
  24353. * Sync impostor to a bone
  24354. * @param bone The bone that the impostor will be synced to.
  24355. * @param boneMesh The mesh that the bone is influencing.
  24356. * @param jointPivot The pivot of the joint / bone in local space.
  24357. * @param distToJoint Optional distance from the impostor to the joint.
  24358. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24359. * @param boneAxis Optional vector3 axis the bone is aligned with
  24360. */
  24361. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24362. /**
  24363. * No-Imposter type
  24364. */
  24365. static NoImpostor: number;
  24366. /**
  24367. * Sphere-Imposter type
  24368. */
  24369. static SphereImpostor: number;
  24370. /**
  24371. * Box-Imposter type
  24372. */
  24373. static BoxImpostor: number;
  24374. /**
  24375. * Plane-Imposter type
  24376. */
  24377. static PlaneImpostor: number;
  24378. /**
  24379. * Mesh-imposter type
  24380. */
  24381. static MeshImpostor: number;
  24382. /**
  24383. * Capsule-Impostor type (Ammo.js plugin only)
  24384. */
  24385. static CapsuleImpostor: number;
  24386. /**
  24387. * Cylinder-Imposter type
  24388. */
  24389. static CylinderImpostor: number;
  24390. /**
  24391. * Particle-Imposter type
  24392. */
  24393. static ParticleImpostor: number;
  24394. /**
  24395. * Heightmap-Imposter type
  24396. */
  24397. static HeightmapImpostor: number;
  24398. /**
  24399. * ConvexHull-Impostor type (Ammo.js plugin only)
  24400. */
  24401. static ConvexHullImpostor: number;
  24402. /**
  24403. * Rope-Imposter type
  24404. */
  24405. static RopeImpostor: number;
  24406. /**
  24407. * Cloth-Imposter type
  24408. */
  24409. static ClothImpostor: number;
  24410. /**
  24411. * Softbody-Imposter type
  24412. */
  24413. static SoftbodyImpostor: number;
  24414. }
  24415. }
  24416. declare module "babylonjs/Meshes/mesh" {
  24417. import { Observable } from "babylonjs/Misc/observable";
  24418. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24419. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24420. import { Camera } from "babylonjs/Cameras/camera";
  24421. import { Scene } from "babylonjs/scene";
  24422. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24423. import { Color4 } from "babylonjs/Maths/math.color";
  24424. import { Engine } from "babylonjs/Engines/engine";
  24425. import { Node } from "babylonjs/node";
  24426. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24427. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24428. import { Buffer } from "babylonjs/Meshes/buffer";
  24429. import { Geometry } from "babylonjs/Meshes/geometry";
  24430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24431. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24432. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24433. import { Effect } from "babylonjs/Materials/effect";
  24434. import { Material } from "babylonjs/Materials/material";
  24435. import { Skeleton } from "babylonjs/Bones/skeleton";
  24436. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24437. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24438. import { Path3D } from "babylonjs/Maths/math.path";
  24439. import { Plane } from "babylonjs/Maths/math.plane";
  24440. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24441. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24442. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24443. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24444. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24445. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24446. /**
  24447. * @hidden
  24448. **/
  24449. export class _CreationDataStorage {
  24450. closePath?: boolean;
  24451. closeArray?: boolean;
  24452. idx: number[];
  24453. dashSize: number;
  24454. gapSize: number;
  24455. path3D: Path3D;
  24456. pathArray: Vector3[][];
  24457. arc: number;
  24458. radius: number;
  24459. cap: number;
  24460. tessellation: number;
  24461. }
  24462. /**
  24463. * @hidden
  24464. **/
  24465. class _InstanceDataStorage {
  24466. visibleInstances: any;
  24467. batchCache: _InstancesBatch;
  24468. instancesBufferSize: number;
  24469. instancesBuffer: Nullable<Buffer>;
  24470. instancesData: Float32Array;
  24471. overridenInstanceCount: number;
  24472. isFrozen: boolean;
  24473. previousBatch: Nullable<_InstancesBatch>;
  24474. hardwareInstancedRendering: boolean;
  24475. sideOrientation: number;
  24476. manualUpdate: boolean;
  24477. }
  24478. /**
  24479. * @hidden
  24480. **/
  24481. export class _InstancesBatch {
  24482. mustReturn: boolean;
  24483. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24484. renderSelf: boolean[];
  24485. hardwareInstancedRendering: boolean[];
  24486. }
  24487. /**
  24488. * Class used to represent renderable models
  24489. */
  24490. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24491. /**
  24492. * Mesh side orientation : usually the external or front surface
  24493. */
  24494. static readonly FRONTSIDE: number;
  24495. /**
  24496. * Mesh side orientation : usually the internal or back surface
  24497. */
  24498. static readonly BACKSIDE: number;
  24499. /**
  24500. * Mesh side orientation : both internal and external or front and back surfaces
  24501. */
  24502. static readonly DOUBLESIDE: number;
  24503. /**
  24504. * Mesh side orientation : by default, `FRONTSIDE`
  24505. */
  24506. static readonly DEFAULTSIDE: number;
  24507. /**
  24508. * Mesh cap setting : no cap
  24509. */
  24510. static readonly NO_CAP: number;
  24511. /**
  24512. * Mesh cap setting : one cap at the beginning of the mesh
  24513. */
  24514. static readonly CAP_START: number;
  24515. /**
  24516. * Mesh cap setting : one cap at the end of the mesh
  24517. */
  24518. static readonly CAP_END: number;
  24519. /**
  24520. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24521. */
  24522. static readonly CAP_ALL: number;
  24523. /**
  24524. * Mesh pattern setting : no flip or rotate
  24525. */
  24526. static readonly NO_FLIP: number;
  24527. /**
  24528. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24529. */
  24530. static readonly FLIP_TILE: number;
  24531. /**
  24532. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24533. */
  24534. static readonly ROTATE_TILE: number;
  24535. /**
  24536. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24537. */
  24538. static readonly FLIP_ROW: number;
  24539. /**
  24540. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24541. */
  24542. static readonly ROTATE_ROW: number;
  24543. /**
  24544. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24545. */
  24546. static readonly FLIP_N_ROTATE_TILE: number;
  24547. /**
  24548. * Mesh pattern setting : rotate pattern and rotate
  24549. */
  24550. static readonly FLIP_N_ROTATE_ROW: number;
  24551. /**
  24552. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24553. */
  24554. static readonly CENTER: number;
  24555. /**
  24556. * Mesh tile positioning : part tiles on left
  24557. */
  24558. static readonly LEFT: number;
  24559. /**
  24560. * Mesh tile positioning : part tiles on right
  24561. */
  24562. static readonly RIGHT: number;
  24563. /**
  24564. * Mesh tile positioning : part tiles on top
  24565. */
  24566. static readonly TOP: number;
  24567. /**
  24568. * Mesh tile positioning : part tiles on bottom
  24569. */
  24570. static readonly BOTTOM: number;
  24571. /**
  24572. * Gets the default side orientation.
  24573. * @param orientation the orientation to value to attempt to get
  24574. * @returns the default orientation
  24575. * @hidden
  24576. */
  24577. static _GetDefaultSideOrientation(orientation?: number): number;
  24578. private _internalMeshDataInfo;
  24579. /**
  24580. * An event triggered before rendering the mesh
  24581. */
  24582. readonly onBeforeRenderObservable: Observable<Mesh>;
  24583. /**
  24584. * An event triggered before binding the mesh
  24585. */
  24586. readonly onBeforeBindObservable: Observable<Mesh>;
  24587. /**
  24588. * An event triggered after rendering the mesh
  24589. */
  24590. readonly onAfterRenderObservable: Observable<Mesh>;
  24591. /**
  24592. * An event triggered before drawing the mesh
  24593. */
  24594. readonly onBeforeDrawObservable: Observable<Mesh>;
  24595. private _onBeforeDrawObserver;
  24596. /**
  24597. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24598. */
  24599. onBeforeDraw: () => void;
  24600. readonly hasInstances: boolean;
  24601. /**
  24602. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24603. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24604. */
  24605. delayLoadState: number;
  24606. /**
  24607. * Gets the list of instances created from this mesh
  24608. * it is not supposed to be modified manually.
  24609. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24610. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24611. */
  24612. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24613. /**
  24614. * Gets the file containing delay loading data for this mesh
  24615. */
  24616. delayLoadingFile: string;
  24617. /** @hidden */
  24618. _binaryInfo: any;
  24619. /**
  24620. * User defined function used to change how LOD level selection is done
  24621. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24622. */
  24623. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24624. /**
  24625. * Gets or sets the morph target manager
  24626. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24627. */
  24628. morphTargetManager: Nullable<MorphTargetManager>;
  24629. /** @hidden */
  24630. _creationDataStorage: Nullable<_CreationDataStorage>;
  24631. /** @hidden */
  24632. _geometry: Nullable<Geometry>;
  24633. /** @hidden */
  24634. _delayInfo: Array<string>;
  24635. /** @hidden */
  24636. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24637. /** @hidden */
  24638. _instanceDataStorage: _InstanceDataStorage;
  24639. private _effectiveMaterial;
  24640. /** @hidden */
  24641. _shouldGenerateFlatShading: boolean;
  24642. /** @hidden */
  24643. _originalBuilderSideOrientation: number;
  24644. /**
  24645. * Use this property to change the original side orientation defined at construction time
  24646. */
  24647. overrideMaterialSideOrientation: Nullable<number>;
  24648. /**
  24649. * Gets the source mesh (the one used to clone this one from)
  24650. */
  24651. readonly source: Nullable<Mesh>;
  24652. /**
  24653. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24654. */
  24655. isUnIndexed: boolean;
  24656. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24657. readonly worldMatrixInstancedBuffer: Float32Array;
  24658. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24659. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24660. /**
  24661. * @constructor
  24662. * @param name The value used by scene.getMeshByName() to do a lookup.
  24663. * @param scene The scene to add this mesh to.
  24664. * @param parent The parent of this mesh, if it has one
  24665. * @param source An optional Mesh from which geometry is shared, cloned.
  24666. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24667. * When false, achieved by calling a clone(), also passing False.
  24668. * This will make creation of children, recursive.
  24669. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24670. */
  24671. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24672. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24673. doNotInstantiate: boolean;
  24674. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24675. /**
  24676. * Gets the class name
  24677. * @returns the string "Mesh".
  24678. */
  24679. getClassName(): string;
  24680. /** @hidden */
  24681. readonly _isMesh: boolean;
  24682. /**
  24683. * Returns a description of this mesh
  24684. * @param fullDetails define if full details about this mesh must be used
  24685. * @returns a descriptive string representing this mesh
  24686. */
  24687. toString(fullDetails?: boolean): string;
  24688. /** @hidden */
  24689. _unBindEffect(): void;
  24690. /**
  24691. * Gets a boolean indicating if this mesh has LOD
  24692. */
  24693. readonly hasLODLevels: boolean;
  24694. /**
  24695. * Gets the list of MeshLODLevel associated with the current mesh
  24696. * @returns an array of MeshLODLevel
  24697. */
  24698. getLODLevels(): MeshLODLevel[];
  24699. private _sortLODLevels;
  24700. /**
  24701. * Add a mesh as LOD level triggered at the given distance.
  24702. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24703. * @param distance The distance from the center of the object to show this level
  24704. * @param mesh The mesh to be added as LOD level (can be null)
  24705. * @return This mesh (for chaining)
  24706. */
  24707. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24708. /**
  24709. * Returns the LOD level mesh at the passed distance or null if not found.
  24710. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24711. * @param distance The distance from the center of the object to show this level
  24712. * @returns a Mesh or `null`
  24713. */
  24714. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24715. /**
  24716. * Remove a mesh from the LOD array
  24717. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24718. * @param mesh defines the mesh to be removed
  24719. * @return This mesh (for chaining)
  24720. */
  24721. removeLODLevel(mesh: Mesh): Mesh;
  24722. /**
  24723. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24724. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24725. * @param camera defines the camera to use to compute distance
  24726. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24727. * @return This mesh (for chaining)
  24728. */
  24729. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24730. /**
  24731. * Gets the mesh internal Geometry object
  24732. */
  24733. readonly geometry: Nullable<Geometry>;
  24734. /**
  24735. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24736. * @returns the total number of vertices
  24737. */
  24738. getTotalVertices(): number;
  24739. /**
  24740. * Returns the content of an associated vertex buffer
  24741. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24742. * - VertexBuffer.PositionKind
  24743. * - VertexBuffer.UVKind
  24744. * - VertexBuffer.UV2Kind
  24745. * - VertexBuffer.UV3Kind
  24746. * - VertexBuffer.UV4Kind
  24747. * - VertexBuffer.UV5Kind
  24748. * - VertexBuffer.UV6Kind
  24749. * - VertexBuffer.ColorKind
  24750. * - VertexBuffer.MatricesIndicesKind
  24751. * - VertexBuffer.MatricesIndicesExtraKind
  24752. * - VertexBuffer.MatricesWeightsKind
  24753. * - VertexBuffer.MatricesWeightsExtraKind
  24754. * @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
  24755. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24756. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24757. */
  24758. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24759. /**
  24760. * Returns the mesh VertexBuffer object from the requested `kind`
  24761. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24762. * - VertexBuffer.PositionKind
  24763. * - VertexBuffer.NormalKind
  24764. * - VertexBuffer.UVKind
  24765. * - VertexBuffer.UV2Kind
  24766. * - VertexBuffer.UV3Kind
  24767. * - VertexBuffer.UV4Kind
  24768. * - VertexBuffer.UV5Kind
  24769. * - VertexBuffer.UV6Kind
  24770. * - VertexBuffer.ColorKind
  24771. * - VertexBuffer.MatricesIndicesKind
  24772. * - VertexBuffer.MatricesIndicesExtraKind
  24773. * - VertexBuffer.MatricesWeightsKind
  24774. * - VertexBuffer.MatricesWeightsExtraKind
  24775. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24776. */
  24777. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24778. /**
  24779. * Tests if a specific vertex buffer is associated with this mesh
  24780. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24781. * - VertexBuffer.PositionKind
  24782. * - VertexBuffer.NormalKind
  24783. * - VertexBuffer.UVKind
  24784. * - VertexBuffer.UV2Kind
  24785. * - VertexBuffer.UV3Kind
  24786. * - VertexBuffer.UV4Kind
  24787. * - VertexBuffer.UV5Kind
  24788. * - VertexBuffer.UV6Kind
  24789. * - VertexBuffer.ColorKind
  24790. * - VertexBuffer.MatricesIndicesKind
  24791. * - VertexBuffer.MatricesIndicesExtraKind
  24792. * - VertexBuffer.MatricesWeightsKind
  24793. * - VertexBuffer.MatricesWeightsExtraKind
  24794. * @returns a boolean
  24795. */
  24796. isVerticesDataPresent(kind: string): boolean;
  24797. /**
  24798. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24799. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24800. * - VertexBuffer.PositionKind
  24801. * - VertexBuffer.UVKind
  24802. * - VertexBuffer.UV2Kind
  24803. * - VertexBuffer.UV3Kind
  24804. * - VertexBuffer.UV4Kind
  24805. * - VertexBuffer.UV5Kind
  24806. * - VertexBuffer.UV6Kind
  24807. * - VertexBuffer.ColorKind
  24808. * - VertexBuffer.MatricesIndicesKind
  24809. * - VertexBuffer.MatricesIndicesExtraKind
  24810. * - VertexBuffer.MatricesWeightsKind
  24811. * - VertexBuffer.MatricesWeightsExtraKind
  24812. * @returns a boolean
  24813. */
  24814. isVertexBufferUpdatable(kind: string): boolean;
  24815. /**
  24816. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24817. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24818. * - VertexBuffer.PositionKind
  24819. * - VertexBuffer.NormalKind
  24820. * - VertexBuffer.UVKind
  24821. * - VertexBuffer.UV2Kind
  24822. * - VertexBuffer.UV3Kind
  24823. * - VertexBuffer.UV4Kind
  24824. * - VertexBuffer.UV5Kind
  24825. * - VertexBuffer.UV6Kind
  24826. * - VertexBuffer.ColorKind
  24827. * - VertexBuffer.MatricesIndicesKind
  24828. * - VertexBuffer.MatricesIndicesExtraKind
  24829. * - VertexBuffer.MatricesWeightsKind
  24830. * - VertexBuffer.MatricesWeightsExtraKind
  24831. * @returns an array of strings
  24832. */
  24833. getVerticesDataKinds(): string[];
  24834. /**
  24835. * Returns a positive integer : the total number of indices in this mesh geometry.
  24836. * @returns the numner of indices or zero if the mesh has no geometry.
  24837. */
  24838. getTotalIndices(): number;
  24839. /**
  24840. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24841. * @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.
  24842. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24843. * @returns the indices array or an empty array if the mesh has no geometry
  24844. */
  24845. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24846. readonly isBlocked: boolean;
  24847. /**
  24848. * Determine if the current mesh is ready to be rendered
  24849. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24850. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24851. * @returns true if all associated assets are ready (material, textures, shaders)
  24852. */
  24853. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24854. /**
  24855. * 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.
  24856. */
  24857. readonly areNormalsFrozen: boolean;
  24858. /**
  24859. * 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.
  24860. * @returns the current mesh
  24861. */
  24862. freezeNormals(): Mesh;
  24863. /**
  24864. * 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
  24865. * @returns the current mesh
  24866. */
  24867. unfreezeNormals(): Mesh;
  24868. /**
  24869. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24870. */
  24871. overridenInstanceCount: number;
  24872. /** @hidden */
  24873. _preActivate(): Mesh;
  24874. /** @hidden */
  24875. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24876. /** @hidden */
  24877. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24878. /**
  24879. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24880. * This means the mesh underlying bounding box and sphere are recomputed.
  24881. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24882. * @returns the current mesh
  24883. */
  24884. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24885. /** @hidden */
  24886. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24887. /**
  24888. * This function will subdivide the mesh into multiple submeshes
  24889. * @param count defines the expected number of submeshes
  24890. */
  24891. subdivide(count: number): void;
  24892. /**
  24893. * Copy a FloatArray into a specific associated vertex buffer
  24894. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24895. * - VertexBuffer.PositionKind
  24896. * - VertexBuffer.UVKind
  24897. * - VertexBuffer.UV2Kind
  24898. * - VertexBuffer.UV3Kind
  24899. * - VertexBuffer.UV4Kind
  24900. * - VertexBuffer.UV5Kind
  24901. * - VertexBuffer.UV6Kind
  24902. * - VertexBuffer.ColorKind
  24903. * - VertexBuffer.MatricesIndicesKind
  24904. * - VertexBuffer.MatricesIndicesExtraKind
  24905. * - VertexBuffer.MatricesWeightsKind
  24906. * - VertexBuffer.MatricesWeightsExtraKind
  24907. * @param data defines the data source
  24908. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24909. * @param stride defines the data stride size (can be null)
  24910. * @returns the current mesh
  24911. */
  24912. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24913. /**
  24914. * Delete a vertex buffer associated with this mesh
  24915. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24916. * - VertexBuffer.PositionKind
  24917. * - VertexBuffer.UVKind
  24918. * - VertexBuffer.UV2Kind
  24919. * - VertexBuffer.UV3Kind
  24920. * - VertexBuffer.UV4Kind
  24921. * - VertexBuffer.UV5Kind
  24922. * - VertexBuffer.UV6Kind
  24923. * - VertexBuffer.ColorKind
  24924. * - VertexBuffer.MatricesIndicesKind
  24925. * - VertexBuffer.MatricesIndicesExtraKind
  24926. * - VertexBuffer.MatricesWeightsKind
  24927. * - VertexBuffer.MatricesWeightsExtraKind
  24928. */
  24929. removeVerticesData(kind: string): void;
  24930. /**
  24931. * Flags an associated vertex buffer as updatable
  24932. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24933. * - VertexBuffer.PositionKind
  24934. * - VertexBuffer.UVKind
  24935. * - VertexBuffer.UV2Kind
  24936. * - VertexBuffer.UV3Kind
  24937. * - VertexBuffer.UV4Kind
  24938. * - VertexBuffer.UV5Kind
  24939. * - VertexBuffer.UV6Kind
  24940. * - VertexBuffer.ColorKind
  24941. * - VertexBuffer.MatricesIndicesKind
  24942. * - VertexBuffer.MatricesIndicesExtraKind
  24943. * - VertexBuffer.MatricesWeightsKind
  24944. * - VertexBuffer.MatricesWeightsExtraKind
  24945. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24946. */
  24947. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24948. /**
  24949. * Sets the mesh global Vertex Buffer
  24950. * @param buffer defines the buffer to use
  24951. * @returns the current mesh
  24952. */
  24953. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24954. /**
  24955. * Update a specific associated vertex buffer
  24956. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24957. * - VertexBuffer.PositionKind
  24958. * - VertexBuffer.UVKind
  24959. * - VertexBuffer.UV2Kind
  24960. * - VertexBuffer.UV3Kind
  24961. * - VertexBuffer.UV4Kind
  24962. * - VertexBuffer.UV5Kind
  24963. * - VertexBuffer.UV6Kind
  24964. * - VertexBuffer.ColorKind
  24965. * - VertexBuffer.MatricesIndicesKind
  24966. * - VertexBuffer.MatricesIndicesExtraKind
  24967. * - VertexBuffer.MatricesWeightsKind
  24968. * - VertexBuffer.MatricesWeightsExtraKind
  24969. * @param data defines the data source
  24970. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24971. * @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)
  24972. * @returns the current mesh
  24973. */
  24974. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24975. /**
  24976. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24977. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24978. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24979. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24980. * @returns the current mesh
  24981. */
  24982. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24983. /**
  24984. * Creates a un-shared specific occurence of the geometry for the mesh.
  24985. * @returns the current mesh
  24986. */
  24987. makeGeometryUnique(): Mesh;
  24988. /**
  24989. * Set the index buffer of this mesh
  24990. * @param indices defines the source data
  24991. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24992. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24993. * @returns the current mesh
  24994. */
  24995. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24996. /**
  24997. * Update the current index buffer
  24998. * @param indices defines the source data
  24999. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25000. * @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)
  25001. * @returns the current mesh
  25002. */
  25003. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25004. /**
  25005. * Invert the geometry to move from a right handed system to a left handed one.
  25006. * @returns the current mesh
  25007. */
  25008. toLeftHanded(): Mesh;
  25009. /** @hidden */
  25010. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25011. /** @hidden */
  25012. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25013. /**
  25014. * Registers for this mesh a javascript function called just before the rendering process
  25015. * @param func defines the function to call before rendering this mesh
  25016. * @returns the current mesh
  25017. */
  25018. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25019. /**
  25020. * Disposes a previously registered javascript function called before the rendering
  25021. * @param func defines the function to remove
  25022. * @returns the current mesh
  25023. */
  25024. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25025. /**
  25026. * Registers for this mesh a javascript function called just after the rendering is complete
  25027. * @param func defines the function to call after rendering this mesh
  25028. * @returns the current mesh
  25029. */
  25030. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25031. /**
  25032. * Disposes a previously registered javascript function called after the rendering.
  25033. * @param func defines the function to remove
  25034. * @returns the current mesh
  25035. */
  25036. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25037. /** @hidden */
  25038. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25039. /** @hidden */
  25040. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25041. /** @hidden */
  25042. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25043. /** @hidden */
  25044. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25045. /** @hidden */
  25046. _rebuild(): void;
  25047. /** @hidden */
  25048. _freeze(): void;
  25049. /** @hidden */
  25050. _unFreeze(): void;
  25051. /**
  25052. * 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
  25053. * @param subMesh defines the subMesh to render
  25054. * @param enableAlphaMode defines if alpha mode can be changed
  25055. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25056. * @returns the current mesh
  25057. */
  25058. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25059. private _onBeforeDraw;
  25060. /**
  25061. * Renormalize the mesh and patch it up if there are no weights
  25062. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25063. * However in the case of zero weights then we set just a single influence to 1.
  25064. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25065. */
  25066. cleanMatrixWeights(): void;
  25067. private normalizeSkinFourWeights;
  25068. private normalizeSkinWeightsAndExtra;
  25069. /**
  25070. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25071. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25072. * the user know there was an issue with importing the mesh
  25073. * @returns a validation object with skinned, valid and report string
  25074. */
  25075. validateSkinning(): {
  25076. skinned: boolean;
  25077. valid: boolean;
  25078. report: string;
  25079. };
  25080. /** @hidden */
  25081. _checkDelayState(): Mesh;
  25082. private _queueLoad;
  25083. /**
  25084. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25085. * A mesh is in the frustum if its bounding box intersects the frustum
  25086. * @param frustumPlanes defines the frustum to test
  25087. * @returns true if the mesh is in the frustum planes
  25088. */
  25089. isInFrustum(frustumPlanes: Plane[]): boolean;
  25090. /**
  25091. * Sets the mesh material by the material or multiMaterial `id` property
  25092. * @param id is a string identifying the material or the multiMaterial
  25093. * @returns the current mesh
  25094. */
  25095. setMaterialByID(id: string): Mesh;
  25096. /**
  25097. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25098. * @returns an array of IAnimatable
  25099. */
  25100. getAnimatables(): IAnimatable[];
  25101. /**
  25102. * Modifies the mesh geometry according to the passed transformation matrix.
  25103. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25104. * The mesh normals are modified using the same transformation.
  25105. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25106. * @param transform defines the transform matrix to use
  25107. * @see http://doc.babylonjs.com/resources/baking_transformations
  25108. * @returns the current mesh
  25109. */
  25110. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25111. /**
  25112. * Modifies the mesh geometry according to its own current World Matrix.
  25113. * The mesh World Matrix is then reset.
  25114. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25115. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25116. * @see http://doc.babylonjs.com/resources/baking_transformations
  25117. * @returns the current mesh
  25118. */
  25119. bakeCurrentTransformIntoVertices(): Mesh;
  25120. /** @hidden */
  25121. readonly _positions: Nullable<Vector3[]>;
  25122. /** @hidden */
  25123. _resetPointsArrayCache(): Mesh;
  25124. /** @hidden */
  25125. _generatePointsArray(): boolean;
  25126. /**
  25127. * Returns a new Mesh object generated from the current mesh properties.
  25128. * This method must not get confused with createInstance()
  25129. * @param name is a string, the name given to the new mesh
  25130. * @param newParent can be any Node object (default `null`)
  25131. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25132. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25133. * @returns a new mesh
  25134. */
  25135. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25136. /**
  25137. * Releases resources associated with this mesh.
  25138. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25139. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25140. */
  25141. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25142. /** @hidden */
  25143. _disposeInstanceSpecificData(): void;
  25144. /**
  25145. * Modifies the mesh geometry according to a displacement map.
  25146. * 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.
  25147. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25148. * @param url is a string, the URL from the image file is to be downloaded.
  25149. * @param minHeight is the lower limit of the displacement.
  25150. * @param maxHeight is the upper limit of the displacement.
  25151. * @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.
  25152. * @param uvOffset is an optional vector2 used to offset UV.
  25153. * @param uvScale is an optional vector2 used to scale UV.
  25154. * @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.
  25155. * @returns the Mesh.
  25156. */
  25157. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25158. /**
  25159. * Modifies the mesh geometry according to a displacementMap buffer.
  25160. * 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.
  25161. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25162. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25163. * @param heightMapWidth is the width of the buffer image.
  25164. * @param heightMapHeight is the height of the buffer image.
  25165. * @param minHeight is the lower limit of the displacement.
  25166. * @param maxHeight is the upper limit of the displacement.
  25167. * @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.
  25168. * @param uvOffset is an optional vector2 used to offset UV.
  25169. * @param uvScale is an optional vector2 used to scale UV.
  25170. * @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.
  25171. * @returns the Mesh.
  25172. */
  25173. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25174. /**
  25175. * Modify the mesh to get a flat shading rendering.
  25176. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25177. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25178. * @returns current mesh
  25179. */
  25180. convertToFlatShadedMesh(): Mesh;
  25181. /**
  25182. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25183. * In other words, more vertices, no more indices and a single bigger VBO.
  25184. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25185. * @returns current mesh
  25186. */
  25187. convertToUnIndexedMesh(): Mesh;
  25188. /**
  25189. * Inverses facet orientations.
  25190. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25191. * @param flipNormals will also inverts the normals
  25192. * @returns current mesh
  25193. */
  25194. flipFaces(flipNormals?: boolean): Mesh;
  25195. /**
  25196. * Increase the number of facets and hence vertices in a mesh
  25197. * Vertex normals are interpolated from existing vertex normals
  25198. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25199. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25200. */
  25201. increaseVertices(numberPerEdge: number): void;
  25202. /**
  25203. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25204. * This will undo any application of covertToFlatShadedMesh
  25205. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25206. */
  25207. forceSharedVertices(): void;
  25208. /** @hidden */
  25209. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25210. /** @hidden */
  25211. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25212. /**
  25213. * Creates a new InstancedMesh object from the mesh model.
  25214. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25215. * @param name defines the name of the new instance
  25216. * @returns a new InstancedMesh
  25217. */
  25218. createInstance(name: string): InstancedMesh;
  25219. /**
  25220. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25221. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25222. * @returns the current mesh
  25223. */
  25224. synchronizeInstances(): Mesh;
  25225. /**
  25226. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25227. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25228. * This should be used together with the simplification to avoid disappearing triangles.
  25229. * @param successCallback an optional success callback to be called after the optimization finished.
  25230. * @returns the current mesh
  25231. */
  25232. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25233. /**
  25234. * Serialize current mesh
  25235. * @param serializationObject defines the object which will receive the serialization data
  25236. */
  25237. serialize(serializationObject: any): void;
  25238. /** @hidden */
  25239. _syncGeometryWithMorphTargetManager(): void;
  25240. /** @hidden */
  25241. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25242. /**
  25243. * Returns a new Mesh object parsed from the source provided.
  25244. * @param parsedMesh is the source
  25245. * @param scene defines the hosting scene
  25246. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25247. * @returns a new Mesh
  25248. */
  25249. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25250. /**
  25251. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25252. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25253. * @param name defines the name of the mesh to create
  25254. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25255. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25256. * @param closePath creates a seam between the first and the last points of each path of the path array
  25257. * @param offset is taken in account only if the `pathArray` is containing a single path
  25258. * @param scene defines the hosting scene
  25259. * @param updatable defines if the mesh must be flagged as updatable
  25260. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25261. * @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)
  25262. * @returns a new Mesh
  25263. */
  25264. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25265. /**
  25266. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25267. * @param name defines the name of the mesh to create
  25268. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25269. * @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
  25270. * @param scene defines the hosting scene
  25271. * @param updatable defines if the mesh must be flagged as updatable
  25272. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25273. * @returns a new Mesh
  25274. */
  25275. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25276. /**
  25277. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25278. * @param name defines the name of the mesh to create
  25279. * @param size sets the size (float) of each box side (default 1)
  25280. * @param scene defines the hosting scene
  25281. * @param updatable defines if the mesh must be flagged as updatable
  25282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25283. * @returns a new Mesh
  25284. */
  25285. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25286. /**
  25287. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25288. * @param name defines the name of the mesh to create
  25289. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25290. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25291. * @param scene defines the hosting scene
  25292. * @param updatable defines if the mesh must be flagged as updatable
  25293. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25294. * @returns a new Mesh
  25295. */
  25296. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25297. /**
  25298. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25299. * @param name defines the name of the mesh to create
  25300. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25301. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25302. * @param scene defines the hosting scene
  25303. * @returns a new Mesh
  25304. */
  25305. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25306. /**
  25307. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25308. * @param name defines the name of the mesh to create
  25309. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25310. * @param diameterTop set the top cap diameter (floats, default 1)
  25311. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25312. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25313. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25314. * @param scene defines the hosting scene
  25315. * @param updatable defines if the mesh must be flagged as updatable
  25316. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25317. * @returns a new Mesh
  25318. */
  25319. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25320. /**
  25321. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25322. * @param name defines the name of the mesh to create
  25323. * @param diameter sets the diameter size (float) of the torus (default 1)
  25324. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25325. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25326. * @param scene defines the hosting scene
  25327. * @param updatable defines if the mesh must be flagged as updatable
  25328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25329. * @returns a new Mesh
  25330. */
  25331. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25332. /**
  25333. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25334. * @param name defines the name of the mesh to create
  25335. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25336. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25337. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25338. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25339. * @param p the number of windings on X axis (positive integers, default 2)
  25340. * @param q the number of windings on Y axis (positive integers, default 3)
  25341. * @param scene defines the hosting scene
  25342. * @param updatable defines if the mesh must be flagged as updatable
  25343. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25344. * @returns a new Mesh
  25345. */
  25346. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25347. /**
  25348. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25349. * @param name defines the name of the mesh to create
  25350. * @param points is an array successive Vector3
  25351. * @param scene defines the hosting scene
  25352. * @param updatable defines if the mesh must be flagged as updatable
  25353. * @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).
  25354. * @returns a new Mesh
  25355. */
  25356. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25357. /**
  25358. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25359. * @param name defines the name of the mesh to create
  25360. * @param points is an array successive Vector3
  25361. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25362. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25363. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25364. * @param scene defines the hosting scene
  25365. * @param updatable defines if the mesh must be flagged as updatable
  25366. * @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)
  25367. * @returns a new Mesh
  25368. */
  25369. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25370. /**
  25371. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25372. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25373. * 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.
  25374. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25375. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25376. * Remember you can only change the shape positions, not their number when updating a polygon.
  25377. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25378. * @param name defines the name of the mesh to create
  25379. * @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
  25380. * @param scene defines the hosting scene
  25381. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25382. * @param updatable defines if the mesh must be flagged as updatable
  25383. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25384. * @param earcutInjection can be used to inject your own earcut reference
  25385. * @returns a new Mesh
  25386. */
  25387. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25388. /**
  25389. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25390. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25391. * @param name defines the name of the mesh to create
  25392. * @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
  25393. * @param depth defines the height of extrusion
  25394. * @param scene defines the hosting scene
  25395. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25396. * @param updatable defines if the mesh must be flagged as updatable
  25397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25398. * @param earcutInjection can be used to inject your own earcut reference
  25399. * @returns a new Mesh
  25400. */
  25401. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25402. /**
  25403. * Creates an extruded shape mesh.
  25404. * 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
  25405. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25406. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25407. * @param name defines the name of the mesh to create
  25408. * @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
  25409. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25410. * @param scale is the value to scale the shape
  25411. * @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
  25412. * @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
  25413. * @param scene defines the hosting scene
  25414. * @param updatable defines if the mesh must be flagged as updatable
  25415. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25416. * @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)
  25417. * @returns a new Mesh
  25418. */
  25419. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25420. /**
  25421. * Creates an custom extruded shape mesh.
  25422. * The custom extrusion is a parametric shape.
  25423. * It has no predefined shape. Its final shape will depend on the input parameters.
  25424. * Please consider using the same method from the MeshBuilder class instead
  25425. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25426. * @param name defines the name of the mesh to create
  25427. * @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
  25428. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25429. * @param scaleFunction is a custom Javascript function called on each path point
  25430. * @param rotationFunction is a custom Javascript function called on each path point
  25431. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25432. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25433. * @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
  25434. * @param scene defines the hosting scene
  25435. * @param updatable defines if the mesh must be flagged as updatable
  25436. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25437. * @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)
  25438. * @returns a new Mesh
  25439. */
  25440. 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;
  25441. /**
  25442. * Creates lathe mesh.
  25443. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25444. * Please consider using the same method from the MeshBuilder class instead
  25445. * @param name defines the name of the mesh to create
  25446. * @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
  25447. * @param radius is the radius value of the lathe
  25448. * @param tessellation is the side number of the lathe.
  25449. * @param scene defines the hosting scene
  25450. * @param updatable defines if the mesh must be flagged as updatable
  25451. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25452. * @returns a new Mesh
  25453. */
  25454. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25455. /**
  25456. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25457. * @param name defines the name of the mesh to create
  25458. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25459. * @param scene defines the hosting scene
  25460. * @param updatable defines if the mesh must be flagged as updatable
  25461. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25462. * @returns a new Mesh
  25463. */
  25464. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25465. /**
  25466. * Creates a ground mesh.
  25467. * Please consider using the same method from the MeshBuilder class instead
  25468. * @param name defines the name of the mesh to create
  25469. * @param width set the width of the ground
  25470. * @param height set the height of the ground
  25471. * @param subdivisions sets the number of subdivisions per side
  25472. * @param scene defines the hosting scene
  25473. * @param updatable defines if the mesh must be flagged as updatable
  25474. * @returns a new Mesh
  25475. */
  25476. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25477. /**
  25478. * Creates a tiled ground mesh.
  25479. * Please consider using the same method from the MeshBuilder class instead
  25480. * @param name defines the name of the mesh to create
  25481. * @param xmin set the ground minimum X coordinate
  25482. * @param zmin set the ground minimum Y coordinate
  25483. * @param xmax set the ground maximum X coordinate
  25484. * @param zmax set the ground maximum Z coordinate
  25485. * @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
  25486. * @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
  25487. * @param scene defines the hosting scene
  25488. * @param updatable defines if the mesh must be flagged as updatable
  25489. * @returns a new Mesh
  25490. */
  25491. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25492. w: number;
  25493. h: number;
  25494. }, precision: {
  25495. w: number;
  25496. h: number;
  25497. }, scene: Scene, updatable?: boolean): Mesh;
  25498. /**
  25499. * Creates a ground mesh from a height map.
  25500. * Please consider using the same method from the MeshBuilder class instead
  25501. * @see http://doc.babylonjs.com/babylon101/height_map
  25502. * @param name defines the name of the mesh to create
  25503. * @param url sets the URL of the height map image resource
  25504. * @param width set the ground width size
  25505. * @param height set the ground height size
  25506. * @param subdivisions sets the number of subdivision per side
  25507. * @param minHeight is the minimum altitude on the ground
  25508. * @param maxHeight is the maximum altitude on the ground
  25509. * @param scene defines the hosting scene
  25510. * @param updatable defines if the mesh must be flagged as updatable
  25511. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25512. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25513. * @returns a new Mesh
  25514. */
  25515. 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;
  25516. /**
  25517. * Creates a tube mesh.
  25518. * The tube is a parametric shape.
  25519. * It has no predefined shape. Its final shape will depend on the input parameters.
  25520. * Please consider using the same method from the MeshBuilder class instead
  25521. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25522. * @param name defines the name of the mesh to create
  25523. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25524. * @param radius sets the tube radius size
  25525. * @param tessellation is the number of sides on the tubular surface
  25526. * @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
  25527. * @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
  25528. * @param scene defines the hosting scene
  25529. * @param updatable defines if the mesh must be flagged as updatable
  25530. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25531. * @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)
  25532. * @returns a new Mesh
  25533. */
  25534. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25535. (i: number, distance: number): number;
  25536. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25537. /**
  25538. * Creates a polyhedron mesh.
  25539. * Please consider using the same method from the MeshBuilder class instead.
  25540. * * 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
  25541. * * The parameter `size` (positive float, default 1) sets the polygon size
  25542. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25543. * * 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`
  25544. * * 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
  25545. * * 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)`)
  25546. * * 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
  25547. * * 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
  25548. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25549. * * If you create a double-sided mesh, you can choose what parts of 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
  25550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25551. * @param name defines the name of the mesh to create
  25552. * @param options defines the options used to create the mesh
  25553. * @param scene defines the hosting scene
  25554. * @returns a new Mesh
  25555. */
  25556. static CreatePolyhedron(name: string, options: {
  25557. type?: number;
  25558. size?: number;
  25559. sizeX?: number;
  25560. sizeY?: number;
  25561. sizeZ?: number;
  25562. custom?: any;
  25563. faceUV?: Vector4[];
  25564. faceColors?: Color4[];
  25565. updatable?: boolean;
  25566. sideOrientation?: number;
  25567. }, scene: Scene): Mesh;
  25568. /**
  25569. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25570. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25571. * * 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`)
  25572. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25573. * * 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
  25574. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25575. * * If you create a double-sided mesh, you can choose what parts of 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
  25576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25577. * @param name defines the name of the mesh
  25578. * @param options defines the options used to create the mesh
  25579. * @param scene defines the hosting scene
  25580. * @returns a new Mesh
  25581. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25582. */
  25583. static CreateIcoSphere(name: string, options: {
  25584. radius?: number;
  25585. flat?: boolean;
  25586. subdivisions?: number;
  25587. sideOrientation?: number;
  25588. updatable?: boolean;
  25589. }, scene: Scene): Mesh;
  25590. /**
  25591. * Creates a decal mesh.
  25592. * Please consider using the same method from the MeshBuilder class instead.
  25593. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25594. * @param name defines the name of the mesh
  25595. * @param sourceMesh defines the mesh receiving the decal
  25596. * @param position sets the position of the decal in world coordinates
  25597. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25598. * @param size sets the decal scaling
  25599. * @param angle sets the angle to rotate the decal
  25600. * @returns a new Mesh
  25601. */
  25602. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25603. /**
  25604. * Prepare internal position array for software CPU skinning
  25605. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25606. */
  25607. setPositionsForCPUSkinning(): Float32Array;
  25608. /**
  25609. * Prepare internal normal array for software CPU skinning
  25610. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25611. */
  25612. setNormalsForCPUSkinning(): Float32Array;
  25613. /**
  25614. * Updates the vertex buffer by applying transformation from the bones
  25615. * @param skeleton defines the skeleton to apply to current mesh
  25616. * @returns the current mesh
  25617. */
  25618. applySkeleton(skeleton: Skeleton): Mesh;
  25619. /**
  25620. * 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
  25621. * @param meshes defines the list of meshes to scan
  25622. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25623. */
  25624. static MinMax(meshes: AbstractMesh[]): {
  25625. min: Vector3;
  25626. max: Vector3;
  25627. };
  25628. /**
  25629. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25630. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25631. * @returns a vector3
  25632. */
  25633. static Center(meshesOrMinMaxVector: {
  25634. min: Vector3;
  25635. max: Vector3;
  25636. } | AbstractMesh[]): Vector3;
  25637. /**
  25638. * Merge the array of meshes into a single mesh for performance reasons.
  25639. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25640. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25641. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25642. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25643. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25644. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25645. * @returns a new mesh
  25646. */
  25647. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25648. /** @hidden */
  25649. addInstance(instance: InstancedMesh): void;
  25650. /** @hidden */
  25651. removeInstance(instance: InstancedMesh): void;
  25652. }
  25653. }
  25654. declare module "babylonjs/Cameras/camera" {
  25655. import { SmartArray } from "babylonjs/Misc/smartArray";
  25656. import { Observable } from "babylonjs/Misc/observable";
  25657. import { Nullable } from "babylonjs/types";
  25658. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25659. import { Scene } from "babylonjs/scene";
  25660. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25661. import { Node } from "babylonjs/node";
  25662. import { Mesh } from "babylonjs/Meshes/mesh";
  25663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25664. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25665. import { Viewport } from "babylonjs/Maths/math.viewport";
  25666. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25667. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25668. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25669. import { Ray } from "babylonjs/Culling/ray";
  25670. /**
  25671. * This is the base class of all the camera used in the application.
  25672. * @see http://doc.babylonjs.com/features/cameras
  25673. */
  25674. export class Camera extends Node {
  25675. /** @hidden */
  25676. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25677. /**
  25678. * This is the default projection mode used by the cameras.
  25679. * It helps recreating a feeling of perspective and better appreciate depth.
  25680. * This is the best way to simulate real life cameras.
  25681. */
  25682. static readonly PERSPECTIVE_CAMERA: number;
  25683. /**
  25684. * This helps creating camera with an orthographic mode.
  25685. * 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.
  25686. */
  25687. static readonly ORTHOGRAPHIC_CAMERA: number;
  25688. /**
  25689. * This is the default FOV mode for perspective cameras.
  25690. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25691. */
  25692. static readonly FOVMODE_VERTICAL_FIXED: number;
  25693. /**
  25694. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25695. */
  25696. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25697. /**
  25698. * This specifies ther is no need for a camera rig.
  25699. * Basically only one eye is rendered corresponding to the camera.
  25700. */
  25701. static readonly RIG_MODE_NONE: number;
  25702. /**
  25703. * Simulates a camera Rig with one blue eye and one red eye.
  25704. * This can be use with 3d blue and red glasses.
  25705. */
  25706. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25707. /**
  25708. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25709. */
  25710. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25711. /**
  25712. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25713. */
  25714. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25715. /**
  25716. * Defines that both eyes of the camera will be rendered over under each other.
  25717. */
  25718. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25719. /**
  25720. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25721. */
  25722. static readonly RIG_MODE_VR: number;
  25723. /**
  25724. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25725. */
  25726. static readonly RIG_MODE_WEBVR: number;
  25727. /**
  25728. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25729. */
  25730. static readonly RIG_MODE_CUSTOM: number;
  25731. /**
  25732. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25733. */
  25734. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25735. /**
  25736. * Define the input manager associated with the camera.
  25737. */
  25738. inputs: CameraInputsManager<Camera>;
  25739. /** @hidden */
  25740. _position: Vector3;
  25741. /**
  25742. * Define the current local position of the camera in the scene
  25743. */
  25744. position: Vector3;
  25745. /**
  25746. * The vector the camera should consider as up.
  25747. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25748. */
  25749. upVector: Vector3;
  25750. /**
  25751. * Define the current limit on the left side for an orthographic camera
  25752. * In scene unit
  25753. */
  25754. orthoLeft: Nullable<number>;
  25755. /**
  25756. * Define the current limit on the right side for an orthographic camera
  25757. * In scene unit
  25758. */
  25759. orthoRight: Nullable<number>;
  25760. /**
  25761. * Define the current limit on the bottom side for an orthographic camera
  25762. * In scene unit
  25763. */
  25764. orthoBottom: Nullable<number>;
  25765. /**
  25766. * Define the current limit on the top side for an orthographic camera
  25767. * In scene unit
  25768. */
  25769. orthoTop: Nullable<number>;
  25770. /**
  25771. * Field Of View is set in Radians. (default is 0.8)
  25772. */
  25773. fov: number;
  25774. /**
  25775. * Define the minimum distance the camera can see from.
  25776. * This is important to note that the depth buffer are not infinite and the closer it starts
  25777. * the more your scene might encounter depth fighting issue.
  25778. */
  25779. minZ: number;
  25780. /**
  25781. * Define the maximum distance the camera can see to.
  25782. * This is important to note that the depth buffer are not infinite and the further it end
  25783. * the more your scene might encounter depth fighting issue.
  25784. */
  25785. maxZ: number;
  25786. /**
  25787. * Define the default inertia of the camera.
  25788. * This helps giving a smooth feeling to the camera movement.
  25789. */
  25790. inertia: number;
  25791. /**
  25792. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25793. */
  25794. mode: number;
  25795. /**
  25796. * Define wether the camera is intermediate.
  25797. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25798. */
  25799. isIntermediate: boolean;
  25800. /**
  25801. * Define the viewport of the camera.
  25802. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25803. */
  25804. viewport: Viewport;
  25805. /**
  25806. * Restricts the camera to viewing objects with the same layerMask.
  25807. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25808. */
  25809. layerMask: number;
  25810. /**
  25811. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25812. */
  25813. fovMode: number;
  25814. /**
  25815. * Rig mode of the camera.
  25816. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25817. * This is normally controlled byt the camera themselves as internal use.
  25818. */
  25819. cameraRigMode: number;
  25820. /**
  25821. * Defines the distance between both "eyes" in case of a RIG
  25822. */
  25823. interaxialDistance: number;
  25824. /**
  25825. * Defines if stereoscopic rendering is done side by side or over under.
  25826. */
  25827. isStereoscopicSideBySide: boolean;
  25828. /**
  25829. * 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
  25830. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25831. * else in the scene. (Eg. security camera)
  25832. *
  25833. * 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)
  25834. */
  25835. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25836. /**
  25837. * When set, the camera will render to this render target instead of the default canvas
  25838. *
  25839. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25840. */
  25841. outputRenderTarget: Nullable<RenderTargetTexture>;
  25842. /**
  25843. * Observable triggered when the camera view matrix has changed.
  25844. */
  25845. onViewMatrixChangedObservable: Observable<Camera>;
  25846. /**
  25847. * Observable triggered when the camera Projection matrix has changed.
  25848. */
  25849. onProjectionMatrixChangedObservable: Observable<Camera>;
  25850. /**
  25851. * Observable triggered when the inputs have been processed.
  25852. */
  25853. onAfterCheckInputsObservable: Observable<Camera>;
  25854. /**
  25855. * Observable triggered when reset has been called and applied to the camera.
  25856. */
  25857. onRestoreStateObservable: Observable<Camera>;
  25858. /** @hidden */
  25859. _cameraRigParams: any;
  25860. /** @hidden */
  25861. _rigCameras: Camera[];
  25862. /** @hidden */
  25863. _rigPostProcess: Nullable<PostProcess>;
  25864. protected _webvrViewMatrix: Matrix;
  25865. /** @hidden */
  25866. _skipRendering: boolean;
  25867. /** @hidden */
  25868. _projectionMatrix: Matrix;
  25869. /** @hidden */
  25870. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25871. /** @hidden */
  25872. _activeMeshes: SmartArray<AbstractMesh>;
  25873. protected _globalPosition: Vector3;
  25874. /** @hidden */
  25875. _computedViewMatrix: Matrix;
  25876. private _doNotComputeProjectionMatrix;
  25877. private _transformMatrix;
  25878. private _frustumPlanes;
  25879. private _refreshFrustumPlanes;
  25880. private _storedFov;
  25881. private _stateStored;
  25882. /**
  25883. * Instantiates a new camera object.
  25884. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25885. * @see http://doc.babylonjs.com/features/cameras
  25886. * @param name Defines the name of the camera in the scene
  25887. * @param position Defines the position of the camera
  25888. * @param scene Defines the scene the camera belongs too
  25889. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25890. */
  25891. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25892. /**
  25893. * Store current camera state (fov, position, etc..)
  25894. * @returns the camera
  25895. */
  25896. storeState(): Camera;
  25897. /**
  25898. * Restores the camera state values if it has been stored. You must call storeState() first
  25899. */
  25900. protected _restoreStateValues(): boolean;
  25901. /**
  25902. * Restored camera state. You must call storeState() first.
  25903. * @returns true if restored and false otherwise
  25904. */
  25905. restoreState(): boolean;
  25906. /**
  25907. * Gets the class name of the camera.
  25908. * @returns the class name
  25909. */
  25910. getClassName(): string;
  25911. /** @hidden */
  25912. readonly _isCamera: boolean;
  25913. /**
  25914. * Gets a string representation of the camera useful for debug purpose.
  25915. * @param fullDetails Defines that a more verboe level of logging is required
  25916. * @returns the string representation
  25917. */
  25918. toString(fullDetails?: boolean): string;
  25919. /**
  25920. * Gets the current world space position of the camera.
  25921. */
  25922. readonly globalPosition: Vector3;
  25923. /**
  25924. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25925. * @returns the active meshe list
  25926. */
  25927. getActiveMeshes(): SmartArray<AbstractMesh>;
  25928. /**
  25929. * Check wether a mesh is part of the current active mesh list of the camera
  25930. * @param mesh Defines the mesh to check
  25931. * @returns true if active, false otherwise
  25932. */
  25933. isActiveMesh(mesh: Mesh): boolean;
  25934. /**
  25935. * Is this camera ready to be used/rendered
  25936. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25937. * @return true if the camera is ready
  25938. */
  25939. isReady(completeCheck?: boolean): boolean;
  25940. /** @hidden */
  25941. _initCache(): void;
  25942. /** @hidden */
  25943. _updateCache(ignoreParentClass?: boolean): void;
  25944. /** @hidden */
  25945. _isSynchronized(): boolean;
  25946. /** @hidden */
  25947. _isSynchronizedViewMatrix(): boolean;
  25948. /** @hidden */
  25949. _isSynchronizedProjectionMatrix(): boolean;
  25950. /**
  25951. * Attach the input controls to a specific dom element to get the input from.
  25952. * @param element Defines the element the controls should be listened from
  25953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25954. */
  25955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25956. /**
  25957. * Detach the current controls from the specified dom element.
  25958. * @param element Defines the element to stop listening the inputs from
  25959. */
  25960. detachControl(element: HTMLElement): void;
  25961. /**
  25962. * Update the camera state according to the different inputs gathered during the frame.
  25963. */
  25964. update(): void;
  25965. /** @hidden */
  25966. _checkInputs(): void;
  25967. /** @hidden */
  25968. readonly rigCameras: Camera[];
  25969. /**
  25970. * Gets the post process used by the rig cameras
  25971. */
  25972. readonly rigPostProcess: Nullable<PostProcess>;
  25973. /**
  25974. * Internal, gets the first post proces.
  25975. * @returns the first post process to be run on this camera.
  25976. */
  25977. _getFirstPostProcess(): Nullable<PostProcess>;
  25978. private _cascadePostProcessesToRigCams;
  25979. /**
  25980. * Attach a post process to the camera.
  25981. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25982. * @param postProcess The post process to attach to the camera
  25983. * @param insertAt The position of the post process in case several of them are in use in the scene
  25984. * @returns the position the post process has been inserted at
  25985. */
  25986. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25987. /**
  25988. * Detach a post process to the camera.
  25989. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25990. * @param postProcess The post process to detach from the camera
  25991. */
  25992. detachPostProcess(postProcess: PostProcess): void;
  25993. /**
  25994. * Gets the current world matrix of the camera
  25995. */
  25996. getWorldMatrix(): Matrix;
  25997. /** @hidden */
  25998. _getViewMatrix(): Matrix;
  25999. /**
  26000. * Gets the current view matrix of the camera.
  26001. * @param force forces the camera to recompute the matrix without looking at the cached state
  26002. * @returns the view matrix
  26003. */
  26004. getViewMatrix(force?: boolean): Matrix;
  26005. /**
  26006. * Freeze the projection matrix.
  26007. * It will prevent the cache check of the camera projection compute and can speed up perf
  26008. * if no parameter of the camera are meant to change
  26009. * @param projection Defines manually a projection if necessary
  26010. */
  26011. freezeProjectionMatrix(projection?: Matrix): void;
  26012. /**
  26013. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26014. */
  26015. unfreezeProjectionMatrix(): void;
  26016. /**
  26017. * Gets the current projection matrix of the camera.
  26018. * @param force forces the camera to recompute the matrix without looking at the cached state
  26019. * @returns the projection matrix
  26020. */
  26021. getProjectionMatrix(force?: boolean): Matrix;
  26022. /**
  26023. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26024. * @returns a Matrix
  26025. */
  26026. getTransformationMatrix(): Matrix;
  26027. private _updateFrustumPlanes;
  26028. /**
  26029. * Checks if a cullable object (mesh...) is in the camera frustum
  26030. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26031. * @param target The object to check
  26032. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26033. * @returns true if the object is in frustum otherwise false
  26034. */
  26035. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26036. /**
  26037. * Checks if a cullable object (mesh...) is in the camera frustum
  26038. * Unlike isInFrustum this cheks the full bounding box
  26039. * @param target The object to check
  26040. * @returns true if the object is in frustum otherwise false
  26041. */
  26042. isCompletelyInFrustum(target: ICullable): boolean;
  26043. /**
  26044. * Gets a ray in the forward direction from the camera.
  26045. * @param length Defines the length of the ray to create
  26046. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26047. * @param origin Defines the start point of the ray which defaults to the camera position
  26048. * @returns the forward ray
  26049. */
  26050. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26051. /**
  26052. * Releases resources associated with this node.
  26053. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26054. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26055. */
  26056. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26057. /** @hidden */
  26058. _isLeftCamera: boolean;
  26059. /**
  26060. * Gets the left camera of a rig setup in case of Rigged Camera
  26061. */
  26062. readonly isLeftCamera: boolean;
  26063. /** @hidden */
  26064. _isRightCamera: boolean;
  26065. /**
  26066. * Gets the right camera of a rig setup in case of Rigged Camera
  26067. */
  26068. readonly isRightCamera: boolean;
  26069. /**
  26070. * Gets the left camera of a rig setup in case of Rigged Camera
  26071. */
  26072. readonly leftCamera: Nullable<FreeCamera>;
  26073. /**
  26074. * Gets the right camera of a rig setup in case of Rigged Camera
  26075. */
  26076. readonly rightCamera: Nullable<FreeCamera>;
  26077. /**
  26078. * Gets the left camera target of a rig setup in case of Rigged Camera
  26079. * @returns the target position
  26080. */
  26081. getLeftTarget(): Nullable<Vector3>;
  26082. /**
  26083. * Gets the right camera target of a rig setup in case of Rigged Camera
  26084. * @returns the target position
  26085. */
  26086. getRightTarget(): Nullable<Vector3>;
  26087. /**
  26088. * @hidden
  26089. */
  26090. setCameraRigMode(mode: number, rigParams: any): void;
  26091. /** @hidden */
  26092. static _setStereoscopicRigMode(camera: Camera): void;
  26093. /** @hidden */
  26094. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26095. /** @hidden */
  26096. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26097. /** @hidden */
  26098. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26099. /** @hidden */
  26100. _getVRProjectionMatrix(): Matrix;
  26101. protected _updateCameraRotationMatrix(): void;
  26102. protected _updateWebVRCameraRotationMatrix(): void;
  26103. /**
  26104. * This function MUST be overwritten by the different WebVR cameras available.
  26105. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26106. * @hidden
  26107. */
  26108. _getWebVRProjectionMatrix(): Matrix;
  26109. /**
  26110. * This function MUST be overwritten by the different WebVR cameras available.
  26111. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26112. * @hidden
  26113. */
  26114. _getWebVRViewMatrix(): Matrix;
  26115. /** @hidden */
  26116. setCameraRigParameter(name: string, value: any): void;
  26117. /**
  26118. * needs to be overridden by children so sub has required properties to be copied
  26119. * @hidden
  26120. */
  26121. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26122. /**
  26123. * May need to be overridden by children
  26124. * @hidden
  26125. */
  26126. _updateRigCameras(): void;
  26127. /** @hidden */
  26128. _setupInputs(): void;
  26129. /**
  26130. * Serialiaze the camera setup to a json represention
  26131. * @returns the JSON representation
  26132. */
  26133. serialize(): any;
  26134. /**
  26135. * Clones the current camera.
  26136. * @param name The cloned camera name
  26137. * @returns the cloned camera
  26138. */
  26139. clone(name: string): Camera;
  26140. /**
  26141. * Gets the direction of the camera relative to a given local axis.
  26142. * @param localAxis Defines the reference axis to provide a relative direction.
  26143. * @return the direction
  26144. */
  26145. getDirection(localAxis: Vector3): Vector3;
  26146. /**
  26147. * Returns the current camera absolute rotation
  26148. */
  26149. readonly absoluteRotation: Quaternion;
  26150. /**
  26151. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26152. * @param localAxis Defines the reference axis to provide a relative direction.
  26153. * @param result Defines the vector to store the result in
  26154. */
  26155. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26156. /**
  26157. * Gets a camera constructor for a given camera type
  26158. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26159. * @param name The name of the camera the result will be able to instantiate
  26160. * @param scene The scene the result will construct the camera in
  26161. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26162. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26163. * @returns a factory method to construc the camera
  26164. */
  26165. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26166. /**
  26167. * Compute the world matrix of the camera.
  26168. * @returns the camera world matrix
  26169. */
  26170. computeWorldMatrix(): Matrix;
  26171. /**
  26172. * Parse a JSON and creates the camera from the parsed information
  26173. * @param parsedCamera The JSON to parse
  26174. * @param scene The scene to instantiate the camera in
  26175. * @returns the newly constructed camera
  26176. */
  26177. static Parse(parsedCamera: any, scene: Scene): Camera;
  26178. }
  26179. }
  26180. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26181. import { Nullable } from "babylonjs/types";
  26182. import { Scene } from "babylonjs/scene";
  26183. import { Vector4 } from "babylonjs/Maths/math.vector";
  26184. import { Mesh } from "babylonjs/Meshes/mesh";
  26185. /**
  26186. * Class containing static functions to help procedurally build meshes
  26187. */
  26188. export class DiscBuilder {
  26189. /**
  26190. * Creates a plane polygonal mesh. By default, this is a disc
  26191. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26192. * * 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
  26193. * * 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
  26194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26197. * @param name defines the name of the mesh
  26198. * @param options defines the options used to create the mesh
  26199. * @param scene defines the hosting scene
  26200. * @returns the plane polygonal mesh
  26201. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26202. */
  26203. static CreateDisc(name: string, options: {
  26204. radius?: number;
  26205. tessellation?: number;
  26206. arc?: number;
  26207. updatable?: boolean;
  26208. sideOrientation?: number;
  26209. frontUVs?: Vector4;
  26210. backUVs?: Vector4;
  26211. }, scene?: Nullable<Scene>): Mesh;
  26212. }
  26213. }
  26214. declare module "babylonjs/Particles/solidParticleSystem" {
  26215. import { Nullable } from "babylonjs/types";
  26216. import { Vector3 } from "babylonjs/Maths/math.vector";
  26217. import { Mesh } from "babylonjs/Meshes/mesh";
  26218. import { Scene, IDisposable } from "babylonjs/scene";
  26219. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26220. /**
  26221. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26222. *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.
  26223. * The SPS is also a particle system. It provides some methods to manage the particles.
  26224. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26225. *
  26226. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26227. */
  26228. export class SolidParticleSystem implements IDisposable {
  26229. /**
  26230. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26231. * Example : var p = SPS.particles[i];
  26232. */
  26233. particles: SolidParticle[];
  26234. /**
  26235. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26236. */
  26237. nbParticles: number;
  26238. /**
  26239. * If the particles must ever face the camera (default false). Useful for planar particles.
  26240. */
  26241. billboard: boolean;
  26242. /**
  26243. * Recompute normals when adding a shape
  26244. */
  26245. recomputeNormals: boolean;
  26246. /**
  26247. * This a counter ofr your own usage. It's not set by any SPS functions.
  26248. */
  26249. counter: number;
  26250. /**
  26251. * The SPS name. This name is also given to the underlying mesh.
  26252. */
  26253. name: string;
  26254. /**
  26255. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26256. */
  26257. mesh: Mesh;
  26258. /**
  26259. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26260. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26261. */
  26262. vars: any;
  26263. /**
  26264. * This array is populated when the SPS is set as 'pickable'.
  26265. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26266. * Each element of this array is an object `{idx: int, faceId: int}`.
  26267. * `idx` is the picked particle index in the `SPS.particles` array
  26268. * `faceId` is the picked face index counted within this particle.
  26269. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26270. */
  26271. pickedParticles: {
  26272. idx: number;
  26273. faceId: number;
  26274. }[];
  26275. /**
  26276. * This array is populated when `enableDepthSort` is set to true.
  26277. * Each element of this array is an instance of the class DepthSortedParticle.
  26278. */
  26279. depthSortedParticles: DepthSortedParticle[];
  26280. /**
  26281. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26282. * @hidden
  26283. */
  26284. _bSphereOnly: boolean;
  26285. /**
  26286. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26287. * @hidden
  26288. */
  26289. _bSphereRadiusFactor: number;
  26290. private _scene;
  26291. private _positions;
  26292. private _indices;
  26293. private _normals;
  26294. private _colors;
  26295. private _uvs;
  26296. private _indices32;
  26297. private _positions32;
  26298. private _normals32;
  26299. private _fixedNormal32;
  26300. private _colors32;
  26301. private _uvs32;
  26302. private _index;
  26303. private _updatable;
  26304. private _pickable;
  26305. private _isVisibilityBoxLocked;
  26306. private _alwaysVisible;
  26307. private _depthSort;
  26308. private _expandable;
  26309. private _shapeCounter;
  26310. private _copy;
  26311. private _color;
  26312. private _computeParticleColor;
  26313. private _computeParticleTexture;
  26314. private _computeParticleRotation;
  26315. private _computeParticleVertex;
  26316. private _computeBoundingBox;
  26317. private _depthSortParticles;
  26318. private _camera;
  26319. private _mustUnrotateFixedNormals;
  26320. private _particlesIntersect;
  26321. private _needs32Bits;
  26322. private _isNotBuilt;
  26323. private _lastParticleId;
  26324. private _idxOfId;
  26325. /**
  26326. * Creates a SPS (Solid Particle System) object.
  26327. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26328. * @param scene (Scene) is the scene in which the SPS is added.
  26329. * @param options defines the options of the sps e.g.
  26330. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26331. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26332. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26333. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26334. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26335. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26336. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26337. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26338. */
  26339. constructor(name: string, scene: Scene, options?: {
  26340. updatable?: boolean;
  26341. isPickable?: boolean;
  26342. enableDepthSort?: boolean;
  26343. particleIntersection?: boolean;
  26344. boundingSphereOnly?: boolean;
  26345. bSphereRadiusFactor?: number;
  26346. expandable?: boolean;
  26347. });
  26348. /**
  26349. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26350. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26351. * @returns the created mesh
  26352. */
  26353. buildMesh(): Mesh;
  26354. /**
  26355. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26356. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26357. * Thus the particles generated from `digest()` have their property `position` set yet.
  26358. * @param mesh ( Mesh ) is the mesh to be digested
  26359. * @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
  26360. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26361. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26362. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26363. * @returns the current SPS
  26364. */
  26365. digest(mesh: Mesh, options?: {
  26366. facetNb?: number;
  26367. number?: number;
  26368. delta?: number;
  26369. storage?: [];
  26370. }): SolidParticleSystem;
  26371. /**
  26372. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26373. * @hidden
  26374. */
  26375. private _unrotateFixedNormals;
  26376. /**
  26377. * Resets the temporary working copy particle
  26378. * @hidden
  26379. */
  26380. private _resetCopy;
  26381. /**
  26382. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26383. * @param p the current index in the positions array to be updated
  26384. * @param shape a Vector3 array, the shape geometry
  26385. * @param positions the positions array to be updated
  26386. * @param meshInd the shape indices array
  26387. * @param indices the indices array to be updated
  26388. * @param meshUV the shape uv array
  26389. * @param uvs the uv array to be updated
  26390. * @param meshCol the shape color array
  26391. * @param colors the color array to be updated
  26392. * @param meshNor the shape normals array
  26393. * @param normals the normals array to be updated
  26394. * @param idx the particle index
  26395. * @param idxInShape the particle index in its shape
  26396. * @param options the addShape() method passed options
  26397. * @hidden
  26398. */
  26399. private _meshBuilder;
  26400. /**
  26401. * Returns a shape Vector3 array from positions float array
  26402. * @param positions float array
  26403. * @returns a vector3 array
  26404. * @hidden
  26405. */
  26406. private _posToShape;
  26407. /**
  26408. * Returns a shapeUV array from a float uvs (array deep copy)
  26409. * @param uvs as a float array
  26410. * @returns a shapeUV array
  26411. * @hidden
  26412. */
  26413. private _uvsToShapeUV;
  26414. /**
  26415. * Adds a new particle object in the particles array
  26416. * @param idx particle index in particles array
  26417. * @param id particle id
  26418. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26419. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26420. * @param model particle ModelShape object
  26421. * @param shapeId model shape identifier
  26422. * @param idxInShape index of the particle in the current model
  26423. * @param bInfo model bounding info object
  26424. * @param storage target storage array, if any
  26425. * @hidden
  26426. */
  26427. private _addParticle;
  26428. /**
  26429. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26430. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26431. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26432. * @param nb (positive integer) the number of particles to be created from this model
  26433. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26434. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26435. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26436. * @returns the number of shapes in the system
  26437. */
  26438. addShape(mesh: Mesh, nb: number, options?: {
  26439. positionFunction?: any;
  26440. vertexFunction?: any;
  26441. storage?: [];
  26442. }): number;
  26443. /**
  26444. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26445. * @hidden
  26446. */
  26447. private _rebuildParticle;
  26448. /**
  26449. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26450. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  26451. * @returns the SPS.
  26452. */
  26453. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26454. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26455. * Returns an array with the removed particles.
  26456. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  26457. * The SPS can't be empty so at least one particle needs to remain in place.
  26458. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26459. * @param start index of the first particle to remove
  26460. * @param end index of the last particle to remove (included)
  26461. * @returns an array populated with the removed particles
  26462. */
  26463. removeParticles(start: number, end: number): SolidParticle[];
  26464. /**
  26465. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26466. * @param solidParticleArray an array populated with Solid Particles objects
  26467. * @returns the SPS
  26468. */
  26469. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26470. /**
  26471. * Creates a new particle and modifies the SPS mesh geometry :
  26472. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26473. * - calls _addParticle() to populate the particle array
  26474. * factorized code from addShape() and insertParticlesFromArray()
  26475. * @param idx particle index in the particles array
  26476. * @param i particle index in its shape
  26477. * @param modelShape particle ModelShape object
  26478. * @param shape shape vertex array
  26479. * @param meshInd shape indices array
  26480. * @param meshUV shape uv array
  26481. * @param meshCol shape color array
  26482. * @param meshNor shape normals array
  26483. * @param bbInfo shape bounding info
  26484. * @param storage target particle storage
  26485. * @options addShape() passed options
  26486. * @hidden
  26487. */
  26488. private _insertNewParticle;
  26489. /**
  26490. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26491. * This method calls `updateParticle()` for each particle of the SPS.
  26492. * For an animated SPS, it is usually called within the render loop.
  26493. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  26494. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26495. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26496. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26497. * @returns the SPS.
  26498. */
  26499. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26500. /**
  26501. * Disposes the SPS.
  26502. */
  26503. dispose(): void;
  26504. /**
  26505. * Returns a SolidParticle object from its identifier : particle.id
  26506. * @param id (integer) the particle Id
  26507. * @returns the searched particle or null if not found in the SPS.
  26508. */
  26509. getParticleById(id: number): Nullable<SolidParticle>;
  26510. /**
  26511. * Returns a new array populated with the particles having the passed shapeId.
  26512. * @param shapeId (integer) the shape identifier
  26513. * @returns a new solid particle array
  26514. */
  26515. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26516. /**
  26517. * Populates the passed array "ref" with the particles having the passed shapeId.
  26518. * @param shapeId the shape identifier
  26519. * @returns the SPS
  26520. * @param ref
  26521. */
  26522. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26523. /**
  26524. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26525. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26526. * @returns the SPS.
  26527. */
  26528. refreshVisibleSize(): SolidParticleSystem;
  26529. /**
  26530. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26531. * @param size the size (float) of the visibility box
  26532. * note : this doesn't lock the SPS mesh bounding box.
  26533. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26534. */
  26535. setVisibilityBox(size: number): void;
  26536. /**
  26537. * Gets whether the SPS as always visible or not
  26538. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26539. */
  26540. /**
  26541. * Sets the SPS as always visible or not
  26542. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26543. */
  26544. isAlwaysVisible: boolean;
  26545. /**
  26546. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26547. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26548. */
  26549. /**
  26550. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26551. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26552. */
  26553. isVisibilityBoxLocked: boolean;
  26554. /**
  26555. * Tells to `setParticles()` to compute the particle rotations or not.
  26556. * Default value : true. The SPS is faster when it's set to false.
  26557. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26558. */
  26559. /**
  26560. * Gets if `setParticles()` computes the particle rotations or not.
  26561. * Default value : true. The SPS is faster when it's set to false.
  26562. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26563. */
  26564. computeParticleRotation: boolean;
  26565. /**
  26566. * Tells to `setParticles()` to compute the particle colors or not.
  26567. * Default value : true. The SPS is faster when it's set to false.
  26568. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26569. */
  26570. /**
  26571. * Gets if `setParticles()` computes the particle colors or not.
  26572. * Default value : true. The SPS is faster when it's set to false.
  26573. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26574. */
  26575. computeParticleColor: boolean;
  26576. /**
  26577. * Gets if `setParticles()` computes the particle textures or not.
  26578. * Default value : true. The SPS is faster when it's set to false.
  26579. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26580. */
  26581. computeParticleTexture: boolean;
  26582. /**
  26583. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26584. * Default value : false. The SPS is faster when it's set to false.
  26585. * Note : the particle custom vertex positions aren't stored values.
  26586. */
  26587. /**
  26588. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26589. * Default value : false. The SPS is faster when it's set to false.
  26590. * Note : the particle custom vertex positions aren't stored values.
  26591. */
  26592. computeParticleVertex: boolean;
  26593. /**
  26594. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26595. */
  26596. /**
  26597. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26598. */
  26599. computeBoundingBox: boolean;
  26600. /**
  26601. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26602. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26603. * Default : `true`
  26604. */
  26605. /**
  26606. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26607. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26608. * Default : `true`
  26609. */
  26610. depthSortParticles: boolean;
  26611. /**
  26612. * Gets if the SPS is created as expandable at construction time.
  26613. * Default : `false`
  26614. */
  26615. readonly expandable: boolean;
  26616. /**
  26617. * This function does nothing. It may be overwritten to set all the particle first values.
  26618. * The SPS doesn't call this function, you may have to call it by your own.
  26619. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26620. */
  26621. initParticles(): void;
  26622. /**
  26623. * This function does nothing. It may be overwritten to recycle a particle.
  26624. * The SPS doesn't call this function, you may have to call it by your own.
  26625. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26626. * @param particle The particle to recycle
  26627. * @returns the recycled particle
  26628. */
  26629. recycleParticle(particle: SolidParticle): SolidParticle;
  26630. /**
  26631. * Updates a particle : this function should be overwritten by the user.
  26632. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26633. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26634. * @example : just set a particle position or velocity and recycle conditions
  26635. * @param particle The particle to update
  26636. * @returns the updated particle
  26637. */
  26638. updateParticle(particle: SolidParticle): SolidParticle;
  26639. /**
  26640. * Updates a vertex of a particle : it can be overwritten by the user.
  26641. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26642. * @param particle the current particle
  26643. * @param vertex the current index of the current particle
  26644. * @param pt the index of the current vertex in the particle shape
  26645. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26646. * @example : just set a vertex particle position
  26647. * @returns the updated vertex
  26648. */
  26649. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26650. /**
  26651. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26652. * This does nothing and may be overwritten by the user.
  26653. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26654. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26655. * @param update the boolean update value actually passed to setParticles()
  26656. */
  26657. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26658. /**
  26659. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26660. * This will be passed three parameters.
  26661. * This does nothing and may be overwritten by the user.
  26662. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26663. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26664. * @param update the boolean update value actually passed to setParticles()
  26665. */
  26666. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26667. }
  26668. }
  26669. declare module "babylonjs/Particles/solidParticle" {
  26670. import { Nullable } from "babylonjs/types";
  26671. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26672. import { Color4 } from "babylonjs/Maths/math.color";
  26673. import { Mesh } from "babylonjs/Meshes/mesh";
  26674. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26675. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26676. import { Plane } from "babylonjs/Maths/math.plane";
  26677. /**
  26678. * Represents one particle of a solid particle system.
  26679. */
  26680. export class SolidParticle {
  26681. /**
  26682. * particle global index
  26683. */
  26684. idx: number;
  26685. /**
  26686. * particle identifier
  26687. */
  26688. id: number;
  26689. /**
  26690. * The color of the particle
  26691. */
  26692. color: Nullable<Color4>;
  26693. /**
  26694. * The world space position of the particle.
  26695. */
  26696. position: Vector3;
  26697. /**
  26698. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26699. */
  26700. rotation: Vector3;
  26701. /**
  26702. * The world space rotation quaternion of the particle.
  26703. */
  26704. rotationQuaternion: Nullable<Quaternion>;
  26705. /**
  26706. * The scaling of the particle.
  26707. */
  26708. scaling: Vector3;
  26709. /**
  26710. * The uvs of the particle.
  26711. */
  26712. uvs: Vector4;
  26713. /**
  26714. * The current speed of the particle.
  26715. */
  26716. velocity: Vector3;
  26717. /**
  26718. * The pivot point in the particle local space.
  26719. */
  26720. pivot: Vector3;
  26721. /**
  26722. * Must the particle be translated from its pivot point in its local space ?
  26723. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26724. * Default : false
  26725. */
  26726. translateFromPivot: boolean;
  26727. /**
  26728. * Is the particle active or not ?
  26729. */
  26730. alive: boolean;
  26731. /**
  26732. * Is the particle visible or not ?
  26733. */
  26734. isVisible: boolean;
  26735. /**
  26736. * Index of this particle in the global "positions" array (Internal use)
  26737. * @hidden
  26738. */
  26739. _pos: number;
  26740. /**
  26741. * @hidden Index of this particle in the global "indices" array (Internal use)
  26742. */
  26743. _ind: number;
  26744. /**
  26745. * @hidden ModelShape of this particle (Internal use)
  26746. */
  26747. _model: ModelShape;
  26748. /**
  26749. * ModelShape id of this particle
  26750. */
  26751. shapeId: number;
  26752. /**
  26753. * Index of the particle in its shape id
  26754. */
  26755. idxInShape: number;
  26756. /**
  26757. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26758. */
  26759. _modelBoundingInfo: BoundingInfo;
  26760. /**
  26761. * @hidden Particle BoundingInfo object (Internal use)
  26762. */
  26763. _boundingInfo: BoundingInfo;
  26764. /**
  26765. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26766. */
  26767. _sps: SolidParticleSystem;
  26768. /**
  26769. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26770. */
  26771. _stillInvisible: boolean;
  26772. /**
  26773. * @hidden Last computed particle rotation matrix
  26774. */
  26775. _rotationMatrix: number[];
  26776. /**
  26777. * Parent particle Id, if any.
  26778. * Default null.
  26779. */
  26780. parentId: Nullable<number>;
  26781. /**
  26782. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26783. * The possible values are :
  26784. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26785. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26786. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26787. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26788. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26789. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26790. * */
  26791. cullingStrategy: number;
  26792. /**
  26793. * @hidden Internal global position in the SPS.
  26794. */
  26795. _globalPosition: Vector3;
  26796. /**
  26797. * Creates a Solid Particle object.
  26798. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26799. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26800. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26801. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26802. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26803. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26804. * @param shapeId (integer) is the model shape identifier in the SPS.
  26805. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26806. * @param sps defines the sps it is associated to
  26807. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26808. */
  26809. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26810. /**
  26811. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26812. * @param target the particle target
  26813. * @returns the current particle
  26814. */
  26815. copyToRef(target: SolidParticle): SolidParticle;
  26816. /**
  26817. * Legacy support, changed scale to scaling
  26818. */
  26819. /**
  26820. * Legacy support, changed scale to scaling
  26821. */
  26822. scale: Vector3;
  26823. /**
  26824. * Legacy support, changed quaternion to rotationQuaternion
  26825. */
  26826. /**
  26827. * Legacy support, changed quaternion to rotationQuaternion
  26828. */
  26829. quaternion: Nullable<Quaternion>;
  26830. /**
  26831. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26832. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26833. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26834. * @returns true if it intersects
  26835. */
  26836. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26837. /**
  26838. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26839. * A particle is in the frustum if its bounding box intersects the frustum
  26840. * @param frustumPlanes defines the frustum to test
  26841. * @returns true if the particle is in the frustum planes
  26842. */
  26843. isInFrustum(frustumPlanes: Plane[]): boolean;
  26844. /**
  26845. * get the rotation matrix of the particle
  26846. * @hidden
  26847. */
  26848. getRotationMatrix(m: Matrix): void;
  26849. }
  26850. /**
  26851. * Represents the shape of the model used by one particle of a solid particle system.
  26852. * SPS internal tool, don't use it manually.
  26853. */
  26854. export class ModelShape {
  26855. /**
  26856. * The shape id
  26857. * @hidden
  26858. */
  26859. shapeID: number;
  26860. /**
  26861. * flat array of model positions (internal use)
  26862. * @hidden
  26863. */
  26864. _shape: Vector3[];
  26865. /**
  26866. * flat array of model UVs (internal use)
  26867. * @hidden
  26868. */
  26869. _shapeUV: number[];
  26870. /**
  26871. * color array of the model
  26872. * @hidden
  26873. */
  26874. _shapeColors: number[];
  26875. /**
  26876. * indices array of the model
  26877. * @hidden
  26878. */
  26879. _indices: number[];
  26880. /**
  26881. * normals array of the model
  26882. * @hidden
  26883. */
  26884. _normals: number[];
  26885. /**
  26886. * length of the shape in the model indices array (internal use)
  26887. * @hidden
  26888. */
  26889. _indicesLength: number;
  26890. /**
  26891. * Custom position function (internal use)
  26892. * @hidden
  26893. */
  26894. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26895. /**
  26896. * Custom vertex function (internal use)
  26897. * @hidden
  26898. */
  26899. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26900. /**
  26901. * 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.
  26902. * SPS internal tool, don't use it manually.
  26903. * @hidden
  26904. */
  26905. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26906. }
  26907. /**
  26908. * Represents a Depth Sorted Particle in the solid particle system.
  26909. */
  26910. export class DepthSortedParticle {
  26911. /**
  26912. * Index of the particle in the "indices" array
  26913. */
  26914. ind: number;
  26915. /**
  26916. * Length of the particle shape in the "indices" array
  26917. */
  26918. indicesLength: number;
  26919. /**
  26920. * Squared distance from the particle to the camera
  26921. */
  26922. sqDistance: number;
  26923. }
  26924. }
  26925. declare module "babylonjs/Collisions/meshCollisionData" {
  26926. import { Collider } from "babylonjs/Collisions/collider";
  26927. import { Vector3 } from "babylonjs/Maths/math.vector";
  26928. import { Nullable } from "babylonjs/types";
  26929. import { Observer } from "babylonjs/Misc/observable";
  26930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26931. /**
  26932. * @hidden
  26933. */
  26934. export class _MeshCollisionData {
  26935. _checkCollisions: boolean;
  26936. _collisionMask: number;
  26937. _collisionGroup: number;
  26938. _collider: Nullable<Collider>;
  26939. _oldPositionForCollisions: Vector3;
  26940. _diffPositionForCollisions: Vector3;
  26941. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26942. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26943. }
  26944. }
  26945. declare module "babylonjs/Meshes/abstractMesh" {
  26946. import { Observable } from "babylonjs/Misc/observable";
  26947. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26948. import { Camera } from "babylonjs/Cameras/camera";
  26949. import { Scene, IDisposable } from "babylonjs/scene";
  26950. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26951. import { Node } from "babylonjs/node";
  26952. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26953. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26954. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26955. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26956. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26957. import { Material } from "babylonjs/Materials/material";
  26958. import { Light } from "babylonjs/Lights/light";
  26959. import { Skeleton } from "babylonjs/Bones/skeleton";
  26960. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26961. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26962. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26963. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26964. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26965. import { Plane } from "babylonjs/Maths/math.plane";
  26966. import { Ray } from "babylonjs/Culling/ray";
  26967. import { Collider } from "babylonjs/Collisions/collider";
  26968. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26969. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26970. /** @hidden */
  26971. class _FacetDataStorage {
  26972. facetPositions: Vector3[];
  26973. facetNormals: Vector3[];
  26974. facetPartitioning: number[][];
  26975. facetNb: number;
  26976. partitioningSubdivisions: number;
  26977. partitioningBBoxRatio: number;
  26978. facetDataEnabled: boolean;
  26979. facetParameters: any;
  26980. bbSize: Vector3;
  26981. subDiv: {
  26982. max: number;
  26983. X: number;
  26984. Y: number;
  26985. Z: number;
  26986. };
  26987. facetDepthSort: boolean;
  26988. facetDepthSortEnabled: boolean;
  26989. depthSortedIndices: IndicesArray;
  26990. depthSortedFacets: {
  26991. ind: number;
  26992. sqDistance: number;
  26993. }[];
  26994. facetDepthSortFunction: (f1: {
  26995. ind: number;
  26996. sqDistance: number;
  26997. }, f2: {
  26998. ind: number;
  26999. sqDistance: number;
  27000. }) => number;
  27001. facetDepthSortFrom: Vector3;
  27002. facetDepthSortOrigin: Vector3;
  27003. invertedMatrix: Matrix;
  27004. }
  27005. /**
  27006. * @hidden
  27007. **/
  27008. class _InternalAbstractMeshDataInfo {
  27009. _hasVertexAlpha: boolean;
  27010. _useVertexColors: boolean;
  27011. _numBoneInfluencers: number;
  27012. _applyFog: boolean;
  27013. _receiveShadows: boolean;
  27014. _facetData: _FacetDataStorage;
  27015. _visibility: number;
  27016. _skeleton: Nullable<Skeleton>;
  27017. _layerMask: number;
  27018. _computeBonesUsingShaders: boolean;
  27019. _isActive: boolean;
  27020. _onlyForInstances: boolean;
  27021. _isActiveIntermediate: boolean;
  27022. _onlyForInstancesIntermediate: boolean;
  27023. _actAsRegularMesh: boolean;
  27024. }
  27025. /**
  27026. * Class used to store all common mesh properties
  27027. */
  27028. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27029. /** No occlusion */
  27030. static OCCLUSION_TYPE_NONE: number;
  27031. /** Occlusion set to optimisitic */
  27032. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27033. /** Occlusion set to strict */
  27034. static OCCLUSION_TYPE_STRICT: number;
  27035. /** Use an accurante occlusion algorithm */
  27036. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27037. /** Use a conservative occlusion algorithm */
  27038. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27039. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27040. * Test order :
  27041. * Is the bounding sphere outside the frustum ?
  27042. * If not, are the bounding box vertices outside the frustum ?
  27043. * It not, then the cullable object is in the frustum.
  27044. */
  27045. static readonly CULLINGSTRATEGY_STANDARD: number;
  27046. /** Culling strategy : Bounding Sphere Only.
  27047. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27048. * It's also less accurate than the standard because some not visible objects can still be selected.
  27049. * Test : is the bounding sphere outside the frustum ?
  27050. * If not, then the cullable object is in the frustum.
  27051. */
  27052. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27053. /** Culling strategy : Optimistic Inclusion.
  27054. * This in an inclusion test first, then the standard exclusion test.
  27055. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27056. * 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.
  27057. * Anyway, it's as accurate as the standard strategy.
  27058. * Test :
  27059. * Is the cullable object bounding sphere center in the frustum ?
  27060. * If not, apply the default culling strategy.
  27061. */
  27062. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27063. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27064. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27065. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27066. * 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.
  27067. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27068. * Test :
  27069. * Is the cullable object bounding sphere center in the frustum ?
  27070. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27071. */
  27072. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27073. /**
  27074. * No billboard
  27075. */
  27076. static readonly BILLBOARDMODE_NONE: number;
  27077. /** Billboard on X axis */
  27078. static readonly BILLBOARDMODE_X: number;
  27079. /** Billboard on Y axis */
  27080. static readonly BILLBOARDMODE_Y: number;
  27081. /** Billboard on Z axis */
  27082. static readonly BILLBOARDMODE_Z: number;
  27083. /** Billboard on all axes */
  27084. static readonly BILLBOARDMODE_ALL: number;
  27085. /** Billboard on using position instead of orientation */
  27086. static readonly BILLBOARDMODE_USE_POSITION: number;
  27087. /** @hidden */
  27088. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27089. /**
  27090. * The culling strategy to use to check whether the mesh must be rendered or not.
  27091. * This value can be changed at any time and will be used on the next render mesh selection.
  27092. * The possible values are :
  27093. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27094. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27095. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27096. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27097. * Please read each static variable documentation to get details about the culling process.
  27098. * */
  27099. cullingStrategy: number;
  27100. /**
  27101. * Gets the number of facets in the mesh
  27102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27103. */
  27104. readonly facetNb: number;
  27105. /**
  27106. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27108. */
  27109. partitioningSubdivisions: number;
  27110. /**
  27111. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27112. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27113. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27114. */
  27115. partitioningBBoxRatio: number;
  27116. /**
  27117. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27118. * Works only for updatable meshes.
  27119. * Doesn't work with multi-materials
  27120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27121. */
  27122. mustDepthSortFacets: boolean;
  27123. /**
  27124. * The location (Vector3) where the facet depth sort must be computed from.
  27125. * By default, the active camera position.
  27126. * Used only when facet depth sort is enabled
  27127. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27128. */
  27129. facetDepthSortFrom: Vector3;
  27130. /**
  27131. * gets a boolean indicating if facetData is enabled
  27132. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27133. */
  27134. readonly isFacetDataEnabled: boolean;
  27135. /** @hidden */
  27136. _updateNonUniformScalingState(value: boolean): boolean;
  27137. /**
  27138. * An event triggered when this mesh collides with another one
  27139. */
  27140. onCollideObservable: Observable<AbstractMesh>;
  27141. /** Set a function to call when this mesh collides with another one */
  27142. onCollide: () => void;
  27143. /**
  27144. * An event triggered when the collision's position changes
  27145. */
  27146. onCollisionPositionChangeObservable: Observable<Vector3>;
  27147. /** Set a function to call when the collision's position changes */
  27148. onCollisionPositionChange: () => void;
  27149. /**
  27150. * An event triggered when material is changed
  27151. */
  27152. onMaterialChangedObservable: Observable<AbstractMesh>;
  27153. /**
  27154. * Gets or sets the orientation for POV movement & rotation
  27155. */
  27156. definedFacingForward: boolean;
  27157. /** @hidden */
  27158. _occlusionQuery: Nullable<WebGLQuery>;
  27159. /** @hidden */
  27160. _renderingGroup: Nullable<RenderingGroup>;
  27161. /**
  27162. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27163. */
  27164. /**
  27165. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27166. */
  27167. visibility: number;
  27168. /** Gets or sets the alpha index used to sort transparent meshes
  27169. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27170. */
  27171. alphaIndex: number;
  27172. /**
  27173. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27174. */
  27175. isVisible: boolean;
  27176. /**
  27177. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27178. */
  27179. isPickable: boolean;
  27180. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27181. showSubMeshesBoundingBox: boolean;
  27182. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27183. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27184. */
  27185. isBlocker: boolean;
  27186. /**
  27187. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27188. */
  27189. enablePointerMoveEvents: boolean;
  27190. /**
  27191. * Specifies the rendering group id for this mesh (0 by default)
  27192. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27193. */
  27194. renderingGroupId: number;
  27195. private _material;
  27196. /** Gets or sets current material */
  27197. material: Nullable<Material>;
  27198. /**
  27199. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27200. * @see http://doc.babylonjs.com/babylon101/shadows
  27201. */
  27202. receiveShadows: boolean;
  27203. /** Defines color to use when rendering outline */
  27204. outlineColor: Color3;
  27205. /** Define width to use when rendering outline */
  27206. outlineWidth: number;
  27207. /** Defines color to use when rendering overlay */
  27208. overlayColor: Color3;
  27209. /** Defines alpha to use when rendering overlay */
  27210. overlayAlpha: number;
  27211. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27212. hasVertexAlpha: boolean;
  27213. /** 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) */
  27214. useVertexColors: boolean;
  27215. /**
  27216. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27217. */
  27218. computeBonesUsingShaders: boolean;
  27219. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27220. numBoneInfluencers: number;
  27221. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27222. applyFog: boolean;
  27223. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27224. useOctreeForRenderingSelection: boolean;
  27225. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27226. useOctreeForPicking: boolean;
  27227. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27228. useOctreeForCollisions: boolean;
  27229. /**
  27230. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27231. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27232. */
  27233. layerMask: number;
  27234. /**
  27235. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27236. */
  27237. alwaysSelectAsActiveMesh: boolean;
  27238. /**
  27239. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27240. */
  27241. doNotSyncBoundingInfo: boolean;
  27242. /**
  27243. * Gets or sets the current action manager
  27244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27245. */
  27246. actionManager: Nullable<AbstractActionManager>;
  27247. private _meshCollisionData;
  27248. /**
  27249. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27250. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27251. */
  27252. ellipsoid: Vector3;
  27253. /**
  27254. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27255. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27256. */
  27257. ellipsoidOffset: Vector3;
  27258. /**
  27259. * Gets or sets a collision mask used to mask collisions (default is -1).
  27260. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27261. */
  27262. collisionMask: number;
  27263. /**
  27264. * Gets or sets the current collision group mask (-1 by default).
  27265. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27266. */
  27267. collisionGroup: number;
  27268. /**
  27269. * Defines edge width used when edgesRenderer is enabled
  27270. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27271. */
  27272. edgesWidth: number;
  27273. /**
  27274. * Defines edge color used when edgesRenderer is enabled
  27275. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27276. */
  27277. edgesColor: Color4;
  27278. /** @hidden */
  27279. _edgesRenderer: Nullable<IEdgesRenderer>;
  27280. /** @hidden */
  27281. _masterMesh: Nullable<AbstractMesh>;
  27282. /** @hidden */
  27283. _boundingInfo: Nullable<BoundingInfo>;
  27284. /** @hidden */
  27285. _renderId: number;
  27286. /**
  27287. * Gets or sets the list of subMeshes
  27288. * @see http://doc.babylonjs.com/how_to/multi_materials
  27289. */
  27290. subMeshes: SubMesh[];
  27291. /** @hidden */
  27292. _intersectionsInProgress: AbstractMesh[];
  27293. /** @hidden */
  27294. _unIndexed: boolean;
  27295. /** @hidden */
  27296. _lightSources: Light[];
  27297. /** Gets the list of lights affecting that mesh */
  27298. readonly lightSources: Light[];
  27299. /** @hidden */
  27300. readonly _positions: Nullable<Vector3[]>;
  27301. /** @hidden */
  27302. _waitingData: {
  27303. lods: Nullable<any>;
  27304. actions: Nullable<any>;
  27305. freezeWorldMatrix: Nullable<boolean>;
  27306. };
  27307. /** @hidden */
  27308. _bonesTransformMatrices: Nullable<Float32Array>;
  27309. /** @hidden */
  27310. _transformMatrixTexture: Nullable<RawTexture>;
  27311. /**
  27312. * Gets or sets a skeleton to apply skining transformations
  27313. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27314. */
  27315. skeleton: Nullable<Skeleton>;
  27316. /**
  27317. * An event triggered when the mesh is rebuilt.
  27318. */
  27319. onRebuildObservable: Observable<AbstractMesh>;
  27320. /**
  27321. * Creates a new AbstractMesh
  27322. * @param name defines the name of the mesh
  27323. * @param scene defines the hosting scene
  27324. */
  27325. constructor(name: string, scene?: Nullable<Scene>);
  27326. /**
  27327. * Returns the string "AbstractMesh"
  27328. * @returns "AbstractMesh"
  27329. */
  27330. getClassName(): string;
  27331. /**
  27332. * Gets a string representation of the current mesh
  27333. * @param fullDetails defines a boolean indicating if full details must be included
  27334. * @returns a string representation of the current mesh
  27335. */
  27336. toString(fullDetails?: boolean): string;
  27337. /**
  27338. * @hidden
  27339. */
  27340. protected _getEffectiveParent(): Nullable<Node>;
  27341. /** @hidden */
  27342. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27343. /** @hidden */
  27344. _rebuild(): void;
  27345. /** @hidden */
  27346. _resyncLightSources(): void;
  27347. /** @hidden */
  27348. _resyncLighSource(light: Light): void;
  27349. /** @hidden */
  27350. _unBindEffect(): void;
  27351. /** @hidden */
  27352. _removeLightSource(light: Light, dispose: boolean): void;
  27353. private _markSubMeshesAsDirty;
  27354. /** @hidden */
  27355. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27356. /** @hidden */
  27357. _markSubMeshesAsAttributesDirty(): void;
  27358. /** @hidden */
  27359. _markSubMeshesAsMiscDirty(): void;
  27360. /**
  27361. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27362. */
  27363. scaling: Vector3;
  27364. /**
  27365. * Returns true if the mesh is blocked. Implemented by child classes
  27366. */
  27367. readonly isBlocked: boolean;
  27368. /**
  27369. * Returns the mesh itself by default. Implemented by child classes
  27370. * @param camera defines the camera to use to pick the right LOD level
  27371. * @returns the currentAbstractMesh
  27372. */
  27373. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27374. /**
  27375. * Returns 0 by default. Implemented by child classes
  27376. * @returns an integer
  27377. */
  27378. getTotalVertices(): number;
  27379. /**
  27380. * Returns a positive integer : the total number of indices in this mesh geometry.
  27381. * @returns the numner of indices or zero if the mesh has no geometry.
  27382. */
  27383. getTotalIndices(): number;
  27384. /**
  27385. * Returns null by default. Implemented by child classes
  27386. * @returns null
  27387. */
  27388. getIndices(): Nullable<IndicesArray>;
  27389. /**
  27390. * Returns the array of the requested vertex data kind. Implemented by child classes
  27391. * @param kind defines the vertex data kind to use
  27392. * @returns null
  27393. */
  27394. getVerticesData(kind: string): Nullable<FloatArray>;
  27395. /**
  27396. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27397. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27398. * Note that a new underlying VertexBuffer object is created each call.
  27399. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27400. * @param kind defines vertex data kind:
  27401. * * VertexBuffer.PositionKind
  27402. * * VertexBuffer.UVKind
  27403. * * VertexBuffer.UV2Kind
  27404. * * VertexBuffer.UV3Kind
  27405. * * VertexBuffer.UV4Kind
  27406. * * VertexBuffer.UV5Kind
  27407. * * VertexBuffer.UV6Kind
  27408. * * VertexBuffer.ColorKind
  27409. * * VertexBuffer.MatricesIndicesKind
  27410. * * VertexBuffer.MatricesIndicesExtraKind
  27411. * * VertexBuffer.MatricesWeightsKind
  27412. * * VertexBuffer.MatricesWeightsExtraKind
  27413. * @param data defines the data source
  27414. * @param updatable defines if the data must be flagged as updatable (or static)
  27415. * @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
  27416. * @returns the current mesh
  27417. */
  27418. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27419. /**
  27420. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27421. * If the mesh has no geometry, it is simply returned as it is.
  27422. * @param kind defines vertex data kind:
  27423. * * VertexBuffer.PositionKind
  27424. * * VertexBuffer.UVKind
  27425. * * VertexBuffer.UV2Kind
  27426. * * VertexBuffer.UV3Kind
  27427. * * VertexBuffer.UV4Kind
  27428. * * VertexBuffer.UV5Kind
  27429. * * VertexBuffer.UV6Kind
  27430. * * VertexBuffer.ColorKind
  27431. * * VertexBuffer.MatricesIndicesKind
  27432. * * VertexBuffer.MatricesIndicesExtraKind
  27433. * * VertexBuffer.MatricesWeightsKind
  27434. * * VertexBuffer.MatricesWeightsExtraKind
  27435. * @param data defines the data source
  27436. * @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
  27437. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27438. * @returns the current mesh
  27439. */
  27440. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27441. /**
  27442. * Sets the mesh indices,
  27443. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27444. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27445. * @param totalVertices Defines the total number of vertices
  27446. * @returns the current mesh
  27447. */
  27448. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27449. /**
  27450. * Gets a boolean indicating if specific vertex data is present
  27451. * @param kind defines the vertex data kind to use
  27452. * @returns true is data kind is present
  27453. */
  27454. isVerticesDataPresent(kind: string): boolean;
  27455. /**
  27456. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27457. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27458. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27459. * @returns a BoundingInfo
  27460. */
  27461. getBoundingInfo(): BoundingInfo;
  27462. /**
  27463. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27464. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27465. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27466. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27467. * @returns the current mesh
  27468. */
  27469. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27470. /**
  27471. * Overwrite the current bounding info
  27472. * @param boundingInfo defines the new bounding info
  27473. * @returns the current mesh
  27474. */
  27475. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27476. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27477. readonly useBones: boolean;
  27478. /** @hidden */
  27479. _preActivate(): void;
  27480. /** @hidden */
  27481. _preActivateForIntermediateRendering(renderId: number): void;
  27482. /** @hidden */
  27483. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27484. /** @hidden */
  27485. _postActivate(): void;
  27486. /** @hidden */
  27487. _freeze(): void;
  27488. /** @hidden */
  27489. _unFreeze(): void;
  27490. /**
  27491. * Gets the current world matrix
  27492. * @returns a Matrix
  27493. */
  27494. getWorldMatrix(): Matrix;
  27495. /** @hidden */
  27496. _getWorldMatrixDeterminant(): number;
  27497. /**
  27498. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27499. */
  27500. readonly isAnInstance: boolean;
  27501. /**
  27502. * Gets a boolean indicating if this mesh has instances
  27503. */
  27504. readonly hasInstances: boolean;
  27505. /**
  27506. * Perform relative position change from the point of view of behind the front of the mesh.
  27507. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27508. * Supports definition of mesh facing forward or backward
  27509. * @param amountRight defines the distance on the right axis
  27510. * @param amountUp defines the distance on the up axis
  27511. * @param amountForward defines the distance on the forward axis
  27512. * @returns the current mesh
  27513. */
  27514. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27515. /**
  27516. * Calculate relative position change from the point of view of behind the front of the mesh.
  27517. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27518. * Supports definition of mesh facing forward or backward
  27519. * @param amountRight defines the distance on the right axis
  27520. * @param amountUp defines the distance on the up axis
  27521. * @param amountForward defines the distance on the forward axis
  27522. * @returns the new displacement vector
  27523. */
  27524. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27525. /**
  27526. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27527. * Supports definition of mesh facing forward or backward
  27528. * @param flipBack defines the flip
  27529. * @param twirlClockwise defines the twirl
  27530. * @param tiltRight defines the tilt
  27531. * @returns the current mesh
  27532. */
  27533. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27534. /**
  27535. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27536. * Supports definition of mesh facing forward or backward.
  27537. * @param flipBack defines the flip
  27538. * @param twirlClockwise defines the twirl
  27539. * @param tiltRight defines the tilt
  27540. * @returns the new rotation vector
  27541. */
  27542. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27543. /**
  27544. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27545. * This means the mesh underlying bounding box and sphere are recomputed.
  27546. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27547. * @returns the current mesh
  27548. */
  27549. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27550. /** @hidden */
  27551. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27552. /** @hidden */
  27553. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27554. /** @hidden */
  27555. _updateBoundingInfo(): AbstractMesh;
  27556. /** @hidden */
  27557. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27558. /** @hidden */
  27559. protected _afterComputeWorldMatrix(): void;
  27560. /** @hidden */
  27561. readonly _effectiveMesh: AbstractMesh;
  27562. /**
  27563. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27564. * A mesh is in the frustum if its bounding box intersects the frustum
  27565. * @param frustumPlanes defines the frustum to test
  27566. * @returns true if the mesh is in the frustum planes
  27567. */
  27568. isInFrustum(frustumPlanes: Plane[]): boolean;
  27569. /**
  27570. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27571. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27572. * @param frustumPlanes defines the frustum to test
  27573. * @returns true if the mesh is completely in the frustum planes
  27574. */
  27575. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27576. /**
  27577. * True if the mesh intersects another mesh or a SolidParticle object
  27578. * @param mesh defines a target mesh or SolidParticle to test
  27579. * @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)
  27580. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27581. * @returns true if there is an intersection
  27582. */
  27583. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27584. /**
  27585. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27586. * @param point defines the point to test
  27587. * @returns true if there is an intersection
  27588. */
  27589. intersectsPoint(point: Vector3): boolean;
  27590. /**
  27591. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27592. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27593. */
  27594. checkCollisions: boolean;
  27595. /**
  27596. * Gets Collider object used to compute collisions (not physics)
  27597. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27598. */
  27599. readonly collider: Nullable<Collider>;
  27600. /**
  27601. * Move the mesh using collision engine
  27602. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27603. * @param displacement defines the requested displacement vector
  27604. * @returns the current mesh
  27605. */
  27606. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27607. private _onCollisionPositionChange;
  27608. /** @hidden */
  27609. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27610. /** @hidden */
  27611. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27612. /** @hidden */
  27613. _checkCollision(collider: Collider): AbstractMesh;
  27614. /** @hidden */
  27615. _generatePointsArray(): boolean;
  27616. /**
  27617. * Checks if the passed Ray intersects with the mesh
  27618. * @param ray defines the ray to use
  27619. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27620. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27621. * @returns the picking info
  27622. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27623. */
  27624. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27625. /**
  27626. * Clones the current mesh
  27627. * @param name defines the mesh name
  27628. * @param newParent defines the new mesh parent
  27629. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27630. * @returns the new mesh
  27631. */
  27632. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27633. /**
  27634. * Disposes all the submeshes of the current meshnp
  27635. * @returns the current mesh
  27636. */
  27637. releaseSubMeshes(): AbstractMesh;
  27638. /**
  27639. * Releases resources associated with this abstract mesh.
  27640. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27641. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27642. */
  27643. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27644. /**
  27645. * Adds the passed mesh as a child to the current mesh
  27646. * @param mesh defines the child mesh
  27647. * @returns the current mesh
  27648. */
  27649. addChild(mesh: AbstractMesh): AbstractMesh;
  27650. /**
  27651. * Removes the passed mesh from the current mesh children list
  27652. * @param mesh defines the child mesh
  27653. * @returns the current mesh
  27654. */
  27655. removeChild(mesh: AbstractMesh): AbstractMesh;
  27656. /** @hidden */
  27657. private _initFacetData;
  27658. /**
  27659. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27660. * This method can be called within the render loop.
  27661. * 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
  27662. * @returns the current mesh
  27663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27664. */
  27665. updateFacetData(): AbstractMesh;
  27666. /**
  27667. * Returns the facetLocalNormals array.
  27668. * The normals are expressed in the mesh local spac
  27669. * @returns an array of Vector3
  27670. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27671. */
  27672. getFacetLocalNormals(): Vector3[];
  27673. /**
  27674. * Returns the facetLocalPositions array.
  27675. * The facet positions are expressed in the mesh local space
  27676. * @returns an array of Vector3
  27677. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27678. */
  27679. getFacetLocalPositions(): Vector3[];
  27680. /**
  27681. * Returns the facetLocalPartioning array
  27682. * @returns an array of array of numbers
  27683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27684. */
  27685. getFacetLocalPartitioning(): number[][];
  27686. /**
  27687. * Returns the i-th facet position in the world system.
  27688. * This method allocates a new Vector3 per call
  27689. * @param i defines the facet index
  27690. * @returns a new Vector3
  27691. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27692. */
  27693. getFacetPosition(i: number): Vector3;
  27694. /**
  27695. * Sets the reference Vector3 with the i-th facet position in the world system
  27696. * @param i defines the facet index
  27697. * @param ref defines the target vector
  27698. * @returns the current mesh
  27699. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27700. */
  27701. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27702. /**
  27703. * Returns the i-th facet normal in the world system.
  27704. * This method allocates a new Vector3 per call
  27705. * @param i defines the facet index
  27706. * @returns a new Vector3
  27707. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27708. */
  27709. getFacetNormal(i: number): Vector3;
  27710. /**
  27711. * Sets the reference Vector3 with the i-th facet normal in the world system
  27712. * @param i defines the facet index
  27713. * @param ref defines the target vector
  27714. * @returns the current mesh
  27715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27716. */
  27717. getFacetNormalToRef(i: number, ref: Vector3): this;
  27718. /**
  27719. * 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)
  27720. * @param x defines x coordinate
  27721. * @param y defines y coordinate
  27722. * @param z defines z coordinate
  27723. * @returns the array of facet indexes
  27724. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27725. */
  27726. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27727. /**
  27728. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27729. * @param projected sets as the (x,y,z) world projection on the facet
  27730. * @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
  27731. * @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
  27732. * @param x defines x coordinate
  27733. * @param y defines y coordinate
  27734. * @param z defines z coordinate
  27735. * @returns the face index if found (or null instead)
  27736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27737. */
  27738. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27739. /**
  27740. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27741. * @param projected sets as the (x,y,z) local projection on the facet
  27742. * @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
  27743. * @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
  27744. * @param x defines x coordinate
  27745. * @param y defines y coordinate
  27746. * @param z defines z coordinate
  27747. * @returns the face index if found (or null instead)
  27748. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27749. */
  27750. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27751. /**
  27752. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27753. * @returns the parameters
  27754. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27755. */
  27756. getFacetDataParameters(): any;
  27757. /**
  27758. * Disables the feature FacetData and frees the related memory
  27759. * @returns the current mesh
  27760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27761. */
  27762. disableFacetData(): AbstractMesh;
  27763. /**
  27764. * Updates the AbstractMesh indices array
  27765. * @param indices defines the data source
  27766. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27767. * @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)
  27768. * @returns the current mesh
  27769. */
  27770. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27771. /**
  27772. * Creates new normals data for the mesh
  27773. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27774. * @returns the current mesh
  27775. */
  27776. createNormals(updatable: boolean): AbstractMesh;
  27777. /**
  27778. * Align the mesh with a normal
  27779. * @param normal defines the normal to use
  27780. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27781. * @returns the current mesh
  27782. */
  27783. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27784. /** @hidden */
  27785. _checkOcclusionQuery(): boolean;
  27786. /**
  27787. * Disables the mesh edge rendering mode
  27788. * @returns the currentAbstractMesh
  27789. */
  27790. disableEdgesRendering(): AbstractMesh;
  27791. /**
  27792. * Enables the edge rendering mode on the mesh.
  27793. * This mode makes the mesh edges visible
  27794. * @param epsilon defines the maximal distance between two angles to detect a face
  27795. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27796. * @returns the currentAbstractMesh
  27797. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27798. */
  27799. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27800. }
  27801. }
  27802. declare module "babylonjs/Actions/actionEvent" {
  27803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27804. import { Nullable } from "babylonjs/types";
  27805. import { Sprite } from "babylonjs/Sprites/sprite";
  27806. import { Scene } from "babylonjs/scene";
  27807. import { Vector2 } from "babylonjs/Maths/math.vector";
  27808. /**
  27809. * Interface used to define ActionEvent
  27810. */
  27811. export interface IActionEvent {
  27812. /** The mesh or sprite that triggered the action */
  27813. source: any;
  27814. /** The X mouse cursor position at the time of the event */
  27815. pointerX: number;
  27816. /** The Y mouse cursor position at the time of the event */
  27817. pointerY: number;
  27818. /** The mesh that is currently pointed at (can be null) */
  27819. meshUnderPointer: Nullable<AbstractMesh>;
  27820. /** the original (browser) event that triggered the ActionEvent */
  27821. sourceEvent?: any;
  27822. /** additional data for the event */
  27823. additionalData?: any;
  27824. }
  27825. /**
  27826. * ActionEvent is the event being sent when an action is triggered.
  27827. */
  27828. export class ActionEvent implements IActionEvent {
  27829. /** The mesh or sprite that triggered the action */
  27830. source: any;
  27831. /** The X mouse cursor position at the time of the event */
  27832. pointerX: number;
  27833. /** The Y mouse cursor position at the time of the event */
  27834. pointerY: number;
  27835. /** The mesh that is currently pointed at (can be null) */
  27836. meshUnderPointer: Nullable<AbstractMesh>;
  27837. /** the original (browser) event that triggered the ActionEvent */
  27838. sourceEvent?: any;
  27839. /** additional data for the event */
  27840. additionalData?: any;
  27841. /**
  27842. * Creates a new ActionEvent
  27843. * @param source The mesh or sprite that triggered the action
  27844. * @param pointerX The X mouse cursor position at the time of the event
  27845. * @param pointerY The Y mouse cursor position at the time of the event
  27846. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27847. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27848. * @param additionalData additional data for the event
  27849. */
  27850. constructor(
  27851. /** The mesh or sprite that triggered the action */
  27852. source: any,
  27853. /** The X mouse cursor position at the time of the event */
  27854. pointerX: number,
  27855. /** The Y mouse cursor position at the time of the event */
  27856. pointerY: number,
  27857. /** The mesh that is currently pointed at (can be null) */
  27858. meshUnderPointer: Nullable<AbstractMesh>,
  27859. /** the original (browser) event that triggered the ActionEvent */
  27860. sourceEvent?: any,
  27861. /** additional data for the event */
  27862. additionalData?: any);
  27863. /**
  27864. * Helper function to auto-create an ActionEvent from a source mesh.
  27865. * @param source The source mesh that triggered the event
  27866. * @param evt The original (browser) event
  27867. * @param additionalData additional data for the event
  27868. * @returns the new ActionEvent
  27869. */
  27870. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27871. /**
  27872. * Helper function to auto-create an ActionEvent from a source sprite
  27873. * @param source The source sprite that triggered the event
  27874. * @param scene Scene associated with the sprite
  27875. * @param evt The original (browser) event
  27876. * @param additionalData additional data for the event
  27877. * @returns the new ActionEvent
  27878. */
  27879. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27880. /**
  27881. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27882. * @param scene the scene where the event occurred
  27883. * @param evt The original (browser) event
  27884. * @returns the new ActionEvent
  27885. */
  27886. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27887. /**
  27888. * Helper function to auto-create an ActionEvent from a primitive
  27889. * @param prim defines the target primitive
  27890. * @param pointerPos defines the pointer position
  27891. * @param evt The original (browser) event
  27892. * @param additionalData additional data for the event
  27893. * @returns the new ActionEvent
  27894. */
  27895. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27896. }
  27897. }
  27898. declare module "babylonjs/Actions/abstractActionManager" {
  27899. import { IDisposable } from "babylonjs/scene";
  27900. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27901. import { IAction } from "babylonjs/Actions/action";
  27902. import { Nullable } from "babylonjs/types";
  27903. /**
  27904. * Abstract class used to decouple action Manager from scene and meshes.
  27905. * Do not instantiate.
  27906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27907. */
  27908. export abstract class AbstractActionManager implements IDisposable {
  27909. /** Gets the list of active triggers */
  27910. static Triggers: {
  27911. [key: string]: number;
  27912. };
  27913. /** Gets the cursor to use when hovering items */
  27914. hoverCursor: string;
  27915. /** Gets the list of actions */
  27916. actions: IAction[];
  27917. /**
  27918. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27919. */
  27920. isRecursive: boolean;
  27921. /**
  27922. * Releases all associated resources
  27923. */
  27924. abstract dispose(): void;
  27925. /**
  27926. * Does this action manager has pointer triggers
  27927. */
  27928. abstract readonly hasPointerTriggers: boolean;
  27929. /**
  27930. * Does this action manager has pick triggers
  27931. */
  27932. abstract readonly hasPickTriggers: boolean;
  27933. /**
  27934. * Process a specific trigger
  27935. * @param trigger defines the trigger to process
  27936. * @param evt defines the event details to be processed
  27937. */
  27938. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27939. /**
  27940. * Does this action manager handles actions of any of the given triggers
  27941. * @param triggers defines the triggers to be tested
  27942. * @return a boolean indicating whether one (or more) of the triggers is handled
  27943. */
  27944. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27945. /**
  27946. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27947. * speed.
  27948. * @param triggerA defines the trigger to be tested
  27949. * @param triggerB defines the trigger to be tested
  27950. * @return a boolean indicating whether one (or more) of the triggers is handled
  27951. */
  27952. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27953. /**
  27954. * Does this action manager handles actions of a given trigger
  27955. * @param trigger defines the trigger to be tested
  27956. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27957. * @return whether the trigger is handled
  27958. */
  27959. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27960. /**
  27961. * Serialize this manager to a JSON object
  27962. * @param name defines the property name to store this manager
  27963. * @returns a JSON representation of this manager
  27964. */
  27965. abstract serialize(name: string): any;
  27966. /**
  27967. * Registers an action to this action manager
  27968. * @param action defines the action to be registered
  27969. * @return the action amended (prepared) after registration
  27970. */
  27971. abstract registerAction(action: IAction): Nullable<IAction>;
  27972. /**
  27973. * Unregisters an action to this action manager
  27974. * @param action defines the action to be unregistered
  27975. * @return a boolean indicating whether the action has been unregistered
  27976. */
  27977. abstract unregisterAction(action: IAction): Boolean;
  27978. /**
  27979. * Does exist one action manager with at least one trigger
  27980. **/
  27981. static readonly HasTriggers: boolean;
  27982. /**
  27983. * Does exist one action manager with at least one pick trigger
  27984. **/
  27985. static readonly HasPickTriggers: boolean;
  27986. /**
  27987. * Does exist one action manager that handles actions of a given trigger
  27988. * @param trigger defines the trigger to be tested
  27989. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27990. **/
  27991. static HasSpecificTrigger(trigger: number): boolean;
  27992. }
  27993. }
  27994. declare module "babylonjs/node" {
  27995. import { Scene } from "babylonjs/scene";
  27996. import { Nullable } from "babylonjs/types";
  27997. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27998. import { Engine } from "babylonjs/Engines/engine";
  27999. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  28000. import { Observable } from "babylonjs/Misc/observable";
  28001. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28002. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28003. import { Animatable } from "babylonjs/Animations/animatable";
  28004. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  28005. import { Animation } from "babylonjs/Animations/animation";
  28006. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28008. /**
  28009. * Defines how a node can be built from a string name.
  28010. */
  28011. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28012. /**
  28013. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28014. */
  28015. export class Node implements IBehaviorAware<Node> {
  28016. /** @hidden */
  28017. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  28018. private static _NodeConstructors;
  28019. /**
  28020. * Add a new node constructor
  28021. * @param type defines the type name of the node to construct
  28022. * @param constructorFunc defines the constructor function
  28023. */
  28024. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28025. /**
  28026. * Returns a node constructor based on type name
  28027. * @param type defines the type name
  28028. * @param name defines the new node name
  28029. * @param scene defines the hosting scene
  28030. * @param options defines optional options to transmit to constructors
  28031. * @returns the new constructor or null
  28032. */
  28033. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28034. /**
  28035. * Gets or sets the name of the node
  28036. */
  28037. name: string;
  28038. /**
  28039. * Gets or sets the id of the node
  28040. */
  28041. id: string;
  28042. /**
  28043. * Gets or sets the unique id of the node
  28044. */
  28045. uniqueId: number;
  28046. /**
  28047. * Gets or sets a string used to store user defined state for the node
  28048. */
  28049. state: string;
  28050. /**
  28051. * Gets or sets an object used to store user defined information for the node
  28052. */
  28053. metadata: any;
  28054. /**
  28055. * For internal use only. Please do not use.
  28056. */
  28057. reservedDataStore: any;
  28058. /**
  28059. * List of inspectable custom properties (used by the Inspector)
  28060. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28061. */
  28062. inspectableCustomProperties: IInspectable[];
  28063. private _doNotSerialize;
  28064. /**
  28065. * Gets or sets a boolean used to define if the node must be serialized
  28066. */
  28067. doNotSerialize: boolean;
  28068. /** @hidden */
  28069. _isDisposed: boolean;
  28070. /**
  28071. * Gets a list of Animations associated with the node
  28072. */
  28073. animations: import("babylonjs/Animations/animation").Animation[];
  28074. protected _ranges: {
  28075. [name: string]: Nullable<AnimationRange>;
  28076. };
  28077. /**
  28078. * Callback raised when the node is ready to be used
  28079. */
  28080. onReady: Nullable<(node: Node) => void>;
  28081. private _isEnabled;
  28082. private _isParentEnabled;
  28083. private _isReady;
  28084. /** @hidden */
  28085. _currentRenderId: number;
  28086. private _parentUpdateId;
  28087. /** @hidden */
  28088. _childUpdateId: number;
  28089. /** @hidden */
  28090. _waitingParentId: Nullable<string>;
  28091. /** @hidden */
  28092. _scene: Scene;
  28093. /** @hidden */
  28094. _cache: any;
  28095. private _parentNode;
  28096. private _children;
  28097. /** @hidden */
  28098. _worldMatrix: Matrix;
  28099. /** @hidden */
  28100. _worldMatrixDeterminant: number;
  28101. /** @hidden */
  28102. _worldMatrixDeterminantIsDirty: boolean;
  28103. /** @hidden */
  28104. private _sceneRootNodesIndex;
  28105. /**
  28106. * Gets a boolean indicating if the node has been disposed
  28107. * @returns true if the node was disposed
  28108. */
  28109. isDisposed(): boolean;
  28110. /**
  28111. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28112. * @see https://doc.babylonjs.com/how_to/parenting
  28113. */
  28114. parent: Nullable<Node>;
  28115. /** @hidden */
  28116. _addToSceneRootNodes(): void;
  28117. /** @hidden */
  28118. _removeFromSceneRootNodes(): void;
  28119. private _animationPropertiesOverride;
  28120. /**
  28121. * Gets or sets the animation properties override
  28122. */
  28123. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28124. /**
  28125. * Gets a string idenfifying the name of the class
  28126. * @returns "Node" string
  28127. */
  28128. getClassName(): string;
  28129. /** @hidden */
  28130. readonly _isNode: boolean;
  28131. /**
  28132. * An event triggered when the mesh is disposed
  28133. */
  28134. onDisposeObservable: Observable<Node>;
  28135. private _onDisposeObserver;
  28136. /**
  28137. * Sets a callback that will be raised when the node will be disposed
  28138. */
  28139. onDispose: () => void;
  28140. /**
  28141. * Creates a new Node
  28142. * @param name the name and id to be given to this node
  28143. * @param scene the scene this node will be added to
  28144. */
  28145. constructor(name: string, scene?: Nullable<Scene>);
  28146. /**
  28147. * Gets the scene of the node
  28148. * @returns a scene
  28149. */
  28150. getScene(): Scene;
  28151. /**
  28152. * Gets the engine of the node
  28153. * @returns a Engine
  28154. */
  28155. getEngine(): Engine;
  28156. private _behaviors;
  28157. /**
  28158. * Attach a behavior to the node
  28159. * @see http://doc.babylonjs.com/features/behaviour
  28160. * @param behavior defines the behavior to attach
  28161. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28162. * @returns the current Node
  28163. */
  28164. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28165. /**
  28166. * Remove an attached behavior
  28167. * @see http://doc.babylonjs.com/features/behaviour
  28168. * @param behavior defines the behavior to attach
  28169. * @returns the current Node
  28170. */
  28171. removeBehavior(behavior: Behavior<Node>): Node;
  28172. /**
  28173. * Gets the list of attached behaviors
  28174. * @see http://doc.babylonjs.com/features/behaviour
  28175. */
  28176. readonly behaviors: Behavior<Node>[];
  28177. /**
  28178. * Gets an attached behavior by name
  28179. * @param name defines the name of the behavior to look for
  28180. * @see http://doc.babylonjs.com/features/behaviour
  28181. * @returns null if behavior was not found else the requested behavior
  28182. */
  28183. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28184. /**
  28185. * Returns the latest update of the World matrix
  28186. * @returns a Matrix
  28187. */
  28188. getWorldMatrix(): Matrix;
  28189. /** @hidden */
  28190. _getWorldMatrixDeterminant(): number;
  28191. /**
  28192. * Returns directly the latest state of the mesh World matrix.
  28193. * A Matrix is returned.
  28194. */
  28195. readonly worldMatrixFromCache: Matrix;
  28196. /** @hidden */
  28197. _initCache(): void;
  28198. /** @hidden */
  28199. updateCache(force?: boolean): void;
  28200. /** @hidden */
  28201. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28202. /** @hidden */
  28203. _updateCache(ignoreParentClass?: boolean): void;
  28204. /** @hidden */
  28205. _isSynchronized(): boolean;
  28206. /** @hidden */
  28207. _markSyncedWithParent(): void;
  28208. /** @hidden */
  28209. isSynchronizedWithParent(): boolean;
  28210. /** @hidden */
  28211. isSynchronized(): boolean;
  28212. /**
  28213. * Is this node ready to be used/rendered
  28214. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28215. * @return true if the node is ready
  28216. */
  28217. isReady(completeCheck?: boolean): boolean;
  28218. /**
  28219. * Is this node enabled?
  28220. * 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
  28221. * @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
  28222. * @return whether this node (and its parent) is enabled
  28223. */
  28224. isEnabled(checkAncestors?: boolean): boolean;
  28225. /** @hidden */
  28226. protected _syncParentEnabledState(): void;
  28227. /**
  28228. * Set the enabled state of this node
  28229. * @param value defines the new enabled state
  28230. */
  28231. setEnabled(value: boolean): void;
  28232. /**
  28233. * Is this node a descendant of the given node?
  28234. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28235. * @param ancestor defines the parent node to inspect
  28236. * @returns a boolean indicating if this node is a descendant of the given node
  28237. */
  28238. isDescendantOf(ancestor: Node): boolean;
  28239. /** @hidden */
  28240. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28241. /**
  28242. * Will return all nodes that have this node as ascendant
  28243. * @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
  28244. * @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
  28245. * @return all children nodes of all types
  28246. */
  28247. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28248. /**
  28249. * Get all child-meshes of this node
  28250. * @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)
  28251. * @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
  28252. * @returns an array of AbstractMesh
  28253. */
  28254. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28255. /**
  28256. * Get all direct children of this node
  28257. * @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
  28258. * @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)
  28259. * @returns an array of Node
  28260. */
  28261. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28262. /** @hidden */
  28263. _setReady(state: boolean): void;
  28264. /**
  28265. * Get an animation by name
  28266. * @param name defines the name of the animation to look for
  28267. * @returns null if not found else the requested animation
  28268. */
  28269. getAnimationByName(name: string): Nullable<Animation>;
  28270. /**
  28271. * Creates an animation range for this node
  28272. * @param name defines the name of the range
  28273. * @param from defines the starting key
  28274. * @param to defines the end key
  28275. */
  28276. createAnimationRange(name: string, from: number, to: number): void;
  28277. /**
  28278. * Delete a specific animation range
  28279. * @param name defines the name of the range to delete
  28280. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28281. */
  28282. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28283. /**
  28284. * Get an animation range by name
  28285. * @param name defines the name of the animation range to look for
  28286. * @returns null if not found else the requested animation range
  28287. */
  28288. getAnimationRange(name: string): Nullable<AnimationRange>;
  28289. /**
  28290. * Gets the list of all animation ranges defined on this node
  28291. * @returns an array
  28292. */
  28293. getAnimationRanges(): Nullable<AnimationRange>[];
  28294. /**
  28295. * Will start the animation sequence
  28296. * @param name defines the range frames for animation sequence
  28297. * @param loop defines if the animation should loop (false by default)
  28298. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28299. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28300. * @returns the object created for this animation. If range does not exist, it will return null
  28301. */
  28302. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28303. /**
  28304. * Serialize animation ranges into a JSON compatible object
  28305. * @returns serialization object
  28306. */
  28307. serializeAnimationRanges(): any;
  28308. /**
  28309. * Computes the world matrix of the node
  28310. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28311. * @returns the world matrix
  28312. */
  28313. computeWorldMatrix(force?: boolean): Matrix;
  28314. /**
  28315. * Releases resources associated with this node.
  28316. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28317. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28318. */
  28319. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28320. /**
  28321. * Parse animation range data from a serialization object and store them into a given node
  28322. * @param node defines where to store the animation ranges
  28323. * @param parsedNode defines the serialization object to read data from
  28324. * @param scene defines the hosting scene
  28325. */
  28326. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28327. /**
  28328. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28329. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28330. * @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
  28331. * @returns the new bounding vectors
  28332. */
  28333. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28334. min: Vector3;
  28335. max: Vector3;
  28336. };
  28337. }
  28338. }
  28339. declare module "babylonjs/Animations/animation" {
  28340. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28341. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28342. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28343. import { Nullable } from "babylonjs/types";
  28344. import { Scene } from "babylonjs/scene";
  28345. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28346. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28347. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28348. import { Node } from "babylonjs/node";
  28349. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28350. import { Size } from "babylonjs/Maths/math.size";
  28351. import { Animatable } from "babylonjs/Animations/animatable";
  28352. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28353. /**
  28354. * @hidden
  28355. */
  28356. export class _IAnimationState {
  28357. key: number;
  28358. repeatCount: number;
  28359. workValue?: any;
  28360. loopMode?: number;
  28361. offsetValue?: any;
  28362. highLimitValue?: any;
  28363. }
  28364. /**
  28365. * Class used to store any kind of animation
  28366. */
  28367. export class Animation {
  28368. /**Name of the animation */
  28369. name: string;
  28370. /**Property to animate */
  28371. targetProperty: string;
  28372. /**The frames per second of the animation */
  28373. framePerSecond: number;
  28374. /**The data type of the animation */
  28375. dataType: number;
  28376. /**The loop mode of the animation */
  28377. loopMode?: number | undefined;
  28378. /**Specifies if blending should be enabled */
  28379. enableBlending?: boolean | undefined;
  28380. /**
  28381. * Use matrix interpolation instead of using direct key value when animating matrices
  28382. */
  28383. static AllowMatricesInterpolation: boolean;
  28384. /**
  28385. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28386. */
  28387. static AllowMatrixDecomposeForInterpolation: boolean;
  28388. /**
  28389. * Stores the key frames of the animation
  28390. */
  28391. private _keys;
  28392. /**
  28393. * Stores the easing function of the animation
  28394. */
  28395. private _easingFunction;
  28396. /**
  28397. * @hidden Internal use only
  28398. */
  28399. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28400. /**
  28401. * The set of event that will be linked to this animation
  28402. */
  28403. private _events;
  28404. /**
  28405. * Stores an array of target property paths
  28406. */
  28407. targetPropertyPath: string[];
  28408. /**
  28409. * Stores the blending speed of the animation
  28410. */
  28411. blendingSpeed: number;
  28412. /**
  28413. * Stores the animation ranges for the animation
  28414. */
  28415. private _ranges;
  28416. /**
  28417. * @hidden Internal use
  28418. */
  28419. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28420. /**
  28421. * Sets up an animation
  28422. * @param property The property to animate
  28423. * @param animationType The animation type to apply
  28424. * @param framePerSecond The frames per second of the animation
  28425. * @param easingFunction The easing function used in the animation
  28426. * @returns The created animation
  28427. */
  28428. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28429. /**
  28430. * Create and start an animation on a node
  28431. * @param name defines the name of the global animation that will be run on all nodes
  28432. * @param node defines the root node where the animation will take place
  28433. * @param targetProperty defines property to animate
  28434. * @param framePerSecond defines the number of frame per second yo use
  28435. * @param totalFrame defines the number of frames in total
  28436. * @param from defines the initial value
  28437. * @param to defines the final value
  28438. * @param loopMode defines which loop mode you want to use (off by default)
  28439. * @param easingFunction defines the easing function to use (linear by default)
  28440. * @param onAnimationEnd defines the callback to call when animation end
  28441. * @returns the animatable created for this animation
  28442. */
  28443. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28444. /**
  28445. * Create and start an animation on a node and its descendants
  28446. * @param name defines the name of the global animation that will be run on all nodes
  28447. * @param node defines the root node where the animation will take place
  28448. * @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
  28449. * @param targetProperty defines property to animate
  28450. * @param framePerSecond defines the number of frame per second to use
  28451. * @param totalFrame defines the number of frames in total
  28452. * @param from defines the initial value
  28453. * @param to defines the final value
  28454. * @param loopMode defines which loop mode you want to use (off by default)
  28455. * @param easingFunction defines the easing function to use (linear by default)
  28456. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28457. * @returns the list of animatables created for all nodes
  28458. * @example https://www.babylonjs-playground.com/#MH0VLI
  28459. */
  28460. 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[]>;
  28461. /**
  28462. * Creates a new animation, merges it with the existing animations and starts it
  28463. * @param name Name of the animation
  28464. * @param node Node which contains the scene that begins the animations
  28465. * @param targetProperty Specifies which property to animate
  28466. * @param framePerSecond The frames per second of the animation
  28467. * @param totalFrame The total number of frames
  28468. * @param from The frame at the beginning of the animation
  28469. * @param to The frame at the end of the animation
  28470. * @param loopMode Specifies the loop mode of the animation
  28471. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28472. * @param onAnimationEnd Callback to run once the animation is complete
  28473. * @returns Nullable animation
  28474. */
  28475. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28476. /**
  28477. * Transition property of an host to the target Value
  28478. * @param property The property to transition
  28479. * @param targetValue The target Value of the property
  28480. * @param host The object where the property to animate belongs
  28481. * @param scene Scene used to run the animation
  28482. * @param frameRate Framerate (in frame/s) to use
  28483. * @param transition The transition type we want to use
  28484. * @param duration The duration of the animation, in milliseconds
  28485. * @param onAnimationEnd Callback trigger at the end of the animation
  28486. * @returns Nullable animation
  28487. */
  28488. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28489. /**
  28490. * Return the array of runtime animations currently using this animation
  28491. */
  28492. readonly runtimeAnimations: RuntimeAnimation[];
  28493. /**
  28494. * Specifies if any of the runtime animations are currently running
  28495. */
  28496. readonly hasRunningRuntimeAnimations: boolean;
  28497. /**
  28498. * Initializes the animation
  28499. * @param name Name of the animation
  28500. * @param targetProperty Property to animate
  28501. * @param framePerSecond The frames per second of the animation
  28502. * @param dataType The data type of the animation
  28503. * @param loopMode The loop mode of the animation
  28504. * @param enableBlending Specifies if blending should be enabled
  28505. */
  28506. constructor(
  28507. /**Name of the animation */
  28508. name: string,
  28509. /**Property to animate */
  28510. targetProperty: string,
  28511. /**The frames per second of the animation */
  28512. framePerSecond: number,
  28513. /**The data type of the animation */
  28514. dataType: number,
  28515. /**The loop mode of the animation */
  28516. loopMode?: number | undefined,
  28517. /**Specifies if blending should be enabled */
  28518. enableBlending?: boolean | undefined);
  28519. /**
  28520. * Converts the animation to a string
  28521. * @param fullDetails support for multiple levels of logging within scene loading
  28522. * @returns String form of the animation
  28523. */
  28524. toString(fullDetails?: boolean): string;
  28525. /**
  28526. * Add an event to this animation
  28527. * @param event Event to add
  28528. */
  28529. addEvent(event: AnimationEvent): void;
  28530. /**
  28531. * Remove all events found at the given frame
  28532. * @param frame The frame to remove events from
  28533. */
  28534. removeEvents(frame: number): void;
  28535. /**
  28536. * Retrieves all the events from the animation
  28537. * @returns Events from the animation
  28538. */
  28539. getEvents(): AnimationEvent[];
  28540. /**
  28541. * Creates an animation range
  28542. * @param name Name of the animation range
  28543. * @param from Starting frame of the animation range
  28544. * @param to Ending frame of the animation
  28545. */
  28546. createRange(name: string, from: number, to: number): void;
  28547. /**
  28548. * Deletes an animation range by name
  28549. * @param name Name of the animation range to delete
  28550. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28551. */
  28552. deleteRange(name: string, deleteFrames?: boolean): void;
  28553. /**
  28554. * Gets the animation range by name, or null if not defined
  28555. * @param name Name of the animation range
  28556. * @returns Nullable animation range
  28557. */
  28558. getRange(name: string): Nullable<AnimationRange>;
  28559. /**
  28560. * Gets the key frames from the animation
  28561. * @returns The key frames of the animation
  28562. */
  28563. getKeys(): Array<IAnimationKey>;
  28564. /**
  28565. * Gets the highest frame rate of the animation
  28566. * @returns Highest frame rate of the animation
  28567. */
  28568. getHighestFrame(): number;
  28569. /**
  28570. * Gets the easing function of the animation
  28571. * @returns Easing function of the animation
  28572. */
  28573. getEasingFunction(): IEasingFunction;
  28574. /**
  28575. * Sets the easing function of the animation
  28576. * @param easingFunction A custom mathematical formula for animation
  28577. */
  28578. setEasingFunction(easingFunction: EasingFunction): void;
  28579. /**
  28580. * Interpolates a scalar linearly
  28581. * @param startValue Start value of the animation curve
  28582. * @param endValue End value of the animation curve
  28583. * @param gradient Scalar amount to interpolate
  28584. * @returns Interpolated scalar value
  28585. */
  28586. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28587. /**
  28588. * Interpolates a scalar cubically
  28589. * @param startValue Start value of the animation curve
  28590. * @param outTangent End tangent of the animation
  28591. * @param endValue End value of the animation curve
  28592. * @param inTangent Start tangent of the animation curve
  28593. * @param gradient Scalar amount to interpolate
  28594. * @returns Interpolated scalar value
  28595. */
  28596. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28597. /**
  28598. * Interpolates a quaternion using a spherical linear interpolation
  28599. * @param startValue Start value of the animation curve
  28600. * @param endValue End value of the animation curve
  28601. * @param gradient Scalar amount to interpolate
  28602. * @returns Interpolated quaternion value
  28603. */
  28604. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28605. /**
  28606. * Interpolates a quaternion cubically
  28607. * @param startValue Start value of the animation curve
  28608. * @param outTangent End tangent of the animation curve
  28609. * @param endValue End value of the animation curve
  28610. * @param inTangent Start tangent of the animation curve
  28611. * @param gradient Scalar amount to interpolate
  28612. * @returns Interpolated quaternion value
  28613. */
  28614. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28615. /**
  28616. * Interpolates a Vector3 linearl
  28617. * @param startValue Start value of the animation curve
  28618. * @param endValue End value of the animation curve
  28619. * @param gradient Scalar amount to interpolate
  28620. * @returns Interpolated scalar value
  28621. */
  28622. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28623. /**
  28624. * Interpolates a Vector3 cubically
  28625. * @param startValue Start value of the animation curve
  28626. * @param outTangent End tangent of the animation
  28627. * @param endValue End value of the animation curve
  28628. * @param inTangent Start tangent of the animation curve
  28629. * @param gradient Scalar amount to interpolate
  28630. * @returns InterpolatedVector3 value
  28631. */
  28632. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28633. /**
  28634. * Interpolates a Vector2 linearly
  28635. * @param startValue Start value of the animation curve
  28636. * @param endValue End value of the animation curve
  28637. * @param gradient Scalar amount to interpolate
  28638. * @returns Interpolated Vector2 value
  28639. */
  28640. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28641. /**
  28642. * Interpolates a Vector2 cubically
  28643. * @param startValue Start value of the animation curve
  28644. * @param outTangent End tangent of the animation
  28645. * @param endValue End value of the animation curve
  28646. * @param inTangent Start tangent of the animation curve
  28647. * @param gradient Scalar amount to interpolate
  28648. * @returns Interpolated Vector2 value
  28649. */
  28650. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28651. /**
  28652. * Interpolates a size linearly
  28653. * @param startValue Start value of the animation curve
  28654. * @param endValue End value of the animation curve
  28655. * @param gradient Scalar amount to interpolate
  28656. * @returns Interpolated Size value
  28657. */
  28658. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28659. /**
  28660. * Interpolates a Color3 linearly
  28661. * @param startValue Start value of the animation curve
  28662. * @param endValue End value of the animation curve
  28663. * @param gradient Scalar amount to interpolate
  28664. * @returns Interpolated Color3 value
  28665. */
  28666. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28667. /**
  28668. * Interpolates a Color4 linearly
  28669. * @param startValue Start value of the animation curve
  28670. * @param endValue End value of the animation curve
  28671. * @param gradient Scalar amount to interpolate
  28672. * @returns Interpolated Color3 value
  28673. */
  28674. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28675. /**
  28676. * @hidden Internal use only
  28677. */
  28678. _getKeyValue(value: any): any;
  28679. /**
  28680. * @hidden Internal use only
  28681. */
  28682. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28683. /**
  28684. * Defines the function to use to interpolate matrices
  28685. * @param startValue defines the start matrix
  28686. * @param endValue defines the end matrix
  28687. * @param gradient defines the gradient between both matrices
  28688. * @param result defines an optional target matrix where to store the interpolation
  28689. * @returns the interpolated matrix
  28690. */
  28691. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28692. /**
  28693. * Makes a copy of the animation
  28694. * @returns Cloned animation
  28695. */
  28696. clone(): Animation;
  28697. /**
  28698. * Sets the key frames of the animation
  28699. * @param values The animation key frames to set
  28700. */
  28701. setKeys(values: Array<IAnimationKey>): void;
  28702. /**
  28703. * Serializes the animation to an object
  28704. * @returns Serialized object
  28705. */
  28706. serialize(): any;
  28707. /**
  28708. * Float animation type
  28709. */
  28710. static readonly ANIMATIONTYPE_FLOAT: number;
  28711. /**
  28712. * Vector3 animation type
  28713. */
  28714. static readonly ANIMATIONTYPE_VECTOR3: number;
  28715. /**
  28716. * Quaternion animation type
  28717. */
  28718. static readonly ANIMATIONTYPE_QUATERNION: number;
  28719. /**
  28720. * Matrix animation type
  28721. */
  28722. static readonly ANIMATIONTYPE_MATRIX: number;
  28723. /**
  28724. * Color3 animation type
  28725. */
  28726. static readonly ANIMATIONTYPE_COLOR3: number;
  28727. /**
  28728. * Color3 animation type
  28729. */
  28730. static readonly ANIMATIONTYPE_COLOR4: number;
  28731. /**
  28732. * Vector2 animation type
  28733. */
  28734. static readonly ANIMATIONTYPE_VECTOR2: number;
  28735. /**
  28736. * Size animation type
  28737. */
  28738. static readonly ANIMATIONTYPE_SIZE: number;
  28739. /**
  28740. * Relative Loop Mode
  28741. */
  28742. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28743. /**
  28744. * Cycle Loop Mode
  28745. */
  28746. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28747. /**
  28748. * Constant Loop Mode
  28749. */
  28750. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28751. /** @hidden */
  28752. static _UniversalLerp(left: any, right: any, amount: number): any;
  28753. /**
  28754. * Parses an animation object and creates an animation
  28755. * @param parsedAnimation Parsed animation object
  28756. * @returns Animation object
  28757. */
  28758. static Parse(parsedAnimation: any): Animation;
  28759. /**
  28760. * Appends the serialized animations from the source animations
  28761. * @param source Source containing the animations
  28762. * @param destination Target to store the animations
  28763. */
  28764. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28765. }
  28766. }
  28767. declare module "babylonjs/Animations/animatable.interface" {
  28768. import { Nullable } from "babylonjs/types";
  28769. import { Animation } from "babylonjs/Animations/animation";
  28770. /**
  28771. * Interface containing an array of animations
  28772. */
  28773. export interface IAnimatable {
  28774. /**
  28775. * Array of animations
  28776. */
  28777. animations: Nullable<Array<Animation>>;
  28778. }
  28779. }
  28780. declare module "babylonjs/Materials/fresnelParameters" {
  28781. import { Color3 } from "babylonjs/Maths/math.color";
  28782. /**
  28783. * This represents all the required information to add a fresnel effect on a material:
  28784. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28785. */
  28786. export class FresnelParameters {
  28787. private _isEnabled;
  28788. /**
  28789. * Define if the fresnel effect is enable or not.
  28790. */
  28791. isEnabled: boolean;
  28792. /**
  28793. * Define the color used on edges (grazing angle)
  28794. */
  28795. leftColor: Color3;
  28796. /**
  28797. * Define the color used on center
  28798. */
  28799. rightColor: Color3;
  28800. /**
  28801. * Define bias applied to computed fresnel term
  28802. */
  28803. bias: number;
  28804. /**
  28805. * Defined the power exponent applied to fresnel term
  28806. */
  28807. power: number;
  28808. /**
  28809. * Clones the current fresnel and its valuues
  28810. * @returns a clone fresnel configuration
  28811. */
  28812. clone(): FresnelParameters;
  28813. /**
  28814. * Serializes the current fresnel parameters to a JSON representation.
  28815. * @return the JSON serialization
  28816. */
  28817. serialize(): any;
  28818. /**
  28819. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28820. * @param parsedFresnelParameters Define the JSON representation
  28821. * @returns the parsed parameters
  28822. */
  28823. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28824. }
  28825. }
  28826. declare module "babylonjs/Misc/decorators" {
  28827. import { Nullable } from "babylonjs/types";
  28828. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28829. import { Scene } from "babylonjs/scene";
  28830. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28831. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28832. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28833. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28834. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28835. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28836. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28837. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28838. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28839. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28840. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28841. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28842. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28843. /**
  28844. * Decorator used to define property that can be serialized as reference to a camera
  28845. * @param sourceName defines the name of the property to decorate
  28846. */
  28847. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28848. /**
  28849. * Class used to help serialization objects
  28850. */
  28851. export class SerializationHelper {
  28852. /** @hidden */
  28853. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28854. /** @hidden */
  28855. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28856. /** @hidden */
  28857. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28858. /** @hidden */
  28859. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28860. /**
  28861. * Appends the serialized animations from the source animations
  28862. * @param source Source containing the animations
  28863. * @param destination Target to store the animations
  28864. */
  28865. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28866. /**
  28867. * Static function used to serialized a specific entity
  28868. * @param entity defines the entity to serialize
  28869. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28870. * @returns a JSON compatible object representing the serialization of the entity
  28871. */
  28872. static Serialize<T>(entity: T, serializationObject?: any): any;
  28873. /**
  28874. * Creates a new entity from a serialization data object
  28875. * @param creationFunction defines a function used to instanciated the new entity
  28876. * @param source defines the source serialization data
  28877. * @param scene defines the hosting scene
  28878. * @param rootUrl defines the root url for resources
  28879. * @returns a new entity
  28880. */
  28881. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28882. /**
  28883. * Clones an object
  28884. * @param creationFunction defines the function used to instanciate the new object
  28885. * @param source defines the source object
  28886. * @returns the cloned object
  28887. */
  28888. static Clone<T>(creationFunction: () => T, source: T): T;
  28889. /**
  28890. * Instanciates a new object based on a source one (some data will be shared between both object)
  28891. * @param creationFunction defines the function used to instanciate the new object
  28892. * @param source defines the source object
  28893. * @returns the new object
  28894. */
  28895. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28896. }
  28897. }
  28898. declare module "babylonjs/Misc/guid" {
  28899. /**
  28900. * Class used to manipulate GUIDs
  28901. */
  28902. export class GUID {
  28903. /**
  28904. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28905. * Be aware Math.random() could cause collisions, but:
  28906. * "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"
  28907. * @returns a pseudo random id
  28908. */
  28909. static RandomId(): string;
  28910. }
  28911. }
  28912. declare module "babylonjs/Materials/Textures/baseTexture" {
  28913. import { Observable } from "babylonjs/Misc/observable";
  28914. import { Nullable } from "babylonjs/types";
  28915. import { Scene } from "babylonjs/scene";
  28916. import { Matrix } from "babylonjs/Maths/math.vector";
  28917. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28918. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28919. import { ISize } from "babylonjs/Maths/math.size";
  28920. /**
  28921. * Base class of all the textures in babylon.
  28922. * It groups all the common properties the materials, post process, lights... might need
  28923. * in order to make a correct use of the texture.
  28924. */
  28925. export class BaseTexture implements IAnimatable {
  28926. /**
  28927. * Default anisotropic filtering level for the application.
  28928. * It is set to 4 as a good tradeoff between perf and quality.
  28929. */
  28930. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28931. /**
  28932. * Gets or sets the unique id of the texture
  28933. */
  28934. uniqueId: number;
  28935. /**
  28936. * Define the name of the texture.
  28937. */
  28938. name: string;
  28939. /**
  28940. * Gets or sets an object used to store user defined information.
  28941. */
  28942. metadata: any;
  28943. /**
  28944. * For internal use only. Please do not use.
  28945. */
  28946. reservedDataStore: any;
  28947. private _hasAlpha;
  28948. /**
  28949. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28950. */
  28951. hasAlpha: boolean;
  28952. /**
  28953. * Defines if the alpha value should be determined via the rgb values.
  28954. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28955. */
  28956. getAlphaFromRGB: boolean;
  28957. /**
  28958. * Intensity or strength of the texture.
  28959. * It is commonly used by materials to fine tune the intensity of the texture
  28960. */
  28961. level: number;
  28962. /**
  28963. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28964. * This is part of the texture as textures usually maps to one uv set.
  28965. */
  28966. coordinatesIndex: number;
  28967. private _coordinatesMode;
  28968. /**
  28969. * How a texture is mapped.
  28970. *
  28971. * | Value | Type | Description |
  28972. * | ----- | ----------------------------------- | ----------- |
  28973. * | 0 | EXPLICIT_MODE | |
  28974. * | 1 | SPHERICAL_MODE | |
  28975. * | 2 | PLANAR_MODE | |
  28976. * | 3 | CUBIC_MODE | |
  28977. * | 4 | PROJECTION_MODE | |
  28978. * | 5 | SKYBOX_MODE | |
  28979. * | 6 | INVCUBIC_MODE | |
  28980. * | 7 | EQUIRECTANGULAR_MODE | |
  28981. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28982. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28983. */
  28984. coordinatesMode: number;
  28985. /**
  28986. * | Value | Type | Description |
  28987. * | ----- | ------------------ | ----------- |
  28988. * | 0 | CLAMP_ADDRESSMODE | |
  28989. * | 1 | WRAP_ADDRESSMODE | |
  28990. * | 2 | MIRROR_ADDRESSMODE | |
  28991. */
  28992. wrapU: number;
  28993. /**
  28994. * | Value | Type | Description |
  28995. * | ----- | ------------------ | ----------- |
  28996. * | 0 | CLAMP_ADDRESSMODE | |
  28997. * | 1 | WRAP_ADDRESSMODE | |
  28998. * | 2 | MIRROR_ADDRESSMODE | |
  28999. */
  29000. wrapV: number;
  29001. /**
  29002. * | Value | Type | Description |
  29003. * | ----- | ------------------ | ----------- |
  29004. * | 0 | CLAMP_ADDRESSMODE | |
  29005. * | 1 | WRAP_ADDRESSMODE | |
  29006. * | 2 | MIRROR_ADDRESSMODE | |
  29007. */
  29008. wrapR: number;
  29009. /**
  29010. * With compliant hardware and browser (supporting anisotropic filtering)
  29011. * this defines the level of anisotropic filtering in the texture.
  29012. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29013. */
  29014. anisotropicFilteringLevel: number;
  29015. /**
  29016. * Define if the texture is a cube texture or if false a 2d texture.
  29017. */
  29018. isCube: boolean;
  29019. /**
  29020. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29021. */
  29022. is3D: boolean;
  29023. /**
  29024. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29025. */
  29026. is2DArray: boolean;
  29027. /**
  29028. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29029. * HDR texture are usually stored in linear space.
  29030. * This only impacts the PBR and Background materials
  29031. */
  29032. gammaSpace: boolean;
  29033. /**
  29034. * Gets or sets whether or not the texture contains RGBD data.
  29035. */
  29036. isRGBD: boolean;
  29037. /**
  29038. * Is Z inverted in the texture (useful in a cube texture).
  29039. */
  29040. invertZ: boolean;
  29041. /**
  29042. * Are mip maps generated for this texture or not.
  29043. */
  29044. readonly noMipmap: boolean;
  29045. /**
  29046. * @hidden
  29047. */
  29048. lodLevelInAlpha: boolean;
  29049. /**
  29050. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29051. */
  29052. lodGenerationOffset: number;
  29053. /**
  29054. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29055. */
  29056. lodGenerationScale: number;
  29057. /**
  29058. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29059. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29060. * average roughness values.
  29061. */
  29062. linearSpecularLOD: boolean;
  29063. /**
  29064. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29065. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29066. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29067. */
  29068. irradianceTexture: Nullable<BaseTexture>;
  29069. /**
  29070. * Define if the texture is a render target.
  29071. */
  29072. isRenderTarget: boolean;
  29073. /**
  29074. * Define the unique id of the texture in the scene.
  29075. */
  29076. readonly uid: string;
  29077. /**
  29078. * Return a string representation of the texture.
  29079. * @returns the texture as a string
  29080. */
  29081. toString(): string;
  29082. /**
  29083. * Get the class name of the texture.
  29084. * @returns "BaseTexture"
  29085. */
  29086. getClassName(): string;
  29087. /**
  29088. * Define the list of animation attached to the texture.
  29089. */
  29090. animations: import("babylonjs/Animations/animation").Animation[];
  29091. /**
  29092. * An event triggered when the texture is disposed.
  29093. */
  29094. onDisposeObservable: Observable<BaseTexture>;
  29095. private _onDisposeObserver;
  29096. /**
  29097. * Callback triggered when the texture has been disposed.
  29098. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29099. */
  29100. onDispose: () => void;
  29101. /**
  29102. * Define the current state of the loading sequence when in delayed load mode.
  29103. */
  29104. delayLoadState: number;
  29105. private _scene;
  29106. /** @hidden */
  29107. _texture: Nullable<InternalTexture>;
  29108. private _uid;
  29109. /**
  29110. * Define if the texture is preventinga material to render or not.
  29111. * If not and the texture is not ready, the engine will use a default black texture instead.
  29112. */
  29113. readonly isBlocking: boolean;
  29114. /**
  29115. * Instantiates a new BaseTexture.
  29116. * Base class of all the textures in babylon.
  29117. * It groups all the common properties the materials, post process, lights... might need
  29118. * in order to make a correct use of the texture.
  29119. * @param scene Define the scene the texture blongs to
  29120. */
  29121. constructor(scene: Nullable<Scene>);
  29122. /**
  29123. * Get the scene the texture belongs to.
  29124. * @returns the scene or null if undefined
  29125. */
  29126. getScene(): Nullable<Scene>;
  29127. /**
  29128. * Get the texture transform matrix used to offset tile the texture for istance.
  29129. * @returns the transformation matrix
  29130. */
  29131. getTextureMatrix(): Matrix;
  29132. /**
  29133. * Get the texture reflection matrix used to rotate/transform the reflection.
  29134. * @returns the reflection matrix
  29135. */
  29136. getReflectionTextureMatrix(): Matrix;
  29137. /**
  29138. * Get the underlying lower level texture from Babylon.
  29139. * @returns the insternal texture
  29140. */
  29141. getInternalTexture(): Nullable<InternalTexture>;
  29142. /**
  29143. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29144. * @returns true if ready or not blocking
  29145. */
  29146. isReadyOrNotBlocking(): boolean;
  29147. /**
  29148. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29149. * @returns true if fully ready
  29150. */
  29151. isReady(): boolean;
  29152. private _cachedSize;
  29153. /**
  29154. * Get the size of the texture.
  29155. * @returns the texture size.
  29156. */
  29157. getSize(): ISize;
  29158. /**
  29159. * Get the base size of the texture.
  29160. * It can be different from the size if the texture has been resized for POT for instance
  29161. * @returns the base size
  29162. */
  29163. getBaseSize(): ISize;
  29164. /**
  29165. * Update the sampling mode of the texture.
  29166. * Default is Trilinear mode.
  29167. *
  29168. * | Value | Type | Description |
  29169. * | ----- | ------------------ | ----------- |
  29170. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29171. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29172. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29173. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29174. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29175. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29176. * | 7 | NEAREST_LINEAR | |
  29177. * | 8 | NEAREST_NEAREST | |
  29178. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29179. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29180. * | 11 | LINEAR_LINEAR | |
  29181. * | 12 | LINEAR_NEAREST | |
  29182. *
  29183. * > _mag_: magnification filter (close to the viewer)
  29184. * > _min_: minification filter (far from the viewer)
  29185. * > _mip_: filter used between mip map levels
  29186. *@param samplingMode Define the new sampling mode of the texture
  29187. */
  29188. updateSamplingMode(samplingMode: number): void;
  29189. /**
  29190. * Scales the texture if is `canRescale()`
  29191. * @param ratio the resize factor we want to use to rescale
  29192. */
  29193. scale(ratio: number): void;
  29194. /**
  29195. * Get if the texture can rescale.
  29196. */
  29197. readonly canRescale: boolean;
  29198. /** @hidden */
  29199. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29200. /** @hidden */
  29201. _rebuild(): void;
  29202. /**
  29203. * Triggers the load sequence in delayed load mode.
  29204. */
  29205. delayLoad(): void;
  29206. /**
  29207. * Clones the texture.
  29208. * @returns the cloned texture
  29209. */
  29210. clone(): Nullable<BaseTexture>;
  29211. /**
  29212. * Get the texture underlying type (INT, FLOAT...)
  29213. */
  29214. readonly textureType: number;
  29215. /**
  29216. * Get the texture underlying format (RGB, RGBA...)
  29217. */
  29218. readonly textureFormat: number;
  29219. /**
  29220. * Indicates that textures need to be re-calculated for all materials
  29221. */
  29222. protected _markAllSubMeshesAsTexturesDirty(): void;
  29223. /**
  29224. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29225. * This will returns an RGBA array buffer containing either in values (0-255) or
  29226. * float values (0-1) depending of the underlying buffer type.
  29227. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29228. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29229. * @param buffer defines a user defined buffer to fill with data (can be null)
  29230. * @returns The Array buffer containing the pixels data.
  29231. */
  29232. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29233. /**
  29234. * Release and destroy the underlying lower level texture aka internalTexture.
  29235. */
  29236. releaseInternalTexture(): void;
  29237. /** @hidden */
  29238. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29239. /** @hidden */
  29240. readonly _lodTextureMid: Nullable<BaseTexture>;
  29241. /** @hidden */
  29242. readonly _lodTextureLow: Nullable<BaseTexture>;
  29243. /**
  29244. * Dispose the texture and release its associated resources.
  29245. */
  29246. dispose(): void;
  29247. /**
  29248. * Serialize the texture into a JSON representation that can be parsed later on.
  29249. * @returns the JSON representation of the texture
  29250. */
  29251. serialize(): any;
  29252. /**
  29253. * Helper function to be called back once a list of texture contains only ready textures.
  29254. * @param textures Define the list of textures to wait for
  29255. * @param callback Define the callback triggered once the entire list will be ready
  29256. */
  29257. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29258. }
  29259. }
  29260. declare module "babylonjs/Materials/effect" {
  29261. import { Observable } from "babylonjs/Misc/observable";
  29262. import { Nullable } from "babylonjs/types";
  29263. import { IDisposable } from "babylonjs/scene";
  29264. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29265. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29266. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29267. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29268. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29269. import { Engine } from "babylonjs/Engines/engine";
  29270. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29271. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29272. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29273. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29274. /**
  29275. * Options to be used when creating an effect.
  29276. */
  29277. export interface IEffectCreationOptions {
  29278. /**
  29279. * Atrributes that will be used in the shader.
  29280. */
  29281. attributes: string[];
  29282. /**
  29283. * Uniform varible names that will be set in the shader.
  29284. */
  29285. uniformsNames: string[];
  29286. /**
  29287. * Uniform buffer variable names that will be set in the shader.
  29288. */
  29289. uniformBuffersNames: string[];
  29290. /**
  29291. * Sampler texture variable names that will be set in the shader.
  29292. */
  29293. samplers: string[];
  29294. /**
  29295. * Define statements that will be set in the shader.
  29296. */
  29297. defines: any;
  29298. /**
  29299. * Possible fallbacks for this effect to improve performance when needed.
  29300. */
  29301. fallbacks: Nullable<IEffectFallbacks>;
  29302. /**
  29303. * Callback that will be called when the shader is compiled.
  29304. */
  29305. onCompiled: Nullable<(effect: Effect) => void>;
  29306. /**
  29307. * Callback that will be called if an error occurs during shader compilation.
  29308. */
  29309. onError: Nullable<(effect: Effect, errors: string) => void>;
  29310. /**
  29311. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29312. */
  29313. indexParameters?: any;
  29314. /**
  29315. * Max number of lights that can be used in the shader.
  29316. */
  29317. maxSimultaneousLights?: number;
  29318. /**
  29319. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29320. */
  29321. transformFeedbackVaryings?: Nullable<string[]>;
  29322. }
  29323. /**
  29324. * Effect containing vertex and fragment shader that can be executed on an object.
  29325. */
  29326. export class Effect implements IDisposable {
  29327. /**
  29328. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29329. */
  29330. static ShadersRepository: string;
  29331. /**
  29332. * Name of the effect.
  29333. */
  29334. name: any;
  29335. /**
  29336. * String container all the define statements that should be set on the shader.
  29337. */
  29338. defines: string;
  29339. /**
  29340. * Callback that will be called when the shader is compiled.
  29341. */
  29342. onCompiled: Nullable<(effect: Effect) => void>;
  29343. /**
  29344. * Callback that will be called if an error occurs during shader compilation.
  29345. */
  29346. onError: Nullable<(effect: Effect, errors: string) => void>;
  29347. /**
  29348. * Callback that will be called when effect is bound.
  29349. */
  29350. onBind: Nullable<(effect: Effect) => void>;
  29351. /**
  29352. * Unique ID of the effect.
  29353. */
  29354. uniqueId: number;
  29355. /**
  29356. * Observable that will be called when the shader is compiled.
  29357. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29358. */
  29359. onCompileObservable: Observable<Effect>;
  29360. /**
  29361. * Observable that will be called if an error occurs during shader compilation.
  29362. */
  29363. onErrorObservable: Observable<Effect>;
  29364. /** @hidden */
  29365. _onBindObservable: Nullable<Observable<Effect>>;
  29366. /**
  29367. * Observable that will be called when effect is bound.
  29368. */
  29369. readonly onBindObservable: Observable<Effect>;
  29370. /** @hidden */
  29371. _bonesComputationForcedToCPU: boolean;
  29372. private static _uniqueIdSeed;
  29373. private _engine;
  29374. private _uniformBuffersNames;
  29375. private _uniformsNames;
  29376. private _samplerList;
  29377. private _samplers;
  29378. private _isReady;
  29379. private _compilationError;
  29380. private _allFallbacksProcessed;
  29381. private _attributesNames;
  29382. private _attributes;
  29383. private _uniforms;
  29384. /**
  29385. * Key for the effect.
  29386. * @hidden
  29387. */
  29388. _key: string;
  29389. private _indexParameters;
  29390. private _fallbacks;
  29391. private _vertexSourceCode;
  29392. private _fragmentSourceCode;
  29393. private _vertexSourceCodeOverride;
  29394. private _fragmentSourceCodeOverride;
  29395. private _transformFeedbackVaryings;
  29396. /**
  29397. * Compiled shader to webGL program.
  29398. * @hidden
  29399. */
  29400. _pipelineContext: Nullable<IPipelineContext>;
  29401. private _valueCache;
  29402. private static _baseCache;
  29403. /**
  29404. * Instantiates an effect.
  29405. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29406. * @param baseName Name of the effect.
  29407. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29408. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29409. * @param samplers List of sampler variables that will be passed to the shader.
  29410. * @param engine Engine to be used to render the effect
  29411. * @param defines Define statements to be added to the shader.
  29412. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29413. * @param onCompiled Callback that will be called when the shader is compiled.
  29414. * @param onError Callback that will be called if an error occurs during shader compilation.
  29415. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29416. */
  29417. 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);
  29418. private _useFinalCode;
  29419. /**
  29420. * Unique key for this effect
  29421. */
  29422. readonly key: string;
  29423. /**
  29424. * If the effect has been compiled and prepared.
  29425. * @returns if the effect is compiled and prepared.
  29426. */
  29427. isReady(): boolean;
  29428. private _isReadyInternal;
  29429. /**
  29430. * The engine the effect was initialized with.
  29431. * @returns the engine.
  29432. */
  29433. getEngine(): Engine;
  29434. /**
  29435. * The pipeline context for this effect
  29436. * @returns the associated pipeline context
  29437. */
  29438. getPipelineContext(): Nullable<IPipelineContext>;
  29439. /**
  29440. * The set of names of attribute variables for the shader.
  29441. * @returns An array of attribute names.
  29442. */
  29443. getAttributesNames(): string[];
  29444. /**
  29445. * Returns the attribute at the given index.
  29446. * @param index The index of the attribute.
  29447. * @returns The location of the attribute.
  29448. */
  29449. getAttributeLocation(index: number): number;
  29450. /**
  29451. * Returns the attribute based on the name of the variable.
  29452. * @param name of the attribute to look up.
  29453. * @returns the attribute location.
  29454. */
  29455. getAttributeLocationByName(name: string): number;
  29456. /**
  29457. * The number of attributes.
  29458. * @returns the numnber of attributes.
  29459. */
  29460. getAttributesCount(): number;
  29461. /**
  29462. * Gets the index of a uniform variable.
  29463. * @param uniformName of the uniform to look up.
  29464. * @returns the index.
  29465. */
  29466. getUniformIndex(uniformName: string): number;
  29467. /**
  29468. * Returns the attribute based on the name of the variable.
  29469. * @param uniformName of the uniform to look up.
  29470. * @returns the location of the uniform.
  29471. */
  29472. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29473. /**
  29474. * Returns an array of sampler variable names
  29475. * @returns The array of sampler variable neames.
  29476. */
  29477. getSamplers(): string[];
  29478. /**
  29479. * The error from the last compilation.
  29480. * @returns the error string.
  29481. */
  29482. getCompilationError(): string;
  29483. /**
  29484. * Gets a boolean indicating that all fallbacks were used during compilation
  29485. * @returns true if all fallbacks were used
  29486. */
  29487. allFallbacksProcessed(): boolean;
  29488. /**
  29489. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29490. * @param func The callback to be used.
  29491. */
  29492. executeWhenCompiled(func: (effect: Effect) => void): void;
  29493. private _checkIsReady;
  29494. private _loadShader;
  29495. /**
  29496. * Recompiles the webGL program
  29497. * @param vertexSourceCode The source code for the vertex shader.
  29498. * @param fragmentSourceCode The source code for the fragment shader.
  29499. * @param onCompiled Callback called when completed.
  29500. * @param onError Callback called on error.
  29501. * @hidden
  29502. */
  29503. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29504. /**
  29505. * Prepares the effect
  29506. * @hidden
  29507. */
  29508. _prepareEffect(): void;
  29509. private _processCompilationErrors;
  29510. /**
  29511. * Checks if the effect is supported. (Must be called after compilation)
  29512. */
  29513. readonly isSupported: boolean;
  29514. /**
  29515. * Binds a texture to the engine to be used as output of the shader.
  29516. * @param channel Name of the output variable.
  29517. * @param texture Texture to bind.
  29518. * @hidden
  29519. */
  29520. _bindTexture(channel: string, texture: InternalTexture): void;
  29521. /**
  29522. * Sets a texture on the engine to be used in the shader.
  29523. * @param channel Name of the sampler variable.
  29524. * @param texture Texture to set.
  29525. */
  29526. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29527. /**
  29528. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29529. * @param channel Name of the sampler variable.
  29530. * @param texture Texture to set.
  29531. */
  29532. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29533. /**
  29534. * Sets an array of textures on the engine to be used in the shader.
  29535. * @param channel Name of the variable.
  29536. * @param textures Textures to set.
  29537. */
  29538. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29539. /**
  29540. * 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)
  29541. * @param channel Name of the sampler variable.
  29542. * @param postProcess Post process to get the input texture from.
  29543. */
  29544. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29545. /**
  29546. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29547. * 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)
  29548. * @param channel Name of the sampler variable.
  29549. * @param postProcess Post process to get the output texture from.
  29550. */
  29551. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29552. /** @hidden */
  29553. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29554. /** @hidden */
  29555. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29556. /** @hidden */
  29557. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29558. /** @hidden */
  29559. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29560. /**
  29561. * Binds a buffer to a uniform.
  29562. * @param buffer Buffer to bind.
  29563. * @param name Name of the uniform variable to bind to.
  29564. */
  29565. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29566. /**
  29567. * Binds block to a uniform.
  29568. * @param blockName Name of the block to bind.
  29569. * @param index Index to bind.
  29570. */
  29571. bindUniformBlock(blockName: string, index: number): void;
  29572. /**
  29573. * Sets an interger value on a uniform variable.
  29574. * @param uniformName Name of the variable.
  29575. * @param value Value to be set.
  29576. * @returns this effect.
  29577. */
  29578. setInt(uniformName: string, value: number): Effect;
  29579. /**
  29580. * Sets an int array on a uniform variable.
  29581. * @param uniformName Name of the variable.
  29582. * @param array array to be set.
  29583. * @returns this effect.
  29584. */
  29585. setIntArray(uniformName: string, array: Int32Array): Effect;
  29586. /**
  29587. * 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)
  29588. * @param uniformName Name of the variable.
  29589. * @param array array to be set.
  29590. * @returns this effect.
  29591. */
  29592. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29593. /**
  29594. * 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)
  29595. * @param uniformName Name of the variable.
  29596. * @param array array to be set.
  29597. * @returns this effect.
  29598. */
  29599. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29600. /**
  29601. * 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)
  29602. * @param uniformName Name of the variable.
  29603. * @param array array to be set.
  29604. * @returns this effect.
  29605. */
  29606. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29607. /**
  29608. * Sets an float array on a uniform variable.
  29609. * @param uniformName Name of the variable.
  29610. * @param array array to be set.
  29611. * @returns this effect.
  29612. */
  29613. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29614. /**
  29615. * 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)
  29616. * @param uniformName Name of the variable.
  29617. * @param array array to be set.
  29618. * @returns this effect.
  29619. */
  29620. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29621. /**
  29622. * 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)
  29623. * @param uniformName Name of the variable.
  29624. * @param array array to be set.
  29625. * @returns this effect.
  29626. */
  29627. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29628. /**
  29629. * 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)
  29630. * @param uniformName Name of the variable.
  29631. * @param array array to be set.
  29632. * @returns this effect.
  29633. */
  29634. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29635. /**
  29636. * Sets an array on a uniform variable.
  29637. * @param uniformName Name of the variable.
  29638. * @param array array to be set.
  29639. * @returns this effect.
  29640. */
  29641. setArray(uniformName: string, array: number[]): Effect;
  29642. /**
  29643. * 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)
  29644. * @param uniformName Name of the variable.
  29645. * @param array array to be set.
  29646. * @returns this effect.
  29647. */
  29648. setArray2(uniformName: string, array: number[]): Effect;
  29649. /**
  29650. * 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)
  29651. * @param uniformName Name of the variable.
  29652. * @param array array to be set.
  29653. * @returns this effect.
  29654. */
  29655. setArray3(uniformName: string, array: number[]): Effect;
  29656. /**
  29657. * 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)
  29658. * @param uniformName Name of the variable.
  29659. * @param array array to be set.
  29660. * @returns this effect.
  29661. */
  29662. setArray4(uniformName: string, array: number[]): Effect;
  29663. /**
  29664. * Sets matrices on a uniform variable.
  29665. * @param uniformName Name of the variable.
  29666. * @param matrices matrices to be set.
  29667. * @returns this effect.
  29668. */
  29669. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29670. /**
  29671. * Sets matrix on a uniform variable.
  29672. * @param uniformName Name of the variable.
  29673. * @param matrix matrix to be set.
  29674. * @returns this effect.
  29675. */
  29676. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29677. /**
  29678. * 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)
  29679. * @param uniformName Name of the variable.
  29680. * @param matrix matrix to be set.
  29681. * @returns this effect.
  29682. */
  29683. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29684. /**
  29685. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29686. * @param uniformName Name of the variable.
  29687. * @param matrix matrix to be set.
  29688. * @returns this effect.
  29689. */
  29690. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29691. /**
  29692. * Sets a float on a uniform variable.
  29693. * @param uniformName Name of the variable.
  29694. * @param value value to be set.
  29695. * @returns this effect.
  29696. */
  29697. setFloat(uniformName: string, value: number): Effect;
  29698. /**
  29699. * Sets a boolean on a uniform variable.
  29700. * @param uniformName Name of the variable.
  29701. * @param bool value to be set.
  29702. * @returns this effect.
  29703. */
  29704. setBool(uniformName: string, bool: boolean): Effect;
  29705. /**
  29706. * Sets a Vector2 on a uniform variable.
  29707. * @param uniformName Name of the variable.
  29708. * @param vector2 vector2 to be set.
  29709. * @returns this effect.
  29710. */
  29711. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29712. /**
  29713. * Sets a float2 on a uniform variable.
  29714. * @param uniformName Name of the variable.
  29715. * @param x First float in float2.
  29716. * @param y Second float in float2.
  29717. * @returns this effect.
  29718. */
  29719. setFloat2(uniformName: string, x: number, y: number): Effect;
  29720. /**
  29721. * Sets a Vector3 on a uniform variable.
  29722. * @param uniformName Name of the variable.
  29723. * @param vector3 Value to be set.
  29724. * @returns this effect.
  29725. */
  29726. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29727. /**
  29728. * Sets a float3 on a uniform variable.
  29729. * @param uniformName Name of the variable.
  29730. * @param x First float in float3.
  29731. * @param y Second float in float3.
  29732. * @param z Third float in float3.
  29733. * @returns this effect.
  29734. */
  29735. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29736. /**
  29737. * Sets a Vector4 on a uniform variable.
  29738. * @param uniformName Name of the variable.
  29739. * @param vector4 Value to be set.
  29740. * @returns this effect.
  29741. */
  29742. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29743. /**
  29744. * Sets a float4 on a uniform variable.
  29745. * @param uniformName Name of the variable.
  29746. * @param x First float in float4.
  29747. * @param y Second float in float4.
  29748. * @param z Third float in float4.
  29749. * @param w Fourth float in float4.
  29750. * @returns this effect.
  29751. */
  29752. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29753. /**
  29754. * Sets a Color3 on a uniform variable.
  29755. * @param uniformName Name of the variable.
  29756. * @param color3 Value to be set.
  29757. * @returns this effect.
  29758. */
  29759. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29760. /**
  29761. * Sets a Color4 on a uniform variable.
  29762. * @param uniformName Name of the variable.
  29763. * @param color3 Value to be set.
  29764. * @param alpha Alpha value to be set.
  29765. * @returns this effect.
  29766. */
  29767. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29768. /**
  29769. * Sets a Color4 on a uniform variable
  29770. * @param uniformName defines the name of the variable
  29771. * @param color4 defines the value to be set
  29772. * @returns this effect.
  29773. */
  29774. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29775. /** Release all associated resources */
  29776. dispose(): void;
  29777. /**
  29778. * This function will add a new shader to the shader store
  29779. * @param name the name of the shader
  29780. * @param pixelShader optional pixel shader content
  29781. * @param vertexShader optional vertex shader content
  29782. */
  29783. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29784. /**
  29785. * Store of each shader (The can be looked up using effect.key)
  29786. */
  29787. static ShadersStore: {
  29788. [key: string]: string;
  29789. };
  29790. /**
  29791. * Store of each included file for a shader (The can be looked up using effect.key)
  29792. */
  29793. static IncludesShadersStore: {
  29794. [key: string]: string;
  29795. };
  29796. /**
  29797. * Resets the cache of effects.
  29798. */
  29799. static ResetCache(): void;
  29800. }
  29801. }
  29802. declare module "babylonjs/Engines/engineCapabilities" {
  29803. /**
  29804. * Interface used to describe the capabilities of the engine relatively to the current browser
  29805. */
  29806. export interface EngineCapabilities {
  29807. /** Maximum textures units per fragment shader */
  29808. maxTexturesImageUnits: number;
  29809. /** Maximum texture units per vertex shader */
  29810. maxVertexTextureImageUnits: number;
  29811. /** Maximum textures units in the entire pipeline */
  29812. maxCombinedTexturesImageUnits: number;
  29813. /** Maximum texture size */
  29814. maxTextureSize: number;
  29815. /** Maximum cube texture size */
  29816. maxCubemapTextureSize: number;
  29817. /** Maximum render texture size */
  29818. maxRenderTextureSize: number;
  29819. /** Maximum number of vertex attributes */
  29820. maxVertexAttribs: number;
  29821. /** Maximum number of varyings */
  29822. maxVaryingVectors: number;
  29823. /** Maximum number of uniforms per vertex shader */
  29824. maxVertexUniformVectors: number;
  29825. /** Maximum number of uniforms per fragment shader */
  29826. maxFragmentUniformVectors: number;
  29827. /** Defines if standard derivates (dx/dy) are supported */
  29828. standardDerivatives: boolean;
  29829. /** Defines if s3tc texture compression is supported */
  29830. s3tc?: WEBGL_compressed_texture_s3tc;
  29831. /** Defines if pvrtc texture compression is supported */
  29832. pvrtc: any;
  29833. /** Defines if etc1 texture compression is supported */
  29834. etc1: any;
  29835. /** Defines if etc2 texture compression is supported */
  29836. etc2: any;
  29837. /** Defines if astc texture compression is supported */
  29838. astc: any;
  29839. /** Defines if float textures are supported */
  29840. textureFloat: boolean;
  29841. /** Defines if vertex array objects are supported */
  29842. vertexArrayObject: boolean;
  29843. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29844. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29845. /** Gets the maximum level of anisotropy supported */
  29846. maxAnisotropy: number;
  29847. /** Defines if instancing is supported */
  29848. instancedArrays: boolean;
  29849. /** Defines if 32 bits indices are supported */
  29850. uintIndices: boolean;
  29851. /** Defines if high precision shaders are supported */
  29852. highPrecisionShaderSupported: boolean;
  29853. /** Defines if depth reading in the fragment shader is supported */
  29854. fragmentDepthSupported: boolean;
  29855. /** Defines if float texture linear filtering is supported*/
  29856. textureFloatLinearFiltering: boolean;
  29857. /** Defines if rendering to float textures is supported */
  29858. textureFloatRender: boolean;
  29859. /** Defines if half float textures are supported*/
  29860. textureHalfFloat: boolean;
  29861. /** Defines if half float texture linear filtering is supported*/
  29862. textureHalfFloatLinearFiltering: boolean;
  29863. /** Defines if rendering to half float textures is supported */
  29864. textureHalfFloatRender: boolean;
  29865. /** Defines if textureLOD shader command is supported */
  29866. textureLOD: boolean;
  29867. /** Defines if draw buffers extension is supported */
  29868. drawBuffersExtension: boolean;
  29869. /** Defines if depth textures are supported */
  29870. depthTextureExtension: boolean;
  29871. /** Defines if float color buffer are supported */
  29872. colorBufferFloat: boolean;
  29873. /** Gets disjoint timer query extension (null if not supported) */
  29874. timerQuery?: EXT_disjoint_timer_query;
  29875. /** Defines if timestamp can be used with timer query */
  29876. canUseTimestampForTimerQuery: boolean;
  29877. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29878. multiview?: any;
  29879. /** Function used to let the system compiles shaders in background */
  29880. parallelShaderCompile?: {
  29881. COMPLETION_STATUS_KHR: number;
  29882. };
  29883. /** Max number of texture samples for MSAA */
  29884. maxMSAASamples: number;
  29885. /** Defines if the blend min max extension is supported */
  29886. blendMinMax: boolean;
  29887. }
  29888. }
  29889. declare module "babylonjs/States/depthCullingState" {
  29890. import { Nullable } from "babylonjs/types";
  29891. /**
  29892. * @hidden
  29893. **/
  29894. export class DepthCullingState {
  29895. private _isDepthTestDirty;
  29896. private _isDepthMaskDirty;
  29897. private _isDepthFuncDirty;
  29898. private _isCullFaceDirty;
  29899. private _isCullDirty;
  29900. private _isZOffsetDirty;
  29901. private _isFrontFaceDirty;
  29902. private _depthTest;
  29903. private _depthMask;
  29904. private _depthFunc;
  29905. private _cull;
  29906. private _cullFace;
  29907. private _zOffset;
  29908. private _frontFace;
  29909. /**
  29910. * Initializes the state.
  29911. */
  29912. constructor();
  29913. readonly isDirty: boolean;
  29914. zOffset: number;
  29915. cullFace: Nullable<number>;
  29916. cull: Nullable<boolean>;
  29917. depthFunc: Nullable<number>;
  29918. depthMask: boolean;
  29919. depthTest: boolean;
  29920. frontFace: Nullable<number>;
  29921. reset(): void;
  29922. apply(gl: WebGLRenderingContext): void;
  29923. }
  29924. }
  29925. declare module "babylonjs/States/stencilState" {
  29926. /**
  29927. * @hidden
  29928. **/
  29929. export class StencilState {
  29930. /** 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 */
  29931. static readonly ALWAYS: number;
  29932. /** Passed to stencilOperation to specify that stencil value must be kept */
  29933. static readonly KEEP: number;
  29934. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29935. static readonly REPLACE: number;
  29936. private _isStencilTestDirty;
  29937. private _isStencilMaskDirty;
  29938. private _isStencilFuncDirty;
  29939. private _isStencilOpDirty;
  29940. private _stencilTest;
  29941. private _stencilMask;
  29942. private _stencilFunc;
  29943. private _stencilFuncRef;
  29944. private _stencilFuncMask;
  29945. private _stencilOpStencilFail;
  29946. private _stencilOpDepthFail;
  29947. private _stencilOpStencilDepthPass;
  29948. readonly isDirty: boolean;
  29949. stencilFunc: number;
  29950. stencilFuncRef: number;
  29951. stencilFuncMask: number;
  29952. stencilOpStencilFail: number;
  29953. stencilOpDepthFail: number;
  29954. stencilOpStencilDepthPass: number;
  29955. stencilMask: number;
  29956. stencilTest: boolean;
  29957. constructor();
  29958. reset(): void;
  29959. apply(gl: WebGLRenderingContext): void;
  29960. }
  29961. }
  29962. declare module "babylonjs/States/alphaCullingState" {
  29963. /**
  29964. * @hidden
  29965. **/
  29966. export class AlphaState {
  29967. private _isAlphaBlendDirty;
  29968. private _isBlendFunctionParametersDirty;
  29969. private _isBlendEquationParametersDirty;
  29970. private _isBlendConstantsDirty;
  29971. private _alphaBlend;
  29972. private _blendFunctionParameters;
  29973. private _blendEquationParameters;
  29974. private _blendConstants;
  29975. /**
  29976. * Initializes the state.
  29977. */
  29978. constructor();
  29979. readonly isDirty: boolean;
  29980. alphaBlend: boolean;
  29981. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29982. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29983. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29984. reset(): void;
  29985. apply(gl: WebGLRenderingContext): void;
  29986. }
  29987. }
  29988. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29989. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29990. /** @hidden */
  29991. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29992. attributeProcessor(attribute: string): string;
  29993. varyingProcessor(varying: string, isFragment: boolean): string;
  29994. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29995. }
  29996. }
  29997. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29998. /**
  29999. * Interface for attribute information associated with buffer instanciation
  30000. */
  30001. export interface InstancingAttributeInfo {
  30002. /**
  30003. * Index/offset of the attribute in the vertex shader
  30004. */
  30005. index: number;
  30006. /**
  30007. * size of the attribute, 1, 2, 3 or 4
  30008. */
  30009. attributeSize: number;
  30010. /**
  30011. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30012. * default is FLOAT
  30013. */
  30014. attributeType: number;
  30015. /**
  30016. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30017. */
  30018. normalized: boolean;
  30019. /**
  30020. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30021. */
  30022. offset: number;
  30023. /**
  30024. * Name of the GLSL attribute, for debugging purpose only
  30025. */
  30026. attributeName: string;
  30027. }
  30028. }
  30029. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  30030. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30031. import { Nullable } from "babylonjs/types";
  30032. module "babylonjs/Engines/thinEngine" {
  30033. interface ThinEngine {
  30034. /**
  30035. * Update a video texture
  30036. * @param texture defines the texture to update
  30037. * @param video defines the video element to use
  30038. * @param invertY defines if data must be stored with Y axis inverted
  30039. */
  30040. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30041. }
  30042. }
  30043. }
  30044. declare module "babylonjs/Materials/Textures/videoTexture" {
  30045. import { Observable } from "babylonjs/Misc/observable";
  30046. import { Nullable } from "babylonjs/types";
  30047. import { Scene } from "babylonjs/scene";
  30048. import { Texture } from "babylonjs/Materials/Textures/texture";
  30049. import "babylonjs/Engines/Extensions/engine.videoTexture";
  30050. /**
  30051. * Settings for finer control over video usage
  30052. */
  30053. export interface VideoTextureSettings {
  30054. /**
  30055. * Applies `autoplay` to video, if specified
  30056. */
  30057. autoPlay?: boolean;
  30058. /**
  30059. * Applies `loop` to video, if specified
  30060. */
  30061. loop?: boolean;
  30062. /**
  30063. * Automatically updates internal texture from video at every frame in the render loop
  30064. */
  30065. autoUpdateTexture: boolean;
  30066. /**
  30067. * Image src displayed during the video loading or until the user interacts with the video.
  30068. */
  30069. poster?: string;
  30070. }
  30071. /**
  30072. * If you want to display a video in your scene, this is the special texture for that.
  30073. * This special texture works similar to other textures, with the exception of a few parameters.
  30074. * @see https://doc.babylonjs.com/how_to/video_texture
  30075. */
  30076. export class VideoTexture extends Texture {
  30077. /**
  30078. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30079. */
  30080. readonly autoUpdateTexture: boolean;
  30081. /**
  30082. * The video instance used by the texture internally
  30083. */
  30084. readonly video: HTMLVideoElement;
  30085. private _onUserActionRequestedObservable;
  30086. /**
  30087. * Event triggerd when a dom action is required by the user to play the video.
  30088. * This happens due to recent changes in browser policies preventing video to auto start.
  30089. */
  30090. readonly onUserActionRequestedObservable: Observable<Texture>;
  30091. private _generateMipMaps;
  30092. private _engine;
  30093. private _stillImageCaptured;
  30094. private _displayingPosterTexture;
  30095. private _settings;
  30096. private _createInternalTextureOnEvent;
  30097. private _frameId;
  30098. /**
  30099. * Creates a video texture.
  30100. * If you want to display a video in your scene, this is the special texture for that.
  30101. * This special texture works similar to other textures, with the exception of a few parameters.
  30102. * @see https://doc.babylonjs.com/how_to/video_texture
  30103. * @param name optional name, will detect from video source, if not defined
  30104. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30105. * @param scene is obviously the current scene.
  30106. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30107. * @param invertY is false by default but can be used to invert video on Y axis
  30108. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30109. * @param settings allows finer control over video usage
  30110. */
  30111. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30112. private _getName;
  30113. private _getVideo;
  30114. private _createInternalTexture;
  30115. private reset;
  30116. /**
  30117. * @hidden Internal method to initiate `update`.
  30118. */
  30119. _rebuild(): void;
  30120. /**
  30121. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30122. */
  30123. update(): void;
  30124. /**
  30125. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30126. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30127. */
  30128. updateTexture(isVisible: boolean): void;
  30129. protected _updateInternalTexture: () => void;
  30130. /**
  30131. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30132. * @param url New url.
  30133. */
  30134. updateURL(url: string): void;
  30135. /**
  30136. * Dispose the texture and release its associated resources.
  30137. */
  30138. dispose(): void;
  30139. /**
  30140. * Creates a video texture straight from a stream.
  30141. * @param scene Define the scene the texture should be created in
  30142. * @param stream Define the stream the texture should be created from
  30143. * @returns The created video texture as a promise
  30144. */
  30145. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30146. /**
  30147. * Creates a video texture straight from your WebCam video feed.
  30148. * @param scene Define the scene the texture should be created in
  30149. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30150. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30151. * @returns The created video texture as a promise
  30152. */
  30153. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30154. minWidth: number;
  30155. maxWidth: number;
  30156. minHeight: number;
  30157. maxHeight: number;
  30158. deviceId: string;
  30159. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30160. /**
  30161. * Creates a video texture straight from your WebCam video feed.
  30162. * @param scene Define the scene the texture should be created in
  30163. * @param onReady Define a callback to triggered once the texture will be ready
  30164. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30165. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30166. */
  30167. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30168. minWidth: number;
  30169. maxWidth: number;
  30170. minHeight: number;
  30171. maxHeight: number;
  30172. deviceId: string;
  30173. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30174. }
  30175. }
  30176. declare module "babylonjs/Engines/thinEngine" {
  30177. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30178. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  30179. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30180. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30181. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30182. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30183. import { Observable } from "babylonjs/Misc/observable";
  30184. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30185. import { StencilState } from "babylonjs/States/stencilState";
  30186. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30187. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30188. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30189. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30190. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30192. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30193. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30194. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30195. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30196. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30197. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30198. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30199. /**
  30200. * Defines the interface used by objects working like Scene
  30201. * @hidden
  30202. */
  30203. interface ISceneLike {
  30204. _addPendingData(data: any): void;
  30205. _removePendingData(data: any): void;
  30206. offlineProvider: IOfflineProvider;
  30207. }
  30208. /** Interface defining initialization parameters for Engine class */
  30209. export interface EngineOptions extends WebGLContextAttributes {
  30210. /**
  30211. * Defines if the engine should no exceed a specified device ratio
  30212. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30213. */
  30214. limitDeviceRatio?: number;
  30215. /**
  30216. * Defines if webvr should be enabled automatically
  30217. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30218. */
  30219. autoEnableWebVR?: boolean;
  30220. /**
  30221. * Defines if webgl2 should be turned off even if supported
  30222. * @see http://doc.babylonjs.com/features/webgl2
  30223. */
  30224. disableWebGL2Support?: boolean;
  30225. /**
  30226. * Defines if webaudio should be initialized as well
  30227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30228. */
  30229. audioEngine?: boolean;
  30230. /**
  30231. * Defines if animations should run using a deterministic lock step
  30232. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30233. */
  30234. deterministicLockstep?: boolean;
  30235. /** Defines the maximum steps to use with deterministic lock step mode */
  30236. lockstepMaxSteps?: number;
  30237. /**
  30238. * Defines that engine should ignore context lost events
  30239. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30240. */
  30241. doNotHandleContextLost?: boolean;
  30242. /**
  30243. * Defines that engine should ignore modifying touch action attribute and style
  30244. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30245. */
  30246. doNotHandleTouchAction?: boolean;
  30247. /**
  30248. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30249. */
  30250. useHighPrecisionFloats?: boolean;
  30251. }
  30252. /**
  30253. * The base engine class (root of all engines)
  30254. */
  30255. export class ThinEngine {
  30256. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30257. static ExceptionList: ({
  30258. key: string;
  30259. capture: string;
  30260. captureConstraint: number;
  30261. targets: string[];
  30262. } | {
  30263. key: string;
  30264. capture: null;
  30265. captureConstraint: null;
  30266. targets: string[];
  30267. })[];
  30268. /** @hidden */
  30269. static _TextureLoaders: IInternalTextureLoader[];
  30270. /**
  30271. * Returns the current npm package of the sdk
  30272. */
  30273. static readonly NpmPackage: string;
  30274. /**
  30275. * Returns the current version of the framework
  30276. */
  30277. static readonly Version: string;
  30278. /**
  30279. * Returns a string describing the current engine
  30280. */
  30281. readonly description: string;
  30282. /**
  30283. * Gets or sets the epsilon value used by collision engine
  30284. */
  30285. static CollisionsEpsilon: number;
  30286. /**
  30287. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30288. */
  30289. static ShadersRepository: string;
  30290. /** @hidden */
  30291. _shaderProcessor: IShaderProcessor;
  30292. /**
  30293. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30294. */
  30295. forcePOTTextures: boolean;
  30296. /**
  30297. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30298. */
  30299. isFullscreen: boolean;
  30300. /**
  30301. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30302. */
  30303. cullBackFaces: boolean;
  30304. /**
  30305. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30306. */
  30307. renderEvenInBackground: boolean;
  30308. /**
  30309. * Gets or sets a boolean indicating that cache can be kept between frames
  30310. */
  30311. preventCacheWipeBetweenFrames: boolean;
  30312. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30313. validateShaderPrograms: boolean;
  30314. /**
  30315. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30316. */
  30317. disableUniformBuffers: boolean;
  30318. /** @hidden */
  30319. _uniformBuffers: UniformBuffer[];
  30320. /**
  30321. * Gets a boolean indicating that the engine supports uniform buffers
  30322. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30323. */
  30324. readonly supportsUniformBuffers: boolean;
  30325. /** @hidden */
  30326. _gl: WebGLRenderingContext;
  30327. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30328. protected _windowIsBackground: boolean;
  30329. protected _webGLVersion: number;
  30330. protected _creationOptions: EngineOptions;
  30331. protected _highPrecisionShadersAllowed: boolean;
  30332. /** @hidden */
  30333. readonly _shouldUseHighPrecisionShader: boolean;
  30334. /**
  30335. * Gets a boolean indicating that only power of 2 textures are supported
  30336. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30337. */
  30338. readonly needPOTTextures: boolean;
  30339. /** @hidden */
  30340. _badOS: boolean;
  30341. /** @hidden */
  30342. _badDesktopOS: boolean;
  30343. private _hardwareScalingLevel;
  30344. /** @hidden */
  30345. _caps: EngineCapabilities;
  30346. private _isStencilEnable;
  30347. protected _colorWrite: boolean;
  30348. private _glVersion;
  30349. private _glRenderer;
  30350. private _glVendor;
  30351. /** @hidden */
  30352. _videoTextureSupported: boolean;
  30353. protected _renderingQueueLaunched: boolean;
  30354. protected _activeRenderLoops: (() => void)[];
  30355. /**
  30356. * Observable signaled when a context lost event is raised
  30357. */
  30358. onContextLostObservable: Observable<ThinEngine>;
  30359. /**
  30360. * Observable signaled when a context restored event is raised
  30361. */
  30362. onContextRestoredObservable: Observable<ThinEngine>;
  30363. private _onContextLost;
  30364. private _onContextRestored;
  30365. protected _contextWasLost: boolean;
  30366. /** @hidden */
  30367. _doNotHandleContextLost: boolean;
  30368. /**
  30369. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30371. */
  30372. doNotHandleContextLost: boolean;
  30373. /**
  30374. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30375. */
  30376. disableVertexArrayObjects: boolean;
  30377. /** @hidden */
  30378. protected _depthCullingState: DepthCullingState;
  30379. /** @hidden */
  30380. protected _stencilState: StencilState;
  30381. /** @hidden */
  30382. protected _alphaState: AlphaState;
  30383. /** @hidden */
  30384. _internalTexturesCache: InternalTexture[];
  30385. /** @hidden */
  30386. protected _activeChannel: number;
  30387. private _currentTextureChannel;
  30388. /** @hidden */
  30389. protected _boundTexturesCache: {
  30390. [key: string]: Nullable<InternalTexture>;
  30391. };
  30392. /** @hidden */
  30393. protected _currentEffect: Nullable<Effect>;
  30394. /** @hidden */
  30395. protected _currentProgram: Nullable<WebGLProgram>;
  30396. private _compiledEffects;
  30397. private _vertexAttribArraysEnabled;
  30398. /** @hidden */
  30399. protected _cachedViewport: Nullable<IViewportLike>;
  30400. private _cachedVertexArrayObject;
  30401. /** @hidden */
  30402. protected _cachedVertexBuffers: any;
  30403. /** @hidden */
  30404. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30405. /** @hidden */
  30406. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30407. /** @hidden */
  30408. _currentRenderTarget: Nullable<InternalTexture>;
  30409. private _uintIndicesCurrentlySet;
  30410. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30411. /** @hidden */
  30412. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30413. private _currentBufferPointers;
  30414. private _currentInstanceLocations;
  30415. private _currentInstanceBuffers;
  30416. private _textureUnits;
  30417. /** @hidden */
  30418. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30419. /** @hidden */
  30420. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30421. /** @hidden */
  30422. _boundRenderFunction: any;
  30423. private _vaoRecordInProgress;
  30424. private _mustWipeVertexAttributes;
  30425. private _emptyTexture;
  30426. private _emptyCubeTexture;
  30427. private _emptyTexture3D;
  30428. private _emptyTexture2DArray;
  30429. /** @hidden */
  30430. _frameHandler: number;
  30431. private _nextFreeTextureSlots;
  30432. private _maxSimultaneousTextures;
  30433. private _activeRequests;
  30434. protected _texturesSupported: string[];
  30435. /** @hidden */
  30436. _textureFormatInUse: Nullable<string>;
  30437. protected readonly _supportsHardwareTextureRescaling: boolean;
  30438. /**
  30439. * Gets the list of texture formats supported
  30440. */
  30441. readonly texturesSupported: Array<string>;
  30442. /**
  30443. * Gets the list of texture formats in use
  30444. */
  30445. readonly textureFormatInUse: Nullable<string>;
  30446. /**
  30447. * Gets the current viewport
  30448. */
  30449. readonly currentViewport: Nullable<IViewportLike>;
  30450. /**
  30451. * Gets the default empty texture
  30452. */
  30453. readonly emptyTexture: InternalTexture;
  30454. /**
  30455. * Gets the default empty 3D texture
  30456. */
  30457. readonly emptyTexture3D: InternalTexture;
  30458. /**
  30459. * Gets the default empty 2D array texture
  30460. */
  30461. readonly emptyTexture2DArray: InternalTexture;
  30462. /**
  30463. * Gets the default empty cube texture
  30464. */
  30465. readonly emptyCubeTexture: InternalTexture;
  30466. /**
  30467. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30468. */
  30469. readonly premultipliedAlpha: boolean;
  30470. /**
  30471. * Observable event triggered before each texture is initialized
  30472. */
  30473. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30474. /**
  30475. * Creates a new engine
  30476. * @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
  30477. * @param antialias defines enable antialiasing (default: false)
  30478. * @param options defines further options to be sent to the getContext() function
  30479. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30480. */
  30481. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30482. private _rebuildInternalTextures;
  30483. private _rebuildEffects;
  30484. /**
  30485. * Gets a boolean indicating if all created effects are ready
  30486. * @returns true if all effects are ready
  30487. */
  30488. areAllEffectsReady(): boolean;
  30489. protected _rebuildBuffers(): void;
  30490. private _initGLContext;
  30491. /**
  30492. * Gets version of the current webGL context
  30493. */
  30494. readonly webGLVersion: number;
  30495. /**
  30496. * Gets a string idenfifying the name of the class
  30497. * @returns "Engine" string
  30498. */
  30499. getClassName(): string;
  30500. /**
  30501. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30502. */
  30503. readonly isStencilEnable: boolean;
  30504. /** @hidden */
  30505. _prepareWorkingCanvas(): void;
  30506. /**
  30507. * Reset the texture cache to empty state
  30508. */
  30509. resetTextureCache(): void;
  30510. /**
  30511. * Gets an object containing information about the current webGL context
  30512. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30513. */
  30514. getGlInfo(): {
  30515. vendor: string;
  30516. renderer: string;
  30517. version: string;
  30518. };
  30519. /**
  30520. * Defines the hardware scaling level.
  30521. * By default the hardware scaling level is computed from the window device ratio.
  30522. * 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.
  30523. * @param level defines the level to use
  30524. */
  30525. setHardwareScalingLevel(level: number): void;
  30526. /**
  30527. * Gets the current hardware scaling level.
  30528. * By default the hardware scaling level is computed from the window device ratio.
  30529. * 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.
  30530. * @returns a number indicating the current hardware scaling level
  30531. */
  30532. getHardwareScalingLevel(): number;
  30533. /**
  30534. * Gets the list of loaded textures
  30535. * @returns an array containing all loaded textures
  30536. */
  30537. getLoadedTexturesCache(): InternalTexture[];
  30538. /**
  30539. * Gets the object containing all engine capabilities
  30540. * @returns the EngineCapabilities object
  30541. */
  30542. getCaps(): EngineCapabilities;
  30543. /**
  30544. * stop executing a render loop function and remove it from the execution array
  30545. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30546. */
  30547. stopRenderLoop(renderFunction?: () => void): void;
  30548. /** @hidden */
  30549. _renderLoop(): void;
  30550. /**
  30551. * Gets the HTML canvas attached with the current webGL context
  30552. * @returns a HTML canvas
  30553. */
  30554. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30555. /**
  30556. * Gets host window
  30557. * @returns the host window object
  30558. */
  30559. getHostWindow(): Nullable<Window>;
  30560. /**
  30561. * Gets the current render width
  30562. * @param useScreen defines if screen size must be used (or the current render target if any)
  30563. * @returns a number defining the current render width
  30564. */
  30565. getRenderWidth(useScreen?: boolean): number;
  30566. /**
  30567. * Gets the current render height
  30568. * @param useScreen defines if screen size must be used (or the current render target if any)
  30569. * @returns a number defining the current render height
  30570. */
  30571. getRenderHeight(useScreen?: boolean): number;
  30572. /**
  30573. * Can be used to override the current requestAnimationFrame requester.
  30574. * @hidden
  30575. */
  30576. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30577. /**
  30578. * Register and execute a render loop. The engine can have more than one render function
  30579. * @param renderFunction defines the function to continuously execute
  30580. */
  30581. runRenderLoop(renderFunction: () => void): void;
  30582. /**
  30583. * Clear the current render buffer or the current render target (if any is set up)
  30584. * @param color defines the color to use
  30585. * @param backBuffer defines if the back buffer must be cleared
  30586. * @param depth defines if the depth buffer must be cleared
  30587. * @param stencil defines if the stencil buffer must be cleared
  30588. */
  30589. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30590. private _viewportCached;
  30591. /** @hidden */
  30592. _viewport(x: number, y: number, width: number, height: number): void;
  30593. /**
  30594. * Set the WebGL's viewport
  30595. * @param viewport defines the viewport element to be used
  30596. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30597. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30598. */
  30599. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30600. /**
  30601. * Begin a new frame
  30602. */
  30603. beginFrame(): void;
  30604. /**
  30605. * Enf the current frame
  30606. */
  30607. endFrame(): void;
  30608. /**
  30609. * Resize the view according to the canvas' size
  30610. */
  30611. resize(): void;
  30612. /**
  30613. * Force a specific size of the canvas
  30614. * @param width defines the new canvas' width
  30615. * @param height defines the new canvas' height
  30616. */
  30617. setSize(width: number, height: number): void;
  30618. /**
  30619. * Binds the frame buffer to the specified texture.
  30620. * @param texture The texture to render to or null for the default canvas
  30621. * @param faceIndex The face of the texture to render to in case of cube texture
  30622. * @param requiredWidth The width of the target to render to
  30623. * @param requiredHeight The height of the target to render to
  30624. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30625. * @param depthStencilTexture The depth stencil texture to use to render
  30626. * @param lodLevel defines le lod level to bind to the frame buffer
  30627. */
  30628. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30629. /** @hidden */
  30630. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30631. /**
  30632. * Unbind the current render target texture from the webGL context
  30633. * @param texture defines the render target texture to unbind
  30634. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30635. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30636. */
  30637. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30638. /**
  30639. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30640. */
  30641. flushFramebuffer(): void;
  30642. /**
  30643. * Unbind the current render target and bind the default framebuffer
  30644. */
  30645. restoreDefaultFramebuffer(): void;
  30646. /** @hidden */
  30647. protected _resetVertexBufferBinding(): void;
  30648. /**
  30649. * Creates a vertex buffer
  30650. * @param data the data for the vertex buffer
  30651. * @returns the new WebGL static buffer
  30652. */
  30653. createVertexBuffer(data: DataArray): DataBuffer;
  30654. private _createVertexBuffer;
  30655. /**
  30656. * Creates a dynamic vertex buffer
  30657. * @param data the data for the dynamic vertex buffer
  30658. * @returns the new WebGL dynamic buffer
  30659. */
  30660. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30661. protected _resetIndexBufferBinding(): void;
  30662. /**
  30663. * Creates a new index buffer
  30664. * @param indices defines the content of the index buffer
  30665. * @param updatable defines if the index buffer must be updatable
  30666. * @returns a new webGL buffer
  30667. */
  30668. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30669. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30670. /**
  30671. * Bind a webGL buffer to the webGL context
  30672. * @param buffer defines the buffer to bind
  30673. */
  30674. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30675. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30676. private bindBuffer;
  30677. /**
  30678. * update the bound buffer with the given data
  30679. * @param data defines the data to update
  30680. */
  30681. updateArrayBuffer(data: Float32Array): void;
  30682. private _vertexAttribPointer;
  30683. private _bindIndexBufferWithCache;
  30684. private _bindVertexBuffersAttributes;
  30685. /**
  30686. * Records a vertex array object
  30687. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30688. * @param vertexBuffers defines the list of vertex buffers to store
  30689. * @param indexBuffer defines the index buffer to store
  30690. * @param effect defines the effect to store
  30691. * @returns the new vertex array object
  30692. */
  30693. recordVertexArrayObject(vertexBuffers: {
  30694. [key: string]: VertexBuffer;
  30695. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30696. /**
  30697. * Bind a specific vertex array object
  30698. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30699. * @param vertexArrayObject defines the vertex array object to bind
  30700. * @param indexBuffer defines the index buffer to bind
  30701. */
  30702. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30703. /**
  30704. * Bind webGl buffers directly to the webGL context
  30705. * @param vertexBuffer defines the vertex buffer to bind
  30706. * @param indexBuffer defines the index buffer to bind
  30707. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30708. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30709. * @param effect defines the effect associated with the vertex buffer
  30710. */
  30711. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30712. private _unbindVertexArrayObject;
  30713. /**
  30714. * Bind a list of vertex buffers to the webGL context
  30715. * @param vertexBuffers defines the list of vertex buffers to bind
  30716. * @param indexBuffer defines the index buffer to bind
  30717. * @param effect defines the effect associated with the vertex buffers
  30718. */
  30719. bindBuffers(vertexBuffers: {
  30720. [key: string]: Nullable<VertexBuffer>;
  30721. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30722. /**
  30723. * Unbind all instance attributes
  30724. */
  30725. unbindInstanceAttributes(): void;
  30726. /**
  30727. * Release and free the memory of a vertex array object
  30728. * @param vao defines the vertex array object to delete
  30729. */
  30730. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30731. /** @hidden */
  30732. _releaseBuffer(buffer: DataBuffer): boolean;
  30733. protected _deleteBuffer(buffer: DataBuffer): void;
  30734. /**
  30735. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30736. * @param instancesBuffer defines the webGL buffer to update and bind
  30737. * @param data defines the data to store in the buffer
  30738. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30739. */
  30740. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30741. /**
  30742. * Apply all cached states (depth, culling, stencil and alpha)
  30743. */
  30744. applyStates(): void;
  30745. /**
  30746. * Send a draw order
  30747. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30748. * @param indexStart defines the starting index
  30749. * @param indexCount defines the number of index to draw
  30750. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30751. */
  30752. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30753. /**
  30754. * Draw a list of points
  30755. * @param verticesStart defines the index of first vertex to draw
  30756. * @param verticesCount defines the count of vertices to draw
  30757. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30758. */
  30759. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30760. /**
  30761. * Draw a list of unindexed primitives
  30762. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30763. * @param verticesStart defines the index of first vertex to draw
  30764. * @param verticesCount defines the count of vertices to draw
  30765. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30766. */
  30767. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30768. /**
  30769. * Draw a list of indexed primitives
  30770. * @param fillMode defines the primitive to use
  30771. * @param indexStart defines the starting index
  30772. * @param indexCount defines the number of index to draw
  30773. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30774. */
  30775. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30776. /**
  30777. * Draw a list of unindexed primitives
  30778. * @param fillMode defines the primitive to use
  30779. * @param verticesStart defines the index of first vertex to draw
  30780. * @param verticesCount defines the count of vertices to draw
  30781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30782. */
  30783. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30784. private _drawMode;
  30785. /** @hidden */
  30786. protected _reportDrawCall(): void;
  30787. /** @hidden */
  30788. _releaseEffect(effect: Effect): void;
  30789. /** @hidden */
  30790. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30791. /**
  30792. * Create a new effect (used to store vertex/fragment shaders)
  30793. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30794. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30795. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30796. * @param samplers defines an array of string used to represent textures
  30797. * @param defines defines the string containing the defines to use to compile the shaders
  30798. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30799. * @param onCompiled defines a function to call when the effect creation is successful
  30800. * @param onError defines a function to call when the effect creation has failed
  30801. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30802. * @returns the new Effect
  30803. */
  30804. 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;
  30805. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30806. private _compileShader;
  30807. private _compileRawShader;
  30808. /**
  30809. * Directly creates a webGL program
  30810. * @param pipelineContext defines the pipeline context to attach to
  30811. * @param vertexCode defines the vertex shader code to use
  30812. * @param fragmentCode defines the fragment shader code to use
  30813. * @param context defines the webGL context to use (if not set, the current one will be used)
  30814. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30815. * @returns the new webGL program
  30816. */
  30817. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30818. /**
  30819. * Creates a webGL program
  30820. * @param pipelineContext defines the pipeline context to attach to
  30821. * @param vertexCode defines the vertex shader code to use
  30822. * @param fragmentCode defines the fragment shader code to use
  30823. * @param defines defines the string containing the defines to use to compile the shaders
  30824. * @param context defines the webGL context to use (if not set, the current one will be used)
  30825. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30826. * @returns the new webGL program
  30827. */
  30828. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30829. /**
  30830. * Creates a new pipeline context
  30831. * @returns the new pipeline
  30832. */
  30833. createPipelineContext(): IPipelineContext;
  30834. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30835. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30836. /** @hidden */
  30837. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30838. /** @hidden */
  30839. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30840. /** @hidden */
  30841. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30842. /**
  30843. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30844. * @param pipelineContext defines the pipeline context to use
  30845. * @param uniformsNames defines the list of uniform names
  30846. * @returns an array of webGL uniform locations
  30847. */
  30848. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30849. /**
  30850. * Gets the lsit of active attributes for a given webGL program
  30851. * @param pipelineContext defines the pipeline context to use
  30852. * @param attributesNames defines the list of attribute names to get
  30853. * @returns an array of indices indicating the offset of each attribute
  30854. */
  30855. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30856. /**
  30857. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30858. * @param effect defines the effect to activate
  30859. */
  30860. enableEffect(effect: Nullable<Effect>): void;
  30861. /**
  30862. * Set the value of an uniform to a number (int)
  30863. * @param uniform defines the webGL uniform location where to store the value
  30864. * @param value defines the int number to store
  30865. */
  30866. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30867. /**
  30868. * Set the value of an uniform to an array of int32
  30869. * @param uniform defines the webGL uniform location where to store the value
  30870. * @param array defines the array of int32 to store
  30871. */
  30872. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30873. /**
  30874. * Set the value of an uniform to an array of int32 (stored as vec2)
  30875. * @param uniform defines the webGL uniform location where to store the value
  30876. * @param array defines the array of int32 to store
  30877. */
  30878. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30879. /**
  30880. * Set the value of an uniform to an array of int32 (stored as vec3)
  30881. * @param uniform defines the webGL uniform location where to store the value
  30882. * @param array defines the array of int32 to store
  30883. */
  30884. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30885. /**
  30886. * Set the value of an uniform to an array of int32 (stored as vec4)
  30887. * @param uniform defines the webGL uniform location where to store the value
  30888. * @param array defines the array of int32 to store
  30889. */
  30890. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30891. /**
  30892. * Set the value of an uniform to an array of number
  30893. * @param uniform defines the webGL uniform location where to store the value
  30894. * @param array defines the array of number to store
  30895. */
  30896. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30897. /**
  30898. * Set the value of an uniform to an array of number (stored as vec2)
  30899. * @param uniform defines the webGL uniform location where to store the value
  30900. * @param array defines the array of number to store
  30901. */
  30902. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30903. /**
  30904. * Set the value of an uniform to an array of number (stored as vec3)
  30905. * @param uniform defines the webGL uniform location where to store the value
  30906. * @param array defines the array of number to store
  30907. */
  30908. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30909. /**
  30910. * Set the value of an uniform to an array of number (stored as vec4)
  30911. * @param uniform defines the webGL uniform location where to store the value
  30912. * @param array defines the array of number to store
  30913. */
  30914. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30915. /**
  30916. * Set the value of an uniform to an array of float32 (stored as matrices)
  30917. * @param uniform defines the webGL uniform location where to store the value
  30918. * @param matrices defines the array of float32 to store
  30919. */
  30920. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30921. /**
  30922. * Set the value of an uniform to a matrix (3x3)
  30923. * @param uniform defines the webGL uniform location where to store the value
  30924. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30925. */
  30926. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30927. /**
  30928. * Set the value of an uniform to a matrix (2x2)
  30929. * @param uniform defines the webGL uniform location where to store the value
  30930. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30931. */
  30932. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30933. /**
  30934. * Set the value of an uniform to a number (float)
  30935. * @param uniform defines the webGL uniform location where to store the value
  30936. * @param value defines the float number to store
  30937. */
  30938. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30939. /**
  30940. * Set the value of an uniform to a vec2
  30941. * @param uniform defines the webGL uniform location where to store the value
  30942. * @param x defines the 1st component of the value
  30943. * @param y defines the 2nd component of the value
  30944. */
  30945. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30946. /**
  30947. * Set the value of an uniform to a vec3
  30948. * @param uniform defines the webGL uniform location where to store the value
  30949. * @param x defines the 1st component of the value
  30950. * @param y defines the 2nd component of the value
  30951. * @param z defines the 3rd component of the value
  30952. */
  30953. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30954. /**
  30955. * Set the value of an uniform to a vec4
  30956. * @param uniform defines the webGL uniform location where to store the value
  30957. * @param x defines the 1st component of the value
  30958. * @param y defines the 2nd component of the value
  30959. * @param z defines the 3rd component of the value
  30960. * @param w defines the 4th component of the value
  30961. */
  30962. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30963. /**
  30964. * Gets the depth culling state manager
  30965. */
  30966. readonly depthCullingState: DepthCullingState;
  30967. /**
  30968. * Gets the alpha state manager
  30969. */
  30970. readonly alphaState: AlphaState;
  30971. /**
  30972. * Gets the stencil state manager
  30973. */
  30974. readonly stencilState: StencilState;
  30975. /**
  30976. * Clears the list of texture accessible through engine.
  30977. * This can help preventing texture load conflict due to name collision.
  30978. */
  30979. clearInternalTexturesCache(): void;
  30980. /**
  30981. * Force the entire cache to be cleared
  30982. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30983. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30984. */
  30985. wipeCaches(bruteForce?: boolean): void;
  30986. /** @hidden */
  30987. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30988. min: number;
  30989. mag: number;
  30990. };
  30991. /** @hidden */
  30992. _createTexture(): WebGLTexture;
  30993. /**
  30994. * Usually called from Texture.ts.
  30995. * Passed information to create a WebGLTexture
  30996. * @param urlArg defines a value which contains one of the following:
  30997. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30998. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30999. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31000. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31001. * @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)
  31002. * @param scene needed for loading to the correct scene
  31003. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31004. * @param onLoad optional callback to be called upon successful completion
  31005. * @param onError optional callback to be called upon failure
  31006. * @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
  31007. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31008. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31009. * @param forcedExtension defines the extension to use to pick the right loader
  31010. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31011. * @param mimeType defines an optional mime type
  31012. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31013. */
  31014. 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;
  31015. /**
  31016. * @hidden
  31017. */
  31018. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31019. /**
  31020. * Creates a raw texture
  31021. * @param data defines the data to store in the texture
  31022. * @param width defines the width of the texture
  31023. * @param height defines the height of the texture
  31024. * @param format defines the format of the data
  31025. * @param generateMipMaps defines if the engine should generate the mip levels
  31026. * @param invertY defines if data must be stored with Y axis inverted
  31027. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31028. * @param compression defines the compression used (null by default)
  31029. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31030. * @returns the raw texture inside an InternalTexture
  31031. */
  31032. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31033. /**
  31034. * Creates a new raw cube texture
  31035. * @param data defines the array of data to use to create each face
  31036. * @param size defines the size of the textures
  31037. * @param format defines the format of the data
  31038. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31039. * @param generateMipMaps defines if the engine should generate the mip levels
  31040. * @param invertY defines if data must be stored with Y axis inverted
  31041. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31042. * @param compression defines the compression used (null by default)
  31043. * @returns the cube texture as an InternalTexture
  31044. */
  31045. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31046. /**
  31047. * Creates a new raw 3D texture
  31048. * @param data defines the data used to create the texture
  31049. * @param width defines the width of the texture
  31050. * @param height defines the height of the texture
  31051. * @param depth defines the depth of the texture
  31052. * @param format defines the format of the texture
  31053. * @param generateMipMaps defines if the engine must generate mip levels
  31054. * @param invertY defines if data must be stored with Y axis inverted
  31055. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31056. * @param compression defines the compressed used (can be null)
  31057. * @param textureType defines the compressed used (can be null)
  31058. * @returns a new raw 3D texture (stored in an InternalTexture)
  31059. */
  31060. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31061. /**
  31062. * Creates a new raw 2D array texture
  31063. * @param data defines the data used to create the texture
  31064. * @param width defines the width of the texture
  31065. * @param height defines the height of the texture
  31066. * @param depth defines the number of layers of the texture
  31067. * @param format defines the format of the texture
  31068. * @param generateMipMaps defines if the engine must generate mip levels
  31069. * @param invertY defines if data must be stored with Y axis inverted
  31070. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31071. * @param compression defines the compressed used (can be null)
  31072. * @param textureType defines the compressed used (can be null)
  31073. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31074. */
  31075. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31076. private _unpackFlipYCached;
  31077. /**
  31078. * In case you are sharing the context with other applications, it might
  31079. * be interested to not cache the unpack flip y state to ensure a consistent
  31080. * value would be set.
  31081. */
  31082. enableUnpackFlipYCached: boolean;
  31083. /** @hidden */
  31084. _unpackFlipY(value: boolean): void;
  31085. /** @hidden */
  31086. _getUnpackAlignement(): number;
  31087. /**
  31088. * Update the sampling mode of a given texture
  31089. * @param samplingMode defines the required sampling mode
  31090. * @param texture defines the texture to update
  31091. */
  31092. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31093. /** @hidden */
  31094. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31095. width: number;
  31096. height: number;
  31097. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31098. /** @hidden */
  31099. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31100. /** @hidden */
  31101. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31102. /** @hidden */
  31103. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31104. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31105. private _prepareWebGLTexture;
  31106. /** @hidden */
  31107. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31108. /** @hidden */
  31109. _releaseFramebufferObjects(texture: InternalTexture): void;
  31110. /** @hidden */
  31111. _releaseTexture(texture: InternalTexture): void;
  31112. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31113. protected _setProgram(program: WebGLProgram): void;
  31114. protected _boundUniforms: {
  31115. [key: number]: WebGLUniformLocation;
  31116. };
  31117. /**
  31118. * Binds an effect to the webGL context
  31119. * @param effect defines the effect to bind
  31120. */
  31121. bindSamplers(effect: Effect): void;
  31122. private _activateCurrentTexture;
  31123. /** @hidden */
  31124. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31125. /** @hidden */
  31126. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31127. /**
  31128. * Unbind all textures from the webGL context
  31129. */
  31130. unbindAllTextures(): void;
  31131. /**
  31132. * Sets a texture to the according uniform.
  31133. * @param channel The texture channel
  31134. * @param uniform The uniform to set
  31135. * @param texture The texture to apply
  31136. */
  31137. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31138. private _bindSamplerUniformToChannel;
  31139. private _getTextureWrapMode;
  31140. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31141. /**
  31142. * Sets an array of texture to the webGL context
  31143. * @param channel defines the channel where the texture array must be set
  31144. * @param uniform defines the associated uniform location
  31145. * @param textures defines the array of textures to bind
  31146. */
  31147. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31148. /** @hidden */
  31149. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31150. private _setTextureParameterFloat;
  31151. private _setTextureParameterInteger;
  31152. /**
  31153. * Unbind all vertex attributes from the webGL context
  31154. */
  31155. unbindAllAttributes(): void;
  31156. /**
  31157. * 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
  31158. */
  31159. releaseEffects(): void;
  31160. /**
  31161. * Dispose and release all associated resources
  31162. */
  31163. dispose(): void;
  31164. /**
  31165. * Attach a new callback raised when context lost event is fired
  31166. * @param callback defines the callback to call
  31167. */
  31168. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31169. /**
  31170. * Attach a new callback raised when context restored event is fired
  31171. * @param callback defines the callback to call
  31172. */
  31173. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31174. /**
  31175. * Get the current error code of the webGL context
  31176. * @returns the error code
  31177. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31178. */
  31179. getError(): number;
  31180. private _canRenderToFloatFramebuffer;
  31181. private _canRenderToHalfFloatFramebuffer;
  31182. private _canRenderToFramebuffer;
  31183. /** @hidden */
  31184. _getWebGLTextureType(type: number): number;
  31185. /** @hidden */
  31186. _getInternalFormat(format: number): number;
  31187. /** @hidden */
  31188. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31189. /** @hidden */
  31190. _getRGBAMultiSampleBufferFormat(type: number): number;
  31191. /** @hidden */
  31192. _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;
  31193. /**
  31194. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31195. * @returns true if the engine can be created
  31196. * @ignorenaming
  31197. */
  31198. static isSupported(): boolean;
  31199. /**
  31200. * Find the next highest power of two.
  31201. * @param x Number to start search from.
  31202. * @return Next highest power of two.
  31203. */
  31204. static CeilingPOT(x: number): number;
  31205. /**
  31206. * Find the next lowest power of two.
  31207. * @param x Number to start search from.
  31208. * @return Next lowest power of two.
  31209. */
  31210. static FloorPOT(x: number): number;
  31211. /**
  31212. * Find the nearest power of two.
  31213. * @param x Number to start search from.
  31214. * @return Next nearest power of two.
  31215. */
  31216. static NearestPOT(x: number): number;
  31217. /**
  31218. * Get the closest exponent of two
  31219. * @param value defines the value to approximate
  31220. * @param max defines the maximum value to return
  31221. * @param mode defines how to define the closest value
  31222. * @returns closest exponent of two of the given value
  31223. */
  31224. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31225. /**
  31226. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31227. * @param func - the function to be called
  31228. * @param requester - the object that will request the next frame. Falls back to window.
  31229. * @returns frame number
  31230. */
  31231. static QueueNewFrame(func: () => void, requester?: any): number;
  31232. }
  31233. }
  31234. declare module "babylonjs/Maths/sphericalPolynomial" {
  31235. import { Vector3 } from "babylonjs/Maths/math.vector";
  31236. import { Color3 } from "babylonjs/Maths/math.color";
  31237. /**
  31238. * Class representing spherical harmonics coefficients to the 3rd degree
  31239. */
  31240. export class SphericalHarmonics {
  31241. /**
  31242. * Defines whether or not the harmonics have been prescaled for rendering.
  31243. */
  31244. preScaled: boolean;
  31245. /**
  31246. * The l0,0 coefficients of the spherical harmonics
  31247. */
  31248. l00: Vector3;
  31249. /**
  31250. * The l1,-1 coefficients of the spherical harmonics
  31251. */
  31252. l1_1: Vector3;
  31253. /**
  31254. * The l1,0 coefficients of the spherical harmonics
  31255. */
  31256. l10: Vector3;
  31257. /**
  31258. * The l1,1 coefficients of the spherical harmonics
  31259. */
  31260. l11: Vector3;
  31261. /**
  31262. * The l2,-2 coefficients of the spherical harmonics
  31263. */
  31264. l2_2: Vector3;
  31265. /**
  31266. * The l2,-1 coefficients of the spherical harmonics
  31267. */
  31268. l2_1: Vector3;
  31269. /**
  31270. * The l2,0 coefficients of the spherical harmonics
  31271. */
  31272. l20: Vector3;
  31273. /**
  31274. * The l2,1 coefficients of the spherical harmonics
  31275. */
  31276. l21: Vector3;
  31277. /**
  31278. * The l2,2 coefficients of the spherical harmonics
  31279. */
  31280. l22: Vector3;
  31281. /**
  31282. * Adds a light to the spherical harmonics
  31283. * @param direction the direction of the light
  31284. * @param color the color of the light
  31285. * @param deltaSolidAngle the delta solid angle of the light
  31286. */
  31287. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31288. /**
  31289. * Scales the spherical harmonics by the given amount
  31290. * @param scale the amount to scale
  31291. */
  31292. scaleInPlace(scale: number): void;
  31293. /**
  31294. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31295. *
  31296. * ```
  31297. * E_lm = A_l * L_lm
  31298. * ```
  31299. *
  31300. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31301. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31302. * the scaling factors are given in equation 9.
  31303. */
  31304. convertIncidentRadianceToIrradiance(): void;
  31305. /**
  31306. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31307. *
  31308. * ```
  31309. * L = (1/pi) * E * rho
  31310. * ```
  31311. *
  31312. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31313. */
  31314. convertIrradianceToLambertianRadiance(): void;
  31315. /**
  31316. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31317. * required operations at run time.
  31318. *
  31319. * This is simply done by scaling back the SH with Ylm constants parameter.
  31320. * The trigonometric part being applied by the shader at run time.
  31321. */
  31322. preScaleForRendering(): void;
  31323. /**
  31324. * Constructs a spherical harmonics from an array.
  31325. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31326. * @returns the spherical harmonics
  31327. */
  31328. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31329. /**
  31330. * Gets the spherical harmonics from polynomial
  31331. * @param polynomial the spherical polynomial
  31332. * @returns the spherical harmonics
  31333. */
  31334. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31335. }
  31336. /**
  31337. * Class representing spherical polynomial coefficients to the 3rd degree
  31338. */
  31339. export class SphericalPolynomial {
  31340. private _harmonics;
  31341. /**
  31342. * The spherical harmonics used to create the polynomials.
  31343. */
  31344. readonly preScaledHarmonics: SphericalHarmonics;
  31345. /**
  31346. * The x coefficients of the spherical polynomial
  31347. */
  31348. x: Vector3;
  31349. /**
  31350. * The y coefficients of the spherical polynomial
  31351. */
  31352. y: Vector3;
  31353. /**
  31354. * The z coefficients of the spherical polynomial
  31355. */
  31356. z: Vector3;
  31357. /**
  31358. * The xx coefficients of the spherical polynomial
  31359. */
  31360. xx: Vector3;
  31361. /**
  31362. * The yy coefficients of the spherical polynomial
  31363. */
  31364. yy: Vector3;
  31365. /**
  31366. * The zz coefficients of the spherical polynomial
  31367. */
  31368. zz: Vector3;
  31369. /**
  31370. * The xy coefficients of the spherical polynomial
  31371. */
  31372. xy: Vector3;
  31373. /**
  31374. * The yz coefficients of the spherical polynomial
  31375. */
  31376. yz: Vector3;
  31377. /**
  31378. * The zx coefficients of the spherical polynomial
  31379. */
  31380. zx: Vector3;
  31381. /**
  31382. * Adds an ambient color to the spherical polynomial
  31383. * @param color the color to add
  31384. */
  31385. addAmbient(color: Color3): void;
  31386. /**
  31387. * Scales the spherical polynomial by the given amount
  31388. * @param scale the amount to scale
  31389. */
  31390. scaleInPlace(scale: number): void;
  31391. /**
  31392. * Gets the spherical polynomial from harmonics
  31393. * @param harmonics the spherical harmonics
  31394. * @returns the spherical polynomial
  31395. */
  31396. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31397. /**
  31398. * Constructs a spherical polynomial from an array.
  31399. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31400. * @returns the spherical polynomial
  31401. */
  31402. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31403. }
  31404. }
  31405. declare module "babylonjs/Materials/Textures/internalTexture" {
  31406. import { Observable } from "babylonjs/Misc/observable";
  31407. import { Nullable, int } from "babylonjs/types";
  31408. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31409. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31410. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31411. /**
  31412. * Defines the source of the internal texture
  31413. */
  31414. export enum InternalTextureSource {
  31415. /**
  31416. * The source of the texture data is unknown
  31417. */
  31418. Unknown = 0,
  31419. /**
  31420. * Texture data comes from an URL
  31421. */
  31422. Url = 1,
  31423. /**
  31424. * Texture data is only used for temporary storage
  31425. */
  31426. Temp = 2,
  31427. /**
  31428. * Texture data comes from raw data (ArrayBuffer)
  31429. */
  31430. Raw = 3,
  31431. /**
  31432. * Texture content is dynamic (video or dynamic texture)
  31433. */
  31434. Dynamic = 4,
  31435. /**
  31436. * Texture content is generated by rendering to it
  31437. */
  31438. RenderTarget = 5,
  31439. /**
  31440. * Texture content is part of a multi render target process
  31441. */
  31442. MultiRenderTarget = 6,
  31443. /**
  31444. * Texture data comes from a cube data file
  31445. */
  31446. Cube = 7,
  31447. /**
  31448. * Texture data comes from a raw cube data
  31449. */
  31450. CubeRaw = 8,
  31451. /**
  31452. * Texture data come from a prefiltered cube data file
  31453. */
  31454. CubePrefiltered = 9,
  31455. /**
  31456. * Texture content is raw 3D data
  31457. */
  31458. Raw3D = 10,
  31459. /**
  31460. * Texture content is raw 2D array data
  31461. */
  31462. Raw2DArray = 11,
  31463. /**
  31464. * Texture content is a depth texture
  31465. */
  31466. Depth = 12,
  31467. /**
  31468. * Texture data comes from a raw cube data encoded with RGBD
  31469. */
  31470. CubeRawRGBD = 13
  31471. }
  31472. /**
  31473. * Class used to store data associated with WebGL texture data for the engine
  31474. * This class should not be used directly
  31475. */
  31476. export class InternalTexture {
  31477. /** @hidden */
  31478. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31479. /**
  31480. * Defines if the texture is ready
  31481. */
  31482. isReady: boolean;
  31483. /**
  31484. * Defines if the texture is a cube texture
  31485. */
  31486. isCube: boolean;
  31487. /**
  31488. * Defines if the texture contains 3D data
  31489. */
  31490. is3D: boolean;
  31491. /**
  31492. * Defines if the texture contains 2D array data
  31493. */
  31494. is2DArray: boolean;
  31495. /**
  31496. * Defines if the texture contains multiview data
  31497. */
  31498. isMultiview: boolean;
  31499. /**
  31500. * Gets the URL used to load this texture
  31501. */
  31502. url: string;
  31503. /**
  31504. * Gets the sampling mode of the texture
  31505. */
  31506. samplingMode: number;
  31507. /**
  31508. * Gets a boolean indicating if the texture needs mipmaps generation
  31509. */
  31510. generateMipMaps: boolean;
  31511. /**
  31512. * Gets the number of samples used by the texture (WebGL2+ only)
  31513. */
  31514. samples: number;
  31515. /**
  31516. * Gets the type of the texture (int, float...)
  31517. */
  31518. type: number;
  31519. /**
  31520. * Gets the format of the texture (RGB, RGBA...)
  31521. */
  31522. format: number;
  31523. /**
  31524. * Observable called when the texture is loaded
  31525. */
  31526. onLoadedObservable: Observable<InternalTexture>;
  31527. /**
  31528. * Gets the width of the texture
  31529. */
  31530. width: number;
  31531. /**
  31532. * Gets the height of the texture
  31533. */
  31534. height: number;
  31535. /**
  31536. * Gets the depth of the texture
  31537. */
  31538. depth: number;
  31539. /**
  31540. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31541. */
  31542. baseWidth: number;
  31543. /**
  31544. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31545. */
  31546. baseHeight: number;
  31547. /**
  31548. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31549. */
  31550. baseDepth: number;
  31551. /**
  31552. * Gets a boolean indicating if the texture is inverted on Y axis
  31553. */
  31554. invertY: boolean;
  31555. /** @hidden */
  31556. _invertVScale: boolean;
  31557. /** @hidden */
  31558. _associatedChannel: number;
  31559. /** @hidden */
  31560. _source: InternalTextureSource;
  31561. /** @hidden */
  31562. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31563. /** @hidden */
  31564. _bufferView: Nullable<ArrayBufferView>;
  31565. /** @hidden */
  31566. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31567. /** @hidden */
  31568. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31569. /** @hidden */
  31570. _size: number;
  31571. /** @hidden */
  31572. _extension: string;
  31573. /** @hidden */
  31574. _files: Nullable<string[]>;
  31575. /** @hidden */
  31576. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31577. /** @hidden */
  31578. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31579. /** @hidden */
  31580. _framebuffer: Nullable<WebGLFramebuffer>;
  31581. /** @hidden */
  31582. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31583. /** @hidden */
  31584. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31585. /** @hidden */
  31586. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31587. /** @hidden */
  31588. _attachments: Nullable<number[]>;
  31589. /** @hidden */
  31590. _cachedCoordinatesMode: Nullable<number>;
  31591. /** @hidden */
  31592. _cachedWrapU: Nullable<number>;
  31593. /** @hidden */
  31594. _cachedWrapV: Nullable<number>;
  31595. /** @hidden */
  31596. _cachedWrapR: Nullable<number>;
  31597. /** @hidden */
  31598. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31599. /** @hidden */
  31600. _isDisabled: boolean;
  31601. /** @hidden */
  31602. _compression: Nullable<string>;
  31603. /** @hidden */
  31604. _generateStencilBuffer: boolean;
  31605. /** @hidden */
  31606. _generateDepthBuffer: boolean;
  31607. /** @hidden */
  31608. _comparisonFunction: number;
  31609. /** @hidden */
  31610. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31611. /** @hidden */
  31612. _lodGenerationScale: number;
  31613. /** @hidden */
  31614. _lodGenerationOffset: number;
  31615. /** @hidden */
  31616. _colorTextureArray: Nullable<WebGLTexture>;
  31617. /** @hidden */
  31618. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31619. /** @hidden */
  31620. _lodTextureHigh: Nullable<BaseTexture>;
  31621. /** @hidden */
  31622. _lodTextureMid: Nullable<BaseTexture>;
  31623. /** @hidden */
  31624. _lodTextureLow: Nullable<BaseTexture>;
  31625. /** @hidden */
  31626. _isRGBD: boolean;
  31627. /** @hidden */
  31628. _linearSpecularLOD: boolean;
  31629. /** @hidden */
  31630. _irradianceTexture: Nullable<BaseTexture>;
  31631. /** @hidden */
  31632. _webGLTexture: Nullable<WebGLTexture>;
  31633. /** @hidden */
  31634. _references: number;
  31635. private _engine;
  31636. /**
  31637. * Gets the Engine the texture belongs to.
  31638. * @returns The babylon engine
  31639. */
  31640. getEngine(): ThinEngine;
  31641. /**
  31642. * Gets the data source type of the texture
  31643. */
  31644. readonly source: InternalTextureSource;
  31645. /**
  31646. * Creates a new InternalTexture
  31647. * @param engine defines the engine to use
  31648. * @param source defines the type of data that will be used
  31649. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31650. */
  31651. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31652. /**
  31653. * Increments the number of references (ie. the number of Texture that point to it)
  31654. */
  31655. incrementReferences(): void;
  31656. /**
  31657. * Change the size of the texture (not the size of the content)
  31658. * @param width defines the new width
  31659. * @param height defines the new height
  31660. * @param depth defines the new depth (1 by default)
  31661. */
  31662. updateSize(width: int, height: int, depth?: int): void;
  31663. /** @hidden */
  31664. _rebuild(): void;
  31665. /** @hidden */
  31666. _swapAndDie(target: InternalTexture): void;
  31667. /**
  31668. * Dispose the current allocated resources
  31669. */
  31670. dispose(): void;
  31671. }
  31672. }
  31673. declare module "babylonjs/Audio/analyser" {
  31674. import { Scene } from "babylonjs/scene";
  31675. /**
  31676. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31678. */
  31679. export class Analyser {
  31680. /**
  31681. * Gets or sets the smoothing
  31682. * @ignorenaming
  31683. */
  31684. SMOOTHING: number;
  31685. /**
  31686. * Gets or sets the FFT table size
  31687. * @ignorenaming
  31688. */
  31689. FFT_SIZE: number;
  31690. /**
  31691. * Gets or sets the bar graph amplitude
  31692. * @ignorenaming
  31693. */
  31694. BARGRAPHAMPLITUDE: number;
  31695. /**
  31696. * Gets or sets the position of the debug canvas
  31697. * @ignorenaming
  31698. */
  31699. DEBUGCANVASPOS: {
  31700. x: number;
  31701. y: number;
  31702. };
  31703. /**
  31704. * Gets or sets the debug canvas size
  31705. * @ignorenaming
  31706. */
  31707. DEBUGCANVASSIZE: {
  31708. width: number;
  31709. height: number;
  31710. };
  31711. private _byteFreqs;
  31712. private _byteTime;
  31713. private _floatFreqs;
  31714. private _webAudioAnalyser;
  31715. private _debugCanvas;
  31716. private _debugCanvasContext;
  31717. private _scene;
  31718. private _registerFunc;
  31719. private _audioEngine;
  31720. /**
  31721. * Creates a new analyser
  31722. * @param scene defines hosting scene
  31723. */
  31724. constructor(scene: Scene);
  31725. /**
  31726. * Get the number of data values you will have to play with for the visualization
  31727. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31728. * @returns a number
  31729. */
  31730. getFrequencyBinCount(): number;
  31731. /**
  31732. * Gets the current frequency data as a byte array
  31733. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31734. * @returns a Uint8Array
  31735. */
  31736. getByteFrequencyData(): Uint8Array;
  31737. /**
  31738. * Gets the current waveform as a byte array
  31739. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31740. * @returns a Uint8Array
  31741. */
  31742. getByteTimeDomainData(): Uint8Array;
  31743. /**
  31744. * Gets the current frequency data as a float array
  31745. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31746. * @returns a Float32Array
  31747. */
  31748. getFloatFrequencyData(): Float32Array;
  31749. /**
  31750. * Renders the debug canvas
  31751. */
  31752. drawDebugCanvas(): void;
  31753. /**
  31754. * Stops rendering the debug canvas and removes it
  31755. */
  31756. stopDebugCanvas(): void;
  31757. /**
  31758. * Connects two audio nodes
  31759. * @param inputAudioNode defines first node to connect
  31760. * @param outputAudioNode defines second node to connect
  31761. */
  31762. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31763. /**
  31764. * Releases all associated resources
  31765. */
  31766. dispose(): void;
  31767. }
  31768. }
  31769. declare module "babylonjs/Audio/audioEngine" {
  31770. import { IDisposable } from "babylonjs/scene";
  31771. import { Analyser } from "babylonjs/Audio/analyser";
  31772. import { Nullable } from "babylonjs/types";
  31773. import { Observable } from "babylonjs/Misc/observable";
  31774. /**
  31775. * This represents an audio engine and it is responsible
  31776. * to play, synchronize and analyse sounds throughout the application.
  31777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31778. */
  31779. export interface IAudioEngine extends IDisposable {
  31780. /**
  31781. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31782. */
  31783. readonly canUseWebAudio: boolean;
  31784. /**
  31785. * Gets the current AudioContext if available.
  31786. */
  31787. readonly audioContext: Nullable<AudioContext>;
  31788. /**
  31789. * The master gain node defines the global audio volume of your audio engine.
  31790. */
  31791. readonly masterGain: GainNode;
  31792. /**
  31793. * Gets whether or not mp3 are supported by your browser.
  31794. */
  31795. readonly isMP3supported: boolean;
  31796. /**
  31797. * Gets whether or not ogg are supported by your browser.
  31798. */
  31799. readonly isOGGsupported: boolean;
  31800. /**
  31801. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31802. * @ignoreNaming
  31803. */
  31804. WarnedWebAudioUnsupported: boolean;
  31805. /**
  31806. * Defines if the audio engine relies on a custom unlocked button.
  31807. * In this case, the embedded button will not be displayed.
  31808. */
  31809. useCustomUnlockedButton: boolean;
  31810. /**
  31811. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31812. */
  31813. readonly unlocked: boolean;
  31814. /**
  31815. * Event raised when audio has been unlocked on the browser.
  31816. */
  31817. onAudioUnlockedObservable: Observable<AudioEngine>;
  31818. /**
  31819. * Event raised when audio has been locked on the browser.
  31820. */
  31821. onAudioLockedObservable: Observable<AudioEngine>;
  31822. /**
  31823. * Flags the audio engine in Locked state.
  31824. * This happens due to new browser policies preventing audio to autoplay.
  31825. */
  31826. lock(): void;
  31827. /**
  31828. * Unlocks the audio engine once a user action has been done on the dom.
  31829. * This is helpful to resume play once browser policies have been satisfied.
  31830. */
  31831. unlock(): void;
  31832. }
  31833. /**
  31834. * This represents the default audio engine used in babylon.
  31835. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31837. */
  31838. export class AudioEngine implements IAudioEngine {
  31839. private _audioContext;
  31840. private _audioContextInitialized;
  31841. private _muteButton;
  31842. private _hostElement;
  31843. /**
  31844. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31845. */
  31846. canUseWebAudio: boolean;
  31847. /**
  31848. * The master gain node defines the global audio volume of your audio engine.
  31849. */
  31850. masterGain: GainNode;
  31851. /**
  31852. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31853. * @ignoreNaming
  31854. */
  31855. WarnedWebAudioUnsupported: boolean;
  31856. /**
  31857. * Gets whether or not mp3 are supported by your browser.
  31858. */
  31859. isMP3supported: boolean;
  31860. /**
  31861. * Gets whether or not ogg are supported by your browser.
  31862. */
  31863. isOGGsupported: boolean;
  31864. /**
  31865. * Gets whether audio has been unlocked on the device.
  31866. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31867. * a user interaction has happened.
  31868. */
  31869. unlocked: boolean;
  31870. /**
  31871. * Defines if the audio engine relies on a custom unlocked button.
  31872. * In this case, the embedded button will not be displayed.
  31873. */
  31874. useCustomUnlockedButton: boolean;
  31875. /**
  31876. * Event raised when audio has been unlocked on the browser.
  31877. */
  31878. onAudioUnlockedObservable: Observable<AudioEngine>;
  31879. /**
  31880. * Event raised when audio has been locked on the browser.
  31881. */
  31882. onAudioLockedObservable: Observable<AudioEngine>;
  31883. /**
  31884. * Gets the current AudioContext if available.
  31885. */
  31886. readonly audioContext: Nullable<AudioContext>;
  31887. private _connectedAnalyser;
  31888. /**
  31889. * Instantiates a new audio engine.
  31890. *
  31891. * There should be only one per page as some browsers restrict the number
  31892. * of audio contexts you can create.
  31893. * @param hostElement defines the host element where to display the mute icon if necessary
  31894. */
  31895. constructor(hostElement?: Nullable<HTMLElement>);
  31896. /**
  31897. * Flags the audio engine in Locked state.
  31898. * This happens due to new browser policies preventing audio to autoplay.
  31899. */
  31900. lock(): void;
  31901. /**
  31902. * Unlocks the audio engine once a user action has been done on the dom.
  31903. * This is helpful to resume play once browser policies have been satisfied.
  31904. */
  31905. unlock(): void;
  31906. private _resumeAudioContext;
  31907. private _initializeAudioContext;
  31908. private _tryToRun;
  31909. private _triggerRunningState;
  31910. private _triggerSuspendedState;
  31911. private _displayMuteButton;
  31912. private _moveButtonToTopLeft;
  31913. private _onResize;
  31914. private _hideMuteButton;
  31915. /**
  31916. * Destroy and release the resources associated with the audio ccontext.
  31917. */
  31918. dispose(): void;
  31919. /**
  31920. * Gets the global volume sets on the master gain.
  31921. * @returns the global volume if set or -1 otherwise
  31922. */
  31923. getGlobalVolume(): number;
  31924. /**
  31925. * Sets the global volume of your experience (sets on the master gain).
  31926. * @param newVolume Defines the new global volume of the application
  31927. */
  31928. setGlobalVolume(newVolume: number): void;
  31929. /**
  31930. * Connect the audio engine to an audio analyser allowing some amazing
  31931. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31933. * @param analyser The analyser to connect to the engine
  31934. */
  31935. connectToAnalyser(analyser: Analyser): void;
  31936. }
  31937. }
  31938. declare module "babylonjs/Loading/loadingScreen" {
  31939. /**
  31940. * Interface used to present a loading screen while loading a scene
  31941. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31942. */
  31943. export interface ILoadingScreen {
  31944. /**
  31945. * Function called to display the loading screen
  31946. */
  31947. displayLoadingUI: () => void;
  31948. /**
  31949. * Function called to hide the loading screen
  31950. */
  31951. hideLoadingUI: () => void;
  31952. /**
  31953. * Gets or sets the color to use for the background
  31954. */
  31955. loadingUIBackgroundColor: string;
  31956. /**
  31957. * Gets or sets the text to display while loading
  31958. */
  31959. loadingUIText: string;
  31960. }
  31961. /**
  31962. * Class used for the default loading screen
  31963. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31964. */
  31965. export class DefaultLoadingScreen implements ILoadingScreen {
  31966. private _renderingCanvas;
  31967. private _loadingText;
  31968. private _loadingDivBackgroundColor;
  31969. private _loadingDiv;
  31970. private _loadingTextDiv;
  31971. /** Gets or sets the logo url to use for the default loading screen */
  31972. static DefaultLogoUrl: string;
  31973. /** Gets or sets the spinner url to use for the default loading screen */
  31974. static DefaultSpinnerUrl: string;
  31975. /**
  31976. * Creates a new default loading screen
  31977. * @param _renderingCanvas defines the canvas used to render the scene
  31978. * @param _loadingText defines the default text to display
  31979. * @param _loadingDivBackgroundColor defines the default background color
  31980. */
  31981. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31982. /**
  31983. * Function called to display the loading screen
  31984. */
  31985. displayLoadingUI(): void;
  31986. /**
  31987. * Function called to hide the loading screen
  31988. */
  31989. hideLoadingUI(): void;
  31990. /**
  31991. * Gets or sets the text to display while loading
  31992. */
  31993. loadingUIText: string;
  31994. /**
  31995. * Gets or sets the color to use for the background
  31996. */
  31997. loadingUIBackgroundColor: string;
  31998. private _resizeLoadingUI;
  31999. }
  32000. }
  32001. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  32002. /**
  32003. * Interface for any object that can request an animation frame
  32004. */
  32005. export interface ICustomAnimationFrameRequester {
  32006. /**
  32007. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32008. */
  32009. renderFunction?: Function;
  32010. /**
  32011. * Called to request the next frame to render to
  32012. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32013. */
  32014. requestAnimationFrame: Function;
  32015. /**
  32016. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32017. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32018. */
  32019. requestID?: number;
  32020. }
  32021. }
  32022. declare module "babylonjs/Misc/performanceMonitor" {
  32023. /**
  32024. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32025. */
  32026. export class PerformanceMonitor {
  32027. private _enabled;
  32028. private _rollingFrameTime;
  32029. private _lastFrameTimeMs;
  32030. /**
  32031. * constructor
  32032. * @param frameSampleSize The number of samples required to saturate the sliding window
  32033. */
  32034. constructor(frameSampleSize?: number);
  32035. /**
  32036. * Samples current frame
  32037. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32038. */
  32039. sampleFrame(timeMs?: number): void;
  32040. /**
  32041. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32042. */
  32043. readonly averageFrameTime: number;
  32044. /**
  32045. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32046. */
  32047. readonly averageFrameTimeVariance: number;
  32048. /**
  32049. * Returns the frame time of the most recent frame
  32050. */
  32051. readonly instantaneousFrameTime: number;
  32052. /**
  32053. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32054. */
  32055. readonly averageFPS: number;
  32056. /**
  32057. * Returns the average framerate in frames per second using the most recent frame time
  32058. */
  32059. readonly instantaneousFPS: number;
  32060. /**
  32061. * Returns true if enough samples have been taken to completely fill the sliding window
  32062. */
  32063. readonly isSaturated: boolean;
  32064. /**
  32065. * Enables contributions to the sliding window sample set
  32066. */
  32067. enable(): void;
  32068. /**
  32069. * Disables contributions to the sliding window sample set
  32070. * Samples will not be interpolated over the disabled period
  32071. */
  32072. disable(): void;
  32073. /**
  32074. * Returns true if sampling is enabled
  32075. */
  32076. readonly isEnabled: boolean;
  32077. /**
  32078. * Resets performance monitor
  32079. */
  32080. reset(): void;
  32081. }
  32082. /**
  32083. * RollingAverage
  32084. *
  32085. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32086. */
  32087. export class RollingAverage {
  32088. /**
  32089. * Current average
  32090. */
  32091. average: number;
  32092. /**
  32093. * Current variance
  32094. */
  32095. variance: number;
  32096. protected _samples: Array<number>;
  32097. protected _sampleCount: number;
  32098. protected _pos: number;
  32099. protected _m2: number;
  32100. /**
  32101. * constructor
  32102. * @param length The number of samples required to saturate the sliding window
  32103. */
  32104. constructor(length: number);
  32105. /**
  32106. * Adds a sample to the sample set
  32107. * @param v The sample value
  32108. */
  32109. add(v: number): void;
  32110. /**
  32111. * Returns previously added values or null if outside of history or outside the sliding window domain
  32112. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32113. * @return Value previously recorded with add() or null if outside of range
  32114. */
  32115. history(i: number): number;
  32116. /**
  32117. * Returns true if enough samples have been taken to completely fill the sliding window
  32118. * @return true if sample-set saturated
  32119. */
  32120. isSaturated(): boolean;
  32121. /**
  32122. * Resets the rolling average (equivalent to 0 samples taken so far)
  32123. */
  32124. reset(): void;
  32125. /**
  32126. * Wraps a value around the sample range boundaries
  32127. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32128. * @return Wrapped position in sample range
  32129. */
  32130. protected _wrapPosition(i: number): number;
  32131. }
  32132. }
  32133. declare module "babylonjs/Misc/perfCounter" {
  32134. /**
  32135. * This class is used to track a performance counter which is number based.
  32136. * The user has access to many properties which give statistics of different nature.
  32137. *
  32138. * The implementer can track two kinds of Performance Counter: time and count.
  32139. * 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.
  32140. * 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.
  32141. */
  32142. export class PerfCounter {
  32143. /**
  32144. * Gets or sets a global boolean to turn on and off all the counters
  32145. */
  32146. static Enabled: boolean;
  32147. /**
  32148. * Returns the smallest value ever
  32149. */
  32150. readonly min: number;
  32151. /**
  32152. * Returns the biggest value ever
  32153. */
  32154. readonly max: number;
  32155. /**
  32156. * Returns the average value since the performance counter is running
  32157. */
  32158. readonly average: number;
  32159. /**
  32160. * Returns the average value of the last second the counter was monitored
  32161. */
  32162. readonly lastSecAverage: number;
  32163. /**
  32164. * Returns the current value
  32165. */
  32166. readonly current: number;
  32167. /**
  32168. * Gets the accumulated total
  32169. */
  32170. readonly total: number;
  32171. /**
  32172. * Gets the total value count
  32173. */
  32174. readonly count: number;
  32175. /**
  32176. * Creates a new counter
  32177. */
  32178. constructor();
  32179. /**
  32180. * Call this method to start monitoring a new frame.
  32181. * 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.
  32182. */
  32183. fetchNewFrame(): void;
  32184. /**
  32185. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32186. * @param newCount the count value to add to the monitored count
  32187. * @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.
  32188. */
  32189. addCount(newCount: number, fetchResult: boolean): void;
  32190. /**
  32191. * Start monitoring this performance counter
  32192. */
  32193. beginMonitoring(): void;
  32194. /**
  32195. * Compute the time lapsed since the previous beginMonitoring() call.
  32196. * @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
  32197. */
  32198. endMonitoring(newFrame?: boolean): void;
  32199. private _fetchResult;
  32200. private _startMonitoringTime;
  32201. private _min;
  32202. private _max;
  32203. private _average;
  32204. private _current;
  32205. private _totalValueCount;
  32206. private _totalAccumulated;
  32207. private _lastSecAverage;
  32208. private _lastSecAccumulated;
  32209. private _lastSecTime;
  32210. private _lastSecValueCount;
  32211. }
  32212. }
  32213. declare module "babylonjs/Engines/engine" {
  32214. import { Observable } from "babylonjs/Misc/observable";
  32215. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  32216. import { Scene } from "babylonjs/scene";
  32217. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32218. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32219. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32220. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32221. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32222. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32223. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32224. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  32225. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32226. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32227. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  32228. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32229. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  32230. import { Material } from "babylonjs/Materials/material";
  32231. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32232. /**
  32233. * Defines the interface used by display changed events
  32234. */
  32235. export interface IDisplayChangedEventArgs {
  32236. /** Gets the vrDisplay object (if any) */
  32237. vrDisplay: Nullable<any>;
  32238. /** Gets a boolean indicating if webVR is supported */
  32239. vrSupported: boolean;
  32240. }
  32241. /**
  32242. * Defines the interface used by objects containing a viewport (like a camera)
  32243. */
  32244. interface IViewportOwnerLike {
  32245. /**
  32246. * Gets or sets the viewport
  32247. */
  32248. viewport: IViewportLike;
  32249. }
  32250. /**
  32251. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32252. */
  32253. export class Engine extends ThinEngine {
  32254. /** Defines that alpha blending is disabled */
  32255. static readonly ALPHA_DISABLE: number;
  32256. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32257. static readonly ALPHA_ADD: number;
  32258. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32259. static readonly ALPHA_COMBINE: number;
  32260. /** Defines that alpha blending to DEST - SRC * DEST */
  32261. static readonly ALPHA_SUBTRACT: number;
  32262. /** Defines that alpha blending to SRC * DEST */
  32263. static readonly ALPHA_MULTIPLY: number;
  32264. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32265. static readonly ALPHA_MAXIMIZED: number;
  32266. /** Defines that alpha blending to SRC + DEST */
  32267. static readonly ALPHA_ONEONE: number;
  32268. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32269. static readonly ALPHA_PREMULTIPLIED: number;
  32270. /**
  32271. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32272. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32273. */
  32274. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32275. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32276. static readonly ALPHA_INTERPOLATE: number;
  32277. /**
  32278. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32279. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32280. */
  32281. static readonly ALPHA_SCREENMODE: number;
  32282. /** Defines that the ressource is not delayed*/
  32283. static readonly DELAYLOADSTATE_NONE: number;
  32284. /** Defines that the ressource was successfully delay loaded */
  32285. static readonly DELAYLOADSTATE_LOADED: number;
  32286. /** Defines that the ressource is currently delay loading */
  32287. static readonly DELAYLOADSTATE_LOADING: number;
  32288. /** Defines that the ressource is delayed and has not started loading */
  32289. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32290. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32291. static readonly NEVER: number;
  32292. /** 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 */
  32293. static readonly ALWAYS: number;
  32294. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32295. static readonly LESS: number;
  32296. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32297. static readonly EQUAL: number;
  32298. /** 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 */
  32299. static readonly LEQUAL: number;
  32300. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32301. static readonly GREATER: number;
  32302. /** 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 */
  32303. static readonly GEQUAL: number;
  32304. /** 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 */
  32305. static readonly NOTEQUAL: number;
  32306. /** Passed to stencilOperation to specify that stencil value must be kept */
  32307. static readonly KEEP: number;
  32308. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32309. static readonly REPLACE: number;
  32310. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32311. static readonly INCR: number;
  32312. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32313. static readonly DECR: number;
  32314. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32315. static readonly INVERT: number;
  32316. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32317. static readonly INCR_WRAP: number;
  32318. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32319. static readonly DECR_WRAP: number;
  32320. /** Texture is not repeating outside of 0..1 UVs */
  32321. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32322. /** Texture is repeating outside of 0..1 UVs */
  32323. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32324. /** Texture is repeating and mirrored */
  32325. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32326. /** ALPHA */
  32327. static readonly TEXTUREFORMAT_ALPHA: number;
  32328. /** LUMINANCE */
  32329. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32330. /** LUMINANCE_ALPHA */
  32331. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32332. /** RGB */
  32333. static readonly TEXTUREFORMAT_RGB: number;
  32334. /** RGBA */
  32335. static readonly TEXTUREFORMAT_RGBA: number;
  32336. /** RED */
  32337. static readonly TEXTUREFORMAT_RED: number;
  32338. /** RED (2nd reference) */
  32339. static readonly TEXTUREFORMAT_R: number;
  32340. /** RG */
  32341. static readonly TEXTUREFORMAT_RG: number;
  32342. /** RED_INTEGER */
  32343. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32344. /** RED_INTEGER (2nd reference) */
  32345. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32346. /** RG_INTEGER */
  32347. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32348. /** RGB_INTEGER */
  32349. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32350. /** RGBA_INTEGER */
  32351. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32352. /** UNSIGNED_BYTE */
  32353. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32354. /** UNSIGNED_BYTE (2nd reference) */
  32355. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32356. /** FLOAT */
  32357. static readonly TEXTURETYPE_FLOAT: number;
  32358. /** HALF_FLOAT */
  32359. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32360. /** BYTE */
  32361. static readonly TEXTURETYPE_BYTE: number;
  32362. /** SHORT */
  32363. static readonly TEXTURETYPE_SHORT: number;
  32364. /** UNSIGNED_SHORT */
  32365. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32366. /** INT */
  32367. static readonly TEXTURETYPE_INT: number;
  32368. /** UNSIGNED_INT */
  32369. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32370. /** UNSIGNED_SHORT_4_4_4_4 */
  32371. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32372. /** UNSIGNED_SHORT_5_5_5_1 */
  32373. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32374. /** UNSIGNED_SHORT_5_6_5 */
  32375. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32376. /** UNSIGNED_INT_2_10_10_10_REV */
  32377. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32378. /** UNSIGNED_INT_24_8 */
  32379. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32380. /** UNSIGNED_INT_10F_11F_11F_REV */
  32381. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32382. /** UNSIGNED_INT_5_9_9_9_REV */
  32383. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32384. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32385. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32386. /** nearest is mag = nearest and min = nearest and mip = linear */
  32387. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32388. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32389. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32390. /** Trilinear is mag = linear and min = linear and mip = linear */
  32391. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32392. /** nearest is mag = nearest and min = nearest and mip = linear */
  32393. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32394. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32395. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32396. /** Trilinear is mag = linear and min = linear and mip = linear */
  32397. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32398. /** mag = nearest and min = nearest and mip = nearest */
  32399. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32400. /** mag = nearest and min = linear and mip = nearest */
  32401. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32402. /** mag = nearest and min = linear and mip = linear */
  32403. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32404. /** mag = nearest and min = linear and mip = none */
  32405. static readonly TEXTURE_NEAREST_LINEAR: number;
  32406. /** mag = nearest and min = nearest and mip = none */
  32407. static readonly TEXTURE_NEAREST_NEAREST: number;
  32408. /** mag = linear and min = nearest and mip = nearest */
  32409. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32410. /** mag = linear and min = nearest and mip = linear */
  32411. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32412. /** mag = linear and min = linear and mip = none */
  32413. static readonly TEXTURE_LINEAR_LINEAR: number;
  32414. /** mag = linear and min = nearest and mip = none */
  32415. static readonly TEXTURE_LINEAR_NEAREST: number;
  32416. /** Explicit coordinates mode */
  32417. static readonly TEXTURE_EXPLICIT_MODE: number;
  32418. /** Spherical coordinates mode */
  32419. static readonly TEXTURE_SPHERICAL_MODE: number;
  32420. /** Planar coordinates mode */
  32421. static readonly TEXTURE_PLANAR_MODE: number;
  32422. /** Cubic coordinates mode */
  32423. static readonly TEXTURE_CUBIC_MODE: number;
  32424. /** Projection coordinates mode */
  32425. static readonly TEXTURE_PROJECTION_MODE: number;
  32426. /** Skybox coordinates mode */
  32427. static readonly TEXTURE_SKYBOX_MODE: number;
  32428. /** Inverse Cubic coordinates mode */
  32429. static readonly TEXTURE_INVCUBIC_MODE: number;
  32430. /** Equirectangular coordinates mode */
  32431. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32432. /** Equirectangular Fixed coordinates mode */
  32433. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32434. /** Equirectangular Fixed Mirrored coordinates mode */
  32435. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32436. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32437. static readonly SCALEMODE_FLOOR: number;
  32438. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32439. static readonly SCALEMODE_NEAREST: number;
  32440. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32441. static readonly SCALEMODE_CEILING: number;
  32442. /**
  32443. * Returns the current npm package of the sdk
  32444. */
  32445. static readonly NpmPackage: string;
  32446. /**
  32447. * Returns the current version of the framework
  32448. */
  32449. static readonly Version: string;
  32450. /** Gets the list of created engines */
  32451. static readonly Instances: Engine[];
  32452. /**
  32453. * Gets the latest created engine
  32454. */
  32455. static readonly LastCreatedEngine: Nullable<Engine>;
  32456. /**
  32457. * Gets the latest created scene
  32458. */
  32459. static readonly LastCreatedScene: Nullable<Scene>;
  32460. /**
  32461. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32462. * @param flag defines which part of the materials must be marked as dirty
  32463. * @param predicate defines a predicate used to filter which materials should be affected
  32464. */
  32465. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32466. /**
  32467. * Method called to create the default loading screen.
  32468. * This can be overriden in your own app.
  32469. * @param canvas The rendering canvas element
  32470. * @returns The loading screen
  32471. */
  32472. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32473. /**
  32474. * Method called to create the default rescale post process on each engine.
  32475. */
  32476. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32477. /**
  32478. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32479. **/
  32480. enableOfflineSupport: boolean;
  32481. /**
  32482. * 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)
  32483. **/
  32484. disableManifestCheck: boolean;
  32485. /**
  32486. * Gets the list of created scenes
  32487. */
  32488. scenes: Scene[];
  32489. /**
  32490. * Event raised when a new scene is created
  32491. */
  32492. onNewSceneAddedObservable: Observable<Scene>;
  32493. /**
  32494. * Gets the list of created postprocesses
  32495. */
  32496. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32497. /**
  32498. * Gets a boolean indicating if the pointer is currently locked
  32499. */
  32500. isPointerLock: boolean;
  32501. /**
  32502. * Observable event triggered each time the rendering canvas is resized
  32503. */
  32504. onResizeObservable: Observable<Engine>;
  32505. /**
  32506. * Observable event triggered each time the canvas loses focus
  32507. */
  32508. onCanvasBlurObservable: Observable<Engine>;
  32509. /**
  32510. * Observable event triggered each time the canvas gains focus
  32511. */
  32512. onCanvasFocusObservable: Observable<Engine>;
  32513. /**
  32514. * Observable event triggered each time the canvas receives pointerout event
  32515. */
  32516. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32517. /**
  32518. * Observable raised when the engine begins a new frame
  32519. */
  32520. onBeginFrameObservable: Observable<Engine>;
  32521. /**
  32522. * If set, will be used to request the next animation frame for the render loop
  32523. */
  32524. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32525. /**
  32526. * Observable raised when the engine ends the current frame
  32527. */
  32528. onEndFrameObservable: Observable<Engine>;
  32529. /**
  32530. * Observable raised when the engine is about to compile a shader
  32531. */
  32532. onBeforeShaderCompilationObservable: Observable<Engine>;
  32533. /**
  32534. * Observable raised when the engine has jsut compiled a shader
  32535. */
  32536. onAfterShaderCompilationObservable: Observable<Engine>;
  32537. /**
  32538. * Gets the audio engine
  32539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32540. * @ignorenaming
  32541. */
  32542. static audioEngine: IAudioEngine;
  32543. /**
  32544. * Default AudioEngine factory responsible of creating the Audio Engine.
  32545. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32546. */
  32547. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32548. /**
  32549. * Default offline support factory responsible of creating a tool used to store data locally.
  32550. * By default, this will create a Database object if the workload has been embedded.
  32551. */
  32552. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32553. private _loadingScreen;
  32554. private _pointerLockRequested;
  32555. private _dummyFramebuffer;
  32556. private _rescalePostProcess;
  32557. /** @hidden */
  32558. protected _alphaMode: number;
  32559. /** @hidden */
  32560. protected _alphaEquation: number;
  32561. private _deterministicLockstep;
  32562. private _lockstepMaxSteps;
  32563. protected readonly _supportsHardwareTextureRescaling: boolean;
  32564. private _fps;
  32565. private _deltaTime;
  32566. /** @hidden */
  32567. _drawCalls: PerfCounter;
  32568. /**
  32569. * Turn this value on if you want to pause FPS computation when in background
  32570. */
  32571. disablePerformanceMonitorInBackground: boolean;
  32572. private _performanceMonitor;
  32573. /**
  32574. * Gets the performance monitor attached to this engine
  32575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32576. */
  32577. readonly performanceMonitor: PerformanceMonitor;
  32578. private _onFocus;
  32579. private _onBlur;
  32580. private _onCanvasPointerOut;
  32581. private _onCanvasBlur;
  32582. private _onCanvasFocus;
  32583. private _onFullscreenChange;
  32584. private _onPointerLockChange;
  32585. /**
  32586. * Gets the HTML element used to attach event listeners
  32587. * @returns a HTML element
  32588. */
  32589. getInputElement(): Nullable<HTMLElement>;
  32590. /**
  32591. * Creates a new engine
  32592. * @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
  32593. * @param antialias defines enable antialiasing (default: false)
  32594. * @param options defines further options to be sent to the getContext() function
  32595. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32596. */
  32597. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32598. /**
  32599. * Gets current aspect ratio
  32600. * @param viewportOwner defines the camera to use to get the aspect ratio
  32601. * @param useScreen defines if screen size must be used (or the current render target if any)
  32602. * @returns a number defining the aspect ratio
  32603. */
  32604. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32605. /**
  32606. * Gets current screen aspect ratio
  32607. * @returns a number defining the aspect ratio
  32608. */
  32609. getScreenAspectRatio(): number;
  32610. /**
  32611. * Gets host document
  32612. * @returns the host document object
  32613. */
  32614. getHostDocument(): Document;
  32615. /**
  32616. * Gets the client rect of the HTML canvas attached with the current webGL context
  32617. * @returns a client rectanglee
  32618. */
  32619. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32620. /**
  32621. * Gets the client rect of the HTML element used for events
  32622. * @returns a client rectanglee
  32623. */
  32624. getInputElementClientRect(): Nullable<ClientRect>;
  32625. /**
  32626. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32627. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32628. * @returns true if engine is in deterministic lock step mode
  32629. */
  32630. isDeterministicLockStep(): boolean;
  32631. /**
  32632. * Gets the max steps when engine is running in deterministic lock step
  32633. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32634. * @returns the max steps
  32635. */
  32636. getLockstepMaxSteps(): number;
  32637. /**
  32638. * Force the mipmap generation for the given render target texture
  32639. * @param texture defines the render target texture to use
  32640. */
  32641. generateMipMapsForCubemap(texture: InternalTexture): void;
  32642. /** States */
  32643. /**
  32644. * Set various states to the webGL context
  32645. * @param culling defines backface culling state
  32646. * @param zOffset defines the value to apply to zOffset (0 by default)
  32647. * @param force defines if states must be applied even if cache is up to date
  32648. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32649. */
  32650. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32651. /**
  32652. * Set the z offset to apply to current rendering
  32653. * @param value defines the offset to apply
  32654. */
  32655. setZOffset(value: number): void;
  32656. /**
  32657. * Gets the current value of the zOffset
  32658. * @returns the current zOffset state
  32659. */
  32660. getZOffset(): number;
  32661. /**
  32662. * Enable or disable depth buffering
  32663. * @param enable defines the state to set
  32664. */
  32665. setDepthBuffer(enable: boolean): void;
  32666. /**
  32667. * Gets a boolean indicating if depth writing is enabled
  32668. * @returns the current depth writing state
  32669. */
  32670. getDepthWrite(): boolean;
  32671. /**
  32672. * Enable or disable depth writing
  32673. * @param enable defines the state to set
  32674. */
  32675. setDepthWrite(enable: boolean): void;
  32676. /**
  32677. * Enable or disable color writing
  32678. * @param enable defines the state to set
  32679. */
  32680. setColorWrite(enable: boolean): void;
  32681. /**
  32682. * Gets a boolean indicating if color writing is enabled
  32683. * @returns the current color writing state
  32684. */
  32685. getColorWrite(): boolean;
  32686. /**
  32687. * Sets alpha constants used by some alpha blending modes
  32688. * @param r defines the red component
  32689. * @param g defines the green component
  32690. * @param b defines the blue component
  32691. * @param a defines the alpha component
  32692. */
  32693. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32694. /**
  32695. * Sets the current alpha mode
  32696. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32697. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32698. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32699. */
  32700. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32701. /**
  32702. * Gets the current alpha mode
  32703. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32704. * @returns the current alpha mode
  32705. */
  32706. getAlphaMode(): number;
  32707. /**
  32708. * Sets the current alpha equation
  32709. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32710. */
  32711. setAlphaEquation(equation: number): void;
  32712. /**
  32713. * Gets the current alpha equation.
  32714. * @returns the current alpha equation
  32715. */
  32716. getAlphaEquation(): number;
  32717. /**
  32718. * Gets a boolean indicating if stencil buffer is enabled
  32719. * @returns the current stencil buffer state
  32720. */
  32721. getStencilBuffer(): boolean;
  32722. /**
  32723. * Enable or disable the stencil buffer
  32724. * @param enable defines if the stencil buffer must be enabled or disabled
  32725. */
  32726. setStencilBuffer(enable: boolean): void;
  32727. /**
  32728. * Gets the current stencil mask
  32729. * @returns a number defining the new stencil mask to use
  32730. */
  32731. getStencilMask(): number;
  32732. /**
  32733. * Sets the current stencil mask
  32734. * @param mask defines the new stencil mask to use
  32735. */
  32736. setStencilMask(mask: number): void;
  32737. /**
  32738. * Gets the current stencil function
  32739. * @returns a number defining the stencil function to use
  32740. */
  32741. getStencilFunction(): number;
  32742. /**
  32743. * Gets the current stencil reference value
  32744. * @returns a number defining the stencil reference value to use
  32745. */
  32746. getStencilFunctionReference(): number;
  32747. /**
  32748. * Gets the current stencil mask
  32749. * @returns a number defining the stencil mask to use
  32750. */
  32751. getStencilFunctionMask(): number;
  32752. /**
  32753. * Sets the current stencil function
  32754. * @param stencilFunc defines the new stencil function to use
  32755. */
  32756. setStencilFunction(stencilFunc: number): void;
  32757. /**
  32758. * Sets the current stencil reference
  32759. * @param reference defines the new stencil reference to use
  32760. */
  32761. setStencilFunctionReference(reference: number): void;
  32762. /**
  32763. * Sets the current stencil mask
  32764. * @param mask defines the new stencil mask to use
  32765. */
  32766. setStencilFunctionMask(mask: number): void;
  32767. /**
  32768. * Gets the current stencil operation when stencil fails
  32769. * @returns a number defining stencil operation to use when stencil fails
  32770. */
  32771. getStencilOperationFail(): number;
  32772. /**
  32773. * Gets the current stencil operation when depth fails
  32774. * @returns a number defining stencil operation to use when depth fails
  32775. */
  32776. getStencilOperationDepthFail(): number;
  32777. /**
  32778. * Gets the current stencil operation when stencil passes
  32779. * @returns a number defining stencil operation to use when stencil passes
  32780. */
  32781. getStencilOperationPass(): number;
  32782. /**
  32783. * Sets the stencil operation to use when stencil fails
  32784. * @param operation defines the stencil operation to use when stencil fails
  32785. */
  32786. setStencilOperationFail(operation: number): void;
  32787. /**
  32788. * Sets the stencil operation to use when depth fails
  32789. * @param operation defines the stencil operation to use when depth fails
  32790. */
  32791. setStencilOperationDepthFail(operation: number): void;
  32792. /**
  32793. * Sets the stencil operation to use when stencil passes
  32794. * @param operation defines the stencil operation to use when stencil passes
  32795. */
  32796. setStencilOperationPass(operation: number): void;
  32797. /**
  32798. * Sets a boolean indicating if the dithering state is enabled or disabled
  32799. * @param value defines the dithering state
  32800. */
  32801. setDitheringState(value: boolean): void;
  32802. /**
  32803. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32804. * @param value defines the rasterizer state
  32805. */
  32806. setRasterizerState(value: boolean): void;
  32807. /**
  32808. * Gets the current depth function
  32809. * @returns a number defining the depth function
  32810. */
  32811. getDepthFunction(): Nullable<number>;
  32812. /**
  32813. * Sets the current depth function
  32814. * @param depthFunc defines the function to use
  32815. */
  32816. setDepthFunction(depthFunc: number): void;
  32817. /**
  32818. * Sets the current depth function to GREATER
  32819. */
  32820. setDepthFunctionToGreater(): void;
  32821. /**
  32822. * Sets the current depth function to GEQUAL
  32823. */
  32824. setDepthFunctionToGreaterOrEqual(): void;
  32825. /**
  32826. * Sets the current depth function to LESS
  32827. */
  32828. setDepthFunctionToLess(): void;
  32829. /**
  32830. * Sets the current depth function to LEQUAL
  32831. */
  32832. setDepthFunctionToLessOrEqual(): void;
  32833. private _cachedStencilBuffer;
  32834. private _cachedStencilFunction;
  32835. private _cachedStencilMask;
  32836. private _cachedStencilOperationPass;
  32837. private _cachedStencilOperationFail;
  32838. private _cachedStencilOperationDepthFail;
  32839. private _cachedStencilReference;
  32840. /**
  32841. * Caches the the state of the stencil buffer
  32842. */
  32843. cacheStencilState(): void;
  32844. /**
  32845. * Restores the state of the stencil buffer
  32846. */
  32847. restoreStencilState(): void;
  32848. /**
  32849. * Directly set the WebGL Viewport
  32850. * @param x defines the x coordinate of the viewport (in screen space)
  32851. * @param y defines the y coordinate of the viewport (in screen space)
  32852. * @param width defines the width of the viewport (in screen space)
  32853. * @param height defines the height of the viewport (in screen space)
  32854. * @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
  32855. */
  32856. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32857. /**
  32858. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32859. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32860. * @param y defines the y-coordinate of the corner of the clear rectangle
  32861. * @param width defines the width of the clear rectangle
  32862. * @param height defines the height of the clear rectangle
  32863. * @param clearColor defines the clear color
  32864. */
  32865. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32866. /**
  32867. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32868. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32869. * @param y defines the y-coordinate of the corner of the clear rectangle
  32870. * @param width defines the width of the clear rectangle
  32871. * @param height defines the height of the clear rectangle
  32872. */
  32873. enableScissor(x: number, y: number, width: number, height: number): void;
  32874. /**
  32875. * Disable previously set scissor test rectangle
  32876. */
  32877. disableScissor(): void;
  32878. protected _reportDrawCall(): void;
  32879. /**
  32880. * Initializes a webVR display and starts listening to display change events
  32881. * The onVRDisplayChangedObservable will be notified upon these changes
  32882. * @returns The onVRDisplayChangedObservable
  32883. */
  32884. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32885. /** @hidden */
  32886. _prepareVRComponent(): void;
  32887. /** @hidden */
  32888. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32889. /** @hidden */
  32890. _submitVRFrame(): void;
  32891. /**
  32892. * Call this function to leave webVR mode
  32893. * Will do nothing if webVR is not supported or if there is no webVR device
  32894. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32895. */
  32896. disableVR(): void;
  32897. /**
  32898. * Gets a boolean indicating that the system is in VR mode and is presenting
  32899. * @returns true if VR mode is engaged
  32900. */
  32901. isVRPresenting(): boolean;
  32902. /** @hidden */
  32903. _requestVRFrame(): void;
  32904. /** @hidden */
  32905. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32906. /**
  32907. * Gets the source code of the vertex shader associated with a specific webGL program
  32908. * @param program defines the program to use
  32909. * @returns a string containing the source code of the vertex shader associated with the program
  32910. */
  32911. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32912. /**
  32913. * Gets the source code of the fragment shader associated with a specific webGL program
  32914. * @param program defines the program to use
  32915. * @returns a string containing the source code of the fragment shader associated with the program
  32916. */
  32917. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32918. /**
  32919. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32920. * @param x defines the x coordinate of the rectangle where pixels must be read
  32921. * @param y defines the y coordinate of the rectangle where pixels must be read
  32922. * @param width defines the width of the rectangle where pixels must be read
  32923. * @param height defines the height of the rectangle where pixels must be read
  32924. * @returns a Uint8Array containing RGBA colors
  32925. */
  32926. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32927. /**
  32928. * Sets a depth stencil texture from a render target to the according uniform.
  32929. * @param channel The texture channel
  32930. * @param uniform The uniform to set
  32931. * @param texture The render target texture containing the depth stencil texture to apply
  32932. */
  32933. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32934. /**
  32935. * Sets a texture to the webGL context from a postprocess
  32936. * @param channel defines the channel to use
  32937. * @param postProcess defines the source postprocess
  32938. */
  32939. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32940. /**
  32941. * Binds the output of the passed in post process to the texture channel specified
  32942. * @param channel The channel the texture should be bound to
  32943. * @param postProcess The post process which's output should be bound
  32944. */
  32945. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32946. /** @hidden */
  32947. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32948. protected _rebuildBuffers(): void;
  32949. /** @hidden */
  32950. _renderFrame(): void;
  32951. _renderLoop(): void;
  32952. /** @hidden */
  32953. _renderViews(): boolean;
  32954. /**
  32955. * Toggle full screen mode
  32956. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32957. */
  32958. switchFullscreen(requestPointerLock: boolean): void;
  32959. /**
  32960. * Enters full screen mode
  32961. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32962. */
  32963. enterFullscreen(requestPointerLock: boolean): void;
  32964. /**
  32965. * Exits full screen mode
  32966. */
  32967. exitFullscreen(): void;
  32968. /**
  32969. * Enters Pointerlock mode
  32970. */
  32971. enterPointerlock(): void;
  32972. /**
  32973. * Exits Pointerlock mode
  32974. */
  32975. exitPointerlock(): void;
  32976. /**
  32977. * Begin a new frame
  32978. */
  32979. beginFrame(): void;
  32980. /**
  32981. * Enf the current frame
  32982. */
  32983. endFrame(): void;
  32984. resize(): void;
  32985. /**
  32986. * Set the compressed texture format to use, based on the formats you have, and the formats
  32987. * supported by the hardware / browser.
  32988. *
  32989. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32990. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32991. * to API arguments needed to compressed textures. This puts the burden on the container
  32992. * generator to house the arcane code for determining these for current & future formats.
  32993. *
  32994. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32995. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32996. *
  32997. * Note: The result of this call is not taken into account when a texture is base64.
  32998. *
  32999. * @param formatsAvailable defines the list of those format families you have created
  33000. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33001. *
  33002. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33003. * @returns The extension selected.
  33004. */
  33005. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33006. /**
  33007. * Force a specific size of the canvas
  33008. * @param width defines the new canvas' width
  33009. * @param height defines the new canvas' height
  33010. */
  33011. setSize(width: number, height: number): void;
  33012. /**
  33013. * Updates a dynamic vertex buffer.
  33014. * @param vertexBuffer the vertex buffer to update
  33015. * @param data the data used to update the vertex buffer
  33016. * @param byteOffset the byte offset of the data
  33017. * @param byteLength the byte length of the data
  33018. */
  33019. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33020. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33021. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33022. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33023. _releaseTexture(texture: InternalTexture): void;
  33024. /**
  33025. * @hidden
  33026. * Rescales a texture
  33027. * @param source input texutre
  33028. * @param destination destination texture
  33029. * @param scene scene to use to render the resize
  33030. * @param internalFormat format to use when resizing
  33031. * @param onComplete callback to be called when resize has completed
  33032. */
  33033. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33034. /**
  33035. * Gets the current framerate
  33036. * @returns a number representing the framerate
  33037. */
  33038. getFps(): number;
  33039. /**
  33040. * Gets the time spent between current and previous frame
  33041. * @returns a number representing the delta time in ms
  33042. */
  33043. getDeltaTime(): number;
  33044. private _measureFps;
  33045. /** @hidden */
  33046. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33047. /**
  33048. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33049. * @param renderTarget The render target to set the frame buffer for
  33050. */
  33051. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33052. /**
  33053. * Update a dynamic index buffer
  33054. * @param indexBuffer defines the target index buffer
  33055. * @param indices defines the data to update
  33056. * @param offset defines the offset in the target index buffer where update should start
  33057. */
  33058. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33059. /**
  33060. * Updates the sample count of a render target texture
  33061. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33062. * @param texture defines the texture to update
  33063. * @param samples defines the sample count to set
  33064. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33065. */
  33066. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33067. /**
  33068. * Updates a depth texture Comparison Mode and Function.
  33069. * If the comparison Function is equal to 0, the mode will be set to none.
  33070. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33071. * @param texture The texture to set the comparison function for
  33072. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33073. */
  33074. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33075. /**
  33076. * Creates a webGL buffer to use with instanciation
  33077. * @param capacity defines the size of the buffer
  33078. * @returns the webGL buffer
  33079. */
  33080. createInstancesBuffer(capacity: number): DataBuffer;
  33081. /**
  33082. * Delete a webGL buffer used with instanciation
  33083. * @param buffer defines the webGL buffer to delete
  33084. */
  33085. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33086. /** @hidden */
  33087. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33088. dispose(): void;
  33089. private _disableTouchAction;
  33090. /**
  33091. * Display the loading screen
  33092. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33093. */
  33094. displayLoadingUI(): void;
  33095. /**
  33096. * Hide the loading screen
  33097. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33098. */
  33099. hideLoadingUI(): void;
  33100. /**
  33101. * Gets the current loading screen object
  33102. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33103. */
  33104. /**
  33105. * Sets the current loading screen object
  33106. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33107. */
  33108. loadingScreen: ILoadingScreen;
  33109. /**
  33110. * Sets the current loading screen text
  33111. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33112. */
  33113. loadingUIText: string;
  33114. /**
  33115. * Sets the current loading screen background color
  33116. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33117. */
  33118. loadingUIBackgroundColor: string;
  33119. /** Pointerlock and fullscreen */
  33120. /**
  33121. * Ask the browser to promote the current element to pointerlock mode
  33122. * @param element defines the DOM element to promote
  33123. */
  33124. static _RequestPointerlock(element: HTMLElement): void;
  33125. /**
  33126. * Asks the browser to exit pointerlock mode
  33127. */
  33128. static _ExitPointerlock(): void;
  33129. /**
  33130. * Ask the browser to promote the current element to fullscreen rendering mode
  33131. * @param element defines the DOM element to promote
  33132. */
  33133. static _RequestFullscreen(element: HTMLElement): void;
  33134. /**
  33135. * Asks the browser to exit fullscreen mode
  33136. */
  33137. static _ExitFullscreen(): void;
  33138. }
  33139. }
  33140. declare module "babylonjs/Engines/engineStore" {
  33141. import { Nullable } from "babylonjs/types";
  33142. import { Engine } from "babylonjs/Engines/engine";
  33143. import { Scene } from "babylonjs/scene";
  33144. /**
  33145. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33146. * during the life time of the application.
  33147. */
  33148. export class EngineStore {
  33149. /** Gets the list of created engines */
  33150. static Instances: import("babylonjs/Engines/engine").Engine[];
  33151. /** @hidden */
  33152. static _LastCreatedScene: Nullable<Scene>;
  33153. /**
  33154. * Gets the latest created engine
  33155. */
  33156. static readonly LastCreatedEngine: Nullable<Engine>;
  33157. /**
  33158. * Gets the latest created scene
  33159. */
  33160. static readonly LastCreatedScene: Nullable<Scene>;
  33161. /**
  33162. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33163. * @ignorenaming
  33164. */
  33165. static UseFallbackTexture: boolean;
  33166. /**
  33167. * Texture content used if a texture cannot loaded
  33168. * @ignorenaming
  33169. */
  33170. static FallbackTexture: string;
  33171. }
  33172. }
  33173. declare module "babylonjs/Misc/promise" {
  33174. /**
  33175. * Helper class that provides a small promise polyfill
  33176. */
  33177. export class PromisePolyfill {
  33178. /**
  33179. * Static function used to check if the polyfill is required
  33180. * If this is the case then the function will inject the polyfill to window.Promise
  33181. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33182. */
  33183. static Apply(force?: boolean): void;
  33184. }
  33185. }
  33186. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  33187. /**
  33188. * Interface for screenshot methods with describe argument called `size` as object with options
  33189. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33190. */
  33191. export interface IScreenshotSize {
  33192. /**
  33193. * number in pixels for canvas height
  33194. */
  33195. height?: number;
  33196. /**
  33197. * multiplier allowing render at a higher or lower resolution
  33198. * If value is defined then height and width will be ignored and taken from camera
  33199. */
  33200. precision?: number;
  33201. /**
  33202. * number in pixels for canvas width
  33203. */
  33204. width?: number;
  33205. }
  33206. }
  33207. declare module "babylonjs/Misc/tools" {
  33208. import { Nullable, float } from "babylonjs/types";
  33209. import { DomManagement } from "babylonjs/Misc/domManagement";
  33210. import { WebRequest } from "babylonjs/Misc/webRequest";
  33211. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33212. import { ReadFileError } from "babylonjs/Misc/fileTools";
  33213. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33214. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  33215. import { Camera } from "babylonjs/Cameras/camera";
  33216. import { Engine } from "babylonjs/Engines/engine";
  33217. interface IColor4Like {
  33218. r: float;
  33219. g: float;
  33220. b: float;
  33221. a: float;
  33222. }
  33223. /**
  33224. * Class containing a set of static utilities functions
  33225. */
  33226. export class Tools {
  33227. /**
  33228. * Gets or sets the base URL to use to load assets
  33229. */
  33230. static BaseUrl: string;
  33231. /**
  33232. * Enable/Disable Custom HTTP Request Headers globally.
  33233. * default = false
  33234. * @see CustomRequestHeaders
  33235. */
  33236. static UseCustomRequestHeaders: boolean;
  33237. /**
  33238. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33239. * i.e. when loading files, where the server/service expects an Authorization header
  33240. */
  33241. static CustomRequestHeaders: {
  33242. [key: string]: string;
  33243. };
  33244. /**
  33245. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33246. */
  33247. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33248. /**
  33249. * Default behaviour for cors in the application.
  33250. * It can be a string if the expected behavior is identical in the entire app.
  33251. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33252. */
  33253. static CorsBehavior: string | ((url: string | string[]) => string);
  33254. /**
  33255. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33256. * @ignorenaming
  33257. */
  33258. static UseFallbackTexture: boolean;
  33259. /**
  33260. * Use this object to register external classes like custom textures or material
  33261. * to allow the laoders to instantiate them
  33262. */
  33263. static RegisteredExternalClasses: {
  33264. [key: string]: Object;
  33265. };
  33266. /**
  33267. * Texture content used if a texture cannot loaded
  33268. * @ignorenaming
  33269. */
  33270. static fallbackTexture: string;
  33271. /**
  33272. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33273. * @param u defines the coordinate on X axis
  33274. * @param v defines the coordinate on Y axis
  33275. * @param width defines the width of the source data
  33276. * @param height defines the height of the source data
  33277. * @param pixels defines the source byte array
  33278. * @param color defines the output color
  33279. */
  33280. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33281. /**
  33282. * Interpolates between a and b via alpha
  33283. * @param a The lower value (returned when alpha = 0)
  33284. * @param b The upper value (returned when alpha = 1)
  33285. * @param alpha The interpolation-factor
  33286. * @return The mixed value
  33287. */
  33288. static Mix(a: number, b: number, alpha: number): number;
  33289. /**
  33290. * Tries to instantiate a new object from a given class name
  33291. * @param className defines the class name to instantiate
  33292. * @returns the new object or null if the system was not able to do the instantiation
  33293. */
  33294. static Instantiate(className: string): any;
  33295. /**
  33296. * Provides a slice function that will work even on IE
  33297. * @param data defines the array to slice
  33298. * @param start defines the start of the data (optional)
  33299. * @param end defines the end of the data (optional)
  33300. * @returns the new sliced array
  33301. */
  33302. static Slice<T>(data: T, start?: number, end?: number): T;
  33303. /**
  33304. * Polyfill for setImmediate
  33305. * @param action defines the action to execute after the current execution block
  33306. */
  33307. static SetImmediate(action: () => void): void;
  33308. /**
  33309. * Function indicating if a number is an exponent of 2
  33310. * @param value defines the value to test
  33311. * @returns true if the value is an exponent of 2
  33312. */
  33313. static IsExponentOfTwo(value: number): boolean;
  33314. private static _tmpFloatArray;
  33315. /**
  33316. * Returns the nearest 32-bit single precision float representation of a Number
  33317. * @param value A Number. If the parameter is of a different type, it will get converted
  33318. * to a number or to NaN if it cannot be converted
  33319. * @returns number
  33320. */
  33321. static FloatRound(value: number): number;
  33322. /**
  33323. * Extracts the filename from a path
  33324. * @param path defines the path to use
  33325. * @returns the filename
  33326. */
  33327. static GetFilename(path: string): string;
  33328. /**
  33329. * Extracts the "folder" part of a path (everything before the filename).
  33330. * @param uri The URI to extract the info from
  33331. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33332. * @returns The "folder" part of the path
  33333. */
  33334. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33335. /**
  33336. * Extracts text content from a DOM element hierarchy
  33337. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33338. */
  33339. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33340. /**
  33341. * Convert an angle in radians to degrees
  33342. * @param angle defines the angle to convert
  33343. * @returns the angle in degrees
  33344. */
  33345. static ToDegrees(angle: number): number;
  33346. /**
  33347. * Convert an angle in degrees to radians
  33348. * @param angle defines the angle to convert
  33349. * @returns the angle in radians
  33350. */
  33351. static ToRadians(angle: number): number;
  33352. /**
  33353. * Returns an array if obj is not an array
  33354. * @param obj defines the object to evaluate as an array
  33355. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33356. * @returns either obj directly if obj is an array or a new array containing obj
  33357. */
  33358. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33359. /**
  33360. * Gets the pointer prefix to use
  33361. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33362. */
  33363. static GetPointerPrefix(): string;
  33364. /**
  33365. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33366. * @param url define the url we are trying
  33367. * @param element define the dom element where to configure the cors policy
  33368. */
  33369. static SetCorsBehavior(url: string | string[], element: {
  33370. crossOrigin: string | null;
  33371. }): void;
  33372. /**
  33373. * Removes unwanted characters from an url
  33374. * @param url defines the url to clean
  33375. * @returns the cleaned url
  33376. */
  33377. static CleanUrl(url: string): string;
  33378. /**
  33379. * Gets or sets a function used to pre-process url before using them to load assets
  33380. */
  33381. static PreprocessUrl: (url: string) => string;
  33382. /**
  33383. * Loads an image as an HTMLImageElement.
  33384. * @param input url string, ArrayBuffer, or Blob to load
  33385. * @param onLoad callback called when the image successfully loads
  33386. * @param onError callback called when the image fails to load
  33387. * @param offlineProvider offline provider for caching
  33388. * @param mimeType optional mime type
  33389. * @returns the HTMLImageElement of the loaded image
  33390. */
  33391. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33392. /**
  33393. * Loads a file from a url
  33394. * @param url url string, ArrayBuffer, or Blob to load
  33395. * @param onSuccess callback called when the file successfully loads
  33396. * @param onProgress callback called while file is loading (if the server supports this mode)
  33397. * @param offlineProvider defines the offline provider for caching
  33398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33399. * @param onError callback called when the file fails to load
  33400. * @returns a file request object
  33401. */
  33402. 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;
  33403. /**
  33404. * Loads a file from a url
  33405. * @param url the file url to load
  33406. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33407. */
  33408. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33409. /**
  33410. * Load a script (identified by an url). When the url returns, the
  33411. * content of this file is added into a new script element, attached to the DOM (body element)
  33412. * @param scriptUrl defines the url of the script to laod
  33413. * @param onSuccess defines the callback called when the script is loaded
  33414. * @param onError defines the callback to call if an error occurs
  33415. * @param scriptId defines the id of the script element
  33416. */
  33417. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33418. /**
  33419. * Load an asynchronous script (identified by an url). When the url returns, the
  33420. * content of this file is added into a new script element, attached to the DOM (body element)
  33421. * @param scriptUrl defines the url of the script to laod
  33422. * @param scriptId defines the id of the script element
  33423. * @returns a promise request object
  33424. */
  33425. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33426. /**
  33427. * Loads a file from a blob
  33428. * @param fileToLoad defines the blob to use
  33429. * @param callback defines the callback to call when data is loaded
  33430. * @param progressCallback defines the callback to call during loading process
  33431. * @returns a file request object
  33432. */
  33433. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33434. /**
  33435. * Reads a file from a File object
  33436. * @param file defines the file to load
  33437. * @param onSuccess defines the callback to call when data is loaded
  33438. * @param onProgress defines the callback to call during loading process
  33439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33440. * @param onError defines the callback to call when an error occurs
  33441. * @returns a file request object
  33442. */
  33443. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33444. /**
  33445. * Creates a data url from a given string content
  33446. * @param content defines the content to convert
  33447. * @returns the new data url link
  33448. */
  33449. static FileAsURL(content: string): string;
  33450. /**
  33451. * Format the given number to a specific decimal format
  33452. * @param value defines the number to format
  33453. * @param decimals defines the number of decimals to use
  33454. * @returns the formatted string
  33455. */
  33456. static Format(value: number, decimals?: number): string;
  33457. /**
  33458. * Tries to copy an object by duplicating every property
  33459. * @param source defines the source object
  33460. * @param destination defines the target object
  33461. * @param doNotCopyList defines a list of properties to avoid
  33462. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33463. */
  33464. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33465. /**
  33466. * Gets a boolean indicating if the given object has no own property
  33467. * @param obj defines the object to test
  33468. * @returns true if object has no own property
  33469. */
  33470. static IsEmpty(obj: any): boolean;
  33471. /**
  33472. * Function used to register events at window level
  33473. * @param windowElement defines the Window object to use
  33474. * @param events defines the events to register
  33475. */
  33476. static RegisterTopRootEvents(windowElement: Window, events: {
  33477. name: string;
  33478. handler: Nullable<(e: FocusEvent) => any>;
  33479. }[]): void;
  33480. /**
  33481. * Function used to unregister events from window level
  33482. * @param windowElement defines the Window object to use
  33483. * @param events defines the events to unregister
  33484. */
  33485. static UnregisterTopRootEvents(windowElement: Window, events: {
  33486. name: string;
  33487. handler: Nullable<(e: FocusEvent) => any>;
  33488. }[]): void;
  33489. /**
  33490. * @ignore
  33491. */
  33492. static _ScreenshotCanvas: HTMLCanvasElement;
  33493. /**
  33494. * Dumps the current bound framebuffer
  33495. * @param width defines the rendering width
  33496. * @param height defines the rendering height
  33497. * @param engine defines the hosting engine
  33498. * @param successCallback defines the callback triggered once the data are available
  33499. * @param mimeType defines the mime type of the result
  33500. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33501. */
  33502. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33503. /**
  33504. * Converts the canvas data to blob.
  33505. * This acts as a polyfill for browsers not supporting the to blob function.
  33506. * @param canvas Defines the canvas to extract the data from
  33507. * @param successCallback Defines the callback triggered once the data are available
  33508. * @param mimeType Defines the mime type of the result
  33509. */
  33510. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33511. /**
  33512. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33513. * @param successCallback defines the callback triggered once the data are available
  33514. * @param mimeType defines the mime type of the result
  33515. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33516. */
  33517. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33518. /**
  33519. * Downloads a blob in the browser
  33520. * @param blob defines the blob to download
  33521. * @param fileName defines the name of the downloaded file
  33522. */
  33523. static Download(blob: Blob, fileName: string): void;
  33524. /**
  33525. * Captures a screenshot of the current rendering
  33526. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33527. * @param engine defines the rendering engine
  33528. * @param camera defines the source camera
  33529. * @param size This parameter can be set to a single number or to an object with the
  33530. * following (optional) properties: precision, width, height. If a single number is passed,
  33531. * it will be used for both width and height. If an object is passed, the screenshot size
  33532. * will be derived from the parameters. The precision property is a multiplier allowing
  33533. * rendering at a higher or lower resolution
  33534. * @param successCallback defines the callback receives a single parameter which contains the
  33535. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33536. * src parameter of an <img> to display it
  33537. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33538. * Check your browser for supported MIME types
  33539. */
  33540. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33541. /**
  33542. * Captures a screenshot of the current rendering
  33543. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33544. * @param engine defines the rendering engine
  33545. * @param camera defines the source camera
  33546. * @param size This parameter can be set to a single number or to an object with the
  33547. * following (optional) properties: precision, width, height. If a single number is passed,
  33548. * it will be used for both width and height. If an object is passed, the screenshot size
  33549. * will be derived from the parameters. The precision property is a multiplier allowing
  33550. * rendering at a higher or lower resolution
  33551. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33552. * Check your browser for supported MIME types
  33553. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33554. * to the src parameter of an <img> to display it
  33555. */
  33556. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33557. /**
  33558. * Generates an image screenshot from the specified camera.
  33559. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33560. * @param engine The engine to use for rendering
  33561. * @param camera The camera to use for rendering
  33562. * @param size This parameter can be set to a single number or to an object with the
  33563. * following (optional) properties: precision, width, height. If a single number is passed,
  33564. * it will be used for both width and height. If an object is passed, the screenshot size
  33565. * will be derived from the parameters. The precision property is a multiplier allowing
  33566. * rendering at a higher or lower resolution
  33567. * @param successCallback The callback receives a single parameter which contains the
  33568. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33569. * src parameter of an <img> to display it
  33570. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33571. * Check your browser for supported MIME types
  33572. * @param samples Texture samples (default: 1)
  33573. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33574. * @param fileName A name for for the downloaded file.
  33575. */
  33576. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33577. /**
  33578. * Generates an image screenshot from the specified camera.
  33579. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33580. * @param engine The engine to use for rendering
  33581. * @param camera The camera to use for rendering
  33582. * @param size This parameter can be set to a single number or to an object with the
  33583. * following (optional) properties: precision, width, height. If a single number is passed,
  33584. * it will be used for both width and height. If an object is passed, the screenshot size
  33585. * will be derived from the parameters. The precision property is a multiplier allowing
  33586. * rendering at a higher or lower resolution
  33587. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33588. * Check your browser for supported MIME types
  33589. * @param samples Texture samples (default: 1)
  33590. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33591. * @param fileName A name for for the downloaded file.
  33592. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33593. * to the src parameter of an <img> to display it
  33594. */
  33595. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33596. /**
  33597. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33598. * Be aware Math.random() could cause collisions, but:
  33599. * "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"
  33600. * @returns a pseudo random id
  33601. */
  33602. static RandomId(): string;
  33603. /**
  33604. * Test if the given uri is a base64 string
  33605. * @param uri The uri to test
  33606. * @return True if the uri is a base64 string or false otherwise
  33607. */
  33608. static IsBase64(uri: string): boolean;
  33609. /**
  33610. * Decode the given base64 uri.
  33611. * @param uri The uri to decode
  33612. * @return The decoded base64 data.
  33613. */
  33614. static DecodeBase64(uri: string): ArrayBuffer;
  33615. /**
  33616. * Gets the absolute url.
  33617. * @param url the input url
  33618. * @return the absolute url
  33619. */
  33620. static GetAbsoluteUrl(url: string): string;
  33621. /**
  33622. * No log
  33623. */
  33624. static readonly NoneLogLevel: number;
  33625. /**
  33626. * Only message logs
  33627. */
  33628. static readonly MessageLogLevel: number;
  33629. /**
  33630. * Only warning logs
  33631. */
  33632. static readonly WarningLogLevel: number;
  33633. /**
  33634. * Only error logs
  33635. */
  33636. static readonly ErrorLogLevel: number;
  33637. /**
  33638. * All logs
  33639. */
  33640. static readonly AllLogLevel: number;
  33641. /**
  33642. * Gets a value indicating the number of loading errors
  33643. * @ignorenaming
  33644. */
  33645. static readonly errorsCount: number;
  33646. /**
  33647. * Callback called when a new log is added
  33648. */
  33649. static OnNewCacheEntry: (entry: string) => void;
  33650. /**
  33651. * Log a message to the console
  33652. * @param message defines the message to log
  33653. */
  33654. static Log(message: string): void;
  33655. /**
  33656. * Write a warning message to the console
  33657. * @param message defines the message to log
  33658. */
  33659. static Warn(message: string): void;
  33660. /**
  33661. * Write an error message to the console
  33662. * @param message defines the message to log
  33663. */
  33664. static Error(message: string): void;
  33665. /**
  33666. * Gets current log cache (list of logs)
  33667. */
  33668. static readonly LogCache: string;
  33669. /**
  33670. * Clears the log cache
  33671. */
  33672. static ClearLogCache(): void;
  33673. /**
  33674. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33675. */
  33676. static LogLevels: number;
  33677. /**
  33678. * Checks if the window object exists
  33679. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33680. */
  33681. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33682. /**
  33683. * No performance log
  33684. */
  33685. static readonly PerformanceNoneLogLevel: number;
  33686. /**
  33687. * Use user marks to log performance
  33688. */
  33689. static readonly PerformanceUserMarkLogLevel: number;
  33690. /**
  33691. * Log performance to the console
  33692. */
  33693. static readonly PerformanceConsoleLogLevel: number;
  33694. private static _performance;
  33695. /**
  33696. * Sets the current performance log level
  33697. */
  33698. static PerformanceLogLevel: number;
  33699. private static _StartPerformanceCounterDisabled;
  33700. private static _EndPerformanceCounterDisabled;
  33701. private static _StartUserMark;
  33702. private static _EndUserMark;
  33703. private static _StartPerformanceConsole;
  33704. private static _EndPerformanceConsole;
  33705. /**
  33706. * Starts a performance counter
  33707. */
  33708. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33709. /**
  33710. * Ends a specific performance coutner
  33711. */
  33712. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33713. /**
  33714. * Gets either window.performance.now() if supported or Date.now() else
  33715. */
  33716. static readonly Now: number;
  33717. /**
  33718. * This method will return the name of the class used to create the instance of the given object.
  33719. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33720. * @param object the object to get the class name from
  33721. * @param isType defines if the object is actually a type
  33722. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33723. */
  33724. static GetClassName(object: any, isType?: boolean): string;
  33725. /**
  33726. * Gets the first element of an array satisfying a given predicate
  33727. * @param array defines the array to browse
  33728. * @param predicate defines the predicate to use
  33729. * @returns null if not found or the element
  33730. */
  33731. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33732. /**
  33733. * This method will return the name of the full name of the class, including its owning module (if any).
  33734. * 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).
  33735. * @param object the object to get the class name from
  33736. * @param isType defines if the object is actually a type
  33737. * @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.
  33738. * @ignorenaming
  33739. */
  33740. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33741. /**
  33742. * Returns a promise that resolves after the given amount of time.
  33743. * @param delay Number of milliseconds to delay
  33744. * @returns Promise that resolves after the given amount of time
  33745. */
  33746. static DelayAsync(delay: number): Promise<void>;
  33747. }
  33748. /**
  33749. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33750. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33751. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33752. * @param name The name of the class, case should be preserved
  33753. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33754. */
  33755. export function className(name: string, module?: string): (target: Object) => void;
  33756. /**
  33757. * An implementation of a loop for asynchronous functions.
  33758. */
  33759. export class AsyncLoop {
  33760. /**
  33761. * Defines the number of iterations for the loop
  33762. */
  33763. iterations: number;
  33764. /**
  33765. * Defines the current index of the loop.
  33766. */
  33767. index: number;
  33768. private _done;
  33769. private _fn;
  33770. private _successCallback;
  33771. /**
  33772. * Constructor.
  33773. * @param iterations the number of iterations.
  33774. * @param func the function to run each iteration
  33775. * @param successCallback the callback that will be called upon succesful execution
  33776. * @param offset starting offset.
  33777. */
  33778. constructor(
  33779. /**
  33780. * Defines the number of iterations for the loop
  33781. */
  33782. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33783. /**
  33784. * Execute the next iteration. Must be called after the last iteration was finished.
  33785. */
  33786. executeNext(): void;
  33787. /**
  33788. * Break the loop and run the success callback.
  33789. */
  33790. breakLoop(): void;
  33791. /**
  33792. * Create and run an async loop.
  33793. * @param iterations the number of iterations.
  33794. * @param fn the function to run each iteration
  33795. * @param successCallback the callback that will be called upon succesful execution
  33796. * @param offset starting offset.
  33797. * @returns the created async loop object
  33798. */
  33799. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33800. /**
  33801. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33802. * @param iterations total number of iterations
  33803. * @param syncedIterations number of synchronous iterations in each async iteration.
  33804. * @param fn the function to call each iteration.
  33805. * @param callback a success call back that will be called when iterating stops.
  33806. * @param breakFunction a break condition (optional)
  33807. * @param timeout timeout settings for the setTimeout function. default - 0.
  33808. * @returns the created async loop object
  33809. */
  33810. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33811. }
  33812. }
  33813. declare module "babylonjs/Misc/stringDictionary" {
  33814. import { Nullable } from "babylonjs/types";
  33815. /**
  33816. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33817. * The underlying implementation relies on an associative array to ensure the best performances.
  33818. * The value can be anything including 'null' but except 'undefined'
  33819. */
  33820. export class StringDictionary<T> {
  33821. /**
  33822. * This will clear this dictionary and copy the content from the 'source' one.
  33823. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33824. * @param source the dictionary to take the content from and copy to this dictionary
  33825. */
  33826. copyFrom(source: StringDictionary<T>): void;
  33827. /**
  33828. * Get a value based from its key
  33829. * @param key the given key to get the matching value from
  33830. * @return the value if found, otherwise undefined is returned
  33831. */
  33832. get(key: string): T | undefined;
  33833. /**
  33834. * Get a value from its key or add it if it doesn't exist.
  33835. * This method will ensure you that a given key/data will be present in the dictionary.
  33836. * @param key the given key to get the matching value from
  33837. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33838. * The factory will only be invoked if there's no data for the given key.
  33839. * @return the value corresponding to the key.
  33840. */
  33841. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33842. /**
  33843. * Get a value from its key if present in the dictionary otherwise add it
  33844. * @param key the key to get the value from
  33845. * @param val if there's no such key/value pair in the dictionary add it with this value
  33846. * @return the value corresponding to the key
  33847. */
  33848. getOrAdd(key: string, val: T): T;
  33849. /**
  33850. * Check if there's a given key in the dictionary
  33851. * @param key the key to check for
  33852. * @return true if the key is present, false otherwise
  33853. */
  33854. contains(key: string): boolean;
  33855. /**
  33856. * Add a new key and its corresponding value
  33857. * @param key the key to add
  33858. * @param value the value corresponding to the key
  33859. * @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
  33860. */
  33861. add(key: string, value: T): boolean;
  33862. /**
  33863. * Update a specific value associated to a key
  33864. * @param key defines the key to use
  33865. * @param value defines the value to store
  33866. * @returns true if the value was updated (or false if the key was not found)
  33867. */
  33868. set(key: string, value: T): boolean;
  33869. /**
  33870. * Get the element of the given key and remove it from the dictionary
  33871. * @param key defines the key to search
  33872. * @returns the value associated with the key or null if not found
  33873. */
  33874. getAndRemove(key: string): Nullable<T>;
  33875. /**
  33876. * Remove a key/value from the dictionary.
  33877. * @param key the key to remove
  33878. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33879. */
  33880. remove(key: string): boolean;
  33881. /**
  33882. * Clear the whole content of the dictionary
  33883. */
  33884. clear(): void;
  33885. /**
  33886. * Gets the current count
  33887. */
  33888. readonly count: number;
  33889. /**
  33890. * Execute a callback on each key/val of the dictionary.
  33891. * Note that you can remove any element in this dictionary in the callback implementation
  33892. * @param callback the callback to execute on a given key/value pair
  33893. */
  33894. forEach(callback: (key: string, val: T) => void): void;
  33895. /**
  33896. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33897. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33898. * Note that you can remove any element in this dictionary in the callback implementation
  33899. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33900. * @returns the first item
  33901. */
  33902. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33903. private _count;
  33904. private _data;
  33905. }
  33906. }
  33907. declare module "babylonjs/Collisions/collisionCoordinator" {
  33908. import { Nullable } from "babylonjs/types";
  33909. import { Scene } from "babylonjs/scene";
  33910. import { Vector3 } from "babylonjs/Maths/math.vector";
  33911. import { Collider } from "babylonjs/Collisions/collider";
  33912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33913. /** @hidden */
  33914. export interface ICollisionCoordinator {
  33915. createCollider(): Collider;
  33916. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33917. init(scene: Scene): void;
  33918. }
  33919. /** @hidden */
  33920. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33921. private _scene;
  33922. private _scaledPosition;
  33923. private _scaledVelocity;
  33924. private _finalPosition;
  33925. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33926. createCollider(): Collider;
  33927. init(scene: Scene): void;
  33928. private _collideWithWorld;
  33929. }
  33930. }
  33931. declare module "babylonjs/Inputs/scene.inputManager" {
  33932. import { Nullable } from "babylonjs/types";
  33933. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33934. import { Vector2 } from "babylonjs/Maths/math.vector";
  33935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33936. import { Scene } from "babylonjs/scene";
  33937. /**
  33938. * Class used to manage all inputs for the scene.
  33939. */
  33940. export class InputManager {
  33941. /** The distance in pixel that you have to move to prevent some events */
  33942. static DragMovementThreshold: number;
  33943. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33944. static LongPressDelay: number;
  33945. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33946. static DoubleClickDelay: number;
  33947. /** If you need to check double click without raising a single click at first click, enable this flag */
  33948. static ExclusiveDoubleClickMode: boolean;
  33949. private _wheelEventName;
  33950. private _onPointerMove;
  33951. private _onPointerDown;
  33952. private _onPointerUp;
  33953. private _initClickEvent;
  33954. private _initActionManager;
  33955. private _delayedSimpleClick;
  33956. private _delayedSimpleClickTimeout;
  33957. private _previousDelayedSimpleClickTimeout;
  33958. private _meshPickProceed;
  33959. private _previousButtonPressed;
  33960. private _currentPickResult;
  33961. private _previousPickResult;
  33962. private _totalPointersPressed;
  33963. private _doubleClickOccured;
  33964. private _pointerOverMesh;
  33965. private _pickedDownMesh;
  33966. private _pickedUpMesh;
  33967. private _pointerX;
  33968. private _pointerY;
  33969. private _unTranslatedPointerX;
  33970. private _unTranslatedPointerY;
  33971. private _startingPointerPosition;
  33972. private _previousStartingPointerPosition;
  33973. private _startingPointerTime;
  33974. private _previousStartingPointerTime;
  33975. private _pointerCaptures;
  33976. private _onKeyDown;
  33977. private _onKeyUp;
  33978. private _onCanvasFocusObserver;
  33979. private _onCanvasBlurObserver;
  33980. private _scene;
  33981. /**
  33982. * Creates a new InputManager
  33983. * @param scene defines the hosting scene
  33984. */
  33985. constructor(scene: Scene);
  33986. /**
  33987. * Gets the mesh that is currently under the pointer
  33988. */
  33989. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33990. /**
  33991. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33992. */
  33993. readonly unTranslatedPointer: Vector2;
  33994. /**
  33995. * Gets or sets the current on-screen X position of the pointer
  33996. */
  33997. pointerX: number;
  33998. /**
  33999. * Gets or sets the current on-screen Y position of the pointer
  34000. */
  34001. pointerY: number;
  34002. private _updatePointerPosition;
  34003. private _processPointerMove;
  34004. private _setRayOnPointerInfo;
  34005. private _checkPrePointerObservable;
  34006. /**
  34007. * Use this method to simulate a pointer move on a mesh
  34008. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34009. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34010. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34011. */
  34012. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34013. /**
  34014. * Use this method to simulate a pointer down on a mesh
  34015. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34016. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34017. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34018. */
  34019. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34020. private _processPointerDown;
  34021. /** @hidden */
  34022. _isPointerSwiping(): boolean;
  34023. /**
  34024. * Use this method to simulate a pointer up on a mesh
  34025. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34026. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34027. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34028. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34029. */
  34030. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34031. private _processPointerUp;
  34032. /**
  34033. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34034. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34035. * @returns true if the pointer was captured
  34036. */
  34037. isPointerCaptured(pointerId?: number): boolean;
  34038. /**
  34039. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34040. * @param attachUp defines if you want to attach events to pointerup
  34041. * @param attachDown defines if you want to attach events to pointerdown
  34042. * @param attachMove defines if you want to attach events to pointermove
  34043. */
  34044. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34045. /**
  34046. * Detaches all event handlers
  34047. */
  34048. detachControl(): void;
  34049. /**
  34050. * Force the value of meshUnderPointer
  34051. * @param mesh defines the mesh to use
  34052. */
  34053. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34054. /**
  34055. * Gets the mesh under the pointer
  34056. * @returns a Mesh or null if no mesh is under the pointer
  34057. */
  34058. getPointerOverMesh(): Nullable<AbstractMesh>;
  34059. }
  34060. }
  34061. declare module "babylonjs/Misc/uniqueIdGenerator" {
  34062. /**
  34063. * Helper class used to generate session unique ID
  34064. */
  34065. export class UniqueIdGenerator {
  34066. private static _UniqueIdCounter;
  34067. /**
  34068. * Gets an unique (relatively to the current scene) Id
  34069. */
  34070. static readonly UniqueId: number;
  34071. }
  34072. }
  34073. declare module "babylonjs/Animations/animationGroup" {
  34074. import { Animatable } from "babylonjs/Animations/animatable";
  34075. import { Animation } from "babylonjs/Animations/animation";
  34076. import { Scene, IDisposable } from "babylonjs/scene";
  34077. import { Observable } from "babylonjs/Misc/observable";
  34078. import { Nullable } from "babylonjs/types";
  34079. import "babylonjs/Animations/animatable";
  34080. /**
  34081. * This class defines the direct association between an animation and a target
  34082. */
  34083. export class TargetedAnimation {
  34084. /**
  34085. * Animation to perform
  34086. */
  34087. animation: Animation;
  34088. /**
  34089. * Target to animate
  34090. */
  34091. target: any;
  34092. /**
  34093. * Serialize the object
  34094. * @returns the JSON object representing the current entity
  34095. */
  34096. serialize(): any;
  34097. }
  34098. /**
  34099. * Use this class to create coordinated animations on multiple targets
  34100. */
  34101. export class AnimationGroup implements IDisposable {
  34102. /** The name of the animation group */
  34103. name: string;
  34104. private _scene;
  34105. private _targetedAnimations;
  34106. private _animatables;
  34107. private _from;
  34108. private _to;
  34109. private _isStarted;
  34110. private _isPaused;
  34111. private _speedRatio;
  34112. private _loopAnimation;
  34113. /**
  34114. * Gets or sets the unique id of the node
  34115. */
  34116. uniqueId: number;
  34117. /**
  34118. * This observable will notify when one animation have ended
  34119. */
  34120. onAnimationEndObservable: Observable<TargetedAnimation>;
  34121. /**
  34122. * Observer raised when one animation loops
  34123. */
  34124. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34125. /**
  34126. * Observer raised when all animations have looped
  34127. */
  34128. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34129. /**
  34130. * This observable will notify when all animations have ended.
  34131. */
  34132. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34133. /**
  34134. * This observable will notify when all animations have paused.
  34135. */
  34136. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34137. /**
  34138. * This observable will notify when all animations are playing.
  34139. */
  34140. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34141. /**
  34142. * Gets the first frame
  34143. */
  34144. readonly from: number;
  34145. /**
  34146. * Gets the last frame
  34147. */
  34148. readonly to: number;
  34149. /**
  34150. * Define if the animations are started
  34151. */
  34152. readonly isStarted: boolean;
  34153. /**
  34154. * Gets a value indicating that the current group is playing
  34155. */
  34156. readonly isPlaying: boolean;
  34157. /**
  34158. * Gets or sets the speed ratio to use for all animations
  34159. */
  34160. /**
  34161. * Gets or sets the speed ratio to use for all animations
  34162. */
  34163. speedRatio: number;
  34164. /**
  34165. * Gets or sets if all animations should loop or not
  34166. */
  34167. loopAnimation: boolean;
  34168. /**
  34169. * Gets the targeted animations for this animation group
  34170. */
  34171. readonly targetedAnimations: Array<TargetedAnimation>;
  34172. /**
  34173. * returning the list of animatables controlled by this animation group.
  34174. */
  34175. readonly animatables: Array<Animatable>;
  34176. /**
  34177. * Instantiates a new Animation Group.
  34178. * This helps managing several animations at once.
  34179. * @see http://doc.babylonjs.com/how_to/group
  34180. * @param name Defines the name of the group
  34181. * @param scene Defines the scene the group belongs to
  34182. */
  34183. constructor(
  34184. /** The name of the animation group */
  34185. name: string, scene?: Nullable<Scene>);
  34186. /**
  34187. * Add an animation (with its target) in the group
  34188. * @param animation defines the animation we want to add
  34189. * @param target defines the target of the animation
  34190. * @returns the TargetedAnimation object
  34191. */
  34192. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34193. /**
  34194. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34195. * It can add constant keys at begin or end
  34196. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34197. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34198. * @returns the animation group
  34199. */
  34200. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34201. private _animationLoopCount;
  34202. private _animationLoopFlags;
  34203. private _processLoop;
  34204. /**
  34205. * Start all animations on given targets
  34206. * @param loop defines if animations must loop
  34207. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34208. * @param from defines the from key (optional)
  34209. * @param to defines the to key (optional)
  34210. * @returns the current animation group
  34211. */
  34212. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34213. /**
  34214. * Pause all animations
  34215. * @returns the animation group
  34216. */
  34217. pause(): AnimationGroup;
  34218. /**
  34219. * Play all animations to initial state
  34220. * This function will start() the animations if they were not started or will restart() them if they were paused
  34221. * @param loop defines if animations must loop
  34222. * @returns the animation group
  34223. */
  34224. play(loop?: boolean): AnimationGroup;
  34225. /**
  34226. * Reset all animations to initial state
  34227. * @returns the animation group
  34228. */
  34229. reset(): AnimationGroup;
  34230. /**
  34231. * Restart animations from key 0
  34232. * @returns the animation group
  34233. */
  34234. restart(): AnimationGroup;
  34235. /**
  34236. * Stop all animations
  34237. * @returns the animation group
  34238. */
  34239. stop(): AnimationGroup;
  34240. /**
  34241. * Set animation weight for all animatables
  34242. * @param weight defines the weight to use
  34243. * @return the animationGroup
  34244. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34245. */
  34246. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34247. /**
  34248. * Synchronize and normalize all animatables with a source animatable
  34249. * @param root defines the root animatable to synchronize with
  34250. * @return the animationGroup
  34251. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34252. */
  34253. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34254. /**
  34255. * Goes to a specific frame in this animation group
  34256. * @param frame the frame number to go to
  34257. * @return the animationGroup
  34258. */
  34259. goToFrame(frame: number): AnimationGroup;
  34260. /**
  34261. * Dispose all associated resources
  34262. */
  34263. dispose(): void;
  34264. private _checkAnimationGroupEnded;
  34265. /**
  34266. * Clone the current animation group and returns a copy
  34267. * @param newName defines the name of the new group
  34268. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34269. * @returns the new aniamtion group
  34270. */
  34271. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34272. /**
  34273. * Serializes the animationGroup to an object
  34274. * @returns Serialized object
  34275. */
  34276. serialize(): any;
  34277. /**
  34278. * Returns a new AnimationGroup object parsed from the source provided.
  34279. * @param parsedAnimationGroup defines the source
  34280. * @param scene defines the scene that will receive the animationGroup
  34281. * @returns a new AnimationGroup
  34282. */
  34283. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34284. /**
  34285. * Returns the string "AnimationGroup"
  34286. * @returns "AnimationGroup"
  34287. */
  34288. getClassName(): string;
  34289. /**
  34290. * Creates a detailled string about the object
  34291. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34292. * @returns a string representing the object
  34293. */
  34294. toString(fullDetails?: boolean): string;
  34295. }
  34296. }
  34297. declare module "babylonjs/scene" {
  34298. import { Nullable } from "babylonjs/types";
  34299. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34300. import { Observable } from "babylonjs/Misc/observable";
  34301. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34302. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34303. import { Geometry } from "babylonjs/Meshes/geometry";
  34304. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34305. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34307. import { Mesh } from "babylonjs/Meshes/mesh";
  34308. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34309. import { Bone } from "babylonjs/Bones/bone";
  34310. import { Skeleton } from "babylonjs/Bones/skeleton";
  34311. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34312. import { Camera } from "babylonjs/Cameras/camera";
  34313. import { AbstractScene } from "babylonjs/abstractScene";
  34314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34315. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34316. import { Material } from "babylonjs/Materials/material";
  34317. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34318. import { Effect } from "babylonjs/Materials/effect";
  34319. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34320. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34321. import { Light } from "babylonjs/Lights/light";
  34322. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34323. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34324. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34325. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34326. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34327. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34328. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34329. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34330. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34331. import { Engine } from "babylonjs/Engines/engine";
  34332. import { Node } from "babylonjs/node";
  34333. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34334. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34335. import { WebRequest } from "babylonjs/Misc/webRequest";
  34336. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34337. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34338. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34339. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34340. import { Plane } from "babylonjs/Maths/math.plane";
  34341. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34342. import { Ray } from "babylonjs/Culling/ray";
  34343. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34344. import { Animation } from "babylonjs/Animations/animation";
  34345. import { Animatable } from "babylonjs/Animations/animatable";
  34346. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34347. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34348. import { Collider } from "babylonjs/Collisions/collider";
  34349. /**
  34350. * Define an interface for all classes that will hold resources
  34351. */
  34352. export interface IDisposable {
  34353. /**
  34354. * Releases all held resources
  34355. */
  34356. dispose(): void;
  34357. }
  34358. /** Interface defining initialization parameters for Scene class */
  34359. export interface SceneOptions {
  34360. /**
  34361. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34362. * It will improve performance when the number of geometries becomes important.
  34363. */
  34364. useGeometryUniqueIdsMap?: boolean;
  34365. /**
  34366. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34367. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34368. */
  34369. useMaterialMeshMap?: boolean;
  34370. /**
  34371. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34372. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34373. */
  34374. useClonedMeshhMap?: boolean;
  34375. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34376. virtual?: boolean;
  34377. }
  34378. /**
  34379. * Represents a scene to be rendered by the engine.
  34380. * @see http://doc.babylonjs.com/features/scene
  34381. */
  34382. export class Scene extends AbstractScene implements IAnimatable {
  34383. /** The fog is deactivated */
  34384. static readonly FOGMODE_NONE: number;
  34385. /** The fog density is following an exponential function */
  34386. static readonly FOGMODE_EXP: number;
  34387. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34388. static readonly FOGMODE_EXP2: number;
  34389. /** The fog density is following a linear function. */
  34390. static readonly FOGMODE_LINEAR: number;
  34391. /**
  34392. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34393. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34394. */
  34395. static MinDeltaTime: number;
  34396. /**
  34397. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34398. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34399. */
  34400. static MaxDeltaTime: number;
  34401. /**
  34402. * Factory used to create the default material.
  34403. * @param name The name of the material to create
  34404. * @param scene The scene to create the material for
  34405. * @returns The default material
  34406. */
  34407. static DefaultMaterialFactory(scene: Scene): Material;
  34408. /**
  34409. * Factory used to create the a collision coordinator.
  34410. * @returns The collision coordinator
  34411. */
  34412. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34413. /** @hidden */
  34414. _inputManager: InputManager;
  34415. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34416. cameraToUseForPointers: Nullable<Camera>;
  34417. /** @hidden */
  34418. readonly _isScene: boolean;
  34419. /**
  34420. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34421. */
  34422. autoClear: boolean;
  34423. /**
  34424. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34425. */
  34426. autoClearDepthAndStencil: boolean;
  34427. /**
  34428. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34429. */
  34430. clearColor: Color4;
  34431. /**
  34432. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34433. */
  34434. ambientColor: Color3;
  34435. /**
  34436. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34437. * It should only be one of the following (if not the default embedded one):
  34438. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34439. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34440. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34441. * The material properties need to be setup according to the type of texture in use.
  34442. */
  34443. environmentBRDFTexture: BaseTexture;
  34444. /** @hidden */
  34445. protected _environmentTexture: Nullable<BaseTexture>;
  34446. /**
  34447. * Texture used in all pbr material as the reflection texture.
  34448. * As in the majority of the scene they are the same (exception for multi room and so on),
  34449. * this is easier to reference from here than from all the materials.
  34450. */
  34451. /**
  34452. * Texture used in all pbr material as the reflection texture.
  34453. * As in the majority of the scene they are the same (exception for multi room and so on),
  34454. * this is easier to set here than in all the materials.
  34455. */
  34456. environmentTexture: Nullable<BaseTexture>;
  34457. /** @hidden */
  34458. protected _environmentIntensity: number;
  34459. /**
  34460. * Intensity of the environment in all pbr material.
  34461. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34462. * As in the majority of the scene they are the same (exception for multi room and so on),
  34463. * this is easier to reference from here than from all the materials.
  34464. */
  34465. /**
  34466. * Intensity of the environment in all pbr material.
  34467. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34468. * As in the majority of the scene they are the same (exception for multi room and so on),
  34469. * this is easier to set here than in all the materials.
  34470. */
  34471. environmentIntensity: number;
  34472. /** @hidden */
  34473. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34474. /**
  34475. * Default image processing configuration used either in the rendering
  34476. * Forward main pass or through the imageProcessingPostProcess if present.
  34477. * As in the majority of the scene they are the same (exception for multi camera),
  34478. * this is easier to reference from here than from all the materials and post process.
  34479. *
  34480. * No setter as we it is a shared configuration, you can set the values instead.
  34481. */
  34482. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34483. private _forceWireframe;
  34484. /**
  34485. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34486. */
  34487. forceWireframe: boolean;
  34488. private _forcePointsCloud;
  34489. /**
  34490. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34491. */
  34492. forcePointsCloud: boolean;
  34493. /**
  34494. * Gets or sets the active clipplane 1
  34495. */
  34496. clipPlane: Nullable<Plane>;
  34497. /**
  34498. * Gets or sets the active clipplane 2
  34499. */
  34500. clipPlane2: Nullable<Plane>;
  34501. /**
  34502. * Gets or sets the active clipplane 3
  34503. */
  34504. clipPlane3: Nullable<Plane>;
  34505. /**
  34506. * Gets or sets the active clipplane 4
  34507. */
  34508. clipPlane4: Nullable<Plane>;
  34509. /**
  34510. * Gets or sets a boolean indicating if animations are enabled
  34511. */
  34512. animationsEnabled: boolean;
  34513. private _animationPropertiesOverride;
  34514. /**
  34515. * Gets or sets the animation properties override
  34516. */
  34517. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34518. /**
  34519. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34520. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34521. */
  34522. useConstantAnimationDeltaTime: boolean;
  34523. /**
  34524. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34525. * Please note that it requires to run a ray cast through the scene on every frame
  34526. */
  34527. constantlyUpdateMeshUnderPointer: boolean;
  34528. /**
  34529. * Defines the HTML cursor to use when hovering over interactive elements
  34530. */
  34531. hoverCursor: string;
  34532. /**
  34533. * Defines the HTML default cursor to use (empty by default)
  34534. */
  34535. defaultCursor: string;
  34536. /**
  34537. * Defines wether cursors are handled by the scene.
  34538. */
  34539. doNotHandleCursors: boolean;
  34540. /**
  34541. * This is used to call preventDefault() on pointer down
  34542. * in order to block unwanted artifacts like system double clicks
  34543. */
  34544. preventDefaultOnPointerDown: boolean;
  34545. /**
  34546. * This is used to call preventDefault() on pointer up
  34547. * in order to block unwanted artifacts like system double clicks
  34548. */
  34549. preventDefaultOnPointerUp: boolean;
  34550. /**
  34551. * Gets or sets user defined metadata
  34552. */
  34553. metadata: any;
  34554. /**
  34555. * For internal use only. Please do not use.
  34556. */
  34557. reservedDataStore: any;
  34558. /**
  34559. * Gets the name of the plugin used to load this scene (null by default)
  34560. */
  34561. loadingPluginName: string;
  34562. /**
  34563. * Use this array to add regular expressions used to disable offline support for specific urls
  34564. */
  34565. disableOfflineSupportExceptionRules: RegExp[];
  34566. /**
  34567. * An event triggered when the scene is disposed.
  34568. */
  34569. onDisposeObservable: Observable<Scene>;
  34570. private _onDisposeObserver;
  34571. /** Sets a function to be executed when this scene is disposed. */
  34572. onDispose: () => void;
  34573. /**
  34574. * An event triggered before rendering the scene (right after animations and physics)
  34575. */
  34576. onBeforeRenderObservable: Observable<Scene>;
  34577. private _onBeforeRenderObserver;
  34578. /** Sets a function to be executed before rendering this scene */
  34579. beforeRender: Nullable<() => void>;
  34580. /**
  34581. * An event triggered after rendering the scene
  34582. */
  34583. onAfterRenderObservable: Observable<Scene>;
  34584. /**
  34585. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34586. */
  34587. onAfterRenderCameraObservable: Observable<Camera>;
  34588. private _onAfterRenderObserver;
  34589. /** Sets a function to be executed after rendering this scene */
  34590. afterRender: Nullable<() => void>;
  34591. /**
  34592. * An event triggered before animating the scene
  34593. */
  34594. onBeforeAnimationsObservable: Observable<Scene>;
  34595. /**
  34596. * An event triggered after animations processing
  34597. */
  34598. onAfterAnimationsObservable: Observable<Scene>;
  34599. /**
  34600. * An event triggered before draw calls are ready to be sent
  34601. */
  34602. onBeforeDrawPhaseObservable: Observable<Scene>;
  34603. /**
  34604. * An event triggered after draw calls have been sent
  34605. */
  34606. onAfterDrawPhaseObservable: Observable<Scene>;
  34607. /**
  34608. * An event triggered when the scene is ready
  34609. */
  34610. onReadyObservable: Observable<Scene>;
  34611. /**
  34612. * An event triggered before rendering a camera
  34613. */
  34614. onBeforeCameraRenderObservable: Observable<Camera>;
  34615. private _onBeforeCameraRenderObserver;
  34616. /** Sets a function to be executed before rendering a camera*/
  34617. beforeCameraRender: () => void;
  34618. /**
  34619. * An event triggered after rendering a camera
  34620. */
  34621. onAfterCameraRenderObservable: Observable<Camera>;
  34622. private _onAfterCameraRenderObserver;
  34623. /** Sets a function to be executed after rendering a camera*/
  34624. afterCameraRender: () => void;
  34625. /**
  34626. * An event triggered when active meshes evaluation is about to start
  34627. */
  34628. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34629. /**
  34630. * An event triggered when active meshes evaluation is done
  34631. */
  34632. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34633. /**
  34634. * An event triggered when particles rendering is about to start
  34635. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34636. */
  34637. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34638. /**
  34639. * An event triggered when particles rendering is done
  34640. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34641. */
  34642. onAfterParticlesRenderingObservable: Observable<Scene>;
  34643. /**
  34644. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34645. */
  34646. onDataLoadedObservable: Observable<Scene>;
  34647. /**
  34648. * An event triggered when a camera is created
  34649. */
  34650. onNewCameraAddedObservable: Observable<Camera>;
  34651. /**
  34652. * An event triggered when a camera is removed
  34653. */
  34654. onCameraRemovedObservable: Observable<Camera>;
  34655. /**
  34656. * An event triggered when a light is created
  34657. */
  34658. onNewLightAddedObservable: Observable<Light>;
  34659. /**
  34660. * An event triggered when a light is removed
  34661. */
  34662. onLightRemovedObservable: Observable<Light>;
  34663. /**
  34664. * An event triggered when a geometry is created
  34665. */
  34666. onNewGeometryAddedObservable: Observable<Geometry>;
  34667. /**
  34668. * An event triggered when a geometry is removed
  34669. */
  34670. onGeometryRemovedObservable: Observable<Geometry>;
  34671. /**
  34672. * An event triggered when a transform node is created
  34673. */
  34674. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34675. /**
  34676. * An event triggered when a transform node is removed
  34677. */
  34678. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34679. /**
  34680. * An event triggered when a mesh is created
  34681. */
  34682. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34683. /**
  34684. * An event triggered when a mesh is removed
  34685. */
  34686. onMeshRemovedObservable: Observable<AbstractMesh>;
  34687. /**
  34688. * An event triggered when a skeleton is created
  34689. */
  34690. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34691. /**
  34692. * An event triggered when a skeleton is removed
  34693. */
  34694. onSkeletonRemovedObservable: Observable<Skeleton>;
  34695. /**
  34696. * An event triggered when a material is created
  34697. */
  34698. onNewMaterialAddedObservable: Observable<Material>;
  34699. /**
  34700. * An event triggered when a material is removed
  34701. */
  34702. onMaterialRemovedObservable: Observable<Material>;
  34703. /**
  34704. * An event triggered when a texture is created
  34705. */
  34706. onNewTextureAddedObservable: Observable<BaseTexture>;
  34707. /**
  34708. * An event triggered when a texture is removed
  34709. */
  34710. onTextureRemovedObservable: Observable<BaseTexture>;
  34711. /**
  34712. * An event triggered when render targets are about to be rendered
  34713. * Can happen multiple times per frame.
  34714. */
  34715. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34716. /**
  34717. * An event triggered when render targets were rendered.
  34718. * Can happen multiple times per frame.
  34719. */
  34720. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34721. /**
  34722. * An event triggered before calculating deterministic simulation step
  34723. */
  34724. onBeforeStepObservable: Observable<Scene>;
  34725. /**
  34726. * An event triggered after calculating deterministic simulation step
  34727. */
  34728. onAfterStepObservable: Observable<Scene>;
  34729. /**
  34730. * An event triggered when the activeCamera property is updated
  34731. */
  34732. onActiveCameraChanged: Observable<Scene>;
  34733. /**
  34734. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34735. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34736. * 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)
  34737. */
  34738. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34739. /**
  34740. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34741. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34742. * 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)
  34743. */
  34744. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34745. /**
  34746. * This Observable will when a mesh has been imported into the scene.
  34747. */
  34748. onMeshImportedObservable: Observable<AbstractMesh>;
  34749. /**
  34750. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34751. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34752. */
  34753. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34754. /** @hidden */
  34755. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34756. /**
  34757. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34758. */
  34759. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34760. /**
  34761. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34762. */
  34763. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34764. /**
  34765. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34766. */
  34767. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34768. /** Callback called when a pointer move is detected */
  34769. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34770. /** Callback called when a pointer down is detected */
  34771. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34772. /** Callback called when a pointer up is detected */
  34773. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34774. /** Callback called when a pointer pick is detected */
  34775. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34776. /**
  34777. * 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).
  34778. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34779. */
  34780. onPrePointerObservable: Observable<PointerInfoPre>;
  34781. /**
  34782. * Observable event triggered each time an input event is received from the rendering canvas
  34783. */
  34784. onPointerObservable: Observable<PointerInfo>;
  34785. /**
  34786. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34787. */
  34788. readonly unTranslatedPointer: Vector2;
  34789. /**
  34790. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34791. */
  34792. static DragMovementThreshold: number;
  34793. /**
  34794. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34795. */
  34796. static LongPressDelay: number;
  34797. /**
  34798. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34799. */
  34800. static DoubleClickDelay: number;
  34801. /** If you need to check double click without raising a single click at first click, enable this flag */
  34802. static ExclusiveDoubleClickMode: boolean;
  34803. /** @hidden */
  34804. _mirroredCameraPosition: Nullable<Vector3>;
  34805. /**
  34806. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34807. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34808. */
  34809. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34810. /**
  34811. * Observable event triggered each time an keyboard event is received from the hosting window
  34812. */
  34813. onKeyboardObservable: Observable<KeyboardInfo>;
  34814. private _useRightHandedSystem;
  34815. /**
  34816. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34817. */
  34818. useRightHandedSystem: boolean;
  34819. private _timeAccumulator;
  34820. private _currentStepId;
  34821. private _currentInternalStep;
  34822. /**
  34823. * Sets the step Id used by deterministic lock step
  34824. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34825. * @param newStepId defines the step Id
  34826. */
  34827. setStepId(newStepId: number): void;
  34828. /**
  34829. * Gets the step Id used by deterministic lock step
  34830. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34831. * @returns the step Id
  34832. */
  34833. getStepId(): number;
  34834. /**
  34835. * Gets the internal step used by deterministic lock step
  34836. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34837. * @returns the internal step
  34838. */
  34839. getInternalStep(): number;
  34840. private _fogEnabled;
  34841. /**
  34842. * Gets or sets a boolean indicating if fog is enabled on this scene
  34843. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34844. * (Default is true)
  34845. */
  34846. fogEnabled: boolean;
  34847. private _fogMode;
  34848. /**
  34849. * Gets or sets the fog mode to use
  34850. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34851. * | mode | value |
  34852. * | --- | --- |
  34853. * | FOGMODE_NONE | 0 |
  34854. * | FOGMODE_EXP | 1 |
  34855. * | FOGMODE_EXP2 | 2 |
  34856. * | FOGMODE_LINEAR | 3 |
  34857. */
  34858. fogMode: number;
  34859. /**
  34860. * Gets or sets the fog color to use
  34861. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34862. * (Default is Color3(0.2, 0.2, 0.3))
  34863. */
  34864. fogColor: Color3;
  34865. /**
  34866. * Gets or sets the fog density to use
  34867. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34868. * (Default is 0.1)
  34869. */
  34870. fogDensity: number;
  34871. /**
  34872. * Gets or sets the fog start distance to use
  34873. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34874. * (Default is 0)
  34875. */
  34876. fogStart: number;
  34877. /**
  34878. * Gets or sets the fog end distance to use
  34879. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34880. * (Default is 1000)
  34881. */
  34882. fogEnd: number;
  34883. private _shadowsEnabled;
  34884. /**
  34885. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34886. */
  34887. shadowsEnabled: boolean;
  34888. private _lightsEnabled;
  34889. /**
  34890. * Gets or sets a boolean indicating if lights are enabled on this scene
  34891. */
  34892. lightsEnabled: boolean;
  34893. /** All of the active cameras added to this scene. */
  34894. activeCameras: Camera[];
  34895. /** @hidden */
  34896. _activeCamera: Nullable<Camera>;
  34897. /** Gets or sets the current active camera */
  34898. activeCamera: Nullable<Camera>;
  34899. private _defaultMaterial;
  34900. /** The default material used on meshes when no material is affected */
  34901. /** The default material used on meshes when no material is affected */
  34902. defaultMaterial: Material;
  34903. private _texturesEnabled;
  34904. /**
  34905. * Gets or sets a boolean indicating if textures are enabled on this scene
  34906. */
  34907. texturesEnabled: boolean;
  34908. /**
  34909. * Gets or sets a boolean indicating if particles are enabled on this scene
  34910. */
  34911. particlesEnabled: boolean;
  34912. /**
  34913. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34914. */
  34915. spritesEnabled: boolean;
  34916. private _skeletonsEnabled;
  34917. /**
  34918. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34919. */
  34920. skeletonsEnabled: boolean;
  34921. /**
  34922. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34923. */
  34924. lensFlaresEnabled: boolean;
  34925. /**
  34926. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34927. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34928. */
  34929. collisionsEnabled: boolean;
  34930. private _collisionCoordinator;
  34931. /** @hidden */
  34932. readonly collisionCoordinator: ICollisionCoordinator;
  34933. /**
  34934. * Defines the gravity applied to this scene (used only for collisions)
  34935. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34936. */
  34937. gravity: Vector3;
  34938. /**
  34939. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34940. */
  34941. postProcessesEnabled: boolean;
  34942. /**
  34943. * The list of postprocesses added to the scene
  34944. */
  34945. postProcesses: PostProcess[];
  34946. /**
  34947. * Gets the current postprocess manager
  34948. */
  34949. postProcessManager: PostProcessManager;
  34950. /**
  34951. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34952. */
  34953. renderTargetsEnabled: boolean;
  34954. /**
  34955. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34956. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34957. */
  34958. dumpNextRenderTargets: boolean;
  34959. /**
  34960. * The list of user defined render targets added to the scene
  34961. */
  34962. customRenderTargets: RenderTargetTexture[];
  34963. /**
  34964. * Defines if texture loading must be delayed
  34965. * If true, textures will only be loaded when they need to be rendered
  34966. */
  34967. useDelayedTextureLoading: boolean;
  34968. /**
  34969. * Gets the list of meshes imported to the scene through SceneLoader
  34970. */
  34971. importedMeshesFiles: String[];
  34972. /**
  34973. * Gets or sets a boolean indicating if probes are enabled on this scene
  34974. */
  34975. probesEnabled: boolean;
  34976. /**
  34977. * Gets or sets the current offline provider to use to store scene data
  34978. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34979. */
  34980. offlineProvider: IOfflineProvider;
  34981. /**
  34982. * Gets or sets the action manager associated with the scene
  34983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34984. */
  34985. actionManager: AbstractActionManager;
  34986. private _meshesForIntersections;
  34987. /**
  34988. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34989. */
  34990. proceduralTexturesEnabled: boolean;
  34991. private _engine;
  34992. private _totalVertices;
  34993. /** @hidden */
  34994. _activeIndices: PerfCounter;
  34995. /** @hidden */
  34996. _activeParticles: PerfCounter;
  34997. /** @hidden */
  34998. _activeBones: PerfCounter;
  34999. private _animationRatio;
  35000. /** @hidden */
  35001. _animationTimeLast: number;
  35002. /** @hidden */
  35003. _animationTime: number;
  35004. /**
  35005. * Gets or sets a general scale for animation speed
  35006. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35007. */
  35008. animationTimeScale: number;
  35009. /** @hidden */
  35010. _cachedMaterial: Nullable<Material>;
  35011. /** @hidden */
  35012. _cachedEffect: Nullable<Effect>;
  35013. /** @hidden */
  35014. _cachedVisibility: Nullable<number>;
  35015. private _renderId;
  35016. private _frameId;
  35017. private _executeWhenReadyTimeoutId;
  35018. private _intermediateRendering;
  35019. private _viewUpdateFlag;
  35020. private _projectionUpdateFlag;
  35021. /** @hidden */
  35022. _toBeDisposed: Nullable<IDisposable>[];
  35023. private _activeRequests;
  35024. /** @hidden */
  35025. _pendingData: any[];
  35026. private _isDisposed;
  35027. /**
  35028. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35029. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35030. */
  35031. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35032. private _activeMeshes;
  35033. private _processedMaterials;
  35034. private _renderTargets;
  35035. /** @hidden */
  35036. _activeParticleSystems: SmartArray<IParticleSystem>;
  35037. private _activeSkeletons;
  35038. private _softwareSkinnedMeshes;
  35039. private _renderingManager;
  35040. /** @hidden */
  35041. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  35042. private _transformMatrix;
  35043. private _sceneUbo;
  35044. /** @hidden */
  35045. _viewMatrix: Matrix;
  35046. private _projectionMatrix;
  35047. /** @hidden */
  35048. _forcedViewPosition: Nullable<Vector3>;
  35049. /** @hidden */
  35050. _frustumPlanes: Plane[];
  35051. /**
  35052. * Gets the list of frustum planes (built from the active camera)
  35053. */
  35054. readonly frustumPlanes: Plane[];
  35055. /**
  35056. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35057. * This is useful if there are more lights that the maximum simulteanous authorized
  35058. */
  35059. requireLightSorting: boolean;
  35060. /** @hidden */
  35061. readonly useMaterialMeshMap: boolean;
  35062. /** @hidden */
  35063. readonly useClonedMeshhMap: boolean;
  35064. private _externalData;
  35065. private _uid;
  35066. /**
  35067. * @hidden
  35068. * Backing store of defined scene components.
  35069. */
  35070. _components: ISceneComponent[];
  35071. /**
  35072. * @hidden
  35073. * Backing store of defined scene components.
  35074. */
  35075. _serializableComponents: ISceneSerializableComponent[];
  35076. /**
  35077. * List of components to register on the next registration step.
  35078. */
  35079. private _transientComponents;
  35080. /**
  35081. * Registers the transient components if needed.
  35082. */
  35083. private _registerTransientComponents;
  35084. /**
  35085. * @hidden
  35086. * Add a component to the scene.
  35087. * Note that the ccomponent could be registered on th next frame if this is called after
  35088. * the register component stage.
  35089. * @param component Defines the component to add to the scene
  35090. */
  35091. _addComponent(component: ISceneComponent): void;
  35092. /**
  35093. * @hidden
  35094. * Gets a component from the scene.
  35095. * @param name defines the name of the component to retrieve
  35096. * @returns the component or null if not present
  35097. */
  35098. _getComponent(name: string): Nullable<ISceneComponent>;
  35099. /**
  35100. * @hidden
  35101. * Defines the actions happening before camera updates.
  35102. */
  35103. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35104. /**
  35105. * @hidden
  35106. * Defines the actions happening before clear the canvas.
  35107. */
  35108. _beforeClearStage: Stage<SimpleStageAction>;
  35109. /**
  35110. * @hidden
  35111. * Defines the actions when collecting render targets for the frame.
  35112. */
  35113. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35114. /**
  35115. * @hidden
  35116. * Defines the actions happening for one camera in the frame.
  35117. */
  35118. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35119. /**
  35120. * @hidden
  35121. * Defines the actions happening during the per mesh ready checks.
  35122. */
  35123. _isReadyForMeshStage: Stage<MeshStageAction>;
  35124. /**
  35125. * @hidden
  35126. * Defines the actions happening before evaluate active mesh checks.
  35127. */
  35128. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35129. /**
  35130. * @hidden
  35131. * Defines the actions happening during the evaluate sub mesh checks.
  35132. */
  35133. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35134. /**
  35135. * @hidden
  35136. * Defines the actions happening during the active mesh stage.
  35137. */
  35138. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35139. /**
  35140. * @hidden
  35141. * Defines the actions happening during the per camera render target step.
  35142. */
  35143. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35144. /**
  35145. * @hidden
  35146. * Defines the actions happening just before the active camera is drawing.
  35147. */
  35148. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35149. /**
  35150. * @hidden
  35151. * Defines the actions happening just before a render target is drawing.
  35152. */
  35153. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35154. /**
  35155. * @hidden
  35156. * Defines the actions happening just before a rendering group is drawing.
  35157. */
  35158. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35159. /**
  35160. * @hidden
  35161. * Defines the actions happening just before a mesh is drawing.
  35162. */
  35163. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35164. /**
  35165. * @hidden
  35166. * Defines the actions happening just after a mesh has been drawn.
  35167. */
  35168. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35169. /**
  35170. * @hidden
  35171. * Defines the actions happening just after a rendering group has been drawn.
  35172. */
  35173. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35174. /**
  35175. * @hidden
  35176. * Defines the actions happening just after the active camera has been drawn.
  35177. */
  35178. _afterCameraDrawStage: Stage<CameraStageAction>;
  35179. /**
  35180. * @hidden
  35181. * Defines the actions happening just after a render target has been drawn.
  35182. */
  35183. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35184. /**
  35185. * @hidden
  35186. * Defines the actions happening just after rendering all cameras and computing intersections.
  35187. */
  35188. _afterRenderStage: Stage<SimpleStageAction>;
  35189. /**
  35190. * @hidden
  35191. * Defines the actions happening when a pointer move event happens.
  35192. */
  35193. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35194. /**
  35195. * @hidden
  35196. * Defines the actions happening when a pointer down event happens.
  35197. */
  35198. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35199. /**
  35200. * @hidden
  35201. * Defines the actions happening when a pointer up event happens.
  35202. */
  35203. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35204. /**
  35205. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35206. */
  35207. private geometriesByUniqueId;
  35208. /**
  35209. * Creates a new Scene
  35210. * @param engine defines the engine to use to render this scene
  35211. * @param options defines the scene options
  35212. */
  35213. constructor(engine: Engine, options?: SceneOptions);
  35214. /**
  35215. * Gets a string idenfifying the name of the class
  35216. * @returns "Scene" string
  35217. */
  35218. getClassName(): string;
  35219. private _defaultMeshCandidates;
  35220. /**
  35221. * @hidden
  35222. */
  35223. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35224. private _defaultSubMeshCandidates;
  35225. /**
  35226. * @hidden
  35227. */
  35228. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35229. /**
  35230. * Sets the default candidate providers for the scene.
  35231. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35232. * and getCollidingSubMeshCandidates to their default function
  35233. */
  35234. setDefaultCandidateProviders(): void;
  35235. /**
  35236. * Gets the mesh that is currently under the pointer
  35237. */
  35238. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35239. /**
  35240. * Gets or sets the current on-screen X position of the pointer
  35241. */
  35242. pointerX: number;
  35243. /**
  35244. * Gets or sets the current on-screen Y position of the pointer
  35245. */
  35246. pointerY: number;
  35247. /**
  35248. * Gets the cached material (ie. the latest rendered one)
  35249. * @returns the cached material
  35250. */
  35251. getCachedMaterial(): Nullable<Material>;
  35252. /**
  35253. * Gets the cached effect (ie. the latest rendered one)
  35254. * @returns the cached effect
  35255. */
  35256. getCachedEffect(): Nullable<Effect>;
  35257. /**
  35258. * Gets the cached visibility state (ie. the latest rendered one)
  35259. * @returns the cached visibility state
  35260. */
  35261. getCachedVisibility(): Nullable<number>;
  35262. /**
  35263. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35264. * @param material defines the current material
  35265. * @param effect defines the current effect
  35266. * @param visibility defines the current visibility state
  35267. * @returns true if one parameter is not cached
  35268. */
  35269. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35270. /**
  35271. * Gets the engine associated with the scene
  35272. * @returns an Engine
  35273. */
  35274. getEngine(): Engine;
  35275. /**
  35276. * Gets the total number of vertices rendered per frame
  35277. * @returns the total number of vertices rendered per frame
  35278. */
  35279. getTotalVertices(): number;
  35280. /**
  35281. * Gets the performance counter for total vertices
  35282. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35283. */
  35284. readonly totalVerticesPerfCounter: PerfCounter;
  35285. /**
  35286. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35287. * @returns the total number of active indices rendered per frame
  35288. */
  35289. getActiveIndices(): number;
  35290. /**
  35291. * Gets the performance counter for active indices
  35292. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35293. */
  35294. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35295. /**
  35296. * Gets the total number of active particles rendered per frame
  35297. * @returns the total number of active particles rendered per frame
  35298. */
  35299. getActiveParticles(): number;
  35300. /**
  35301. * Gets the performance counter for active particles
  35302. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35303. */
  35304. readonly activeParticlesPerfCounter: PerfCounter;
  35305. /**
  35306. * Gets the total number of active bones rendered per frame
  35307. * @returns the total number of active bones rendered per frame
  35308. */
  35309. getActiveBones(): number;
  35310. /**
  35311. * Gets the performance counter for active bones
  35312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35313. */
  35314. readonly activeBonesPerfCounter: PerfCounter;
  35315. /**
  35316. * Gets the array of active meshes
  35317. * @returns an array of AbstractMesh
  35318. */
  35319. getActiveMeshes(): SmartArray<AbstractMesh>;
  35320. /**
  35321. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35322. * @returns a number
  35323. */
  35324. getAnimationRatio(): number;
  35325. /**
  35326. * Gets an unique Id for the current render phase
  35327. * @returns a number
  35328. */
  35329. getRenderId(): number;
  35330. /**
  35331. * Gets an unique Id for the current frame
  35332. * @returns a number
  35333. */
  35334. getFrameId(): number;
  35335. /** Call this function if you want to manually increment the render Id*/
  35336. incrementRenderId(): void;
  35337. private _createUbo;
  35338. /**
  35339. * Use this method to simulate a pointer move on a mesh
  35340. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35341. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35342. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35343. * @returns the current scene
  35344. */
  35345. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35346. /**
  35347. * Use this method to simulate a pointer down on a mesh
  35348. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35349. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35350. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35351. * @returns the current scene
  35352. */
  35353. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35354. /**
  35355. * Use this method to simulate a pointer up on a mesh
  35356. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35357. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35358. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35359. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35360. * @returns the current scene
  35361. */
  35362. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35363. /**
  35364. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35365. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35366. * @returns true if the pointer was captured
  35367. */
  35368. isPointerCaptured(pointerId?: number): boolean;
  35369. /**
  35370. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35371. * @param attachUp defines if you want to attach events to pointerup
  35372. * @param attachDown defines if you want to attach events to pointerdown
  35373. * @param attachMove defines if you want to attach events to pointermove
  35374. */
  35375. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35376. /** Detaches all event handlers*/
  35377. detachControl(): void;
  35378. /**
  35379. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35380. * Delay loaded resources are not taking in account
  35381. * @return true if all required resources are ready
  35382. */
  35383. isReady(): boolean;
  35384. /** Resets all cached information relative to material (including effect and visibility) */
  35385. resetCachedMaterial(): void;
  35386. /**
  35387. * Registers a function to be called before every frame render
  35388. * @param func defines the function to register
  35389. */
  35390. registerBeforeRender(func: () => void): void;
  35391. /**
  35392. * Unregisters a function called before every frame render
  35393. * @param func defines the function to unregister
  35394. */
  35395. unregisterBeforeRender(func: () => void): void;
  35396. /**
  35397. * Registers a function to be called after every frame render
  35398. * @param func defines the function to register
  35399. */
  35400. registerAfterRender(func: () => void): void;
  35401. /**
  35402. * Unregisters a function called after every frame render
  35403. * @param func defines the function to unregister
  35404. */
  35405. unregisterAfterRender(func: () => void): void;
  35406. private _executeOnceBeforeRender;
  35407. /**
  35408. * The provided function will run before render once and will be disposed afterwards.
  35409. * A timeout delay can be provided so that the function will be executed in N ms.
  35410. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35411. * @param func The function to be executed.
  35412. * @param timeout optional delay in ms
  35413. */
  35414. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35415. /** @hidden */
  35416. _addPendingData(data: any): void;
  35417. /** @hidden */
  35418. _removePendingData(data: any): void;
  35419. /**
  35420. * Returns the number of items waiting to be loaded
  35421. * @returns the number of items waiting to be loaded
  35422. */
  35423. getWaitingItemsCount(): number;
  35424. /**
  35425. * Returns a boolean indicating if the scene is still loading data
  35426. */
  35427. readonly isLoading: boolean;
  35428. /**
  35429. * Registers a function to be executed when the scene is ready
  35430. * @param {Function} func - the function to be executed
  35431. */
  35432. executeWhenReady(func: () => void): void;
  35433. /**
  35434. * Returns a promise that resolves when the scene is ready
  35435. * @returns A promise that resolves when the scene is ready
  35436. */
  35437. whenReadyAsync(): Promise<void>;
  35438. /** @hidden */
  35439. _checkIsReady(): void;
  35440. /**
  35441. * Gets all animatable attached to the scene
  35442. */
  35443. readonly animatables: Animatable[];
  35444. /**
  35445. * Resets the last animation time frame.
  35446. * Useful to override when animations start running when loading a scene for the first time.
  35447. */
  35448. resetLastAnimationTimeFrame(): void;
  35449. /**
  35450. * Gets the current view matrix
  35451. * @returns a Matrix
  35452. */
  35453. getViewMatrix(): Matrix;
  35454. /**
  35455. * Gets the current projection matrix
  35456. * @returns a Matrix
  35457. */
  35458. getProjectionMatrix(): Matrix;
  35459. /**
  35460. * Gets the current transform matrix
  35461. * @returns a Matrix made of View * Projection
  35462. */
  35463. getTransformMatrix(): Matrix;
  35464. /**
  35465. * Sets the current transform matrix
  35466. * @param viewL defines the View matrix to use
  35467. * @param projectionL defines the Projection matrix to use
  35468. * @param viewR defines the right View matrix to use (if provided)
  35469. * @param projectionR defines the right Projection matrix to use (if provided)
  35470. */
  35471. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35472. /**
  35473. * Gets the uniform buffer used to store scene data
  35474. * @returns a UniformBuffer
  35475. */
  35476. getSceneUniformBuffer(): UniformBuffer;
  35477. /**
  35478. * Gets an unique (relatively to the current scene) Id
  35479. * @returns an unique number for the scene
  35480. */
  35481. getUniqueId(): number;
  35482. /**
  35483. * Add a mesh to the list of scene's meshes
  35484. * @param newMesh defines the mesh to add
  35485. * @param recursive if all child meshes should also be added to the scene
  35486. */
  35487. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35488. /**
  35489. * Remove a mesh for the list of scene's meshes
  35490. * @param toRemove defines the mesh to remove
  35491. * @param recursive if all child meshes should also be removed from the scene
  35492. * @returns the index where the mesh was in the mesh list
  35493. */
  35494. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35495. /**
  35496. * Add a transform node to the list of scene's transform nodes
  35497. * @param newTransformNode defines the transform node to add
  35498. */
  35499. addTransformNode(newTransformNode: TransformNode): void;
  35500. /**
  35501. * Remove a transform node for the list of scene's transform nodes
  35502. * @param toRemove defines the transform node to remove
  35503. * @returns the index where the transform node was in the transform node list
  35504. */
  35505. removeTransformNode(toRemove: TransformNode): number;
  35506. /**
  35507. * Remove a skeleton for the list of scene's skeletons
  35508. * @param toRemove defines the skeleton to remove
  35509. * @returns the index where the skeleton was in the skeleton list
  35510. */
  35511. removeSkeleton(toRemove: Skeleton): number;
  35512. /**
  35513. * Remove a morph target for the list of scene's morph targets
  35514. * @param toRemove defines the morph target to remove
  35515. * @returns the index where the morph target was in the morph target list
  35516. */
  35517. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35518. /**
  35519. * Remove a light for the list of scene's lights
  35520. * @param toRemove defines the light to remove
  35521. * @returns the index where the light was in the light list
  35522. */
  35523. removeLight(toRemove: Light): number;
  35524. /**
  35525. * Remove a camera for the list of scene's cameras
  35526. * @param toRemove defines the camera to remove
  35527. * @returns the index where the camera was in the camera list
  35528. */
  35529. removeCamera(toRemove: Camera): number;
  35530. /**
  35531. * Remove a particle system for the list of scene's particle systems
  35532. * @param toRemove defines the particle system to remove
  35533. * @returns the index where the particle system was in the particle system list
  35534. */
  35535. removeParticleSystem(toRemove: IParticleSystem): number;
  35536. /**
  35537. * Remove a animation for the list of scene's animations
  35538. * @param toRemove defines the animation to remove
  35539. * @returns the index where the animation was in the animation list
  35540. */
  35541. removeAnimation(toRemove: Animation): number;
  35542. /**
  35543. * Will stop the animation of the given target
  35544. * @param target - the target
  35545. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35546. * @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)
  35547. */
  35548. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35549. /**
  35550. * Removes the given animation group from this scene.
  35551. * @param toRemove The animation group to remove
  35552. * @returns The index of the removed animation group
  35553. */
  35554. removeAnimationGroup(toRemove: AnimationGroup): number;
  35555. /**
  35556. * Removes the given multi-material from this scene.
  35557. * @param toRemove The multi-material to remove
  35558. * @returns The index of the removed multi-material
  35559. */
  35560. removeMultiMaterial(toRemove: MultiMaterial): number;
  35561. /**
  35562. * Removes the given material from this scene.
  35563. * @param toRemove The material to remove
  35564. * @returns The index of the removed material
  35565. */
  35566. removeMaterial(toRemove: Material): number;
  35567. /**
  35568. * Removes the given action manager from this scene.
  35569. * @param toRemove The action manager to remove
  35570. * @returns The index of the removed action manager
  35571. */
  35572. removeActionManager(toRemove: AbstractActionManager): number;
  35573. /**
  35574. * Removes the given texture from this scene.
  35575. * @param toRemove The texture to remove
  35576. * @returns The index of the removed texture
  35577. */
  35578. removeTexture(toRemove: BaseTexture): number;
  35579. /**
  35580. * Adds the given light to this scene
  35581. * @param newLight The light to add
  35582. */
  35583. addLight(newLight: Light): void;
  35584. /**
  35585. * Sorts the list list based on light priorities
  35586. */
  35587. sortLightsByPriority(): void;
  35588. /**
  35589. * Adds the given camera to this scene
  35590. * @param newCamera The camera to add
  35591. */
  35592. addCamera(newCamera: Camera): void;
  35593. /**
  35594. * Adds the given skeleton to this scene
  35595. * @param newSkeleton The skeleton to add
  35596. */
  35597. addSkeleton(newSkeleton: Skeleton): void;
  35598. /**
  35599. * Adds the given particle system to this scene
  35600. * @param newParticleSystem The particle system to add
  35601. */
  35602. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35603. /**
  35604. * Adds the given animation to this scene
  35605. * @param newAnimation The animation to add
  35606. */
  35607. addAnimation(newAnimation: Animation): void;
  35608. /**
  35609. * Adds the given animation group to this scene.
  35610. * @param newAnimationGroup The animation group to add
  35611. */
  35612. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35613. /**
  35614. * Adds the given multi-material to this scene
  35615. * @param newMultiMaterial The multi-material to add
  35616. */
  35617. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35618. /**
  35619. * Adds the given material to this scene
  35620. * @param newMaterial The material to add
  35621. */
  35622. addMaterial(newMaterial: Material): void;
  35623. /**
  35624. * Adds the given morph target to this scene
  35625. * @param newMorphTargetManager The morph target to add
  35626. */
  35627. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35628. /**
  35629. * Adds the given geometry to this scene
  35630. * @param newGeometry The geometry to add
  35631. */
  35632. addGeometry(newGeometry: Geometry): void;
  35633. /**
  35634. * Adds the given action manager to this scene
  35635. * @param newActionManager The action manager to add
  35636. */
  35637. addActionManager(newActionManager: AbstractActionManager): void;
  35638. /**
  35639. * Adds the given texture to this scene.
  35640. * @param newTexture The texture to add
  35641. */
  35642. addTexture(newTexture: BaseTexture): void;
  35643. /**
  35644. * Switch active camera
  35645. * @param newCamera defines the new active camera
  35646. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35647. */
  35648. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35649. /**
  35650. * sets the active camera of the scene using its ID
  35651. * @param id defines the camera's ID
  35652. * @return the new active camera or null if none found.
  35653. */
  35654. setActiveCameraByID(id: string): Nullable<Camera>;
  35655. /**
  35656. * sets the active camera of the scene using its name
  35657. * @param name defines the camera's name
  35658. * @returns the new active camera or null if none found.
  35659. */
  35660. setActiveCameraByName(name: string): Nullable<Camera>;
  35661. /**
  35662. * get an animation group using its name
  35663. * @param name defines the material's name
  35664. * @return the animation group or null if none found.
  35665. */
  35666. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35667. /**
  35668. * Get a material using its unique id
  35669. * @param uniqueId defines the material's unique id
  35670. * @return the material or null if none found.
  35671. */
  35672. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35673. /**
  35674. * get a material using its id
  35675. * @param id defines the material's ID
  35676. * @return the material or null if none found.
  35677. */
  35678. getMaterialByID(id: string): Nullable<Material>;
  35679. /**
  35680. * Gets a the last added material using a given id
  35681. * @param id defines the material's ID
  35682. * @return the last material with the given id or null if none found.
  35683. */
  35684. getLastMaterialByID(id: string): Nullable<Material>;
  35685. /**
  35686. * Gets a material using its name
  35687. * @param name defines the material's name
  35688. * @return the material or null if none found.
  35689. */
  35690. getMaterialByName(name: string): Nullable<Material>;
  35691. /**
  35692. * Get a texture using its unique id
  35693. * @param uniqueId defines the texture's unique id
  35694. * @return the texture or null if none found.
  35695. */
  35696. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35697. /**
  35698. * Gets a camera using its id
  35699. * @param id defines the id to look for
  35700. * @returns the camera or null if not found
  35701. */
  35702. getCameraByID(id: string): Nullable<Camera>;
  35703. /**
  35704. * Gets a camera using its unique id
  35705. * @param uniqueId defines the unique id to look for
  35706. * @returns the camera or null if not found
  35707. */
  35708. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35709. /**
  35710. * Gets a camera using its name
  35711. * @param name defines the camera's name
  35712. * @return the camera or null if none found.
  35713. */
  35714. getCameraByName(name: string): Nullable<Camera>;
  35715. /**
  35716. * Gets a bone using its id
  35717. * @param id defines the bone's id
  35718. * @return the bone or null if not found
  35719. */
  35720. getBoneByID(id: string): Nullable<Bone>;
  35721. /**
  35722. * Gets a bone using its id
  35723. * @param name defines the bone's name
  35724. * @return the bone or null if not found
  35725. */
  35726. getBoneByName(name: string): Nullable<Bone>;
  35727. /**
  35728. * Gets a light node using its name
  35729. * @param name defines the the light's name
  35730. * @return the light or null if none found.
  35731. */
  35732. getLightByName(name: string): Nullable<Light>;
  35733. /**
  35734. * Gets a light node using its id
  35735. * @param id defines the light's id
  35736. * @return the light or null if none found.
  35737. */
  35738. getLightByID(id: string): Nullable<Light>;
  35739. /**
  35740. * Gets a light node using its scene-generated unique ID
  35741. * @param uniqueId defines the light's unique id
  35742. * @return the light or null if none found.
  35743. */
  35744. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35745. /**
  35746. * Gets a particle system by id
  35747. * @param id defines the particle system id
  35748. * @return the corresponding system or null if none found
  35749. */
  35750. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35751. /**
  35752. * Gets a geometry using its ID
  35753. * @param id defines the geometry's id
  35754. * @return the geometry or null if none found.
  35755. */
  35756. getGeometryByID(id: string): Nullable<Geometry>;
  35757. private _getGeometryByUniqueID;
  35758. /**
  35759. * Add a new geometry to this scene
  35760. * @param geometry defines the geometry to be added to the scene.
  35761. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35762. * @return a boolean defining if the geometry was added or not
  35763. */
  35764. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35765. /**
  35766. * Removes an existing geometry
  35767. * @param geometry defines the geometry to be removed from the scene
  35768. * @return a boolean defining if the geometry was removed or not
  35769. */
  35770. removeGeometry(geometry: Geometry): boolean;
  35771. /**
  35772. * Gets the list of geometries attached to the scene
  35773. * @returns an array of Geometry
  35774. */
  35775. getGeometries(): Geometry[];
  35776. /**
  35777. * Gets the first added mesh found of a given ID
  35778. * @param id defines the id to search for
  35779. * @return the mesh found or null if not found at all
  35780. */
  35781. getMeshByID(id: string): Nullable<AbstractMesh>;
  35782. /**
  35783. * Gets a list of meshes using their id
  35784. * @param id defines the id to search for
  35785. * @returns a list of meshes
  35786. */
  35787. getMeshesByID(id: string): Array<AbstractMesh>;
  35788. /**
  35789. * Gets the first added transform node found of a given ID
  35790. * @param id defines the id to search for
  35791. * @return the found transform node or null if not found at all.
  35792. */
  35793. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35794. /**
  35795. * Gets a transform node with its auto-generated unique id
  35796. * @param uniqueId efines the unique id to search for
  35797. * @return the found transform node or null if not found at all.
  35798. */
  35799. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35800. /**
  35801. * Gets a list of transform nodes using their id
  35802. * @param id defines the id to search for
  35803. * @returns a list of transform nodes
  35804. */
  35805. getTransformNodesByID(id: string): Array<TransformNode>;
  35806. /**
  35807. * Gets a mesh with its auto-generated unique id
  35808. * @param uniqueId defines the unique id to search for
  35809. * @return the found mesh or null if not found at all.
  35810. */
  35811. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35812. /**
  35813. * Gets a the last added mesh using a given id
  35814. * @param id defines the id to search for
  35815. * @return the found mesh or null if not found at all.
  35816. */
  35817. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35818. /**
  35819. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35820. * @param id defines the id to search for
  35821. * @return the found node or null if not found at all
  35822. */
  35823. getLastEntryByID(id: string): Nullable<Node>;
  35824. /**
  35825. * Gets a node (Mesh, Camera, Light) using a given id
  35826. * @param id defines the id to search for
  35827. * @return the found node or null if not found at all
  35828. */
  35829. getNodeByID(id: string): Nullable<Node>;
  35830. /**
  35831. * Gets a node (Mesh, Camera, Light) using a given name
  35832. * @param name defines the name to search for
  35833. * @return the found node or null if not found at all.
  35834. */
  35835. getNodeByName(name: string): Nullable<Node>;
  35836. /**
  35837. * Gets a mesh using a given name
  35838. * @param name defines the name to search for
  35839. * @return the found mesh or null if not found at all.
  35840. */
  35841. getMeshByName(name: string): Nullable<AbstractMesh>;
  35842. /**
  35843. * Gets a transform node using a given name
  35844. * @param name defines the name to search for
  35845. * @return the found transform node or null if not found at all.
  35846. */
  35847. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35848. /**
  35849. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35850. * @param id defines the id to search for
  35851. * @return the found skeleton or null if not found at all.
  35852. */
  35853. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35854. /**
  35855. * Gets a skeleton using a given auto generated unique id
  35856. * @param uniqueId defines the unique id to search for
  35857. * @return the found skeleton or null if not found at all.
  35858. */
  35859. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35860. /**
  35861. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35862. * @param id defines the id to search for
  35863. * @return the found skeleton or null if not found at all.
  35864. */
  35865. getSkeletonById(id: string): Nullable<Skeleton>;
  35866. /**
  35867. * Gets a skeleton using a given name
  35868. * @param name defines the name to search for
  35869. * @return the found skeleton or null if not found at all.
  35870. */
  35871. getSkeletonByName(name: string): Nullable<Skeleton>;
  35872. /**
  35873. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35874. * @param id defines the id to search for
  35875. * @return the found morph target manager or null if not found at all.
  35876. */
  35877. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35878. /**
  35879. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35880. * @param id defines the id to search for
  35881. * @return the found morph target or null if not found at all.
  35882. */
  35883. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35884. /**
  35885. * Gets a boolean indicating if the given mesh is active
  35886. * @param mesh defines the mesh to look for
  35887. * @returns true if the mesh is in the active list
  35888. */
  35889. isActiveMesh(mesh: AbstractMesh): boolean;
  35890. /**
  35891. * Return a unique id as a string which can serve as an identifier for the scene
  35892. */
  35893. readonly uid: string;
  35894. /**
  35895. * Add an externaly attached data from its key.
  35896. * This method call will fail and return false, if such key already exists.
  35897. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35898. * @param key the unique key that identifies the data
  35899. * @param data the data object to associate to the key for this Engine instance
  35900. * @return true if no such key were already present and the data was added successfully, false otherwise
  35901. */
  35902. addExternalData<T>(key: string, data: T): boolean;
  35903. /**
  35904. * Get an externaly attached data from its key
  35905. * @param key the unique key that identifies the data
  35906. * @return the associated data, if present (can be null), or undefined if not present
  35907. */
  35908. getExternalData<T>(key: string): Nullable<T>;
  35909. /**
  35910. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35911. * @param key the unique key that identifies the data
  35912. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35913. * @return the associated data, can be null if the factory returned null.
  35914. */
  35915. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35916. /**
  35917. * Remove an externaly attached data from the Engine instance
  35918. * @param key the unique key that identifies the data
  35919. * @return true if the data was successfully removed, false if it doesn't exist
  35920. */
  35921. removeExternalData(key: string): boolean;
  35922. private _evaluateSubMesh;
  35923. /**
  35924. * Clear the processed materials smart array preventing retention point in material dispose.
  35925. */
  35926. freeProcessedMaterials(): void;
  35927. private _preventFreeActiveMeshesAndRenderingGroups;
  35928. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35929. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35930. * when disposing several meshes in a row or a hierarchy of meshes.
  35931. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35932. */
  35933. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35934. /**
  35935. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35936. */
  35937. freeActiveMeshes(): void;
  35938. /**
  35939. * Clear the info related to rendering groups preventing retention points during dispose.
  35940. */
  35941. freeRenderingGroups(): void;
  35942. /** @hidden */
  35943. _isInIntermediateRendering(): boolean;
  35944. /**
  35945. * Lambda returning the list of potentially active meshes.
  35946. */
  35947. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35948. /**
  35949. * Lambda returning the list of potentially active sub meshes.
  35950. */
  35951. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35952. /**
  35953. * Lambda returning the list of potentially intersecting sub meshes.
  35954. */
  35955. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35956. /**
  35957. * Lambda returning the list of potentially colliding sub meshes.
  35958. */
  35959. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35960. private _activeMeshesFrozen;
  35961. private _skipEvaluateActiveMeshesCompletely;
  35962. /**
  35963. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35964. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  35965. * @returns the current scene
  35966. */
  35967. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  35968. /**
  35969. * Use this function to restart evaluating active meshes on every frame
  35970. * @returns the current scene
  35971. */
  35972. unfreezeActiveMeshes(): Scene;
  35973. private _evaluateActiveMeshes;
  35974. private _activeMesh;
  35975. /**
  35976. * Update the transform matrix to update from the current active camera
  35977. * @param force defines a boolean used to force the update even if cache is up to date
  35978. */
  35979. updateTransformMatrix(force?: boolean): void;
  35980. private _bindFrameBuffer;
  35981. /** @hidden */
  35982. _allowPostProcessClearColor: boolean;
  35983. /** @hidden */
  35984. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35985. private _processSubCameras;
  35986. private _checkIntersections;
  35987. /** @hidden */
  35988. _advancePhysicsEngineStep(step: number): void;
  35989. /**
  35990. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35991. */
  35992. getDeterministicFrameTime: () => number;
  35993. /** @hidden */
  35994. _animate(): void;
  35995. /** Execute all animations (for a frame) */
  35996. animate(): void;
  35997. /**
  35998. * Render the scene
  35999. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36000. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36001. */
  36002. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36003. /**
  36004. * Freeze all materials
  36005. * A frozen material will not be updatable but should be faster to render
  36006. */
  36007. freezeMaterials(): void;
  36008. /**
  36009. * Unfreeze all materials
  36010. * A frozen material will not be updatable but should be faster to render
  36011. */
  36012. unfreezeMaterials(): void;
  36013. /**
  36014. * Releases all held ressources
  36015. */
  36016. dispose(): void;
  36017. /**
  36018. * Gets if the scene is already disposed
  36019. */
  36020. readonly isDisposed: boolean;
  36021. /**
  36022. * Call this function to reduce memory footprint of the scene.
  36023. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36024. */
  36025. clearCachedVertexData(): void;
  36026. /**
  36027. * This function will remove the local cached buffer data from texture.
  36028. * It will save memory but will prevent the texture from being rebuilt
  36029. */
  36030. cleanCachedTextureBuffer(): void;
  36031. /**
  36032. * Get the world extend vectors with an optional filter
  36033. *
  36034. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36035. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36036. */
  36037. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36038. min: Vector3;
  36039. max: Vector3;
  36040. };
  36041. /**
  36042. * Creates a ray that can be used to pick in the scene
  36043. * @param x defines the x coordinate of the origin (on-screen)
  36044. * @param y defines the y coordinate of the origin (on-screen)
  36045. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36046. * @param camera defines the camera to use for the picking
  36047. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36048. * @returns a Ray
  36049. */
  36050. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36051. /**
  36052. * Creates a ray that can be used to pick in the scene
  36053. * @param x defines the x coordinate of the origin (on-screen)
  36054. * @param y defines the y coordinate of the origin (on-screen)
  36055. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36056. * @param result defines the ray where to store the picking ray
  36057. * @param camera defines the camera to use for the picking
  36058. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36059. * @returns the current scene
  36060. */
  36061. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36062. /**
  36063. * Creates a ray that can be used to pick in the scene
  36064. * @param x defines the x coordinate of the origin (on-screen)
  36065. * @param y defines the y coordinate of the origin (on-screen)
  36066. * @param camera defines the camera to use for the picking
  36067. * @returns a Ray
  36068. */
  36069. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36070. /**
  36071. * Creates a ray that can be used to pick in the scene
  36072. * @param x defines the x coordinate of the origin (on-screen)
  36073. * @param y defines the y coordinate of the origin (on-screen)
  36074. * @param result defines the ray where to store the picking ray
  36075. * @param camera defines the camera to use for the picking
  36076. * @returns the current scene
  36077. */
  36078. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36079. /** Launch a ray to try to pick a mesh in the scene
  36080. * @param x position on screen
  36081. * @param y position on screen
  36082. * @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
  36083. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36084. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36085. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36086. * @returns a PickingInfo
  36087. */
  36088. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36089. /** Use the given ray to pick a mesh in the scene
  36090. * @param ray The ray to use to pick meshes
  36091. * @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
  36092. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36093. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36094. * @returns a PickingInfo
  36095. */
  36096. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36097. /**
  36098. * Launch a ray to try to pick a mesh in the scene
  36099. * @param x X position on screen
  36100. * @param y Y position on screen
  36101. * @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
  36102. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36103. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36104. * @returns an array of PickingInfo
  36105. */
  36106. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36107. /**
  36108. * Launch a ray to try to pick a mesh in the scene
  36109. * @param ray Ray to use
  36110. * @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
  36111. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36112. * @returns an array of PickingInfo
  36113. */
  36114. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36115. /**
  36116. * Force the value of meshUnderPointer
  36117. * @param mesh defines the mesh to use
  36118. */
  36119. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36120. /**
  36121. * Gets the mesh under the pointer
  36122. * @returns a Mesh or null if no mesh is under the pointer
  36123. */
  36124. getPointerOverMesh(): Nullable<AbstractMesh>;
  36125. /** @hidden */
  36126. _rebuildGeometries(): void;
  36127. /** @hidden */
  36128. _rebuildTextures(): void;
  36129. private _getByTags;
  36130. /**
  36131. * Get a list of meshes by tags
  36132. * @param tagsQuery defines the tags query to use
  36133. * @param forEach defines a predicate used to filter results
  36134. * @returns an array of Mesh
  36135. */
  36136. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36137. /**
  36138. * Get a list of cameras by tags
  36139. * @param tagsQuery defines the tags query to use
  36140. * @param forEach defines a predicate used to filter results
  36141. * @returns an array of Camera
  36142. */
  36143. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36144. /**
  36145. * Get a list of lights by tags
  36146. * @param tagsQuery defines the tags query to use
  36147. * @param forEach defines a predicate used to filter results
  36148. * @returns an array of Light
  36149. */
  36150. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36151. /**
  36152. * Get a list of materials by tags
  36153. * @param tagsQuery defines the tags query to use
  36154. * @param forEach defines a predicate used to filter results
  36155. * @returns an array of Material
  36156. */
  36157. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36158. /**
  36159. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36160. * This allowed control for front to back rendering or reversly depending of the special needs.
  36161. *
  36162. * @param renderingGroupId The rendering group id corresponding to its index
  36163. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36164. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36165. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36166. */
  36167. 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;
  36168. /**
  36169. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36170. *
  36171. * @param renderingGroupId The rendering group id corresponding to its index
  36172. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36173. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36174. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36175. */
  36176. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36177. /**
  36178. * Gets the current auto clear configuration for one rendering group of the rendering
  36179. * manager.
  36180. * @param index the rendering group index to get the information for
  36181. * @returns The auto clear setup for the requested rendering group
  36182. */
  36183. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36184. private _blockMaterialDirtyMechanism;
  36185. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36186. blockMaterialDirtyMechanism: boolean;
  36187. /**
  36188. * Will flag all materials as dirty to trigger new shader compilation
  36189. * @param flag defines the flag used to specify which material part must be marked as dirty
  36190. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36191. */
  36192. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36193. /** @hidden */
  36194. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  36195. /** @hidden */
  36196. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36197. /** @hidden */
  36198. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  36199. /** @hidden */
  36200. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36201. /** @hidden */
  36202. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36203. /** @hidden */
  36204. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36205. }
  36206. }
  36207. declare module "babylonjs/assetContainer" {
  36208. import { AbstractScene } from "babylonjs/abstractScene";
  36209. import { Scene } from "babylonjs/scene";
  36210. import { Mesh } from "babylonjs/Meshes/mesh";
  36211. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36212. import { Skeleton } from "babylonjs/Bones/skeleton";
  36213. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36214. /**
  36215. * Set of assets to keep when moving a scene into an asset container.
  36216. */
  36217. export class KeepAssets extends AbstractScene {
  36218. }
  36219. /**
  36220. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36221. */
  36222. export class InstantiatedEntries {
  36223. /**
  36224. * List of new root nodes (eg. nodes with no parent)
  36225. */
  36226. rootNodes: TransformNode[];
  36227. /**
  36228. * List of new skeletons
  36229. */
  36230. skeletons: Skeleton[];
  36231. /**
  36232. * List of new animation groups
  36233. */
  36234. animationGroups: AnimationGroup[];
  36235. }
  36236. /**
  36237. * Container with a set of assets that can be added or removed from a scene.
  36238. */
  36239. export class AssetContainer extends AbstractScene {
  36240. /**
  36241. * The scene the AssetContainer belongs to.
  36242. */
  36243. scene: Scene;
  36244. /**
  36245. * Instantiates an AssetContainer.
  36246. * @param scene The scene the AssetContainer belongs to.
  36247. */
  36248. constructor(scene: Scene);
  36249. /**
  36250. * Instantiate or clone all meshes and add the new ones to the scene.
  36251. * Skeletons and animation groups will all be cloned
  36252. * @param nameFunction defines an optional function used to get new names for clones
  36253. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36254. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36255. */
  36256. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36257. /**
  36258. * Adds all the assets from the container to the scene.
  36259. */
  36260. addAllToScene(): void;
  36261. /**
  36262. * Removes all the assets in the container from the scene
  36263. */
  36264. removeAllFromScene(): void;
  36265. /**
  36266. * Disposes all the assets in the container
  36267. */
  36268. dispose(): void;
  36269. private _moveAssets;
  36270. /**
  36271. * Removes all the assets contained in the scene and adds them to the container.
  36272. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36273. */
  36274. moveAllFromScene(keepAssets?: KeepAssets): void;
  36275. /**
  36276. * 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.
  36277. * @returns the root mesh
  36278. */
  36279. createRootMesh(): Mesh;
  36280. }
  36281. }
  36282. declare module "babylonjs/abstractScene" {
  36283. import { Scene } from "babylonjs/scene";
  36284. import { Nullable } from "babylonjs/types";
  36285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36286. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36287. import { Geometry } from "babylonjs/Meshes/geometry";
  36288. import { Skeleton } from "babylonjs/Bones/skeleton";
  36289. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36290. import { AssetContainer } from "babylonjs/assetContainer";
  36291. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36292. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36293. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36294. import { Material } from "babylonjs/Materials/material";
  36295. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36296. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36297. import { Camera } from "babylonjs/Cameras/camera";
  36298. import { Light } from "babylonjs/Lights/light";
  36299. import { Node } from "babylonjs/node";
  36300. import { Animation } from "babylonjs/Animations/animation";
  36301. /**
  36302. * Defines how the parser contract is defined.
  36303. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36304. */
  36305. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36306. /**
  36307. * Defines how the individual parser contract is defined.
  36308. * These parser can parse an individual asset
  36309. */
  36310. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36311. /**
  36312. * Base class of the scene acting as a container for the different elements composing a scene.
  36313. * This class is dynamically extended by the different components of the scene increasing
  36314. * flexibility and reducing coupling
  36315. */
  36316. export abstract class AbstractScene {
  36317. /**
  36318. * Stores the list of available parsers in the application.
  36319. */
  36320. private static _BabylonFileParsers;
  36321. /**
  36322. * Stores the list of available individual parsers in the application.
  36323. */
  36324. private static _IndividualBabylonFileParsers;
  36325. /**
  36326. * Adds a parser in the list of available ones
  36327. * @param name Defines the name of the parser
  36328. * @param parser Defines the parser to add
  36329. */
  36330. static AddParser(name: string, parser: BabylonFileParser): void;
  36331. /**
  36332. * Gets a general parser from the list of avaialble ones
  36333. * @param name Defines the name of the parser
  36334. * @returns the requested parser or null
  36335. */
  36336. static GetParser(name: string): Nullable<BabylonFileParser>;
  36337. /**
  36338. * Adds n individual parser in the list of available ones
  36339. * @param name Defines the name of the parser
  36340. * @param parser Defines the parser to add
  36341. */
  36342. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36343. /**
  36344. * Gets an individual parser from the list of avaialble ones
  36345. * @param name Defines the name of the parser
  36346. * @returns the requested parser or null
  36347. */
  36348. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36349. /**
  36350. * Parser json data and populate both a scene and its associated container object
  36351. * @param jsonData Defines the data to parse
  36352. * @param scene Defines the scene to parse the data for
  36353. * @param container Defines the container attached to the parsing sequence
  36354. * @param rootUrl Defines the root url of the data
  36355. */
  36356. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36357. /**
  36358. * Gets the list of root nodes (ie. nodes with no parent)
  36359. */
  36360. rootNodes: Node[];
  36361. /** All of the cameras added to this scene
  36362. * @see http://doc.babylonjs.com/babylon101/cameras
  36363. */
  36364. cameras: Camera[];
  36365. /**
  36366. * All of the lights added to this scene
  36367. * @see http://doc.babylonjs.com/babylon101/lights
  36368. */
  36369. lights: Light[];
  36370. /**
  36371. * All of the (abstract) meshes added to this scene
  36372. */
  36373. meshes: AbstractMesh[];
  36374. /**
  36375. * The list of skeletons added to the scene
  36376. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36377. */
  36378. skeletons: Skeleton[];
  36379. /**
  36380. * All of the particle systems added to this scene
  36381. * @see http://doc.babylonjs.com/babylon101/particles
  36382. */
  36383. particleSystems: IParticleSystem[];
  36384. /**
  36385. * Gets a list of Animations associated with the scene
  36386. */
  36387. animations: Animation[];
  36388. /**
  36389. * All of the animation groups added to this scene
  36390. * @see http://doc.babylonjs.com/how_to/group
  36391. */
  36392. animationGroups: AnimationGroup[];
  36393. /**
  36394. * All of the multi-materials added to this scene
  36395. * @see http://doc.babylonjs.com/how_to/multi_materials
  36396. */
  36397. multiMaterials: MultiMaterial[];
  36398. /**
  36399. * All of the materials added to this scene
  36400. * In the context of a Scene, it is not supposed to be modified manually.
  36401. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36402. * Note also that the order of the Material within the array is not significant and might change.
  36403. * @see http://doc.babylonjs.com/babylon101/materials
  36404. */
  36405. materials: Material[];
  36406. /**
  36407. * The list of morph target managers added to the scene
  36408. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36409. */
  36410. morphTargetManagers: MorphTargetManager[];
  36411. /**
  36412. * The list of geometries used in the scene.
  36413. */
  36414. geometries: Geometry[];
  36415. /**
  36416. * All of the tranform nodes added to this scene
  36417. * In the context of a Scene, it is not supposed to be modified manually.
  36418. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36419. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36420. * @see http://doc.babylonjs.com/how_to/transformnode
  36421. */
  36422. transformNodes: TransformNode[];
  36423. /**
  36424. * ActionManagers available on the scene.
  36425. */
  36426. actionManagers: AbstractActionManager[];
  36427. /**
  36428. * Textures to keep.
  36429. */
  36430. textures: BaseTexture[];
  36431. /**
  36432. * Environment texture for the scene
  36433. */
  36434. environmentTexture: Nullable<BaseTexture>;
  36435. }
  36436. }
  36437. declare module "babylonjs/Audio/sound" {
  36438. import { Observable } from "babylonjs/Misc/observable";
  36439. import { Vector3 } from "babylonjs/Maths/math.vector";
  36440. import { Nullable } from "babylonjs/types";
  36441. import { Scene } from "babylonjs/scene";
  36442. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36443. /**
  36444. * Interface used to define options for Sound class
  36445. */
  36446. export interface ISoundOptions {
  36447. /**
  36448. * Does the sound autoplay once loaded.
  36449. */
  36450. autoplay?: boolean;
  36451. /**
  36452. * Does the sound loop after it finishes playing once.
  36453. */
  36454. loop?: boolean;
  36455. /**
  36456. * Sound's volume
  36457. */
  36458. volume?: number;
  36459. /**
  36460. * Is it a spatial sound?
  36461. */
  36462. spatialSound?: boolean;
  36463. /**
  36464. * Maximum distance to hear that sound
  36465. */
  36466. maxDistance?: number;
  36467. /**
  36468. * Uses user defined attenuation function
  36469. */
  36470. useCustomAttenuation?: boolean;
  36471. /**
  36472. * Define the roll off factor of spatial sounds.
  36473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36474. */
  36475. rolloffFactor?: number;
  36476. /**
  36477. * Define the reference distance the sound should be heard perfectly.
  36478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36479. */
  36480. refDistance?: number;
  36481. /**
  36482. * Define the distance attenuation model the sound will follow.
  36483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36484. */
  36485. distanceModel?: string;
  36486. /**
  36487. * Defines the playback speed (1 by default)
  36488. */
  36489. playbackRate?: number;
  36490. /**
  36491. * Defines if the sound is from a streaming source
  36492. */
  36493. streaming?: boolean;
  36494. /**
  36495. * Defines an optional length (in seconds) inside the sound file
  36496. */
  36497. length?: number;
  36498. /**
  36499. * Defines an optional offset (in seconds) inside the sound file
  36500. */
  36501. offset?: number;
  36502. /**
  36503. * If true, URLs will not be required to state the audio file codec to use.
  36504. */
  36505. skipCodecCheck?: boolean;
  36506. }
  36507. /**
  36508. * Defines a sound that can be played in the application.
  36509. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36511. */
  36512. export class Sound {
  36513. /**
  36514. * The name of the sound in the scene.
  36515. */
  36516. name: string;
  36517. /**
  36518. * Does the sound autoplay once loaded.
  36519. */
  36520. autoplay: boolean;
  36521. /**
  36522. * Does the sound loop after it finishes playing once.
  36523. */
  36524. loop: boolean;
  36525. /**
  36526. * Does the sound use a custom attenuation curve to simulate the falloff
  36527. * happening when the source gets further away from the camera.
  36528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36529. */
  36530. useCustomAttenuation: boolean;
  36531. /**
  36532. * The sound track id this sound belongs to.
  36533. */
  36534. soundTrackId: number;
  36535. /**
  36536. * Is this sound currently played.
  36537. */
  36538. isPlaying: boolean;
  36539. /**
  36540. * Is this sound currently paused.
  36541. */
  36542. isPaused: boolean;
  36543. /**
  36544. * Does this sound enables spatial sound.
  36545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36546. */
  36547. spatialSound: boolean;
  36548. /**
  36549. * Define the reference distance the sound should be heard perfectly.
  36550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36551. */
  36552. refDistance: number;
  36553. /**
  36554. * Define the roll off factor of spatial sounds.
  36555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36556. */
  36557. rolloffFactor: number;
  36558. /**
  36559. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36561. */
  36562. maxDistance: number;
  36563. /**
  36564. * Define the distance attenuation model the sound will follow.
  36565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36566. */
  36567. distanceModel: string;
  36568. /**
  36569. * @hidden
  36570. * Back Compat
  36571. **/
  36572. onended: () => any;
  36573. /**
  36574. * Observable event when the current playing sound finishes.
  36575. */
  36576. onEndedObservable: Observable<Sound>;
  36577. private _panningModel;
  36578. private _playbackRate;
  36579. private _streaming;
  36580. private _startTime;
  36581. private _startOffset;
  36582. private _position;
  36583. /** @hidden */
  36584. _positionInEmitterSpace: boolean;
  36585. private _localDirection;
  36586. private _volume;
  36587. private _isReadyToPlay;
  36588. private _isDirectional;
  36589. private _readyToPlayCallback;
  36590. private _audioBuffer;
  36591. private _soundSource;
  36592. private _streamingSource;
  36593. private _soundPanner;
  36594. private _soundGain;
  36595. private _inputAudioNode;
  36596. private _outputAudioNode;
  36597. private _coneInnerAngle;
  36598. private _coneOuterAngle;
  36599. private _coneOuterGain;
  36600. private _scene;
  36601. private _connectedTransformNode;
  36602. private _customAttenuationFunction;
  36603. private _registerFunc;
  36604. private _isOutputConnected;
  36605. private _htmlAudioElement;
  36606. private _urlType;
  36607. private _length?;
  36608. private _offset?;
  36609. /** @hidden */
  36610. static _SceneComponentInitialization: (scene: Scene) => void;
  36611. /**
  36612. * Create a sound and attach it to a scene
  36613. * @param name Name of your sound
  36614. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36615. * @param scene defines the scene the sound belongs to
  36616. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36617. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36618. */
  36619. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36620. /**
  36621. * Release the sound and its associated resources
  36622. */
  36623. dispose(): void;
  36624. /**
  36625. * Gets if the sounds is ready to be played or not.
  36626. * @returns true if ready, otherwise false
  36627. */
  36628. isReady(): boolean;
  36629. private _soundLoaded;
  36630. /**
  36631. * Sets the data of the sound from an audiobuffer
  36632. * @param audioBuffer The audioBuffer containing the data
  36633. */
  36634. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36635. /**
  36636. * Updates the current sounds options such as maxdistance, loop...
  36637. * @param options A JSON object containing values named as the object properties
  36638. */
  36639. updateOptions(options: ISoundOptions): void;
  36640. private _createSpatialParameters;
  36641. private _updateSpatialParameters;
  36642. /**
  36643. * Switch the panning model to HRTF:
  36644. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36646. */
  36647. switchPanningModelToHRTF(): void;
  36648. /**
  36649. * Switch the panning model to Equal Power:
  36650. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36652. */
  36653. switchPanningModelToEqualPower(): void;
  36654. private _switchPanningModel;
  36655. /**
  36656. * Connect this sound to a sound track audio node like gain...
  36657. * @param soundTrackAudioNode the sound track audio node to connect to
  36658. */
  36659. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36660. /**
  36661. * Transform this sound into a directional source
  36662. * @param coneInnerAngle Size of the inner cone in degree
  36663. * @param coneOuterAngle Size of the outer cone in degree
  36664. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36665. */
  36666. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36667. /**
  36668. * Gets or sets the inner angle for the directional cone.
  36669. */
  36670. /**
  36671. * Gets or sets the inner angle for the directional cone.
  36672. */
  36673. directionalConeInnerAngle: number;
  36674. /**
  36675. * Gets or sets the outer angle for the directional cone.
  36676. */
  36677. /**
  36678. * Gets or sets the outer angle for the directional cone.
  36679. */
  36680. directionalConeOuterAngle: number;
  36681. /**
  36682. * Sets the position of the emitter if spatial sound is enabled
  36683. * @param newPosition Defines the new posisiton
  36684. */
  36685. setPosition(newPosition: Vector3): void;
  36686. /**
  36687. * Sets the local direction of the emitter if spatial sound is enabled
  36688. * @param newLocalDirection Defines the new local direction
  36689. */
  36690. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36691. private _updateDirection;
  36692. /** @hidden */
  36693. updateDistanceFromListener(): void;
  36694. /**
  36695. * Sets a new custom attenuation function for the sound.
  36696. * @param callback Defines the function used for the attenuation
  36697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36698. */
  36699. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36700. /**
  36701. * Play the sound
  36702. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36703. * @param offset (optional) Start the sound at a specific time in seconds
  36704. * @param length (optional) Sound duration (in seconds)
  36705. */
  36706. play(time?: number, offset?: number, length?: number): void;
  36707. private _onended;
  36708. /**
  36709. * Stop the sound
  36710. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36711. */
  36712. stop(time?: number): void;
  36713. /**
  36714. * Put the sound in pause
  36715. */
  36716. pause(): void;
  36717. /**
  36718. * Sets a dedicated volume for this sounds
  36719. * @param newVolume Define the new volume of the sound
  36720. * @param time Define time for gradual change to new volume
  36721. */
  36722. setVolume(newVolume: number, time?: number): void;
  36723. /**
  36724. * Set the sound play back rate
  36725. * @param newPlaybackRate Define the playback rate the sound should be played at
  36726. */
  36727. setPlaybackRate(newPlaybackRate: number): void;
  36728. /**
  36729. * Gets the volume of the sound.
  36730. * @returns the volume of the sound
  36731. */
  36732. getVolume(): number;
  36733. /**
  36734. * Attach the sound to a dedicated mesh
  36735. * @param transformNode The transform node to connect the sound with
  36736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36737. */
  36738. attachToMesh(transformNode: TransformNode): void;
  36739. /**
  36740. * Detach the sound from the previously attached mesh
  36741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36742. */
  36743. detachFromMesh(): void;
  36744. private _onRegisterAfterWorldMatrixUpdate;
  36745. /**
  36746. * Clone the current sound in the scene.
  36747. * @returns the new sound clone
  36748. */
  36749. clone(): Nullable<Sound>;
  36750. /**
  36751. * Gets the current underlying audio buffer containing the data
  36752. * @returns the audio buffer
  36753. */
  36754. getAudioBuffer(): Nullable<AudioBuffer>;
  36755. /**
  36756. * Serializes the Sound in a JSON representation
  36757. * @returns the JSON representation of the sound
  36758. */
  36759. serialize(): any;
  36760. /**
  36761. * Parse a JSON representation of a sound to innstantiate in a given scene
  36762. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36763. * @param scene Define the scene the new parsed sound should be created in
  36764. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36765. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36766. * @returns the newly parsed sound
  36767. */
  36768. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36769. }
  36770. }
  36771. declare module "babylonjs/Actions/directAudioActions" {
  36772. import { Action } from "babylonjs/Actions/action";
  36773. import { Condition } from "babylonjs/Actions/condition";
  36774. import { Sound } from "babylonjs/Audio/sound";
  36775. /**
  36776. * This defines an action helpful to play a defined sound on a triggered action.
  36777. */
  36778. export class PlaySoundAction extends Action {
  36779. private _sound;
  36780. /**
  36781. * Instantiate the action
  36782. * @param triggerOptions defines the trigger options
  36783. * @param sound defines the sound to play
  36784. * @param condition defines the trigger related conditions
  36785. */
  36786. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36787. /** @hidden */
  36788. _prepare(): void;
  36789. /**
  36790. * Execute the action and play the sound.
  36791. */
  36792. execute(): void;
  36793. /**
  36794. * Serializes the actions and its related information.
  36795. * @param parent defines the object to serialize in
  36796. * @returns the serialized object
  36797. */
  36798. serialize(parent: any): any;
  36799. }
  36800. /**
  36801. * This defines an action helpful to stop a defined sound on a triggered action.
  36802. */
  36803. export class StopSoundAction extends Action {
  36804. private _sound;
  36805. /**
  36806. * Instantiate the action
  36807. * @param triggerOptions defines the trigger options
  36808. * @param sound defines the sound to stop
  36809. * @param condition defines the trigger related conditions
  36810. */
  36811. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36812. /** @hidden */
  36813. _prepare(): void;
  36814. /**
  36815. * Execute the action and stop the sound.
  36816. */
  36817. execute(): void;
  36818. /**
  36819. * Serializes the actions and its related information.
  36820. * @param parent defines the object to serialize in
  36821. * @returns the serialized object
  36822. */
  36823. serialize(parent: any): any;
  36824. }
  36825. }
  36826. declare module "babylonjs/Actions/interpolateValueAction" {
  36827. import { Action } from "babylonjs/Actions/action";
  36828. import { Condition } from "babylonjs/Actions/condition";
  36829. import { Observable } from "babylonjs/Misc/observable";
  36830. /**
  36831. * This defines an action responsible to change the value of a property
  36832. * by interpolating between its current value and the newly set one once triggered.
  36833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36834. */
  36835. export class InterpolateValueAction extends Action {
  36836. /**
  36837. * Defines the path of the property where the value should be interpolated
  36838. */
  36839. propertyPath: string;
  36840. /**
  36841. * Defines the target value at the end of the interpolation.
  36842. */
  36843. value: any;
  36844. /**
  36845. * Defines the time it will take for the property to interpolate to the value.
  36846. */
  36847. duration: number;
  36848. /**
  36849. * Defines if the other scene animations should be stopped when the action has been triggered
  36850. */
  36851. stopOtherAnimations?: boolean;
  36852. /**
  36853. * Defines a callback raised once the interpolation animation has been done.
  36854. */
  36855. onInterpolationDone?: () => void;
  36856. /**
  36857. * Observable triggered once the interpolation animation has been done.
  36858. */
  36859. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36860. private _target;
  36861. private _effectiveTarget;
  36862. private _property;
  36863. /**
  36864. * Instantiate the action
  36865. * @param triggerOptions defines the trigger options
  36866. * @param target defines the object containing the value to interpolate
  36867. * @param propertyPath defines the path to the property in the target object
  36868. * @param value defines the target value at the end of the interpolation
  36869. * @param duration deines the time it will take for the property to interpolate to the value.
  36870. * @param condition defines the trigger related conditions
  36871. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36872. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36873. */
  36874. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36875. /** @hidden */
  36876. _prepare(): void;
  36877. /**
  36878. * Execute the action starts the value interpolation.
  36879. */
  36880. execute(): void;
  36881. /**
  36882. * Serializes the actions and its related information.
  36883. * @param parent defines the object to serialize in
  36884. * @returns the serialized object
  36885. */
  36886. serialize(parent: any): any;
  36887. }
  36888. }
  36889. declare module "babylonjs/Actions/index" {
  36890. export * from "babylonjs/Actions/abstractActionManager";
  36891. export * from "babylonjs/Actions/action";
  36892. export * from "babylonjs/Actions/actionEvent";
  36893. export * from "babylonjs/Actions/actionManager";
  36894. export * from "babylonjs/Actions/condition";
  36895. export * from "babylonjs/Actions/directActions";
  36896. export * from "babylonjs/Actions/directAudioActions";
  36897. export * from "babylonjs/Actions/interpolateValueAction";
  36898. }
  36899. declare module "babylonjs/Animations/index" {
  36900. export * from "babylonjs/Animations/animatable";
  36901. export * from "babylonjs/Animations/animation";
  36902. export * from "babylonjs/Animations/animationGroup";
  36903. export * from "babylonjs/Animations/animationPropertiesOverride";
  36904. export * from "babylonjs/Animations/easing";
  36905. export * from "babylonjs/Animations/runtimeAnimation";
  36906. export * from "babylonjs/Animations/animationEvent";
  36907. export * from "babylonjs/Animations/animationGroup";
  36908. export * from "babylonjs/Animations/animationKey";
  36909. export * from "babylonjs/Animations/animationRange";
  36910. export * from "babylonjs/Animations/animatable.interface";
  36911. }
  36912. declare module "babylonjs/Audio/soundTrack" {
  36913. import { Sound } from "babylonjs/Audio/sound";
  36914. import { Analyser } from "babylonjs/Audio/analyser";
  36915. import { Scene } from "babylonjs/scene";
  36916. /**
  36917. * Options allowed during the creation of a sound track.
  36918. */
  36919. export interface ISoundTrackOptions {
  36920. /**
  36921. * The volume the sound track should take during creation
  36922. */
  36923. volume?: number;
  36924. /**
  36925. * Define if the sound track is the main sound track of the scene
  36926. */
  36927. mainTrack?: boolean;
  36928. }
  36929. /**
  36930. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36931. * It will be also used in a future release to apply effects on a specific track.
  36932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36933. */
  36934. export class SoundTrack {
  36935. /**
  36936. * The unique identifier of the sound track in the scene.
  36937. */
  36938. id: number;
  36939. /**
  36940. * The list of sounds included in the sound track.
  36941. */
  36942. soundCollection: Array<Sound>;
  36943. private _outputAudioNode;
  36944. private _scene;
  36945. private _connectedAnalyser;
  36946. private _options;
  36947. private _isInitialized;
  36948. /**
  36949. * Creates a new sound track.
  36950. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36951. * @param scene Define the scene the sound track belongs to
  36952. * @param options
  36953. */
  36954. constructor(scene: Scene, options?: ISoundTrackOptions);
  36955. private _initializeSoundTrackAudioGraph;
  36956. /**
  36957. * Release the sound track and its associated resources
  36958. */
  36959. dispose(): void;
  36960. /**
  36961. * Adds a sound to this sound track
  36962. * @param sound define the cound to add
  36963. * @ignoreNaming
  36964. */
  36965. AddSound(sound: Sound): void;
  36966. /**
  36967. * Removes a sound to this sound track
  36968. * @param sound define the cound to remove
  36969. * @ignoreNaming
  36970. */
  36971. RemoveSound(sound: Sound): void;
  36972. /**
  36973. * Set a global volume for the full sound track.
  36974. * @param newVolume Define the new volume of the sound track
  36975. */
  36976. setVolume(newVolume: number): void;
  36977. /**
  36978. * Switch the panning model to HRTF:
  36979. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36981. */
  36982. switchPanningModelToHRTF(): void;
  36983. /**
  36984. * Switch the panning model to Equal Power:
  36985. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36987. */
  36988. switchPanningModelToEqualPower(): void;
  36989. /**
  36990. * Connect the sound track to an audio analyser allowing some amazing
  36991. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36993. * @param analyser The analyser to connect to the engine
  36994. */
  36995. connectToAnalyser(analyser: Analyser): void;
  36996. }
  36997. }
  36998. declare module "babylonjs/Audio/audioSceneComponent" {
  36999. import { Sound } from "babylonjs/Audio/sound";
  37000. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  37001. import { Nullable } from "babylonjs/types";
  37002. import { Vector3 } from "babylonjs/Maths/math.vector";
  37003. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  37004. import { Scene } from "babylonjs/scene";
  37005. import { AbstractScene } from "babylonjs/abstractScene";
  37006. import "babylonjs/Audio/audioEngine";
  37007. module "babylonjs/abstractScene" {
  37008. interface AbstractScene {
  37009. /**
  37010. * The list of sounds used in the scene.
  37011. */
  37012. sounds: Nullable<Array<Sound>>;
  37013. }
  37014. }
  37015. module "babylonjs/scene" {
  37016. interface Scene {
  37017. /**
  37018. * @hidden
  37019. * Backing field
  37020. */
  37021. _mainSoundTrack: SoundTrack;
  37022. /**
  37023. * The main sound track played by the scene.
  37024. * It cotains your primary collection of sounds.
  37025. */
  37026. mainSoundTrack: SoundTrack;
  37027. /**
  37028. * The list of sound tracks added to the scene
  37029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37030. */
  37031. soundTracks: Nullable<Array<SoundTrack>>;
  37032. /**
  37033. * Gets a sound using a given name
  37034. * @param name defines the name to search for
  37035. * @return the found sound or null if not found at all.
  37036. */
  37037. getSoundByName(name: string): Nullable<Sound>;
  37038. /**
  37039. * Gets or sets if audio support is enabled
  37040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37041. */
  37042. audioEnabled: boolean;
  37043. /**
  37044. * Gets or sets if audio will be output to headphones
  37045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37046. */
  37047. headphone: boolean;
  37048. /**
  37049. * Gets or sets custom audio listener position provider
  37050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37051. */
  37052. audioListenerPositionProvider: Nullable<() => Vector3>;
  37053. /**
  37054. * Gets or sets a refresh rate when using 3D audio positioning
  37055. */
  37056. audioPositioningRefreshRate: number;
  37057. }
  37058. }
  37059. /**
  37060. * Defines the sound scene component responsible to manage any sounds
  37061. * in a given scene.
  37062. */
  37063. export class AudioSceneComponent implements ISceneSerializableComponent {
  37064. /**
  37065. * The component name helpfull to identify the component in the list of scene components.
  37066. */
  37067. readonly name: string;
  37068. /**
  37069. * The scene the component belongs to.
  37070. */
  37071. scene: Scene;
  37072. private _audioEnabled;
  37073. /**
  37074. * Gets whether audio is enabled or not.
  37075. * Please use related enable/disable method to switch state.
  37076. */
  37077. readonly audioEnabled: boolean;
  37078. private _headphone;
  37079. /**
  37080. * Gets whether audio is outputing to headphone or not.
  37081. * Please use the according Switch methods to change output.
  37082. */
  37083. readonly headphone: boolean;
  37084. /**
  37085. * Gets or sets a refresh rate when using 3D audio positioning
  37086. */
  37087. audioPositioningRefreshRate: number;
  37088. private _audioListenerPositionProvider;
  37089. /**
  37090. * Gets the current audio listener position provider
  37091. */
  37092. /**
  37093. * Sets a custom listener position for all sounds in the scene
  37094. * By default, this is the position of the first active camera
  37095. */
  37096. audioListenerPositionProvider: Nullable<() => Vector3>;
  37097. /**
  37098. * Creates a new instance of the component for the given scene
  37099. * @param scene Defines the scene to register the component in
  37100. */
  37101. constructor(scene: Scene);
  37102. /**
  37103. * Registers the component in a given scene
  37104. */
  37105. register(): void;
  37106. /**
  37107. * Rebuilds the elements related to this component in case of
  37108. * context lost for instance.
  37109. */
  37110. rebuild(): void;
  37111. /**
  37112. * Serializes the component data to the specified json object
  37113. * @param serializationObject The object to serialize to
  37114. */
  37115. serialize(serializationObject: any): void;
  37116. /**
  37117. * Adds all the elements from the container to the scene
  37118. * @param container the container holding the elements
  37119. */
  37120. addFromContainer(container: AbstractScene): void;
  37121. /**
  37122. * Removes all the elements in the container from the scene
  37123. * @param container contains the elements to remove
  37124. * @param dispose if the removed element should be disposed (default: false)
  37125. */
  37126. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37127. /**
  37128. * Disposes the component and the associated ressources.
  37129. */
  37130. dispose(): void;
  37131. /**
  37132. * Disables audio in the associated scene.
  37133. */
  37134. disableAudio(): void;
  37135. /**
  37136. * Enables audio in the associated scene.
  37137. */
  37138. enableAudio(): void;
  37139. /**
  37140. * Switch audio to headphone output.
  37141. */
  37142. switchAudioModeForHeadphones(): void;
  37143. /**
  37144. * Switch audio to normal speakers.
  37145. */
  37146. switchAudioModeForNormalSpeakers(): void;
  37147. private _cachedCameraDirection;
  37148. private _cachedCameraPosition;
  37149. private _lastCheck;
  37150. private _afterRender;
  37151. }
  37152. }
  37153. declare module "babylonjs/Audio/weightedsound" {
  37154. import { Sound } from "babylonjs/Audio/sound";
  37155. /**
  37156. * Wraps one or more Sound objects and selects one with random weight for playback.
  37157. */
  37158. export class WeightedSound {
  37159. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37160. loop: boolean;
  37161. private _coneInnerAngle;
  37162. private _coneOuterAngle;
  37163. private _volume;
  37164. /** A Sound is currently playing. */
  37165. isPlaying: boolean;
  37166. /** A Sound is currently paused. */
  37167. isPaused: boolean;
  37168. private _sounds;
  37169. private _weights;
  37170. private _currentIndex?;
  37171. /**
  37172. * Creates a new WeightedSound from the list of sounds given.
  37173. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37174. * @param sounds Array of Sounds that will be selected from.
  37175. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37176. */
  37177. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37178. /**
  37179. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37180. */
  37181. /**
  37182. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37183. */
  37184. directionalConeInnerAngle: number;
  37185. /**
  37186. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37187. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37188. */
  37189. /**
  37190. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37191. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37192. */
  37193. directionalConeOuterAngle: number;
  37194. /**
  37195. * Playback volume.
  37196. */
  37197. /**
  37198. * Playback volume.
  37199. */
  37200. volume: number;
  37201. private _onended;
  37202. /**
  37203. * Suspend playback
  37204. */
  37205. pause(): void;
  37206. /**
  37207. * Stop playback
  37208. */
  37209. stop(): void;
  37210. /**
  37211. * Start playback.
  37212. * @param startOffset Position the clip head at a specific time in seconds.
  37213. */
  37214. play(startOffset?: number): void;
  37215. }
  37216. }
  37217. declare module "babylonjs/Audio/index" {
  37218. export * from "babylonjs/Audio/analyser";
  37219. export * from "babylonjs/Audio/audioEngine";
  37220. export * from "babylonjs/Audio/audioSceneComponent";
  37221. export * from "babylonjs/Audio/sound";
  37222. export * from "babylonjs/Audio/soundTrack";
  37223. export * from "babylonjs/Audio/weightedsound";
  37224. }
  37225. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  37226. import { Behavior } from "babylonjs/Behaviors/behavior";
  37227. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37228. import { BackEase } from "babylonjs/Animations/easing";
  37229. /**
  37230. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37231. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37232. */
  37233. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37234. /**
  37235. * Gets the name of the behavior.
  37236. */
  37237. readonly name: string;
  37238. /**
  37239. * The easing function used by animations
  37240. */
  37241. static EasingFunction: BackEase;
  37242. /**
  37243. * The easing mode used by animations
  37244. */
  37245. static EasingMode: number;
  37246. /**
  37247. * The duration of the animation, in milliseconds
  37248. */
  37249. transitionDuration: number;
  37250. /**
  37251. * Length of the distance animated by the transition when lower radius is reached
  37252. */
  37253. lowerRadiusTransitionRange: number;
  37254. /**
  37255. * Length of the distance animated by the transition when upper radius is reached
  37256. */
  37257. upperRadiusTransitionRange: number;
  37258. private _autoTransitionRange;
  37259. /**
  37260. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37261. */
  37262. /**
  37263. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37264. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37265. */
  37266. autoTransitionRange: boolean;
  37267. private _attachedCamera;
  37268. private _onAfterCheckInputsObserver;
  37269. private _onMeshTargetChangedObserver;
  37270. /**
  37271. * Initializes the behavior.
  37272. */
  37273. init(): void;
  37274. /**
  37275. * Attaches the behavior to its arc rotate camera.
  37276. * @param camera Defines the camera to attach the behavior to
  37277. */
  37278. attach(camera: ArcRotateCamera): void;
  37279. /**
  37280. * Detaches the behavior from its current arc rotate camera.
  37281. */
  37282. detach(): void;
  37283. private _radiusIsAnimating;
  37284. private _radiusBounceTransition;
  37285. private _animatables;
  37286. private _cachedWheelPrecision;
  37287. /**
  37288. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37289. * @param radiusLimit The limit to check against.
  37290. * @return Bool to indicate if at limit.
  37291. */
  37292. private _isRadiusAtLimit;
  37293. /**
  37294. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37295. * @param radiusDelta The delta by which to animate to. Can be negative.
  37296. */
  37297. private _applyBoundRadiusAnimation;
  37298. /**
  37299. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37300. */
  37301. protected _clearAnimationLocks(): void;
  37302. /**
  37303. * Stops and removes all animations that have been applied to the camera
  37304. */
  37305. stopAllAnimations(): void;
  37306. }
  37307. }
  37308. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37309. import { Behavior } from "babylonjs/Behaviors/behavior";
  37310. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37311. import { ExponentialEase } from "babylonjs/Animations/easing";
  37312. import { Nullable } from "babylonjs/types";
  37313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37314. import { Vector3 } from "babylonjs/Maths/math.vector";
  37315. /**
  37316. * 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.
  37317. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37318. */
  37319. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37320. /**
  37321. * Gets the name of the behavior.
  37322. */
  37323. readonly name: string;
  37324. private _mode;
  37325. private _radiusScale;
  37326. private _positionScale;
  37327. private _defaultElevation;
  37328. private _elevationReturnTime;
  37329. private _elevationReturnWaitTime;
  37330. private _zoomStopsAnimation;
  37331. private _framingTime;
  37332. /**
  37333. * The easing function used by animations
  37334. */
  37335. static EasingFunction: ExponentialEase;
  37336. /**
  37337. * The easing mode used by animations
  37338. */
  37339. static EasingMode: number;
  37340. /**
  37341. * Sets the current mode used by the behavior
  37342. */
  37343. /**
  37344. * Gets current mode used by the behavior.
  37345. */
  37346. mode: number;
  37347. /**
  37348. * Sets the scale applied to the radius (1 by default)
  37349. */
  37350. /**
  37351. * Gets the scale applied to the radius
  37352. */
  37353. radiusScale: number;
  37354. /**
  37355. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37356. */
  37357. /**
  37358. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37359. */
  37360. positionScale: number;
  37361. /**
  37362. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37363. * behaviour is triggered, in radians.
  37364. */
  37365. /**
  37366. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37367. * behaviour is triggered, in radians.
  37368. */
  37369. defaultElevation: number;
  37370. /**
  37371. * Sets the time (in milliseconds) taken to return to the default beta position.
  37372. * Negative value indicates camera should not return to default.
  37373. */
  37374. /**
  37375. * Gets the time (in milliseconds) taken to return to the default beta position.
  37376. * Negative value indicates camera should not return to default.
  37377. */
  37378. elevationReturnTime: number;
  37379. /**
  37380. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37381. */
  37382. /**
  37383. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37384. */
  37385. elevationReturnWaitTime: number;
  37386. /**
  37387. * Sets the flag that indicates if user zooming should stop animation.
  37388. */
  37389. /**
  37390. * Gets the flag that indicates if user zooming should stop animation.
  37391. */
  37392. zoomStopsAnimation: boolean;
  37393. /**
  37394. * Sets the transition time when framing the mesh, in milliseconds
  37395. */
  37396. /**
  37397. * Gets the transition time when framing the mesh, in milliseconds
  37398. */
  37399. framingTime: number;
  37400. /**
  37401. * Define if the behavior should automatically change the configured
  37402. * camera limits and sensibilities.
  37403. */
  37404. autoCorrectCameraLimitsAndSensibility: boolean;
  37405. private _onPrePointerObservableObserver;
  37406. private _onAfterCheckInputsObserver;
  37407. private _onMeshTargetChangedObserver;
  37408. private _attachedCamera;
  37409. private _isPointerDown;
  37410. private _lastInteractionTime;
  37411. /**
  37412. * Initializes the behavior.
  37413. */
  37414. init(): void;
  37415. /**
  37416. * Attaches the behavior to its arc rotate camera.
  37417. * @param camera Defines the camera to attach the behavior to
  37418. */
  37419. attach(camera: ArcRotateCamera): void;
  37420. /**
  37421. * Detaches the behavior from its current arc rotate camera.
  37422. */
  37423. detach(): void;
  37424. private _animatables;
  37425. private _betaIsAnimating;
  37426. private _betaTransition;
  37427. private _radiusTransition;
  37428. private _vectorTransition;
  37429. /**
  37430. * Targets the given mesh and updates zoom level accordingly.
  37431. * @param mesh The mesh to target.
  37432. * @param radius Optional. If a cached radius position already exists, overrides default.
  37433. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37434. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37435. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37436. */
  37437. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37438. /**
  37439. * Targets the given mesh with its children and updates zoom level accordingly.
  37440. * @param mesh The mesh to target.
  37441. * @param radius Optional. If a cached radius position already exists, overrides default.
  37442. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37443. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37444. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37445. */
  37446. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37447. /**
  37448. * Targets the given meshes with their children and updates zoom level accordingly.
  37449. * @param meshes The mesh to target.
  37450. * @param radius Optional. If a cached radius position already exists, overrides default.
  37451. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37452. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37453. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37454. */
  37455. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37456. /**
  37457. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37458. * @param minimumWorld Determines the smaller position of the bounding box extend
  37459. * @param maximumWorld Determines the bigger position of the bounding box extend
  37460. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37461. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37462. */
  37463. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37464. /**
  37465. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37466. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37467. * frustum width.
  37468. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37469. * to fully enclose the mesh in the viewing frustum.
  37470. */
  37471. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37472. /**
  37473. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37474. * is automatically returned to its default position (expected to be above ground plane).
  37475. */
  37476. private _maintainCameraAboveGround;
  37477. /**
  37478. * Returns the frustum slope based on the canvas ratio and camera FOV
  37479. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37480. */
  37481. private _getFrustumSlope;
  37482. /**
  37483. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37484. */
  37485. private _clearAnimationLocks;
  37486. /**
  37487. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37488. */
  37489. private _applyUserInteraction;
  37490. /**
  37491. * Stops and removes all animations that have been applied to the camera
  37492. */
  37493. stopAllAnimations(): void;
  37494. /**
  37495. * Gets a value indicating if the user is moving the camera
  37496. */
  37497. readonly isUserIsMoving: boolean;
  37498. /**
  37499. * The camera can move all the way towards the mesh.
  37500. */
  37501. static IgnoreBoundsSizeMode: number;
  37502. /**
  37503. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37504. */
  37505. static FitFrustumSidesMode: number;
  37506. }
  37507. }
  37508. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37509. import { Nullable } from "babylonjs/types";
  37510. import { Camera } from "babylonjs/Cameras/camera";
  37511. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37512. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37513. /**
  37514. * Base class for Camera Pointer Inputs.
  37515. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37516. * for example usage.
  37517. */
  37518. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37519. /**
  37520. * Defines the camera the input is attached to.
  37521. */
  37522. abstract camera: Camera;
  37523. /**
  37524. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37525. */
  37526. protected _altKey: boolean;
  37527. protected _ctrlKey: boolean;
  37528. protected _metaKey: boolean;
  37529. protected _shiftKey: boolean;
  37530. /**
  37531. * Which mouse buttons were pressed at time of last mouse event.
  37532. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37533. */
  37534. protected _buttonsPressed: number;
  37535. /**
  37536. * Defines the buttons associated with the input to handle camera move.
  37537. */
  37538. buttons: number[];
  37539. /**
  37540. * Attach the input controls to a specific dom element to get the input from.
  37541. * @param element Defines the element the controls should be listened from
  37542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37543. */
  37544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37545. /**
  37546. * Detach the current controls from the specified dom element.
  37547. * @param element Defines the element to stop listening the inputs from
  37548. */
  37549. detachControl(element: Nullable<HTMLElement>): void;
  37550. /**
  37551. * Gets the class name of the current input.
  37552. * @returns the class name
  37553. */
  37554. getClassName(): string;
  37555. /**
  37556. * Get the friendly name associated with the input class.
  37557. * @returns the input friendly name
  37558. */
  37559. getSimpleName(): string;
  37560. /**
  37561. * Called on pointer POINTERDOUBLETAP event.
  37562. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37563. */
  37564. protected onDoubleTap(type: string): void;
  37565. /**
  37566. * Called on pointer POINTERMOVE event if only a single touch is active.
  37567. * Override this method to provide functionality.
  37568. */
  37569. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37570. /**
  37571. * Called on pointer POINTERMOVE event if multiple touches are active.
  37572. * Override this method to provide functionality.
  37573. */
  37574. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37575. /**
  37576. * Called on JS contextmenu event.
  37577. * Override this method to provide functionality.
  37578. */
  37579. protected onContextMenu(evt: PointerEvent): void;
  37580. /**
  37581. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37582. * press.
  37583. * Override this method to provide functionality.
  37584. */
  37585. protected onButtonDown(evt: PointerEvent): void;
  37586. /**
  37587. * Called each time a new POINTERUP event occurs. Ie, for each button
  37588. * release.
  37589. * Override this method to provide functionality.
  37590. */
  37591. protected onButtonUp(evt: PointerEvent): void;
  37592. /**
  37593. * Called when window becomes inactive.
  37594. * Override this method to provide functionality.
  37595. */
  37596. protected onLostFocus(): void;
  37597. private _pointerInput;
  37598. private _observer;
  37599. private _onLostFocus;
  37600. private pointA;
  37601. private pointB;
  37602. }
  37603. }
  37604. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37605. import { Nullable } from "babylonjs/types";
  37606. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37607. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37608. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37609. /**
  37610. * Manage the pointers inputs to control an arc rotate camera.
  37611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37612. */
  37613. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37614. /**
  37615. * Defines the camera the input is attached to.
  37616. */
  37617. camera: ArcRotateCamera;
  37618. /**
  37619. * Gets the class name of the current input.
  37620. * @returns the class name
  37621. */
  37622. getClassName(): string;
  37623. /**
  37624. * Defines the buttons associated with the input to handle camera move.
  37625. */
  37626. buttons: number[];
  37627. /**
  37628. * Defines the pointer angular sensibility along the X axis or how fast is
  37629. * the camera rotating.
  37630. */
  37631. angularSensibilityX: number;
  37632. /**
  37633. * Defines the pointer angular sensibility along the Y axis or how fast is
  37634. * the camera rotating.
  37635. */
  37636. angularSensibilityY: number;
  37637. /**
  37638. * Defines the pointer pinch precision or how fast is the camera zooming.
  37639. */
  37640. pinchPrecision: number;
  37641. /**
  37642. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37643. * from 0.
  37644. * It defines the percentage of current camera.radius to use as delta when
  37645. * pinch zoom is used.
  37646. */
  37647. pinchDeltaPercentage: number;
  37648. /**
  37649. * Defines the pointer panning sensibility or how fast is the camera moving.
  37650. */
  37651. panningSensibility: number;
  37652. /**
  37653. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37654. */
  37655. multiTouchPanning: boolean;
  37656. /**
  37657. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37658. * zoom (pinch) through multitouch.
  37659. */
  37660. multiTouchPanAndZoom: boolean;
  37661. /**
  37662. * Revers pinch action direction.
  37663. */
  37664. pinchInwards: boolean;
  37665. private _isPanClick;
  37666. private _twoFingerActivityCount;
  37667. private _isPinching;
  37668. /**
  37669. * Called on pointer POINTERMOVE event if only a single touch is active.
  37670. */
  37671. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37672. /**
  37673. * Called on pointer POINTERDOUBLETAP event.
  37674. */
  37675. protected onDoubleTap(type: string): void;
  37676. /**
  37677. * Called on pointer POINTERMOVE event if multiple touches are active.
  37678. */
  37679. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37680. /**
  37681. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37682. * press.
  37683. */
  37684. protected onButtonDown(evt: PointerEvent): void;
  37685. /**
  37686. * Called each time a new POINTERUP event occurs. Ie, for each button
  37687. * release.
  37688. */
  37689. protected onButtonUp(evt: PointerEvent): void;
  37690. /**
  37691. * Called when window becomes inactive.
  37692. */
  37693. protected onLostFocus(): void;
  37694. }
  37695. }
  37696. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37697. import { Nullable } from "babylonjs/types";
  37698. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37699. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37700. /**
  37701. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37703. */
  37704. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37705. /**
  37706. * Defines the camera the input is attached to.
  37707. */
  37708. camera: ArcRotateCamera;
  37709. /**
  37710. * Defines the list of key codes associated with the up action (increase alpha)
  37711. */
  37712. keysUp: number[];
  37713. /**
  37714. * Defines the list of key codes associated with the down action (decrease alpha)
  37715. */
  37716. keysDown: number[];
  37717. /**
  37718. * Defines the list of key codes associated with the left action (increase beta)
  37719. */
  37720. keysLeft: number[];
  37721. /**
  37722. * Defines the list of key codes associated with the right action (decrease beta)
  37723. */
  37724. keysRight: number[];
  37725. /**
  37726. * Defines the list of key codes associated with the reset action.
  37727. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37728. */
  37729. keysReset: number[];
  37730. /**
  37731. * Defines the panning sensibility of the inputs.
  37732. * (How fast is the camera paning)
  37733. */
  37734. panningSensibility: number;
  37735. /**
  37736. * Defines the zooming sensibility of the inputs.
  37737. * (How fast is the camera zooming)
  37738. */
  37739. zoomingSensibility: number;
  37740. /**
  37741. * Defines wether maintaining the alt key down switch the movement mode from
  37742. * orientation to zoom.
  37743. */
  37744. useAltToZoom: boolean;
  37745. /**
  37746. * Rotation speed of the camera
  37747. */
  37748. angularSpeed: number;
  37749. private _keys;
  37750. private _ctrlPressed;
  37751. private _altPressed;
  37752. private _onCanvasBlurObserver;
  37753. private _onKeyboardObserver;
  37754. private _engine;
  37755. private _scene;
  37756. /**
  37757. * Attach the input controls to a specific dom element to get the input from.
  37758. * @param element Defines the element the controls should be listened from
  37759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37760. */
  37761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37762. /**
  37763. * Detach the current controls from the specified dom element.
  37764. * @param element Defines the element to stop listening the inputs from
  37765. */
  37766. detachControl(element: Nullable<HTMLElement>): void;
  37767. /**
  37768. * Update the current camera state depending on the inputs that have been used this frame.
  37769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37770. */
  37771. checkInputs(): void;
  37772. /**
  37773. * Gets the class name of the current intput.
  37774. * @returns the class name
  37775. */
  37776. getClassName(): string;
  37777. /**
  37778. * Get the friendly name associated with the input class.
  37779. * @returns the input friendly name
  37780. */
  37781. getSimpleName(): string;
  37782. }
  37783. }
  37784. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37785. import { Nullable } from "babylonjs/types";
  37786. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37787. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37788. /**
  37789. * Manage the mouse wheel inputs to control an arc rotate camera.
  37790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37791. */
  37792. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37793. /**
  37794. * Defines the camera the input is attached to.
  37795. */
  37796. camera: ArcRotateCamera;
  37797. /**
  37798. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37799. */
  37800. wheelPrecision: number;
  37801. /**
  37802. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37803. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37804. */
  37805. wheelDeltaPercentage: number;
  37806. private _wheel;
  37807. private _observer;
  37808. private computeDeltaFromMouseWheelLegacyEvent;
  37809. /**
  37810. * Attach the input controls to a specific dom element to get the input from.
  37811. * @param element Defines the element the controls should be listened from
  37812. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37813. */
  37814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37815. /**
  37816. * Detach the current controls from the specified dom element.
  37817. * @param element Defines the element to stop listening the inputs from
  37818. */
  37819. detachControl(element: Nullable<HTMLElement>): void;
  37820. /**
  37821. * Gets the class name of the current intput.
  37822. * @returns the class name
  37823. */
  37824. getClassName(): string;
  37825. /**
  37826. * Get the friendly name associated with the input class.
  37827. * @returns the input friendly name
  37828. */
  37829. getSimpleName(): string;
  37830. }
  37831. }
  37832. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37833. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37834. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37835. /**
  37836. * Default Inputs manager for the ArcRotateCamera.
  37837. * It groups all the default supported inputs for ease of use.
  37838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37839. */
  37840. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37841. /**
  37842. * Instantiates a new ArcRotateCameraInputsManager.
  37843. * @param camera Defines the camera the inputs belong to
  37844. */
  37845. constructor(camera: ArcRotateCamera);
  37846. /**
  37847. * Add mouse wheel input support to the input manager.
  37848. * @returns the current input manager
  37849. */
  37850. addMouseWheel(): ArcRotateCameraInputsManager;
  37851. /**
  37852. * Add pointers input support to the input manager.
  37853. * @returns the current input manager
  37854. */
  37855. addPointers(): ArcRotateCameraInputsManager;
  37856. /**
  37857. * Add keyboard input support to the input manager.
  37858. * @returns the current input manager
  37859. */
  37860. addKeyboard(): ArcRotateCameraInputsManager;
  37861. }
  37862. }
  37863. declare module "babylonjs/Cameras/arcRotateCamera" {
  37864. import { Observable } from "babylonjs/Misc/observable";
  37865. import { Nullable } from "babylonjs/types";
  37866. import { Scene } from "babylonjs/scene";
  37867. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37869. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37870. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37871. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37872. import { Camera } from "babylonjs/Cameras/camera";
  37873. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37874. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37875. import { Collider } from "babylonjs/Collisions/collider";
  37876. /**
  37877. * This represents an orbital type of camera.
  37878. *
  37879. * 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.
  37880. * 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.
  37881. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37882. */
  37883. export class ArcRotateCamera extends TargetCamera {
  37884. /**
  37885. * Defines the rotation angle of the camera along the longitudinal axis.
  37886. */
  37887. alpha: number;
  37888. /**
  37889. * Defines the rotation angle of the camera along the latitudinal axis.
  37890. */
  37891. beta: number;
  37892. /**
  37893. * Defines the radius of the camera from it s target point.
  37894. */
  37895. radius: number;
  37896. protected _target: Vector3;
  37897. protected _targetHost: Nullable<AbstractMesh>;
  37898. /**
  37899. * Defines the target point of the camera.
  37900. * The camera looks towards it form the radius distance.
  37901. */
  37902. target: Vector3;
  37903. /**
  37904. * Define the current local position of the camera in the scene
  37905. */
  37906. position: Vector3;
  37907. protected _upVector: Vector3;
  37908. protected _upToYMatrix: Matrix;
  37909. protected _YToUpMatrix: Matrix;
  37910. /**
  37911. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37912. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37913. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37914. */
  37915. upVector: Vector3;
  37916. /**
  37917. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37918. */
  37919. setMatUp(): void;
  37920. /**
  37921. * Current inertia value on the longitudinal axis.
  37922. * The bigger this number the longer it will take for the camera to stop.
  37923. */
  37924. inertialAlphaOffset: number;
  37925. /**
  37926. * Current inertia value on the latitudinal axis.
  37927. * The bigger this number the longer it will take for the camera to stop.
  37928. */
  37929. inertialBetaOffset: number;
  37930. /**
  37931. * Current inertia value on the radius axis.
  37932. * The bigger this number the longer it will take for the camera to stop.
  37933. */
  37934. inertialRadiusOffset: number;
  37935. /**
  37936. * Minimum allowed angle on the longitudinal axis.
  37937. * This can help limiting how the Camera is able to move in the scene.
  37938. */
  37939. lowerAlphaLimit: Nullable<number>;
  37940. /**
  37941. * Maximum allowed angle on the longitudinal axis.
  37942. * This can help limiting how the Camera is able to move in the scene.
  37943. */
  37944. upperAlphaLimit: Nullable<number>;
  37945. /**
  37946. * Minimum allowed angle on the latitudinal axis.
  37947. * This can help limiting how the Camera is able to move in the scene.
  37948. */
  37949. lowerBetaLimit: number;
  37950. /**
  37951. * Maximum allowed angle on the latitudinal axis.
  37952. * This can help limiting how the Camera is able to move in the scene.
  37953. */
  37954. upperBetaLimit: number;
  37955. /**
  37956. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37957. * This can help limiting how the Camera is able to move in the scene.
  37958. */
  37959. lowerRadiusLimit: Nullable<number>;
  37960. /**
  37961. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37962. * This can help limiting how the Camera is able to move in the scene.
  37963. */
  37964. upperRadiusLimit: Nullable<number>;
  37965. /**
  37966. * Defines the current inertia value used during panning of the camera along the X axis.
  37967. */
  37968. inertialPanningX: number;
  37969. /**
  37970. * Defines the current inertia value used during panning of the camera along the Y axis.
  37971. */
  37972. inertialPanningY: number;
  37973. /**
  37974. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37975. * Basically if your fingers moves away from more than this distance you will be considered
  37976. * in pinch mode.
  37977. */
  37978. pinchToPanMaxDistance: number;
  37979. /**
  37980. * Defines the maximum distance the camera can pan.
  37981. * This could help keeping the cammera always in your scene.
  37982. */
  37983. panningDistanceLimit: Nullable<number>;
  37984. /**
  37985. * Defines the target of the camera before paning.
  37986. */
  37987. panningOriginTarget: Vector3;
  37988. /**
  37989. * Defines the value of the inertia used during panning.
  37990. * 0 would mean stop inertia and one would mean no decelleration at all.
  37991. */
  37992. panningInertia: number;
  37993. /**
  37994. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37995. */
  37996. angularSensibilityX: number;
  37997. /**
  37998. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37999. */
  38000. angularSensibilityY: number;
  38001. /**
  38002. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38003. */
  38004. pinchPrecision: number;
  38005. /**
  38006. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38007. * It will be used instead of pinchDeltaPrecision if different from 0.
  38008. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38009. */
  38010. pinchDeltaPercentage: number;
  38011. /**
  38012. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38013. */
  38014. panningSensibility: number;
  38015. /**
  38016. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38017. */
  38018. keysUp: number[];
  38019. /**
  38020. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38021. */
  38022. keysDown: number[];
  38023. /**
  38024. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38025. */
  38026. keysLeft: number[];
  38027. /**
  38028. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38029. */
  38030. keysRight: number[];
  38031. /**
  38032. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38033. */
  38034. wheelPrecision: number;
  38035. /**
  38036. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38037. * It will be used instead of pinchDeltaPrecision if different from 0.
  38038. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38039. */
  38040. wheelDeltaPercentage: number;
  38041. /**
  38042. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38043. */
  38044. zoomOnFactor: number;
  38045. /**
  38046. * Defines a screen offset for the camera position.
  38047. */
  38048. targetScreenOffset: Vector2;
  38049. /**
  38050. * Allows the camera to be completely reversed.
  38051. * If false the camera can not arrive upside down.
  38052. */
  38053. allowUpsideDown: boolean;
  38054. /**
  38055. * Define if double tap/click is used to restore the previously saved state of the camera.
  38056. */
  38057. useInputToRestoreState: boolean;
  38058. /** @hidden */
  38059. _viewMatrix: Matrix;
  38060. /** @hidden */
  38061. _useCtrlForPanning: boolean;
  38062. /** @hidden */
  38063. _panningMouseButton: number;
  38064. /**
  38065. * Defines the input associated to the camera.
  38066. */
  38067. inputs: ArcRotateCameraInputsManager;
  38068. /** @hidden */
  38069. _reset: () => void;
  38070. /**
  38071. * Defines the allowed panning axis.
  38072. */
  38073. panningAxis: Vector3;
  38074. protected _localDirection: Vector3;
  38075. protected _transformedDirection: Vector3;
  38076. private _bouncingBehavior;
  38077. /**
  38078. * Gets the bouncing behavior of the camera if it has been enabled.
  38079. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38080. */
  38081. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38082. /**
  38083. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38084. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38085. */
  38086. useBouncingBehavior: boolean;
  38087. private _framingBehavior;
  38088. /**
  38089. * Gets the framing behavior of the camera if it has been enabled.
  38090. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38091. */
  38092. readonly framingBehavior: Nullable<FramingBehavior>;
  38093. /**
  38094. * Defines if the framing behavior of the camera is enabled on the camera.
  38095. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38096. */
  38097. useFramingBehavior: boolean;
  38098. private _autoRotationBehavior;
  38099. /**
  38100. * Gets the auto rotation behavior of the camera if it has been enabled.
  38101. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38102. */
  38103. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38104. /**
  38105. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38106. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38107. */
  38108. useAutoRotationBehavior: boolean;
  38109. /**
  38110. * Observable triggered when the mesh target has been changed on the camera.
  38111. */
  38112. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38113. /**
  38114. * Event raised when the camera is colliding with a mesh.
  38115. */
  38116. onCollide: (collidedMesh: AbstractMesh) => void;
  38117. /**
  38118. * Defines whether the camera should check collision with the objects oh the scene.
  38119. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38120. */
  38121. checkCollisions: boolean;
  38122. /**
  38123. * Defines the collision radius of the camera.
  38124. * This simulates a sphere around the camera.
  38125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38126. */
  38127. collisionRadius: Vector3;
  38128. protected _collider: Collider;
  38129. protected _previousPosition: Vector3;
  38130. protected _collisionVelocity: Vector3;
  38131. protected _newPosition: Vector3;
  38132. protected _previousAlpha: number;
  38133. protected _previousBeta: number;
  38134. protected _previousRadius: number;
  38135. protected _collisionTriggered: boolean;
  38136. protected _targetBoundingCenter: Nullable<Vector3>;
  38137. private _computationVector;
  38138. /**
  38139. * Instantiates a new ArcRotateCamera in a given scene
  38140. * @param name Defines the name of the camera
  38141. * @param alpha Defines the camera rotation along the logitudinal axis
  38142. * @param beta Defines the camera rotation along the latitudinal axis
  38143. * @param radius Defines the camera distance from its target
  38144. * @param target Defines the camera target
  38145. * @param scene Defines the scene the camera belongs to
  38146. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38147. */
  38148. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38149. /** @hidden */
  38150. _initCache(): void;
  38151. /** @hidden */
  38152. _updateCache(ignoreParentClass?: boolean): void;
  38153. protected _getTargetPosition(): Vector3;
  38154. private _storedAlpha;
  38155. private _storedBeta;
  38156. private _storedRadius;
  38157. private _storedTarget;
  38158. private _storedTargetScreenOffset;
  38159. /**
  38160. * Stores the current state of the camera (alpha, beta, radius and target)
  38161. * @returns the camera itself
  38162. */
  38163. storeState(): Camera;
  38164. /**
  38165. * @hidden
  38166. * Restored camera state. You must call storeState() first
  38167. */
  38168. _restoreStateValues(): boolean;
  38169. /** @hidden */
  38170. _isSynchronizedViewMatrix(): boolean;
  38171. /**
  38172. * Attached controls to the current camera.
  38173. * @param element Defines the element the controls should be listened from
  38174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38175. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38176. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38177. */
  38178. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38179. /**
  38180. * Detach the current controls from the camera.
  38181. * The camera will stop reacting to inputs.
  38182. * @param element Defines the element to stop listening the inputs from
  38183. */
  38184. detachControl(element: HTMLElement): void;
  38185. /** @hidden */
  38186. _checkInputs(): void;
  38187. protected _checkLimits(): void;
  38188. /**
  38189. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38190. */
  38191. rebuildAnglesAndRadius(): void;
  38192. /**
  38193. * Use a position to define the current camera related information like alpha, beta and radius
  38194. * @param position Defines the position to set the camera at
  38195. */
  38196. setPosition(position: Vector3): void;
  38197. /**
  38198. * Defines the target the camera should look at.
  38199. * This will automatically adapt alpha beta and radius to fit within the new target.
  38200. * @param target Defines the new target as a Vector or a mesh
  38201. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38202. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38203. */
  38204. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38205. /** @hidden */
  38206. _getViewMatrix(): Matrix;
  38207. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38208. /**
  38209. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38210. * @param meshes Defines the mesh to zoom on
  38211. * @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)
  38212. */
  38213. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38214. /**
  38215. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38216. * The target will be changed but the radius
  38217. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38218. * @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)
  38219. */
  38220. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38221. min: Vector3;
  38222. max: Vector3;
  38223. distance: number;
  38224. }, doNotUpdateMaxZ?: boolean): void;
  38225. /**
  38226. * @override
  38227. * Override Camera.createRigCamera
  38228. */
  38229. createRigCamera(name: string, cameraIndex: number): Camera;
  38230. /**
  38231. * @hidden
  38232. * @override
  38233. * Override Camera._updateRigCameras
  38234. */
  38235. _updateRigCameras(): void;
  38236. /**
  38237. * Destroy the camera and release the current resources hold by it.
  38238. */
  38239. dispose(): void;
  38240. /**
  38241. * Gets the current object class name.
  38242. * @return the class name
  38243. */
  38244. getClassName(): string;
  38245. }
  38246. }
  38247. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38248. import { Behavior } from "babylonjs/Behaviors/behavior";
  38249. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38250. /**
  38251. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38252. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38253. */
  38254. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38255. /**
  38256. * Gets the name of the behavior.
  38257. */
  38258. readonly name: string;
  38259. private _zoomStopsAnimation;
  38260. private _idleRotationSpeed;
  38261. private _idleRotationWaitTime;
  38262. private _idleRotationSpinupTime;
  38263. /**
  38264. * Sets the flag that indicates if user zooming should stop animation.
  38265. */
  38266. /**
  38267. * Gets the flag that indicates if user zooming should stop animation.
  38268. */
  38269. zoomStopsAnimation: boolean;
  38270. /**
  38271. * Sets the default speed at which the camera rotates around the model.
  38272. */
  38273. /**
  38274. * Gets the default speed at which the camera rotates around the model.
  38275. */
  38276. idleRotationSpeed: number;
  38277. /**
  38278. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38279. */
  38280. /**
  38281. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38282. */
  38283. idleRotationWaitTime: number;
  38284. /**
  38285. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38286. */
  38287. /**
  38288. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38289. */
  38290. idleRotationSpinupTime: number;
  38291. /**
  38292. * Gets a value indicating if the camera is currently rotating because of this behavior
  38293. */
  38294. readonly rotationInProgress: boolean;
  38295. private _onPrePointerObservableObserver;
  38296. private _onAfterCheckInputsObserver;
  38297. private _attachedCamera;
  38298. private _isPointerDown;
  38299. private _lastFrameTime;
  38300. private _lastInteractionTime;
  38301. private _cameraRotationSpeed;
  38302. /**
  38303. * Initializes the behavior.
  38304. */
  38305. init(): void;
  38306. /**
  38307. * Attaches the behavior to its arc rotate camera.
  38308. * @param camera Defines the camera to attach the behavior to
  38309. */
  38310. attach(camera: ArcRotateCamera): void;
  38311. /**
  38312. * Detaches the behavior from its current arc rotate camera.
  38313. */
  38314. detach(): void;
  38315. /**
  38316. * Returns true if user is scrolling.
  38317. * @return true if user is scrolling.
  38318. */
  38319. private _userIsZooming;
  38320. private _lastFrameRadius;
  38321. private _shouldAnimationStopForInteraction;
  38322. /**
  38323. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38324. */
  38325. private _applyUserInteraction;
  38326. private _userIsMoving;
  38327. }
  38328. }
  38329. declare module "babylonjs/Behaviors/Cameras/index" {
  38330. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38331. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38332. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38333. }
  38334. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38335. import { Mesh } from "babylonjs/Meshes/mesh";
  38336. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38337. import { Behavior } from "babylonjs/Behaviors/behavior";
  38338. /**
  38339. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38340. */
  38341. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38342. private ui;
  38343. /**
  38344. * The name of the behavior
  38345. */
  38346. name: string;
  38347. /**
  38348. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38349. */
  38350. distanceAwayFromFace: number;
  38351. /**
  38352. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38353. */
  38354. distanceAwayFromBottomOfFace: number;
  38355. private _faceVectors;
  38356. private _target;
  38357. private _scene;
  38358. private _onRenderObserver;
  38359. private _tmpMatrix;
  38360. private _tmpVector;
  38361. /**
  38362. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38363. * @param ui The transform node that should be attched to the mesh
  38364. */
  38365. constructor(ui: TransformNode);
  38366. /**
  38367. * Initializes the behavior
  38368. */
  38369. init(): void;
  38370. private _closestFace;
  38371. private _zeroVector;
  38372. private _lookAtTmpMatrix;
  38373. private _lookAtToRef;
  38374. /**
  38375. * Attaches the AttachToBoxBehavior to the passed in mesh
  38376. * @param target The mesh that the specified node will be attached to
  38377. */
  38378. attach(target: Mesh): void;
  38379. /**
  38380. * Detaches the behavior from the mesh
  38381. */
  38382. detach(): void;
  38383. }
  38384. }
  38385. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38386. import { Behavior } from "babylonjs/Behaviors/behavior";
  38387. import { Mesh } from "babylonjs/Meshes/mesh";
  38388. /**
  38389. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38390. */
  38391. export class FadeInOutBehavior implements Behavior<Mesh> {
  38392. /**
  38393. * Time in milliseconds to delay before fading in (Default: 0)
  38394. */
  38395. delay: number;
  38396. /**
  38397. * Time in milliseconds for the mesh to fade in (Default: 300)
  38398. */
  38399. fadeInTime: number;
  38400. private _millisecondsPerFrame;
  38401. private _hovered;
  38402. private _hoverValue;
  38403. private _ownerNode;
  38404. /**
  38405. * Instatiates the FadeInOutBehavior
  38406. */
  38407. constructor();
  38408. /**
  38409. * The name of the behavior
  38410. */
  38411. readonly name: string;
  38412. /**
  38413. * Initializes the behavior
  38414. */
  38415. init(): void;
  38416. /**
  38417. * Attaches the fade behavior on the passed in mesh
  38418. * @param ownerNode The mesh that will be faded in/out once attached
  38419. */
  38420. attach(ownerNode: Mesh): void;
  38421. /**
  38422. * Detaches the behavior from the mesh
  38423. */
  38424. detach(): void;
  38425. /**
  38426. * Triggers the mesh to begin fading in or out
  38427. * @param value if the object should fade in or out (true to fade in)
  38428. */
  38429. fadeIn(value: boolean): void;
  38430. private _update;
  38431. private _setAllVisibility;
  38432. }
  38433. }
  38434. declare module "babylonjs/Misc/pivotTools" {
  38435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38436. /**
  38437. * Class containing a set of static utilities functions for managing Pivots
  38438. * @hidden
  38439. */
  38440. export class PivotTools {
  38441. private static _PivotCached;
  38442. private static _OldPivotPoint;
  38443. private static _PivotTranslation;
  38444. private static _PivotTmpVector;
  38445. /** @hidden */
  38446. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38447. /** @hidden */
  38448. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38449. }
  38450. }
  38451. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38452. import { Scene } from "babylonjs/scene";
  38453. import { Vector4 } from "babylonjs/Maths/math.vector";
  38454. import { Mesh } from "babylonjs/Meshes/mesh";
  38455. import { Nullable } from "babylonjs/types";
  38456. import { Plane } from "babylonjs/Maths/math.plane";
  38457. /**
  38458. * Class containing static functions to help procedurally build meshes
  38459. */
  38460. export class PlaneBuilder {
  38461. /**
  38462. * Creates a plane mesh
  38463. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38464. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38465. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38469. * @param name defines the name of the mesh
  38470. * @param options defines the options used to create the mesh
  38471. * @param scene defines the hosting scene
  38472. * @returns the plane mesh
  38473. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38474. */
  38475. static CreatePlane(name: string, options: {
  38476. size?: number;
  38477. width?: number;
  38478. height?: number;
  38479. sideOrientation?: number;
  38480. frontUVs?: Vector4;
  38481. backUVs?: Vector4;
  38482. updatable?: boolean;
  38483. sourcePlane?: Plane;
  38484. }, scene?: Nullable<Scene>): Mesh;
  38485. }
  38486. }
  38487. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38488. import { Behavior } from "babylonjs/Behaviors/behavior";
  38489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38490. import { Observable } from "babylonjs/Misc/observable";
  38491. import { Vector3 } from "babylonjs/Maths/math.vector";
  38492. import { Ray } from "babylonjs/Culling/ray";
  38493. import "babylonjs/Meshes/Builders/planeBuilder";
  38494. /**
  38495. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38496. */
  38497. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38498. private static _AnyMouseID;
  38499. /**
  38500. * Abstract mesh the behavior is set on
  38501. */
  38502. attachedNode: AbstractMesh;
  38503. private _dragPlane;
  38504. private _scene;
  38505. private _pointerObserver;
  38506. private _beforeRenderObserver;
  38507. private static _planeScene;
  38508. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38509. /**
  38510. * 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)
  38511. */
  38512. maxDragAngle: number;
  38513. /**
  38514. * @hidden
  38515. */
  38516. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38517. /**
  38518. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38519. */
  38520. currentDraggingPointerID: number;
  38521. /**
  38522. * The last position where the pointer hit the drag plane in world space
  38523. */
  38524. lastDragPosition: Vector3;
  38525. /**
  38526. * If the behavior is currently in a dragging state
  38527. */
  38528. dragging: boolean;
  38529. /**
  38530. * 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)
  38531. */
  38532. dragDeltaRatio: number;
  38533. /**
  38534. * If the drag plane orientation should be updated during the dragging (Default: true)
  38535. */
  38536. updateDragPlane: boolean;
  38537. private _debugMode;
  38538. private _moving;
  38539. /**
  38540. * Fires each time the attached mesh is dragged with the pointer
  38541. * * delta between last drag position and current drag position in world space
  38542. * * dragDistance along the drag axis
  38543. * * dragPlaneNormal normal of the current drag plane used during the drag
  38544. * * dragPlanePoint in world space where the drag intersects the drag plane
  38545. */
  38546. onDragObservable: Observable<{
  38547. delta: Vector3;
  38548. dragPlanePoint: Vector3;
  38549. dragPlaneNormal: Vector3;
  38550. dragDistance: number;
  38551. pointerId: number;
  38552. }>;
  38553. /**
  38554. * Fires each time a drag begins (eg. mouse down on mesh)
  38555. */
  38556. onDragStartObservable: Observable<{
  38557. dragPlanePoint: Vector3;
  38558. pointerId: number;
  38559. }>;
  38560. /**
  38561. * Fires each time a drag ends (eg. mouse release after drag)
  38562. */
  38563. onDragEndObservable: Observable<{
  38564. dragPlanePoint: Vector3;
  38565. pointerId: number;
  38566. }>;
  38567. /**
  38568. * If the attached mesh should be moved when dragged
  38569. */
  38570. moveAttached: boolean;
  38571. /**
  38572. * If the drag behavior will react to drag events (Default: true)
  38573. */
  38574. enabled: boolean;
  38575. /**
  38576. * If pointer events should start and release the drag (Default: true)
  38577. */
  38578. startAndReleaseDragOnPointerEvents: boolean;
  38579. /**
  38580. * If camera controls should be detached during the drag
  38581. */
  38582. detachCameraControls: boolean;
  38583. /**
  38584. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38585. */
  38586. useObjectOrienationForDragging: boolean;
  38587. private _options;
  38588. /**
  38589. * Creates a pointer drag behavior that can be attached to a mesh
  38590. * @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)
  38591. */
  38592. constructor(options?: {
  38593. dragAxis?: Vector3;
  38594. dragPlaneNormal?: Vector3;
  38595. });
  38596. /**
  38597. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38598. */
  38599. validateDrag: (targetPosition: Vector3) => boolean;
  38600. /**
  38601. * The name of the behavior
  38602. */
  38603. readonly name: string;
  38604. /**
  38605. * Initializes the behavior
  38606. */
  38607. init(): void;
  38608. private _tmpVector;
  38609. private _alternatePickedPoint;
  38610. private _worldDragAxis;
  38611. private _targetPosition;
  38612. private _attachedElement;
  38613. /**
  38614. * Attaches the drag behavior the passed in mesh
  38615. * @param ownerNode The mesh that will be dragged around once attached
  38616. * @param predicate Predicate to use for pick filtering
  38617. */
  38618. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38619. /**
  38620. * Force relase the drag action by code.
  38621. */
  38622. releaseDrag(): void;
  38623. private _startDragRay;
  38624. private _lastPointerRay;
  38625. /**
  38626. * Simulates the start of a pointer drag event on the behavior
  38627. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38628. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38629. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38630. */
  38631. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38632. private _startDrag;
  38633. private _dragDelta;
  38634. private _moveDrag;
  38635. private _pickWithRayOnDragPlane;
  38636. private _pointA;
  38637. private _pointB;
  38638. private _pointC;
  38639. private _lineA;
  38640. private _lineB;
  38641. private _localAxis;
  38642. private _lookAt;
  38643. private _updateDragPlanePosition;
  38644. /**
  38645. * Detaches the behavior from the mesh
  38646. */
  38647. detach(): void;
  38648. }
  38649. }
  38650. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38651. import { Mesh } from "babylonjs/Meshes/mesh";
  38652. import { Behavior } from "babylonjs/Behaviors/behavior";
  38653. /**
  38654. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38655. */
  38656. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38657. private _dragBehaviorA;
  38658. private _dragBehaviorB;
  38659. private _startDistance;
  38660. private _initialScale;
  38661. private _targetScale;
  38662. private _ownerNode;
  38663. private _sceneRenderObserver;
  38664. /**
  38665. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38666. */
  38667. constructor();
  38668. /**
  38669. * The name of the behavior
  38670. */
  38671. readonly name: string;
  38672. /**
  38673. * Initializes the behavior
  38674. */
  38675. init(): void;
  38676. private _getCurrentDistance;
  38677. /**
  38678. * Attaches the scale behavior the passed in mesh
  38679. * @param ownerNode The mesh that will be scaled around once attached
  38680. */
  38681. attach(ownerNode: Mesh): void;
  38682. /**
  38683. * Detaches the behavior from the mesh
  38684. */
  38685. detach(): void;
  38686. }
  38687. }
  38688. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38689. import { Behavior } from "babylonjs/Behaviors/behavior";
  38690. import { Mesh } from "babylonjs/Meshes/mesh";
  38691. import { Observable } from "babylonjs/Misc/observable";
  38692. /**
  38693. * 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
  38694. */
  38695. export class SixDofDragBehavior implements Behavior<Mesh> {
  38696. private static _virtualScene;
  38697. private _ownerNode;
  38698. private _sceneRenderObserver;
  38699. private _scene;
  38700. private _targetPosition;
  38701. private _virtualOriginMesh;
  38702. private _virtualDragMesh;
  38703. private _pointerObserver;
  38704. private _moving;
  38705. private _startingOrientation;
  38706. /**
  38707. * 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)
  38708. */
  38709. private zDragFactor;
  38710. /**
  38711. * If the object should rotate to face the drag origin
  38712. */
  38713. rotateDraggedObject: boolean;
  38714. /**
  38715. * If the behavior is currently in a dragging state
  38716. */
  38717. dragging: boolean;
  38718. /**
  38719. * 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)
  38720. */
  38721. dragDeltaRatio: number;
  38722. /**
  38723. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38724. */
  38725. currentDraggingPointerID: number;
  38726. /**
  38727. * If camera controls should be detached during the drag
  38728. */
  38729. detachCameraControls: boolean;
  38730. /**
  38731. * Fires each time a drag starts
  38732. */
  38733. onDragStartObservable: Observable<{}>;
  38734. /**
  38735. * Fires each time a drag ends (eg. mouse release after drag)
  38736. */
  38737. onDragEndObservable: Observable<{}>;
  38738. /**
  38739. * 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
  38740. */
  38741. constructor();
  38742. /**
  38743. * The name of the behavior
  38744. */
  38745. readonly name: string;
  38746. /**
  38747. * Initializes the behavior
  38748. */
  38749. init(): void;
  38750. /**
  38751. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38752. */
  38753. private readonly _pointerCamera;
  38754. /**
  38755. * Attaches the scale behavior the passed in mesh
  38756. * @param ownerNode The mesh that will be scaled around once attached
  38757. */
  38758. attach(ownerNode: Mesh): void;
  38759. /**
  38760. * Detaches the behavior from the mesh
  38761. */
  38762. detach(): void;
  38763. }
  38764. }
  38765. declare module "babylonjs/Behaviors/Meshes/index" {
  38766. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38767. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38768. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38769. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38770. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38771. }
  38772. declare module "babylonjs/Behaviors/index" {
  38773. export * from "babylonjs/Behaviors/behavior";
  38774. export * from "babylonjs/Behaviors/Cameras/index";
  38775. export * from "babylonjs/Behaviors/Meshes/index";
  38776. }
  38777. declare module "babylonjs/Bones/boneIKController" {
  38778. import { Bone } from "babylonjs/Bones/bone";
  38779. import { Vector3 } from "babylonjs/Maths/math.vector";
  38780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38781. import { Nullable } from "babylonjs/types";
  38782. /**
  38783. * Class used to apply inverse kinematics to bones
  38784. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38785. */
  38786. export class BoneIKController {
  38787. private static _tmpVecs;
  38788. private static _tmpQuat;
  38789. private static _tmpMats;
  38790. /**
  38791. * Gets or sets the target mesh
  38792. */
  38793. targetMesh: AbstractMesh;
  38794. /** Gets or sets the mesh used as pole */
  38795. poleTargetMesh: AbstractMesh;
  38796. /**
  38797. * Gets or sets the bone used as pole
  38798. */
  38799. poleTargetBone: Nullable<Bone>;
  38800. /**
  38801. * Gets or sets the target position
  38802. */
  38803. targetPosition: Vector3;
  38804. /**
  38805. * Gets or sets the pole target position
  38806. */
  38807. poleTargetPosition: Vector3;
  38808. /**
  38809. * Gets or sets the pole target local offset
  38810. */
  38811. poleTargetLocalOffset: Vector3;
  38812. /**
  38813. * Gets or sets the pole angle
  38814. */
  38815. poleAngle: number;
  38816. /**
  38817. * Gets or sets the mesh associated with the controller
  38818. */
  38819. mesh: AbstractMesh;
  38820. /**
  38821. * 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)
  38822. */
  38823. slerpAmount: number;
  38824. private _bone1Quat;
  38825. private _bone1Mat;
  38826. private _bone2Ang;
  38827. private _bone1;
  38828. private _bone2;
  38829. private _bone1Length;
  38830. private _bone2Length;
  38831. private _maxAngle;
  38832. private _maxReach;
  38833. private _rightHandedSystem;
  38834. private _bendAxis;
  38835. private _slerping;
  38836. private _adjustRoll;
  38837. /**
  38838. * Gets or sets maximum allowed angle
  38839. */
  38840. maxAngle: number;
  38841. /**
  38842. * Creates a new BoneIKController
  38843. * @param mesh defines the mesh to control
  38844. * @param bone defines the bone to control
  38845. * @param options defines options to set up the controller
  38846. */
  38847. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38848. targetMesh?: AbstractMesh;
  38849. poleTargetMesh?: AbstractMesh;
  38850. poleTargetBone?: Bone;
  38851. poleTargetLocalOffset?: Vector3;
  38852. poleAngle?: number;
  38853. bendAxis?: Vector3;
  38854. maxAngle?: number;
  38855. slerpAmount?: number;
  38856. });
  38857. private _setMaxAngle;
  38858. /**
  38859. * Force the controller to update the bones
  38860. */
  38861. update(): void;
  38862. }
  38863. }
  38864. declare module "babylonjs/Bones/boneLookController" {
  38865. import { Vector3 } from "babylonjs/Maths/math.vector";
  38866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38867. import { Bone } from "babylonjs/Bones/bone";
  38868. import { Space } from "babylonjs/Maths/math.axis";
  38869. /**
  38870. * Class used to make a bone look toward a point in space
  38871. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38872. */
  38873. export class BoneLookController {
  38874. private static _tmpVecs;
  38875. private static _tmpQuat;
  38876. private static _tmpMats;
  38877. /**
  38878. * The target Vector3 that the bone will look at
  38879. */
  38880. target: Vector3;
  38881. /**
  38882. * The mesh that the bone is attached to
  38883. */
  38884. mesh: AbstractMesh;
  38885. /**
  38886. * The bone that will be looking to the target
  38887. */
  38888. bone: Bone;
  38889. /**
  38890. * The up axis of the coordinate system that is used when the bone is rotated
  38891. */
  38892. upAxis: Vector3;
  38893. /**
  38894. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38895. */
  38896. upAxisSpace: Space;
  38897. /**
  38898. * Used to make an adjustment to the yaw of the bone
  38899. */
  38900. adjustYaw: number;
  38901. /**
  38902. * Used to make an adjustment to the pitch of the bone
  38903. */
  38904. adjustPitch: number;
  38905. /**
  38906. * Used to make an adjustment to the roll of the bone
  38907. */
  38908. adjustRoll: number;
  38909. /**
  38910. * 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)
  38911. */
  38912. slerpAmount: number;
  38913. private _minYaw;
  38914. private _maxYaw;
  38915. private _minPitch;
  38916. private _maxPitch;
  38917. private _minYawSin;
  38918. private _minYawCos;
  38919. private _maxYawSin;
  38920. private _maxYawCos;
  38921. private _midYawConstraint;
  38922. private _minPitchTan;
  38923. private _maxPitchTan;
  38924. private _boneQuat;
  38925. private _slerping;
  38926. private _transformYawPitch;
  38927. private _transformYawPitchInv;
  38928. private _firstFrameSkipped;
  38929. private _yawRange;
  38930. private _fowardAxis;
  38931. /**
  38932. * Gets or sets the minimum yaw angle that the bone can look to
  38933. */
  38934. minYaw: number;
  38935. /**
  38936. * Gets or sets the maximum yaw angle that the bone can look to
  38937. */
  38938. maxYaw: number;
  38939. /**
  38940. * Gets or sets the minimum pitch angle that the bone can look to
  38941. */
  38942. minPitch: number;
  38943. /**
  38944. * Gets or sets the maximum pitch angle that the bone can look to
  38945. */
  38946. maxPitch: number;
  38947. /**
  38948. * Create a BoneLookController
  38949. * @param mesh the mesh that the bone belongs to
  38950. * @param bone the bone that will be looking to the target
  38951. * @param target the target Vector3 to look at
  38952. * @param options optional settings:
  38953. * * maxYaw: the maximum angle the bone will yaw to
  38954. * * minYaw: the minimum angle the bone will yaw to
  38955. * * maxPitch: the maximum angle the bone will pitch to
  38956. * * minPitch: the minimum angle the bone will yaw to
  38957. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38958. * * upAxis: the up axis of the coordinate system
  38959. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38960. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38961. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38962. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38963. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38964. * * adjustRoll: used to make an adjustment to the roll of the bone
  38965. **/
  38966. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38967. maxYaw?: number;
  38968. minYaw?: number;
  38969. maxPitch?: number;
  38970. minPitch?: number;
  38971. slerpAmount?: number;
  38972. upAxis?: Vector3;
  38973. upAxisSpace?: Space;
  38974. yawAxis?: Vector3;
  38975. pitchAxis?: Vector3;
  38976. adjustYaw?: number;
  38977. adjustPitch?: number;
  38978. adjustRoll?: number;
  38979. });
  38980. /**
  38981. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38982. */
  38983. update(): void;
  38984. private _getAngleDiff;
  38985. private _getAngleBetween;
  38986. private _isAngleBetween;
  38987. }
  38988. }
  38989. declare module "babylonjs/Bones/index" {
  38990. export * from "babylonjs/Bones/bone";
  38991. export * from "babylonjs/Bones/boneIKController";
  38992. export * from "babylonjs/Bones/boneLookController";
  38993. export * from "babylonjs/Bones/skeleton";
  38994. }
  38995. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38996. import { Nullable } from "babylonjs/types";
  38997. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38998. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38999. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39000. /**
  39001. * Manage the gamepad inputs to control an arc rotate camera.
  39002. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39003. */
  39004. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39005. /**
  39006. * Defines the camera the input is attached to.
  39007. */
  39008. camera: ArcRotateCamera;
  39009. /**
  39010. * Defines the gamepad the input is gathering event from.
  39011. */
  39012. gamepad: Nullable<Gamepad>;
  39013. /**
  39014. * Defines the gamepad rotation sensiblity.
  39015. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39016. */
  39017. gamepadRotationSensibility: number;
  39018. /**
  39019. * Defines the gamepad move sensiblity.
  39020. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39021. */
  39022. gamepadMoveSensibility: number;
  39023. private _yAxisScale;
  39024. /**
  39025. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39026. */
  39027. invertYAxis: boolean;
  39028. private _onGamepadConnectedObserver;
  39029. private _onGamepadDisconnectedObserver;
  39030. /**
  39031. * Attach the input controls to a specific dom element to get the input from.
  39032. * @param element Defines the element the controls should be listened from
  39033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39034. */
  39035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39036. /**
  39037. * Detach the current controls from the specified dom element.
  39038. * @param element Defines the element to stop listening the inputs from
  39039. */
  39040. detachControl(element: Nullable<HTMLElement>): void;
  39041. /**
  39042. * Update the current camera state depending on the inputs that have been used this frame.
  39043. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39044. */
  39045. checkInputs(): void;
  39046. /**
  39047. * Gets the class name of the current intput.
  39048. * @returns the class name
  39049. */
  39050. getClassName(): string;
  39051. /**
  39052. * Get the friendly name associated with the input class.
  39053. * @returns the input friendly name
  39054. */
  39055. getSimpleName(): string;
  39056. }
  39057. }
  39058. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  39059. import { Nullable } from "babylonjs/types";
  39060. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39061. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39062. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39063. interface ArcRotateCameraInputsManager {
  39064. /**
  39065. * Add orientation input support to the input manager.
  39066. * @returns the current input manager
  39067. */
  39068. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39069. }
  39070. }
  39071. /**
  39072. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39074. */
  39075. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39076. /**
  39077. * Defines the camera the input is attached to.
  39078. */
  39079. camera: ArcRotateCamera;
  39080. /**
  39081. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39082. */
  39083. alphaCorrection: number;
  39084. /**
  39085. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39086. */
  39087. gammaCorrection: number;
  39088. private _alpha;
  39089. private _gamma;
  39090. private _dirty;
  39091. private _deviceOrientationHandler;
  39092. /**
  39093. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39094. */
  39095. constructor();
  39096. /**
  39097. * Attach the input controls to a specific dom element to get the input from.
  39098. * @param element Defines the element the controls should be listened from
  39099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39100. */
  39101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39102. /** @hidden */
  39103. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39104. /**
  39105. * Update the current camera state depending on the inputs that have been used this frame.
  39106. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39107. */
  39108. checkInputs(): void;
  39109. /**
  39110. * Detach the current controls from the specified dom element.
  39111. * @param element Defines the element to stop listening the inputs from
  39112. */
  39113. detachControl(element: Nullable<HTMLElement>): void;
  39114. /**
  39115. * Gets the class name of the current intput.
  39116. * @returns the class name
  39117. */
  39118. getClassName(): string;
  39119. /**
  39120. * Get the friendly name associated with the input class.
  39121. * @returns the input friendly name
  39122. */
  39123. getSimpleName(): string;
  39124. }
  39125. }
  39126. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  39127. import { Nullable } from "babylonjs/types";
  39128. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39129. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39130. /**
  39131. * Listen to mouse events to control the camera.
  39132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39133. */
  39134. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39135. /**
  39136. * Defines the camera the input is attached to.
  39137. */
  39138. camera: FlyCamera;
  39139. /**
  39140. * Defines if touch is enabled. (Default is true.)
  39141. */
  39142. touchEnabled: boolean;
  39143. /**
  39144. * Defines the buttons associated with the input to handle camera rotation.
  39145. */
  39146. buttons: number[];
  39147. /**
  39148. * Assign buttons for Yaw control.
  39149. */
  39150. buttonsYaw: number[];
  39151. /**
  39152. * Assign buttons for Pitch control.
  39153. */
  39154. buttonsPitch: number[];
  39155. /**
  39156. * Assign buttons for Roll control.
  39157. */
  39158. buttonsRoll: number[];
  39159. /**
  39160. * Detect if any button is being pressed while mouse is moved.
  39161. * -1 = Mouse locked.
  39162. * 0 = Left button.
  39163. * 1 = Middle Button.
  39164. * 2 = Right Button.
  39165. */
  39166. activeButton: number;
  39167. /**
  39168. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39169. * Higher values reduce its sensitivity.
  39170. */
  39171. angularSensibility: number;
  39172. private _mousemoveCallback;
  39173. private _observer;
  39174. private _rollObserver;
  39175. private previousPosition;
  39176. private noPreventDefault;
  39177. private element;
  39178. /**
  39179. * Listen to mouse events to control the camera.
  39180. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39182. */
  39183. constructor(touchEnabled?: boolean);
  39184. /**
  39185. * Attach the mouse control to the HTML DOM element.
  39186. * @param element Defines the element that listens to the input events.
  39187. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39188. */
  39189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39190. /**
  39191. * Detach the current controls from the specified dom element.
  39192. * @param element Defines the element to stop listening the inputs from
  39193. */
  39194. detachControl(element: Nullable<HTMLElement>): void;
  39195. /**
  39196. * Gets the class name of the current input.
  39197. * @returns the class name.
  39198. */
  39199. getClassName(): string;
  39200. /**
  39201. * Get the friendly name associated with the input class.
  39202. * @returns the input's friendly name.
  39203. */
  39204. getSimpleName(): string;
  39205. private _pointerInput;
  39206. private _onMouseMove;
  39207. /**
  39208. * Rotate camera by mouse offset.
  39209. */
  39210. private rotateCamera;
  39211. }
  39212. }
  39213. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39214. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39215. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39216. /**
  39217. * Default Inputs manager for the FlyCamera.
  39218. * It groups all the default supported inputs for ease of use.
  39219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39220. */
  39221. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39222. /**
  39223. * Instantiates a new FlyCameraInputsManager.
  39224. * @param camera Defines the camera the inputs belong to.
  39225. */
  39226. constructor(camera: FlyCamera);
  39227. /**
  39228. * Add keyboard input support to the input manager.
  39229. * @returns the new FlyCameraKeyboardMoveInput().
  39230. */
  39231. addKeyboard(): FlyCameraInputsManager;
  39232. /**
  39233. * Add mouse input support to the input manager.
  39234. * @param touchEnabled Enable touch screen support.
  39235. * @returns the new FlyCameraMouseInput().
  39236. */
  39237. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39238. }
  39239. }
  39240. declare module "babylonjs/Cameras/flyCamera" {
  39241. import { Scene } from "babylonjs/scene";
  39242. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39244. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39245. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39246. /**
  39247. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39248. * such as in a 3D Space Shooter or a Flight Simulator.
  39249. */
  39250. export class FlyCamera extends TargetCamera {
  39251. /**
  39252. * Define the collision ellipsoid of the camera.
  39253. * This is helpful for simulating a camera body, like a player's body.
  39254. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39255. */
  39256. ellipsoid: Vector3;
  39257. /**
  39258. * Define an offset for the position of the ellipsoid around the camera.
  39259. * This can be helpful if the camera is attached away from the player's body center,
  39260. * such as at its head.
  39261. */
  39262. ellipsoidOffset: Vector3;
  39263. /**
  39264. * Enable or disable collisions of the camera with the rest of the scene objects.
  39265. */
  39266. checkCollisions: boolean;
  39267. /**
  39268. * Enable or disable gravity on the camera.
  39269. */
  39270. applyGravity: boolean;
  39271. /**
  39272. * Define the current direction the camera is moving to.
  39273. */
  39274. cameraDirection: Vector3;
  39275. /**
  39276. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39277. * This overrides and empties cameraRotation.
  39278. */
  39279. rotationQuaternion: Quaternion;
  39280. /**
  39281. * Track Roll to maintain the wanted Rolling when looking around.
  39282. */
  39283. _trackRoll: number;
  39284. /**
  39285. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39286. */
  39287. rollCorrect: number;
  39288. /**
  39289. * Mimic a banked turn, Rolling the camera when Yawing.
  39290. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39291. */
  39292. bankedTurn: boolean;
  39293. /**
  39294. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39295. */
  39296. bankedTurnLimit: number;
  39297. /**
  39298. * Value of 0 disables the banked Roll.
  39299. * Value of 1 is equal to the Yaw angle in radians.
  39300. */
  39301. bankedTurnMultiplier: number;
  39302. /**
  39303. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39304. */
  39305. inputs: FlyCameraInputsManager;
  39306. /**
  39307. * Gets the input sensibility for mouse input.
  39308. * Higher values reduce sensitivity.
  39309. */
  39310. /**
  39311. * Sets the input sensibility for a mouse input.
  39312. * Higher values reduce sensitivity.
  39313. */
  39314. angularSensibility: number;
  39315. /**
  39316. * Get the keys for camera movement forward.
  39317. */
  39318. /**
  39319. * Set the keys for camera movement forward.
  39320. */
  39321. keysForward: number[];
  39322. /**
  39323. * Get the keys for camera movement backward.
  39324. */
  39325. keysBackward: number[];
  39326. /**
  39327. * Get the keys for camera movement up.
  39328. */
  39329. /**
  39330. * Set the keys for camera movement up.
  39331. */
  39332. keysUp: number[];
  39333. /**
  39334. * Get the keys for camera movement down.
  39335. */
  39336. /**
  39337. * Set the keys for camera movement down.
  39338. */
  39339. keysDown: number[];
  39340. /**
  39341. * Get the keys for camera movement left.
  39342. */
  39343. /**
  39344. * Set the keys for camera movement left.
  39345. */
  39346. keysLeft: number[];
  39347. /**
  39348. * Set the keys for camera movement right.
  39349. */
  39350. /**
  39351. * Set the keys for camera movement right.
  39352. */
  39353. keysRight: number[];
  39354. /**
  39355. * Event raised when the camera collides with a mesh in the scene.
  39356. */
  39357. onCollide: (collidedMesh: AbstractMesh) => void;
  39358. private _collider;
  39359. private _needMoveForGravity;
  39360. private _oldPosition;
  39361. private _diffPosition;
  39362. private _newPosition;
  39363. /** @hidden */
  39364. _localDirection: Vector3;
  39365. /** @hidden */
  39366. _transformedDirection: Vector3;
  39367. /**
  39368. * Instantiates a FlyCamera.
  39369. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39370. * such as in a 3D Space Shooter or a Flight Simulator.
  39371. * @param name Define the name of the camera in the scene.
  39372. * @param position Define the starting position of the camera in the scene.
  39373. * @param scene Define the scene the camera belongs to.
  39374. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39375. */
  39376. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39377. /**
  39378. * Attach a control to the HTML DOM element.
  39379. * @param element Defines the element that listens to the input events.
  39380. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39381. */
  39382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39383. /**
  39384. * Detach a control from the HTML DOM element.
  39385. * The camera will stop reacting to that input.
  39386. * @param element Defines the element that listens to the input events.
  39387. */
  39388. detachControl(element: HTMLElement): void;
  39389. private _collisionMask;
  39390. /**
  39391. * Get the mask that the camera ignores in collision events.
  39392. */
  39393. /**
  39394. * Set the mask that the camera ignores in collision events.
  39395. */
  39396. collisionMask: number;
  39397. /** @hidden */
  39398. _collideWithWorld(displacement: Vector3): void;
  39399. /** @hidden */
  39400. private _onCollisionPositionChange;
  39401. /** @hidden */
  39402. _checkInputs(): void;
  39403. /** @hidden */
  39404. _decideIfNeedsToMove(): boolean;
  39405. /** @hidden */
  39406. _updatePosition(): void;
  39407. /**
  39408. * Restore the Roll to its target value at the rate specified.
  39409. * @param rate - Higher means slower restoring.
  39410. * @hidden
  39411. */
  39412. restoreRoll(rate: number): void;
  39413. /**
  39414. * Destroy the camera and release the current resources held by it.
  39415. */
  39416. dispose(): void;
  39417. /**
  39418. * Get the current object class name.
  39419. * @returns the class name.
  39420. */
  39421. getClassName(): string;
  39422. }
  39423. }
  39424. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39425. import { Nullable } from "babylonjs/types";
  39426. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39427. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39428. /**
  39429. * Listen to keyboard events to control the camera.
  39430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39431. */
  39432. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39433. /**
  39434. * Defines the camera the input is attached to.
  39435. */
  39436. camera: FlyCamera;
  39437. /**
  39438. * The list of keyboard keys used to control the forward move of the camera.
  39439. */
  39440. keysForward: number[];
  39441. /**
  39442. * The list of keyboard keys used to control the backward move of the camera.
  39443. */
  39444. keysBackward: number[];
  39445. /**
  39446. * The list of keyboard keys used to control the forward move of the camera.
  39447. */
  39448. keysUp: number[];
  39449. /**
  39450. * The list of keyboard keys used to control the backward move of the camera.
  39451. */
  39452. keysDown: number[];
  39453. /**
  39454. * The list of keyboard keys used to control the right strafe move of the camera.
  39455. */
  39456. keysRight: number[];
  39457. /**
  39458. * The list of keyboard keys used to control the left strafe move of the camera.
  39459. */
  39460. keysLeft: number[];
  39461. private _keys;
  39462. private _onCanvasBlurObserver;
  39463. private _onKeyboardObserver;
  39464. private _engine;
  39465. private _scene;
  39466. /**
  39467. * Attach the input controls to a specific dom element to get the input from.
  39468. * @param element Defines the element the controls should be listened from
  39469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39470. */
  39471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39472. /**
  39473. * Detach the current controls from the specified dom element.
  39474. * @param element Defines the element to stop listening the inputs from
  39475. */
  39476. detachControl(element: Nullable<HTMLElement>): void;
  39477. /**
  39478. * Gets the class name of the current intput.
  39479. * @returns the class name
  39480. */
  39481. getClassName(): string;
  39482. /** @hidden */
  39483. _onLostFocus(e: FocusEvent): void;
  39484. /**
  39485. * Get the friendly name associated with the input class.
  39486. * @returns the input friendly name
  39487. */
  39488. getSimpleName(): string;
  39489. /**
  39490. * Update the current camera state depending on the inputs that have been used this frame.
  39491. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39492. */
  39493. checkInputs(): void;
  39494. }
  39495. }
  39496. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39497. import { Nullable } from "babylonjs/types";
  39498. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39499. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39500. /**
  39501. * Manage the mouse wheel inputs to control a follow camera.
  39502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39503. */
  39504. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39505. /**
  39506. * Defines the camera the input is attached to.
  39507. */
  39508. camera: FollowCamera;
  39509. /**
  39510. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39511. */
  39512. axisControlRadius: boolean;
  39513. /**
  39514. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39515. */
  39516. axisControlHeight: boolean;
  39517. /**
  39518. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39519. */
  39520. axisControlRotation: boolean;
  39521. /**
  39522. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39523. * relation to mouseWheel events.
  39524. */
  39525. wheelPrecision: number;
  39526. /**
  39527. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39528. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39529. */
  39530. wheelDeltaPercentage: number;
  39531. private _wheel;
  39532. private _observer;
  39533. /**
  39534. * Attach the input controls to a specific dom element to get the input from.
  39535. * @param element Defines the element the controls should be listened from
  39536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39537. */
  39538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39539. /**
  39540. * Detach the current controls from the specified dom element.
  39541. * @param element Defines the element to stop listening the inputs from
  39542. */
  39543. detachControl(element: Nullable<HTMLElement>): void;
  39544. /**
  39545. * Gets the class name of the current intput.
  39546. * @returns the class name
  39547. */
  39548. getClassName(): string;
  39549. /**
  39550. * Get the friendly name associated with the input class.
  39551. * @returns the input friendly name
  39552. */
  39553. getSimpleName(): string;
  39554. }
  39555. }
  39556. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39557. import { Nullable } from "babylonjs/types";
  39558. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39559. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39560. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39561. /**
  39562. * Manage the pointers inputs to control an follow camera.
  39563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39564. */
  39565. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39566. /**
  39567. * Defines the camera the input is attached to.
  39568. */
  39569. camera: FollowCamera;
  39570. /**
  39571. * Gets the class name of the current input.
  39572. * @returns the class name
  39573. */
  39574. getClassName(): string;
  39575. /**
  39576. * Defines the pointer angular sensibility along the X axis or how fast is
  39577. * the camera rotating.
  39578. * A negative number will reverse the axis direction.
  39579. */
  39580. angularSensibilityX: number;
  39581. /**
  39582. * Defines the pointer angular sensibility along the Y axis or how fast is
  39583. * the camera rotating.
  39584. * A negative number will reverse the axis direction.
  39585. */
  39586. angularSensibilityY: number;
  39587. /**
  39588. * Defines the pointer pinch precision or how fast is the camera zooming.
  39589. * A negative number will reverse the axis direction.
  39590. */
  39591. pinchPrecision: number;
  39592. /**
  39593. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39594. * from 0.
  39595. * It defines the percentage of current camera.radius to use as delta when
  39596. * pinch zoom is used.
  39597. */
  39598. pinchDeltaPercentage: number;
  39599. /**
  39600. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39601. */
  39602. axisXControlRadius: boolean;
  39603. /**
  39604. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39605. */
  39606. axisXControlHeight: boolean;
  39607. /**
  39608. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39609. */
  39610. axisXControlRotation: boolean;
  39611. /**
  39612. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39613. */
  39614. axisYControlRadius: boolean;
  39615. /**
  39616. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39617. */
  39618. axisYControlHeight: boolean;
  39619. /**
  39620. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39621. */
  39622. axisYControlRotation: boolean;
  39623. /**
  39624. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39625. */
  39626. axisPinchControlRadius: boolean;
  39627. /**
  39628. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39629. */
  39630. axisPinchControlHeight: boolean;
  39631. /**
  39632. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39633. */
  39634. axisPinchControlRotation: boolean;
  39635. /**
  39636. * Log error messages if basic misconfiguration has occurred.
  39637. */
  39638. warningEnable: boolean;
  39639. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39640. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39641. private _warningCounter;
  39642. private _warning;
  39643. }
  39644. }
  39645. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39646. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39647. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39648. /**
  39649. * Default Inputs manager for the FollowCamera.
  39650. * It groups all the default supported inputs for ease of use.
  39651. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39652. */
  39653. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39654. /**
  39655. * Instantiates a new FollowCameraInputsManager.
  39656. * @param camera Defines the camera the inputs belong to
  39657. */
  39658. constructor(camera: FollowCamera);
  39659. /**
  39660. * Add keyboard input support to the input manager.
  39661. * @returns the current input manager
  39662. */
  39663. addKeyboard(): FollowCameraInputsManager;
  39664. /**
  39665. * Add mouse wheel input support to the input manager.
  39666. * @returns the current input manager
  39667. */
  39668. addMouseWheel(): FollowCameraInputsManager;
  39669. /**
  39670. * Add pointers input support to the input manager.
  39671. * @returns the current input manager
  39672. */
  39673. addPointers(): FollowCameraInputsManager;
  39674. /**
  39675. * Add orientation input support to the input manager.
  39676. * @returns the current input manager
  39677. */
  39678. addVRDeviceOrientation(): FollowCameraInputsManager;
  39679. }
  39680. }
  39681. declare module "babylonjs/Cameras/followCamera" {
  39682. import { Nullable } from "babylonjs/types";
  39683. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39684. import { Scene } from "babylonjs/scene";
  39685. import { Vector3 } from "babylonjs/Maths/math.vector";
  39686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39687. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39688. /**
  39689. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39690. * an arc rotate version arcFollowCamera are available.
  39691. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39692. */
  39693. export class FollowCamera extends TargetCamera {
  39694. /**
  39695. * Distance the follow camera should follow an object at
  39696. */
  39697. radius: number;
  39698. /**
  39699. * Minimum allowed distance of the camera to the axis of rotation
  39700. * (The camera can not get closer).
  39701. * This can help limiting how the Camera is able to move in the scene.
  39702. */
  39703. lowerRadiusLimit: Nullable<number>;
  39704. /**
  39705. * Maximum allowed distance of the camera to the axis of rotation
  39706. * (The camera can not get further).
  39707. * This can help limiting how the Camera is able to move in the scene.
  39708. */
  39709. upperRadiusLimit: Nullable<number>;
  39710. /**
  39711. * Define a rotation offset between the camera and the object it follows
  39712. */
  39713. rotationOffset: number;
  39714. /**
  39715. * Minimum allowed angle to camera position relative to target object.
  39716. * This can help limiting how the Camera is able to move in the scene.
  39717. */
  39718. lowerRotationOffsetLimit: Nullable<number>;
  39719. /**
  39720. * Maximum allowed angle to camera position relative to target object.
  39721. * This can help limiting how the Camera is able to move in the scene.
  39722. */
  39723. upperRotationOffsetLimit: Nullable<number>;
  39724. /**
  39725. * Define a height offset between the camera and the object it follows.
  39726. * It can help following an object from the top (like a car chaing a plane)
  39727. */
  39728. heightOffset: number;
  39729. /**
  39730. * Minimum allowed height of camera position relative to target object.
  39731. * This can help limiting how the Camera is able to move in the scene.
  39732. */
  39733. lowerHeightOffsetLimit: Nullable<number>;
  39734. /**
  39735. * Maximum allowed height of camera position relative to target object.
  39736. * This can help limiting how the Camera is able to move in the scene.
  39737. */
  39738. upperHeightOffsetLimit: Nullable<number>;
  39739. /**
  39740. * Define how fast the camera can accelerate to follow it s target.
  39741. */
  39742. cameraAcceleration: number;
  39743. /**
  39744. * Define the speed limit of the camera following an object.
  39745. */
  39746. maxCameraSpeed: number;
  39747. /**
  39748. * Define the target of the camera.
  39749. */
  39750. lockedTarget: Nullable<AbstractMesh>;
  39751. /**
  39752. * Defines the input associated with the camera.
  39753. */
  39754. inputs: FollowCameraInputsManager;
  39755. /**
  39756. * Instantiates the follow camera.
  39757. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39758. * @param name Define the name of the camera in the scene
  39759. * @param position Define the position of the camera
  39760. * @param scene Define the scene the camera belong to
  39761. * @param lockedTarget Define the target of the camera
  39762. */
  39763. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39764. private _follow;
  39765. /**
  39766. * Attached controls to the current camera.
  39767. * @param element Defines the element the controls should be listened from
  39768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39769. */
  39770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39771. /**
  39772. * Detach the current controls from the camera.
  39773. * The camera will stop reacting to inputs.
  39774. * @param element Defines the element to stop listening the inputs from
  39775. */
  39776. detachControl(element: HTMLElement): void;
  39777. /** @hidden */
  39778. _checkInputs(): void;
  39779. private _checkLimits;
  39780. /**
  39781. * Gets the camera class name.
  39782. * @returns the class name
  39783. */
  39784. getClassName(): string;
  39785. }
  39786. /**
  39787. * Arc Rotate version of the follow camera.
  39788. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39789. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39790. */
  39791. export class ArcFollowCamera extends TargetCamera {
  39792. /** The longitudinal angle of the camera */
  39793. alpha: number;
  39794. /** The latitudinal angle of the camera */
  39795. beta: number;
  39796. /** The radius of the camera from its target */
  39797. radius: number;
  39798. /** Define the camera target (the messh it should follow) */
  39799. target: Nullable<AbstractMesh>;
  39800. private _cartesianCoordinates;
  39801. /**
  39802. * Instantiates a new ArcFollowCamera
  39803. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39804. * @param name Define the name of the camera
  39805. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39806. * @param beta Define the rotation angle of the camera around the elevation axis
  39807. * @param radius Define the radius of the camera from its target point
  39808. * @param target Define the target of the camera
  39809. * @param scene Define the scene the camera belongs to
  39810. */
  39811. constructor(name: string,
  39812. /** The longitudinal angle of the camera */
  39813. alpha: number,
  39814. /** The latitudinal angle of the camera */
  39815. beta: number,
  39816. /** The radius of the camera from its target */
  39817. radius: number,
  39818. /** Define the camera target (the messh it should follow) */
  39819. target: Nullable<AbstractMesh>, scene: Scene);
  39820. private _follow;
  39821. /** @hidden */
  39822. _checkInputs(): void;
  39823. /**
  39824. * Returns the class name of the object.
  39825. * It is mostly used internally for serialization purposes.
  39826. */
  39827. getClassName(): string;
  39828. }
  39829. }
  39830. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39831. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39832. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39833. import { Nullable } from "babylonjs/types";
  39834. /**
  39835. * Manage the keyboard inputs to control the movement of a follow camera.
  39836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39837. */
  39838. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39839. /**
  39840. * Defines the camera the input is attached to.
  39841. */
  39842. camera: FollowCamera;
  39843. /**
  39844. * Defines the list of key codes associated with the up action (increase heightOffset)
  39845. */
  39846. keysHeightOffsetIncr: number[];
  39847. /**
  39848. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39849. */
  39850. keysHeightOffsetDecr: number[];
  39851. /**
  39852. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39853. */
  39854. keysHeightOffsetModifierAlt: boolean;
  39855. /**
  39856. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39857. */
  39858. keysHeightOffsetModifierCtrl: boolean;
  39859. /**
  39860. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39861. */
  39862. keysHeightOffsetModifierShift: boolean;
  39863. /**
  39864. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39865. */
  39866. keysRotationOffsetIncr: number[];
  39867. /**
  39868. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39869. */
  39870. keysRotationOffsetDecr: number[];
  39871. /**
  39872. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39873. */
  39874. keysRotationOffsetModifierAlt: boolean;
  39875. /**
  39876. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39877. */
  39878. keysRotationOffsetModifierCtrl: boolean;
  39879. /**
  39880. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39881. */
  39882. keysRotationOffsetModifierShift: boolean;
  39883. /**
  39884. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39885. */
  39886. keysRadiusIncr: number[];
  39887. /**
  39888. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39889. */
  39890. keysRadiusDecr: number[];
  39891. /**
  39892. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39893. */
  39894. keysRadiusModifierAlt: boolean;
  39895. /**
  39896. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39897. */
  39898. keysRadiusModifierCtrl: boolean;
  39899. /**
  39900. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39901. */
  39902. keysRadiusModifierShift: boolean;
  39903. /**
  39904. * Defines the rate of change of heightOffset.
  39905. */
  39906. heightSensibility: number;
  39907. /**
  39908. * Defines the rate of change of rotationOffset.
  39909. */
  39910. rotationSensibility: number;
  39911. /**
  39912. * Defines the rate of change of radius.
  39913. */
  39914. radiusSensibility: number;
  39915. private _keys;
  39916. private _ctrlPressed;
  39917. private _altPressed;
  39918. private _shiftPressed;
  39919. private _onCanvasBlurObserver;
  39920. private _onKeyboardObserver;
  39921. private _engine;
  39922. private _scene;
  39923. /**
  39924. * Attach the input controls to a specific dom element to get the input from.
  39925. * @param element Defines the element the controls should be listened from
  39926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39927. */
  39928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39929. /**
  39930. * Detach the current controls from the specified dom element.
  39931. * @param element Defines the element to stop listening the inputs from
  39932. */
  39933. detachControl(element: Nullable<HTMLElement>): void;
  39934. /**
  39935. * Update the current camera state depending on the inputs that have been used this frame.
  39936. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39937. */
  39938. checkInputs(): void;
  39939. /**
  39940. * Gets the class name of the current input.
  39941. * @returns the class name
  39942. */
  39943. getClassName(): string;
  39944. /**
  39945. * Get the friendly name associated with the input class.
  39946. * @returns the input friendly name
  39947. */
  39948. getSimpleName(): string;
  39949. /**
  39950. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39951. * allow modification of the heightOffset value.
  39952. */
  39953. private _modifierHeightOffset;
  39954. /**
  39955. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39956. * allow modification of the rotationOffset value.
  39957. */
  39958. private _modifierRotationOffset;
  39959. /**
  39960. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39961. * allow modification of the radius value.
  39962. */
  39963. private _modifierRadius;
  39964. }
  39965. }
  39966. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39967. import { Nullable } from "babylonjs/types";
  39968. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39969. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39970. import { Observable } from "babylonjs/Misc/observable";
  39971. module "babylonjs/Cameras/freeCameraInputsManager" {
  39972. interface FreeCameraInputsManager {
  39973. /**
  39974. * @hidden
  39975. */
  39976. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39977. /**
  39978. * Add orientation input support to the input manager.
  39979. * @returns the current input manager
  39980. */
  39981. addDeviceOrientation(): FreeCameraInputsManager;
  39982. }
  39983. }
  39984. /**
  39985. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39986. * Screen rotation is taken into account.
  39987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39988. */
  39989. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39990. private _camera;
  39991. private _screenOrientationAngle;
  39992. private _constantTranform;
  39993. private _screenQuaternion;
  39994. private _alpha;
  39995. private _beta;
  39996. private _gamma;
  39997. /**
  39998. * Can be used to detect if a device orientation sensor is availible on a device
  39999. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40000. * @returns a promise that will resolve on orientation change
  40001. */
  40002. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40003. /**
  40004. * @hidden
  40005. */
  40006. _onDeviceOrientationChangedObservable: Observable<void>;
  40007. /**
  40008. * Instantiates a new input
  40009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40010. */
  40011. constructor();
  40012. /**
  40013. * Define the camera controlled by the input.
  40014. */
  40015. camera: FreeCamera;
  40016. /**
  40017. * Attach the input controls to a specific dom element to get the input from.
  40018. * @param element Defines the element the controls should be listened from
  40019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40020. */
  40021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40022. private _orientationChanged;
  40023. private _deviceOrientation;
  40024. /**
  40025. * Detach the current controls from the specified dom element.
  40026. * @param element Defines the element to stop listening the inputs from
  40027. */
  40028. detachControl(element: Nullable<HTMLElement>): void;
  40029. /**
  40030. * Update the current camera state depending on the inputs that have been used this frame.
  40031. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40032. */
  40033. checkInputs(): void;
  40034. /**
  40035. * Gets the class name of the current intput.
  40036. * @returns the class name
  40037. */
  40038. getClassName(): string;
  40039. /**
  40040. * Get the friendly name associated with the input class.
  40041. * @returns the input friendly name
  40042. */
  40043. getSimpleName(): string;
  40044. }
  40045. }
  40046. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  40047. import { Nullable } from "babylonjs/types";
  40048. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40049. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40050. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40051. /**
  40052. * Manage the gamepad inputs to control a free camera.
  40053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40054. */
  40055. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40056. /**
  40057. * Define the camera the input is attached to.
  40058. */
  40059. camera: FreeCamera;
  40060. /**
  40061. * Define the Gamepad controlling the input
  40062. */
  40063. gamepad: Nullable<Gamepad>;
  40064. /**
  40065. * Defines the gamepad rotation sensiblity.
  40066. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40067. */
  40068. gamepadAngularSensibility: number;
  40069. /**
  40070. * Defines the gamepad move sensiblity.
  40071. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40072. */
  40073. gamepadMoveSensibility: number;
  40074. private _yAxisScale;
  40075. /**
  40076. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40077. */
  40078. invertYAxis: boolean;
  40079. private _onGamepadConnectedObserver;
  40080. private _onGamepadDisconnectedObserver;
  40081. private _cameraTransform;
  40082. private _deltaTransform;
  40083. private _vector3;
  40084. private _vector2;
  40085. /**
  40086. * Attach the input controls to a specific dom element to get the input from.
  40087. * @param element Defines the element the controls should be listened from
  40088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40089. */
  40090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40091. /**
  40092. * Detach the current controls from the specified dom element.
  40093. * @param element Defines the element to stop listening the inputs from
  40094. */
  40095. detachControl(element: Nullable<HTMLElement>): void;
  40096. /**
  40097. * Update the current camera state depending on the inputs that have been used this frame.
  40098. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40099. */
  40100. checkInputs(): void;
  40101. /**
  40102. * Gets the class name of the current intput.
  40103. * @returns the class name
  40104. */
  40105. getClassName(): string;
  40106. /**
  40107. * Get the friendly name associated with the input class.
  40108. * @returns the input friendly name
  40109. */
  40110. getSimpleName(): string;
  40111. }
  40112. }
  40113. declare module "babylonjs/Misc/virtualJoystick" {
  40114. import { Nullable } from "babylonjs/types";
  40115. import { Vector3 } from "babylonjs/Maths/math.vector";
  40116. /**
  40117. * Defines the potential axis of a Joystick
  40118. */
  40119. export enum JoystickAxis {
  40120. /** X axis */
  40121. X = 0,
  40122. /** Y axis */
  40123. Y = 1,
  40124. /** Z axis */
  40125. Z = 2
  40126. }
  40127. /**
  40128. * Class used to define virtual joystick (used in touch mode)
  40129. */
  40130. export class VirtualJoystick {
  40131. /**
  40132. * Gets or sets a boolean indicating that left and right values must be inverted
  40133. */
  40134. reverseLeftRight: boolean;
  40135. /**
  40136. * Gets or sets a boolean indicating that up and down values must be inverted
  40137. */
  40138. reverseUpDown: boolean;
  40139. /**
  40140. * Gets the offset value for the position (ie. the change of the position value)
  40141. */
  40142. deltaPosition: Vector3;
  40143. /**
  40144. * Gets a boolean indicating if the virtual joystick was pressed
  40145. */
  40146. pressed: boolean;
  40147. /**
  40148. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40149. */
  40150. static Canvas: Nullable<HTMLCanvasElement>;
  40151. private static _globalJoystickIndex;
  40152. private static vjCanvasContext;
  40153. private static vjCanvasWidth;
  40154. private static vjCanvasHeight;
  40155. private static halfWidth;
  40156. private _action;
  40157. private _axisTargetedByLeftAndRight;
  40158. private _axisTargetedByUpAndDown;
  40159. private _joystickSensibility;
  40160. private _inversedSensibility;
  40161. private _joystickPointerID;
  40162. private _joystickColor;
  40163. private _joystickPointerPos;
  40164. private _joystickPreviousPointerPos;
  40165. private _joystickPointerStartPos;
  40166. private _deltaJoystickVector;
  40167. private _leftJoystick;
  40168. private _touches;
  40169. private _onPointerDownHandlerRef;
  40170. private _onPointerMoveHandlerRef;
  40171. private _onPointerUpHandlerRef;
  40172. private _onResize;
  40173. /**
  40174. * Creates a new virtual joystick
  40175. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40176. */
  40177. constructor(leftJoystick?: boolean);
  40178. /**
  40179. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40180. * @param newJoystickSensibility defines the new sensibility
  40181. */
  40182. setJoystickSensibility(newJoystickSensibility: number): void;
  40183. private _onPointerDown;
  40184. private _onPointerMove;
  40185. private _onPointerUp;
  40186. /**
  40187. * Change the color of the virtual joystick
  40188. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40189. */
  40190. setJoystickColor(newColor: string): void;
  40191. /**
  40192. * Defines a callback to call when the joystick is touched
  40193. * @param action defines the callback
  40194. */
  40195. setActionOnTouch(action: () => any): void;
  40196. /**
  40197. * Defines which axis you'd like to control for left & right
  40198. * @param axis defines the axis to use
  40199. */
  40200. setAxisForLeftRight(axis: JoystickAxis): void;
  40201. /**
  40202. * Defines which axis you'd like to control for up & down
  40203. * @param axis defines the axis to use
  40204. */
  40205. setAxisForUpDown(axis: JoystickAxis): void;
  40206. private _drawVirtualJoystick;
  40207. /**
  40208. * Release internal HTML canvas
  40209. */
  40210. releaseCanvas(): void;
  40211. }
  40212. }
  40213. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  40214. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  40215. import { Nullable } from "babylonjs/types";
  40216. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40217. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40218. module "babylonjs/Cameras/freeCameraInputsManager" {
  40219. interface FreeCameraInputsManager {
  40220. /**
  40221. * Add virtual joystick input support to the input manager.
  40222. * @returns the current input manager
  40223. */
  40224. addVirtualJoystick(): FreeCameraInputsManager;
  40225. }
  40226. }
  40227. /**
  40228. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40229. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40230. */
  40231. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40232. /**
  40233. * Defines the camera the input is attached to.
  40234. */
  40235. camera: FreeCamera;
  40236. private _leftjoystick;
  40237. private _rightjoystick;
  40238. /**
  40239. * Gets the left stick of the virtual joystick.
  40240. * @returns The virtual Joystick
  40241. */
  40242. getLeftJoystick(): VirtualJoystick;
  40243. /**
  40244. * Gets the right stick of the virtual joystick.
  40245. * @returns The virtual Joystick
  40246. */
  40247. getRightJoystick(): VirtualJoystick;
  40248. /**
  40249. * Update the current camera state depending on the inputs that have been used this frame.
  40250. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40251. */
  40252. checkInputs(): void;
  40253. /**
  40254. * Attach the input controls to a specific dom element to get the input from.
  40255. * @param element Defines the element the controls should be listened from
  40256. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40257. */
  40258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40259. /**
  40260. * Detach the current controls from the specified dom element.
  40261. * @param element Defines the element to stop listening the inputs from
  40262. */
  40263. detachControl(element: Nullable<HTMLElement>): void;
  40264. /**
  40265. * Gets the class name of the current intput.
  40266. * @returns the class name
  40267. */
  40268. getClassName(): string;
  40269. /**
  40270. * Get the friendly name associated with the input class.
  40271. * @returns the input friendly name
  40272. */
  40273. getSimpleName(): string;
  40274. }
  40275. }
  40276. declare module "babylonjs/Cameras/Inputs/index" {
  40277. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40278. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40279. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40280. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40281. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40282. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40283. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40284. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40285. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40286. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40287. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40288. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40289. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40290. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40291. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40292. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40293. }
  40294. declare module "babylonjs/Cameras/touchCamera" {
  40295. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40296. import { Scene } from "babylonjs/scene";
  40297. import { Vector3 } from "babylonjs/Maths/math.vector";
  40298. /**
  40299. * This represents a FPS type of camera controlled by touch.
  40300. * This is like a universal camera minus the Gamepad controls.
  40301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40302. */
  40303. export class TouchCamera extends FreeCamera {
  40304. /**
  40305. * Defines the touch sensibility for rotation.
  40306. * The higher the faster.
  40307. */
  40308. touchAngularSensibility: number;
  40309. /**
  40310. * Defines the touch sensibility for move.
  40311. * The higher the faster.
  40312. */
  40313. touchMoveSensibility: number;
  40314. /**
  40315. * Instantiates a new touch camera.
  40316. * This represents a FPS type of camera controlled by touch.
  40317. * This is like a universal camera minus the Gamepad controls.
  40318. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40319. * @param name Define the name of the camera in the scene
  40320. * @param position Define the start position of the camera in the scene
  40321. * @param scene Define the scene the camera belongs to
  40322. */
  40323. constructor(name: string, position: Vector3, scene: Scene);
  40324. /**
  40325. * Gets the current object class name.
  40326. * @return the class name
  40327. */
  40328. getClassName(): string;
  40329. /** @hidden */
  40330. _setupInputs(): void;
  40331. }
  40332. }
  40333. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40334. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40335. import { Scene } from "babylonjs/scene";
  40336. import { Vector3 } from "babylonjs/Maths/math.vector";
  40337. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40338. import { Axis } from "babylonjs/Maths/math.axis";
  40339. /**
  40340. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40341. * being tilted forward or back and left or right.
  40342. */
  40343. export class DeviceOrientationCamera extends FreeCamera {
  40344. private _initialQuaternion;
  40345. private _quaternionCache;
  40346. private _tmpDragQuaternion;
  40347. private _disablePointerInputWhenUsingDeviceOrientation;
  40348. /**
  40349. * Creates a new device orientation camera
  40350. * @param name The name of the camera
  40351. * @param position The start position camera
  40352. * @param scene The scene the camera belongs to
  40353. */
  40354. constructor(name: string, position: Vector3, scene: Scene);
  40355. /**
  40356. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40357. */
  40358. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40359. private _dragFactor;
  40360. /**
  40361. * Enabled turning on the y axis when the orientation sensor is active
  40362. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40363. */
  40364. enableHorizontalDragging(dragFactor?: number): void;
  40365. /**
  40366. * Gets the current instance class name ("DeviceOrientationCamera").
  40367. * This helps avoiding instanceof at run time.
  40368. * @returns the class name
  40369. */
  40370. getClassName(): string;
  40371. /**
  40372. * @hidden
  40373. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40374. */
  40375. _checkInputs(): void;
  40376. /**
  40377. * Reset the camera to its default orientation on the specified axis only.
  40378. * @param axis The axis to reset
  40379. */
  40380. resetToCurrentRotation(axis?: Axis): void;
  40381. }
  40382. }
  40383. declare module "babylonjs/Gamepads/xboxGamepad" {
  40384. import { Observable } from "babylonjs/Misc/observable";
  40385. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40386. /**
  40387. * Defines supported buttons for XBox360 compatible gamepads
  40388. */
  40389. export enum Xbox360Button {
  40390. /** A */
  40391. A = 0,
  40392. /** B */
  40393. B = 1,
  40394. /** X */
  40395. X = 2,
  40396. /** Y */
  40397. Y = 3,
  40398. /** Start */
  40399. Start = 4,
  40400. /** Back */
  40401. Back = 5,
  40402. /** Left button */
  40403. LB = 6,
  40404. /** Right button */
  40405. RB = 7,
  40406. /** Left stick */
  40407. LeftStick = 8,
  40408. /** Right stick */
  40409. RightStick = 9
  40410. }
  40411. /** Defines values for XBox360 DPad */
  40412. export enum Xbox360Dpad {
  40413. /** Up */
  40414. Up = 0,
  40415. /** Down */
  40416. Down = 1,
  40417. /** Left */
  40418. Left = 2,
  40419. /** Right */
  40420. Right = 3
  40421. }
  40422. /**
  40423. * Defines a XBox360 gamepad
  40424. */
  40425. export class Xbox360Pad extends Gamepad {
  40426. private _leftTrigger;
  40427. private _rightTrigger;
  40428. private _onlefttriggerchanged;
  40429. private _onrighttriggerchanged;
  40430. private _onbuttondown;
  40431. private _onbuttonup;
  40432. private _ondpaddown;
  40433. private _ondpadup;
  40434. /** Observable raised when a button is pressed */
  40435. onButtonDownObservable: Observable<Xbox360Button>;
  40436. /** Observable raised when a button is released */
  40437. onButtonUpObservable: Observable<Xbox360Button>;
  40438. /** Observable raised when a pad is pressed */
  40439. onPadDownObservable: Observable<Xbox360Dpad>;
  40440. /** Observable raised when a pad is released */
  40441. onPadUpObservable: Observable<Xbox360Dpad>;
  40442. private _buttonA;
  40443. private _buttonB;
  40444. private _buttonX;
  40445. private _buttonY;
  40446. private _buttonBack;
  40447. private _buttonStart;
  40448. private _buttonLB;
  40449. private _buttonRB;
  40450. private _buttonLeftStick;
  40451. private _buttonRightStick;
  40452. private _dPadUp;
  40453. private _dPadDown;
  40454. private _dPadLeft;
  40455. private _dPadRight;
  40456. private _isXboxOnePad;
  40457. /**
  40458. * Creates a new XBox360 gamepad object
  40459. * @param id defines the id of this gamepad
  40460. * @param index defines its index
  40461. * @param gamepad defines the internal HTML gamepad object
  40462. * @param xboxOne defines if it is a XBox One gamepad
  40463. */
  40464. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40465. /**
  40466. * Defines the callback to call when left trigger is pressed
  40467. * @param callback defines the callback to use
  40468. */
  40469. onlefttriggerchanged(callback: (value: number) => void): void;
  40470. /**
  40471. * Defines the callback to call when right trigger is pressed
  40472. * @param callback defines the callback to use
  40473. */
  40474. onrighttriggerchanged(callback: (value: number) => void): void;
  40475. /**
  40476. * Gets the left trigger value
  40477. */
  40478. /**
  40479. * Sets the left trigger value
  40480. */
  40481. leftTrigger: number;
  40482. /**
  40483. * Gets the right trigger value
  40484. */
  40485. /**
  40486. * Sets the right trigger value
  40487. */
  40488. rightTrigger: number;
  40489. /**
  40490. * Defines the callback to call when a button is pressed
  40491. * @param callback defines the callback to use
  40492. */
  40493. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40494. /**
  40495. * Defines the callback to call when a button is released
  40496. * @param callback defines the callback to use
  40497. */
  40498. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40499. /**
  40500. * Defines the callback to call when a pad is pressed
  40501. * @param callback defines the callback to use
  40502. */
  40503. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40504. /**
  40505. * Defines the callback to call when a pad is released
  40506. * @param callback defines the callback to use
  40507. */
  40508. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40509. private _setButtonValue;
  40510. private _setDPadValue;
  40511. /**
  40512. * Gets the value of the `A` button
  40513. */
  40514. /**
  40515. * Sets the value of the `A` button
  40516. */
  40517. buttonA: number;
  40518. /**
  40519. * Gets the value of the `B` button
  40520. */
  40521. /**
  40522. * Sets the value of the `B` button
  40523. */
  40524. buttonB: number;
  40525. /**
  40526. * Gets the value of the `X` button
  40527. */
  40528. /**
  40529. * Sets the value of the `X` button
  40530. */
  40531. buttonX: number;
  40532. /**
  40533. * Gets the value of the `Y` button
  40534. */
  40535. /**
  40536. * Sets the value of the `Y` button
  40537. */
  40538. buttonY: number;
  40539. /**
  40540. * Gets the value of the `Start` button
  40541. */
  40542. /**
  40543. * Sets the value of the `Start` button
  40544. */
  40545. buttonStart: number;
  40546. /**
  40547. * Gets the value of the `Back` button
  40548. */
  40549. /**
  40550. * Sets the value of the `Back` button
  40551. */
  40552. buttonBack: number;
  40553. /**
  40554. * Gets the value of the `Left` button
  40555. */
  40556. /**
  40557. * Sets the value of the `Left` button
  40558. */
  40559. buttonLB: number;
  40560. /**
  40561. * Gets the value of the `Right` button
  40562. */
  40563. /**
  40564. * Sets the value of the `Right` button
  40565. */
  40566. buttonRB: number;
  40567. /**
  40568. * Gets the value of the Left joystick
  40569. */
  40570. /**
  40571. * Sets the value of the Left joystick
  40572. */
  40573. buttonLeftStick: number;
  40574. /**
  40575. * Gets the value of the Right joystick
  40576. */
  40577. /**
  40578. * Sets the value of the Right joystick
  40579. */
  40580. buttonRightStick: number;
  40581. /**
  40582. * Gets the value of D-pad up
  40583. */
  40584. /**
  40585. * Sets the value of D-pad up
  40586. */
  40587. dPadUp: number;
  40588. /**
  40589. * Gets the value of D-pad down
  40590. */
  40591. /**
  40592. * Sets the value of D-pad down
  40593. */
  40594. dPadDown: number;
  40595. /**
  40596. * Gets the value of D-pad left
  40597. */
  40598. /**
  40599. * Sets the value of D-pad left
  40600. */
  40601. dPadLeft: number;
  40602. /**
  40603. * Gets the value of D-pad right
  40604. */
  40605. /**
  40606. * Sets the value of D-pad right
  40607. */
  40608. dPadRight: number;
  40609. /**
  40610. * Force the gamepad to synchronize with device values
  40611. */
  40612. update(): void;
  40613. /**
  40614. * Disposes the gamepad
  40615. */
  40616. dispose(): void;
  40617. }
  40618. }
  40619. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40620. import { Observable } from "babylonjs/Misc/observable";
  40621. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40622. /**
  40623. * Defines supported buttons for DualShock compatible gamepads
  40624. */
  40625. export enum DualShockButton {
  40626. /** Cross */
  40627. Cross = 0,
  40628. /** Circle */
  40629. Circle = 1,
  40630. /** Square */
  40631. Square = 2,
  40632. /** Triangle */
  40633. Triangle = 3,
  40634. /** Options */
  40635. Options = 4,
  40636. /** Share */
  40637. Share = 5,
  40638. /** L1 */
  40639. L1 = 6,
  40640. /** R1 */
  40641. R1 = 7,
  40642. /** Left stick */
  40643. LeftStick = 8,
  40644. /** Right stick */
  40645. RightStick = 9
  40646. }
  40647. /** Defines values for DualShock DPad */
  40648. export enum DualShockDpad {
  40649. /** Up */
  40650. Up = 0,
  40651. /** Down */
  40652. Down = 1,
  40653. /** Left */
  40654. Left = 2,
  40655. /** Right */
  40656. Right = 3
  40657. }
  40658. /**
  40659. * Defines a DualShock gamepad
  40660. */
  40661. export class DualShockPad extends Gamepad {
  40662. private _leftTrigger;
  40663. private _rightTrigger;
  40664. private _onlefttriggerchanged;
  40665. private _onrighttriggerchanged;
  40666. private _onbuttondown;
  40667. private _onbuttonup;
  40668. private _ondpaddown;
  40669. private _ondpadup;
  40670. /** Observable raised when a button is pressed */
  40671. onButtonDownObservable: Observable<DualShockButton>;
  40672. /** Observable raised when a button is released */
  40673. onButtonUpObservable: Observable<DualShockButton>;
  40674. /** Observable raised when a pad is pressed */
  40675. onPadDownObservable: Observable<DualShockDpad>;
  40676. /** Observable raised when a pad is released */
  40677. onPadUpObservable: Observable<DualShockDpad>;
  40678. private _buttonCross;
  40679. private _buttonCircle;
  40680. private _buttonSquare;
  40681. private _buttonTriangle;
  40682. private _buttonShare;
  40683. private _buttonOptions;
  40684. private _buttonL1;
  40685. private _buttonR1;
  40686. private _buttonLeftStick;
  40687. private _buttonRightStick;
  40688. private _dPadUp;
  40689. private _dPadDown;
  40690. private _dPadLeft;
  40691. private _dPadRight;
  40692. /**
  40693. * Creates a new DualShock gamepad object
  40694. * @param id defines the id of this gamepad
  40695. * @param index defines its index
  40696. * @param gamepad defines the internal HTML gamepad object
  40697. */
  40698. constructor(id: string, index: number, gamepad: any);
  40699. /**
  40700. * Defines the callback to call when left trigger is pressed
  40701. * @param callback defines the callback to use
  40702. */
  40703. onlefttriggerchanged(callback: (value: number) => void): void;
  40704. /**
  40705. * Defines the callback to call when right trigger is pressed
  40706. * @param callback defines the callback to use
  40707. */
  40708. onrighttriggerchanged(callback: (value: number) => void): void;
  40709. /**
  40710. * Gets the left trigger value
  40711. */
  40712. /**
  40713. * Sets the left trigger value
  40714. */
  40715. leftTrigger: number;
  40716. /**
  40717. * Gets the right trigger value
  40718. */
  40719. /**
  40720. * Sets the right trigger value
  40721. */
  40722. rightTrigger: number;
  40723. /**
  40724. * Defines the callback to call when a button is pressed
  40725. * @param callback defines the callback to use
  40726. */
  40727. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40728. /**
  40729. * Defines the callback to call when a button is released
  40730. * @param callback defines the callback to use
  40731. */
  40732. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40733. /**
  40734. * Defines the callback to call when a pad is pressed
  40735. * @param callback defines the callback to use
  40736. */
  40737. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40738. /**
  40739. * Defines the callback to call when a pad is released
  40740. * @param callback defines the callback to use
  40741. */
  40742. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40743. private _setButtonValue;
  40744. private _setDPadValue;
  40745. /**
  40746. * Gets the value of the `Cross` button
  40747. */
  40748. /**
  40749. * Sets the value of the `Cross` button
  40750. */
  40751. buttonCross: number;
  40752. /**
  40753. * Gets the value of the `Circle` button
  40754. */
  40755. /**
  40756. * Sets the value of the `Circle` button
  40757. */
  40758. buttonCircle: number;
  40759. /**
  40760. * Gets the value of the `Square` button
  40761. */
  40762. /**
  40763. * Sets the value of the `Square` button
  40764. */
  40765. buttonSquare: number;
  40766. /**
  40767. * Gets the value of the `Triangle` button
  40768. */
  40769. /**
  40770. * Sets the value of the `Triangle` button
  40771. */
  40772. buttonTriangle: number;
  40773. /**
  40774. * Gets the value of the `Options` button
  40775. */
  40776. /**
  40777. * Sets the value of the `Options` button
  40778. */
  40779. buttonOptions: number;
  40780. /**
  40781. * Gets the value of the `Share` button
  40782. */
  40783. /**
  40784. * Sets the value of the `Share` button
  40785. */
  40786. buttonShare: number;
  40787. /**
  40788. * Gets the value of the `L1` button
  40789. */
  40790. /**
  40791. * Sets the value of the `L1` button
  40792. */
  40793. buttonL1: number;
  40794. /**
  40795. * Gets the value of the `R1` button
  40796. */
  40797. /**
  40798. * Sets the value of the `R1` button
  40799. */
  40800. buttonR1: number;
  40801. /**
  40802. * Gets the value of the Left joystick
  40803. */
  40804. /**
  40805. * Sets the value of the Left joystick
  40806. */
  40807. buttonLeftStick: number;
  40808. /**
  40809. * Gets the value of the Right joystick
  40810. */
  40811. /**
  40812. * Sets the value of the Right joystick
  40813. */
  40814. buttonRightStick: number;
  40815. /**
  40816. * Gets the value of D-pad up
  40817. */
  40818. /**
  40819. * Sets the value of D-pad up
  40820. */
  40821. dPadUp: number;
  40822. /**
  40823. * Gets the value of D-pad down
  40824. */
  40825. /**
  40826. * Sets the value of D-pad down
  40827. */
  40828. dPadDown: number;
  40829. /**
  40830. * Gets the value of D-pad left
  40831. */
  40832. /**
  40833. * Sets the value of D-pad left
  40834. */
  40835. dPadLeft: number;
  40836. /**
  40837. * Gets the value of D-pad right
  40838. */
  40839. /**
  40840. * Sets the value of D-pad right
  40841. */
  40842. dPadRight: number;
  40843. /**
  40844. * Force the gamepad to synchronize with device values
  40845. */
  40846. update(): void;
  40847. /**
  40848. * Disposes the gamepad
  40849. */
  40850. dispose(): void;
  40851. }
  40852. }
  40853. declare module "babylonjs/Gamepads/gamepadManager" {
  40854. import { Observable } from "babylonjs/Misc/observable";
  40855. import { Nullable } from "babylonjs/types";
  40856. import { Scene } from "babylonjs/scene";
  40857. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40858. /**
  40859. * Manager for handling gamepads
  40860. */
  40861. export class GamepadManager {
  40862. private _scene?;
  40863. private _babylonGamepads;
  40864. private _oneGamepadConnected;
  40865. /** @hidden */
  40866. _isMonitoring: boolean;
  40867. private _gamepadEventSupported;
  40868. private _gamepadSupport;
  40869. /**
  40870. * observable to be triggered when the gamepad controller has been connected
  40871. */
  40872. onGamepadConnectedObservable: Observable<Gamepad>;
  40873. /**
  40874. * observable to be triggered when the gamepad controller has been disconnected
  40875. */
  40876. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40877. private _onGamepadConnectedEvent;
  40878. private _onGamepadDisconnectedEvent;
  40879. /**
  40880. * Initializes the gamepad manager
  40881. * @param _scene BabylonJS scene
  40882. */
  40883. constructor(_scene?: Scene | undefined);
  40884. /**
  40885. * The gamepads in the game pad manager
  40886. */
  40887. readonly gamepads: Gamepad[];
  40888. /**
  40889. * Get the gamepad controllers based on type
  40890. * @param type The type of gamepad controller
  40891. * @returns Nullable gamepad
  40892. */
  40893. getGamepadByType(type?: number): Nullable<Gamepad>;
  40894. /**
  40895. * Disposes the gamepad manager
  40896. */
  40897. dispose(): void;
  40898. private _addNewGamepad;
  40899. private _startMonitoringGamepads;
  40900. private _stopMonitoringGamepads;
  40901. /** @hidden */
  40902. _checkGamepadsStatus(): void;
  40903. private _updateGamepadObjects;
  40904. }
  40905. }
  40906. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40907. import { Nullable } from "babylonjs/types";
  40908. import { Scene } from "babylonjs/scene";
  40909. import { ISceneComponent } from "babylonjs/sceneComponent";
  40910. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40911. module "babylonjs/scene" {
  40912. interface Scene {
  40913. /** @hidden */
  40914. _gamepadManager: Nullable<GamepadManager>;
  40915. /**
  40916. * Gets the gamepad manager associated with the scene
  40917. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40918. */
  40919. gamepadManager: GamepadManager;
  40920. }
  40921. }
  40922. module "babylonjs/Cameras/freeCameraInputsManager" {
  40923. /**
  40924. * Interface representing a free camera inputs manager
  40925. */
  40926. interface FreeCameraInputsManager {
  40927. /**
  40928. * Adds gamepad input support to the FreeCameraInputsManager.
  40929. * @returns the FreeCameraInputsManager
  40930. */
  40931. addGamepad(): FreeCameraInputsManager;
  40932. }
  40933. }
  40934. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40935. /**
  40936. * Interface representing an arc rotate camera inputs manager
  40937. */
  40938. interface ArcRotateCameraInputsManager {
  40939. /**
  40940. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40941. * @returns the camera inputs manager
  40942. */
  40943. addGamepad(): ArcRotateCameraInputsManager;
  40944. }
  40945. }
  40946. /**
  40947. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40948. */
  40949. export class GamepadSystemSceneComponent implements ISceneComponent {
  40950. /**
  40951. * The component name helpfull to identify the component in the list of scene components.
  40952. */
  40953. readonly name: string;
  40954. /**
  40955. * The scene the component belongs to.
  40956. */
  40957. scene: Scene;
  40958. /**
  40959. * Creates a new instance of the component for the given scene
  40960. * @param scene Defines the scene to register the component in
  40961. */
  40962. constructor(scene: Scene);
  40963. /**
  40964. * Registers the component in a given scene
  40965. */
  40966. register(): void;
  40967. /**
  40968. * Rebuilds the elements related to this component in case of
  40969. * context lost for instance.
  40970. */
  40971. rebuild(): void;
  40972. /**
  40973. * Disposes the component and the associated ressources
  40974. */
  40975. dispose(): void;
  40976. private _beforeCameraUpdate;
  40977. }
  40978. }
  40979. declare module "babylonjs/Cameras/universalCamera" {
  40980. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40981. import { Scene } from "babylonjs/scene";
  40982. import { Vector3 } from "babylonjs/Maths/math.vector";
  40983. import "babylonjs/Gamepads/gamepadSceneComponent";
  40984. /**
  40985. * 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,
  40986. * which still works and will still be found in many Playgrounds.
  40987. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40988. */
  40989. export class UniversalCamera extends TouchCamera {
  40990. /**
  40991. * Defines the gamepad rotation sensiblity.
  40992. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40993. */
  40994. gamepadAngularSensibility: number;
  40995. /**
  40996. * Defines the gamepad move sensiblity.
  40997. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40998. */
  40999. gamepadMoveSensibility: number;
  41000. /**
  41001. * 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,
  41002. * which still works and will still be found in many Playgrounds.
  41003. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41004. * @param name Define the name of the camera in the scene
  41005. * @param position Define the start position of the camera in the scene
  41006. * @param scene Define the scene the camera belongs to
  41007. */
  41008. constructor(name: string, position: Vector3, scene: Scene);
  41009. /**
  41010. * Gets the current object class name.
  41011. * @return the class name
  41012. */
  41013. getClassName(): string;
  41014. }
  41015. }
  41016. declare module "babylonjs/Cameras/gamepadCamera" {
  41017. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41018. import { Scene } from "babylonjs/scene";
  41019. import { Vector3 } from "babylonjs/Maths/math.vector";
  41020. /**
  41021. * This represents a FPS type of camera. This is only here for back compat purpose.
  41022. * Please use the UniversalCamera instead as both are identical.
  41023. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41024. */
  41025. export class GamepadCamera extends UniversalCamera {
  41026. /**
  41027. * Instantiates a new Gamepad Camera
  41028. * This represents a FPS type of camera. This is only here for back compat purpose.
  41029. * Please use the UniversalCamera instead as both are identical.
  41030. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41031. * @param name Define the name of the camera in the scene
  41032. * @param position Define the start position of the camera in the scene
  41033. * @param scene Define the scene the camera belongs to
  41034. */
  41035. constructor(name: string, position: Vector3, scene: Scene);
  41036. /**
  41037. * Gets the current object class name.
  41038. * @return the class name
  41039. */
  41040. getClassName(): string;
  41041. }
  41042. }
  41043. declare module "babylonjs/Shaders/pass.fragment" {
  41044. /** @hidden */
  41045. export var passPixelShader: {
  41046. name: string;
  41047. shader: string;
  41048. };
  41049. }
  41050. declare module "babylonjs/Shaders/passCube.fragment" {
  41051. /** @hidden */
  41052. export var passCubePixelShader: {
  41053. name: string;
  41054. shader: string;
  41055. };
  41056. }
  41057. declare module "babylonjs/PostProcesses/passPostProcess" {
  41058. import { Nullable } from "babylonjs/types";
  41059. import { Camera } from "babylonjs/Cameras/camera";
  41060. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41061. import { Engine } from "babylonjs/Engines/engine";
  41062. import "babylonjs/Shaders/pass.fragment";
  41063. import "babylonjs/Shaders/passCube.fragment";
  41064. /**
  41065. * PassPostProcess which produces an output the same as it's input
  41066. */
  41067. export class PassPostProcess extends PostProcess {
  41068. /**
  41069. * Creates the PassPostProcess
  41070. * @param name The name of the effect.
  41071. * @param options The required width/height ratio to downsize to before computing the render pass.
  41072. * @param camera The camera to apply the render pass to.
  41073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41074. * @param engine The engine which the post process will be applied. (default: current engine)
  41075. * @param reusable If the post process can be reused on the same frame. (default: false)
  41076. * @param textureType The type of texture to be used when performing the post processing.
  41077. * @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)
  41078. */
  41079. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41080. }
  41081. /**
  41082. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41083. */
  41084. export class PassCubePostProcess extends PostProcess {
  41085. private _face;
  41086. /**
  41087. * Gets or sets the cube face to display.
  41088. * * 0 is +X
  41089. * * 1 is -X
  41090. * * 2 is +Y
  41091. * * 3 is -Y
  41092. * * 4 is +Z
  41093. * * 5 is -Z
  41094. */
  41095. face: number;
  41096. /**
  41097. * Creates the PassCubePostProcess
  41098. * @param name The name of the effect.
  41099. * @param options The required width/height ratio to downsize to before computing the render pass.
  41100. * @param camera The camera to apply the render pass to.
  41101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41102. * @param engine The engine which the post process will be applied. (default: current engine)
  41103. * @param reusable If the post process can be reused on the same frame. (default: false)
  41104. * @param textureType The type of texture to be used when performing the post processing.
  41105. * @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)
  41106. */
  41107. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41108. }
  41109. }
  41110. declare module "babylonjs/Shaders/anaglyph.fragment" {
  41111. /** @hidden */
  41112. export var anaglyphPixelShader: {
  41113. name: string;
  41114. shader: string;
  41115. };
  41116. }
  41117. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  41118. import { Engine } from "babylonjs/Engines/engine";
  41119. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41120. import { Camera } from "babylonjs/Cameras/camera";
  41121. import "babylonjs/Shaders/anaglyph.fragment";
  41122. /**
  41123. * Postprocess used to generate anaglyphic rendering
  41124. */
  41125. export class AnaglyphPostProcess extends PostProcess {
  41126. private _passedProcess;
  41127. /**
  41128. * Creates a new AnaglyphPostProcess
  41129. * @param name defines postprocess name
  41130. * @param options defines creation options or target ratio scale
  41131. * @param rigCameras defines cameras using this postprocess
  41132. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41133. * @param engine defines hosting engine
  41134. * @param reusable defines if the postprocess will be reused multiple times per frame
  41135. */
  41136. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41137. }
  41138. }
  41139. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  41140. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  41141. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41142. import { Scene } from "babylonjs/scene";
  41143. import { Vector3 } from "babylonjs/Maths/math.vector";
  41144. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41145. /**
  41146. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41147. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41148. */
  41149. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41150. /**
  41151. * Creates a new AnaglyphArcRotateCamera
  41152. * @param name defines camera name
  41153. * @param alpha defines alpha angle (in radians)
  41154. * @param beta defines beta angle (in radians)
  41155. * @param radius defines radius
  41156. * @param target defines camera target
  41157. * @param interaxialDistance defines distance between each color axis
  41158. * @param scene defines the hosting scene
  41159. */
  41160. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41161. /**
  41162. * Gets camera class name
  41163. * @returns AnaglyphArcRotateCamera
  41164. */
  41165. getClassName(): string;
  41166. }
  41167. }
  41168. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  41169. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41170. import { Scene } from "babylonjs/scene";
  41171. import { Vector3 } from "babylonjs/Maths/math.vector";
  41172. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41173. /**
  41174. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41175. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41176. */
  41177. export class AnaglyphFreeCamera extends FreeCamera {
  41178. /**
  41179. * Creates a new AnaglyphFreeCamera
  41180. * @param name defines camera name
  41181. * @param position defines initial position
  41182. * @param interaxialDistance defines distance between each color axis
  41183. * @param scene defines the hosting scene
  41184. */
  41185. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41186. /**
  41187. * Gets camera class name
  41188. * @returns AnaglyphFreeCamera
  41189. */
  41190. getClassName(): string;
  41191. }
  41192. }
  41193. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  41194. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41195. import { Scene } from "babylonjs/scene";
  41196. import { Vector3 } from "babylonjs/Maths/math.vector";
  41197. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41198. /**
  41199. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41200. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41201. */
  41202. export class AnaglyphGamepadCamera extends GamepadCamera {
  41203. /**
  41204. * Creates a new AnaglyphGamepadCamera
  41205. * @param name defines camera name
  41206. * @param position defines initial position
  41207. * @param interaxialDistance defines distance between each color axis
  41208. * @param scene defines the hosting scene
  41209. */
  41210. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41211. /**
  41212. * Gets camera class name
  41213. * @returns AnaglyphGamepadCamera
  41214. */
  41215. getClassName(): string;
  41216. }
  41217. }
  41218. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  41219. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41220. import { Scene } from "babylonjs/scene";
  41221. import { Vector3 } from "babylonjs/Maths/math.vector";
  41222. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41223. /**
  41224. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41225. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41226. */
  41227. export class AnaglyphUniversalCamera extends UniversalCamera {
  41228. /**
  41229. * Creates a new AnaglyphUniversalCamera
  41230. * @param name defines camera name
  41231. * @param position defines initial position
  41232. * @param interaxialDistance defines distance between each color axis
  41233. * @param scene defines the hosting scene
  41234. */
  41235. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41236. /**
  41237. * Gets camera class name
  41238. * @returns AnaglyphUniversalCamera
  41239. */
  41240. getClassName(): string;
  41241. }
  41242. }
  41243. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41244. /** @hidden */
  41245. export var stereoscopicInterlacePixelShader: {
  41246. name: string;
  41247. shader: string;
  41248. };
  41249. }
  41250. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41251. import { Camera } from "babylonjs/Cameras/camera";
  41252. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41253. import { Engine } from "babylonjs/Engines/engine";
  41254. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41255. /**
  41256. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41257. */
  41258. export class StereoscopicInterlacePostProcess extends PostProcess {
  41259. private _stepSize;
  41260. private _passedProcess;
  41261. /**
  41262. * Initializes a StereoscopicInterlacePostProcess
  41263. * @param name The name of the effect.
  41264. * @param rigCameras The rig cameras to be appled to the post process
  41265. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41267. * @param engine The engine which the post process will be applied. (default: current engine)
  41268. * @param reusable If the post process can be reused on the same frame. (default: false)
  41269. */
  41270. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41271. }
  41272. }
  41273. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41274. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41275. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41276. import { Scene } from "babylonjs/scene";
  41277. import { Vector3 } from "babylonjs/Maths/math.vector";
  41278. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41279. /**
  41280. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41281. * @see http://doc.babylonjs.com/features/cameras
  41282. */
  41283. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41284. /**
  41285. * Creates a new StereoscopicArcRotateCamera
  41286. * @param name defines camera name
  41287. * @param alpha defines alpha angle (in radians)
  41288. * @param beta defines beta angle (in radians)
  41289. * @param radius defines radius
  41290. * @param target defines camera target
  41291. * @param interaxialDistance defines distance between each color axis
  41292. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41293. * @param scene defines the hosting scene
  41294. */
  41295. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41296. /**
  41297. * Gets camera class name
  41298. * @returns StereoscopicArcRotateCamera
  41299. */
  41300. getClassName(): string;
  41301. }
  41302. }
  41303. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41304. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41305. import { Scene } from "babylonjs/scene";
  41306. import { Vector3 } from "babylonjs/Maths/math.vector";
  41307. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41308. /**
  41309. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41310. * @see http://doc.babylonjs.com/features/cameras
  41311. */
  41312. export class StereoscopicFreeCamera extends FreeCamera {
  41313. /**
  41314. * Creates a new StereoscopicFreeCamera
  41315. * @param name defines camera name
  41316. * @param position defines initial position
  41317. * @param interaxialDistance defines distance between each color axis
  41318. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41319. * @param scene defines the hosting scene
  41320. */
  41321. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41322. /**
  41323. * Gets camera class name
  41324. * @returns StereoscopicFreeCamera
  41325. */
  41326. getClassName(): string;
  41327. }
  41328. }
  41329. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41330. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41331. import { Scene } from "babylonjs/scene";
  41332. import { Vector3 } from "babylonjs/Maths/math.vector";
  41333. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41334. /**
  41335. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41336. * @see http://doc.babylonjs.com/features/cameras
  41337. */
  41338. export class StereoscopicGamepadCamera extends GamepadCamera {
  41339. /**
  41340. * Creates a new StereoscopicGamepadCamera
  41341. * @param name defines camera name
  41342. * @param position defines initial position
  41343. * @param interaxialDistance defines distance between each color axis
  41344. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41345. * @param scene defines the hosting scene
  41346. */
  41347. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41348. /**
  41349. * Gets camera class name
  41350. * @returns StereoscopicGamepadCamera
  41351. */
  41352. getClassName(): string;
  41353. }
  41354. }
  41355. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41356. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41357. import { Scene } from "babylonjs/scene";
  41358. import { Vector3 } from "babylonjs/Maths/math.vector";
  41359. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41360. /**
  41361. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41362. * @see http://doc.babylonjs.com/features/cameras
  41363. */
  41364. export class StereoscopicUniversalCamera extends UniversalCamera {
  41365. /**
  41366. * Creates a new StereoscopicUniversalCamera
  41367. * @param name defines camera name
  41368. * @param position defines initial position
  41369. * @param interaxialDistance defines distance between each color axis
  41370. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41371. * @param scene defines the hosting scene
  41372. */
  41373. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41374. /**
  41375. * Gets camera class name
  41376. * @returns StereoscopicUniversalCamera
  41377. */
  41378. getClassName(): string;
  41379. }
  41380. }
  41381. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41382. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41383. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41384. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41385. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41386. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41387. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41388. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41389. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41390. }
  41391. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41392. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41393. import { Scene } from "babylonjs/scene";
  41394. import { Vector3 } from "babylonjs/Maths/math.vector";
  41395. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41396. /**
  41397. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41398. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41399. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41400. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41401. */
  41402. export class VirtualJoysticksCamera extends FreeCamera {
  41403. /**
  41404. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41405. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41406. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41407. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41408. * @param name Define the name of the camera in the scene
  41409. * @param position Define the start position of the camera in the scene
  41410. * @param scene Define the scene the camera belongs to
  41411. */
  41412. constructor(name: string, position: Vector3, scene: Scene);
  41413. /**
  41414. * Gets the current object class name.
  41415. * @return the class name
  41416. */
  41417. getClassName(): string;
  41418. }
  41419. }
  41420. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41421. import { Matrix } from "babylonjs/Maths/math.vector";
  41422. /**
  41423. * This represents all the required metrics to create a VR camera.
  41424. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41425. */
  41426. export class VRCameraMetrics {
  41427. /**
  41428. * Define the horizontal resolution off the screen.
  41429. */
  41430. hResolution: number;
  41431. /**
  41432. * Define the vertical resolution off the screen.
  41433. */
  41434. vResolution: number;
  41435. /**
  41436. * Define the horizontal screen size.
  41437. */
  41438. hScreenSize: number;
  41439. /**
  41440. * Define the vertical screen size.
  41441. */
  41442. vScreenSize: number;
  41443. /**
  41444. * Define the vertical screen center position.
  41445. */
  41446. vScreenCenter: number;
  41447. /**
  41448. * Define the distance of the eyes to the screen.
  41449. */
  41450. eyeToScreenDistance: number;
  41451. /**
  41452. * Define the distance between both lenses
  41453. */
  41454. lensSeparationDistance: number;
  41455. /**
  41456. * Define the distance between both viewer's eyes.
  41457. */
  41458. interpupillaryDistance: number;
  41459. /**
  41460. * Define the distortion factor of the VR postprocess.
  41461. * Please, touch with care.
  41462. */
  41463. distortionK: number[];
  41464. /**
  41465. * Define the chromatic aberration correction factors for the VR post process.
  41466. */
  41467. chromaAbCorrection: number[];
  41468. /**
  41469. * Define the scale factor of the post process.
  41470. * The smaller the better but the slower.
  41471. */
  41472. postProcessScaleFactor: number;
  41473. /**
  41474. * Define an offset for the lens center.
  41475. */
  41476. lensCenterOffset: number;
  41477. /**
  41478. * Define if the current vr camera should compensate the distortion of the lense or not.
  41479. */
  41480. compensateDistortion: boolean;
  41481. /**
  41482. * Defines if multiview should be enabled when rendering (Default: false)
  41483. */
  41484. multiviewEnabled: boolean;
  41485. /**
  41486. * Gets the rendering aspect ratio based on the provided resolutions.
  41487. */
  41488. readonly aspectRatio: number;
  41489. /**
  41490. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41491. */
  41492. readonly aspectRatioFov: number;
  41493. /**
  41494. * @hidden
  41495. */
  41496. readonly leftHMatrix: Matrix;
  41497. /**
  41498. * @hidden
  41499. */
  41500. readonly rightHMatrix: Matrix;
  41501. /**
  41502. * @hidden
  41503. */
  41504. readonly leftPreViewMatrix: Matrix;
  41505. /**
  41506. * @hidden
  41507. */
  41508. readonly rightPreViewMatrix: Matrix;
  41509. /**
  41510. * Get the default VRMetrics based on the most generic setup.
  41511. * @returns the default vr metrics
  41512. */
  41513. static GetDefault(): VRCameraMetrics;
  41514. }
  41515. }
  41516. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41517. /** @hidden */
  41518. export var vrDistortionCorrectionPixelShader: {
  41519. name: string;
  41520. shader: string;
  41521. };
  41522. }
  41523. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41524. import { Camera } from "babylonjs/Cameras/camera";
  41525. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41526. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41527. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41528. /**
  41529. * VRDistortionCorrectionPostProcess used for mobile VR
  41530. */
  41531. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41532. private _isRightEye;
  41533. private _distortionFactors;
  41534. private _postProcessScaleFactor;
  41535. private _lensCenterOffset;
  41536. private _scaleIn;
  41537. private _scaleFactor;
  41538. private _lensCenter;
  41539. /**
  41540. * Initializes the VRDistortionCorrectionPostProcess
  41541. * @param name The name of the effect.
  41542. * @param camera The camera to apply the render pass to.
  41543. * @param isRightEye If this is for the right eye distortion
  41544. * @param vrMetrics All the required metrics for the VR camera
  41545. */
  41546. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41547. }
  41548. }
  41549. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41550. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41551. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41552. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41553. import { Scene } from "babylonjs/scene";
  41554. import { Vector3 } from "babylonjs/Maths/math.vector";
  41555. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41556. import "babylonjs/Cameras/RigModes/vrRigMode";
  41557. /**
  41558. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41559. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41560. */
  41561. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41562. /**
  41563. * Creates a new VRDeviceOrientationArcRotateCamera
  41564. * @param name defines camera name
  41565. * @param alpha defines the camera rotation along the logitudinal axis
  41566. * @param beta defines the camera rotation along the latitudinal axis
  41567. * @param radius defines the camera distance from its target
  41568. * @param target defines the camera target
  41569. * @param scene defines the scene the camera belongs to
  41570. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41571. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41572. */
  41573. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41574. /**
  41575. * Gets camera class name
  41576. * @returns VRDeviceOrientationArcRotateCamera
  41577. */
  41578. getClassName(): string;
  41579. }
  41580. }
  41581. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41582. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41583. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41584. import { Scene } from "babylonjs/scene";
  41585. import { Vector3 } from "babylonjs/Maths/math.vector";
  41586. import "babylonjs/Cameras/RigModes/vrRigMode";
  41587. /**
  41588. * Camera used to simulate VR rendering (based on FreeCamera)
  41589. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41590. */
  41591. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41592. /**
  41593. * Creates a new VRDeviceOrientationFreeCamera
  41594. * @param name defines camera name
  41595. * @param position defines the start position of the camera
  41596. * @param scene defines the scene the camera belongs to
  41597. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41598. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41599. */
  41600. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41601. /**
  41602. * Gets camera class name
  41603. * @returns VRDeviceOrientationFreeCamera
  41604. */
  41605. getClassName(): string;
  41606. }
  41607. }
  41608. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41609. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41610. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41611. import { Scene } from "babylonjs/scene";
  41612. import { Vector3 } from "babylonjs/Maths/math.vector";
  41613. import "babylonjs/Gamepads/gamepadSceneComponent";
  41614. /**
  41615. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41616. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41617. */
  41618. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41619. /**
  41620. * Creates a new VRDeviceOrientationGamepadCamera
  41621. * @param name defines camera name
  41622. * @param position defines the start position of the camera
  41623. * @param scene defines the scene the camera belongs to
  41624. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41625. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41626. */
  41627. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41628. /**
  41629. * Gets camera class name
  41630. * @returns VRDeviceOrientationGamepadCamera
  41631. */
  41632. getClassName(): string;
  41633. }
  41634. }
  41635. declare module "babylonjs/Materials/pushMaterial" {
  41636. import { Nullable } from "babylonjs/types";
  41637. import { Scene } from "babylonjs/scene";
  41638. import { Matrix } from "babylonjs/Maths/math.vector";
  41639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41640. import { Mesh } from "babylonjs/Meshes/mesh";
  41641. import { Material } from "babylonjs/Materials/material";
  41642. import { Effect } from "babylonjs/Materials/effect";
  41643. /**
  41644. * Base class of materials working in push mode in babylon JS
  41645. * @hidden
  41646. */
  41647. export class PushMaterial extends Material {
  41648. protected _activeEffect: Effect;
  41649. protected _normalMatrix: Matrix;
  41650. /**
  41651. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41652. * This means that the material can keep using a previous shader while a new one is being compiled.
  41653. * This is mostly used when shader parallel compilation is supported (true by default)
  41654. */
  41655. allowShaderHotSwapping: boolean;
  41656. constructor(name: string, scene: Scene);
  41657. getEffect(): Effect;
  41658. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41659. /**
  41660. * Binds the given world matrix to the active effect
  41661. *
  41662. * @param world the matrix to bind
  41663. */
  41664. bindOnlyWorldMatrix(world: Matrix): void;
  41665. /**
  41666. * Binds the given normal matrix to the active effect
  41667. *
  41668. * @param normalMatrix the matrix to bind
  41669. */
  41670. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41671. bind(world: Matrix, mesh?: Mesh): void;
  41672. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41673. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41674. }
  41675. }
  41676. declare module "babylonjs/Materials/materialFlags" {
  41677. /**
  41678. * This groups all the flags used to control the materials channel.
  41679. */
  41680. export class MaterialFlags {
  41681. private static _DiffuseTextureEnabled;
  41682. /**
  41683. * Are diffuse textures enabled in the application.
  41684. */
  41685. static DiffuseTextureEnabled: boolean;
  41686. private static _AmbientTextureEnabled;
  41687. /**
  41688. * Are ambient textures enabled in the application.
  41689. */
  41690. static AmbientTextureEnabled: boolean;
  41691. private static _OpacityTextureEnabled;
  41692. /**
  41693. * Are opacity textures enabled in the application.
  41694. */
  41695. static OpacityTextureEnabled: boolean;
  41696. private static _ReflectionTextureEnabled;
  41697. /**
  41698. * Are reflection textures enabled in the application.
  41699. */
  41700. static ReflectionTextureEnabled: boolean;
  41701. private static _EmissiveTextureEnabled;
  41702. /**
  41703. * Are emissive textures enabled in the application.
  41704. */
  41705. static EmissiveTextureEnabled: boolean;
  41706. private static _SpecularTextureEnabled;
  41707. /**
  41708. * Are specular textures enabled in the application.
  41709. */
  41710. static SpecularTextureEnabled: boolean;
  41711. private static _BumpTextureEnabled;
  41712. /**
  41713. * Are bump textures enabled in the application.
  41714. */
  41715. static BumpTextureEnabled: boolean;
  41716. private static _LightmapTextureEnabled;
  41717. /**
  41718. * Are lightmap textures enabled in the application.
  41719. */
  41720. static LightmapTextureEnabled: boolean;
  41721. private static _RefractionTextureEnabled;
  41722. /**
  41723. * Are refraction textures enabled in the application.
  41724. */
  41725. static RefractionTextureEnabled: boolean;
  41726. private static _ColorGradingTextureEnabled;
  41727. /**
  41728. * Are color grading textures enabled in the application.
  41729. */
  41730. static ColorGradingTextureEnabled: boolean;
  41731. private static _FresnelEnabled;
  41732. /**
  41733. * Are fresnels enabled in the application.
  41734. */
  41735. static FresnelEnabled: boolean;
  41736. private static _ClearCoatTextureEnabled;
  41737. /**
  41738. * Are clear coat textures enabled in the application.
  41739. */
  41740. static ClearCoatTextureEnabled: boolean;
  41741. private static _ClearCoatBumpTextureEnabled;
  41742. /**
  41743. * Are clear coat bump textures enabled in the application.
  41744. */
  41745. static ClearCoatBumpTextureEnabled: boolean;
  41746. private static _ClearCoatTintTextureEnabled;
  41747. /**
  41748. * Are clear coat tint textures enabled in the application.
  41749. */
  41750. static ClearCoatTintTextureEnabled: boolean;
  41751. private static _SheenTextureEnabled;
  41752. /**
  41753. * Are sheen textures enabled in the application.
  41754. */
  41755. static SheenTextureEnabled: boolean;
  41756. private static _AnisotropicTextureEnabled;
  41757. /**
  41758. * Are anisotropic textures enabled in the application.
  41759. */
  41760. static AnisotropicTextureEnabled: boolean;
  41761. private static _ThicknessTextureEnabled;
  41762. /**
  41763. * Are thickness textures enabled in the application.
  41764. */
  41765. static ThicknessTextureEnabled: boolean;
  41766. }
  41767. }
  41768. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41769. /** @hidden */
  41770. export var defaultFragmentDeclaration: {
  41771. name: string;
  41772. shader: string;
  41773. };
  41774. }
  41775. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41776. /** @hidden */
  41777. export var defaultUboDeclaration: {
  41778. name: string;
  41779. shader: string;
  41780. };
  41781. }
  41782. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41783. /** @hidden */
  41784. export var lightFragmentDeclaration: {
  41785. name: string;
  41786. shader: string;
  41787. };
  41788. }
  41789. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41790. /** @hidden */
  41791. export var lightUboDeclaration: {
  41792. name: string;
  41793. shader: string;
  41794. };
  41795. }
  41796. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41797. /** @hidden */
  41798. export var lightsFragmentFunctions: {
  41799. name: string;
  41800. shader: string;
  41801. };
  41802. }
  41803. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41804. /** @hidden */
  41805. export var shadowsFragmentFunctions: {
  41806. name: string;
  41807. shader: string;
  41808. };
  41809. }
  41810. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41811. /** @hidden */
  41812. export var fresnelFunction: {
  41813. name: string;
  41814. shader: string;
  41815. };
  41816. }
  41817. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41818. /** @hidden */
  41819. export var reflectionFunction: {
  41820. name: string;
  41821. shader: string;
  41822. };
  41823. }
  41824. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41825. /** @hidden */
  41826. export var bumpFragmentFunctions: {
  41827. name: string;
  41828. shader: string;
  41829. };
  41830. }
  41831. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41832. /** @hidden */
  41833. export var logDepthDeclaration: {
  41834. name: string;
  41835. shader: string;
  41836. };
  41837. }
  41838. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41839. /** @hidden */
  41840. export var bumpFragment: {
  41841. name: string;
  41842. shader: string;
  41843. };
  41844. }
  41845. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41846. /** @hidden */
  41847. export var depthPrePass: {
  41848. name: string;
  41849. shader: string;
  41850. };
  41851. }
  41852. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41853. /** @hidden */
  41854. export var lightFragment: {
  41855. name: string;
  41856. shader: string;
  41857. };
  41858. }
  41859. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41860. /** @hidden */
  41861. export var logDepthFragment: {
  41862. name: string;
  41863. shader: string;
  41864. };
  41865. }
  41866. declare module "babylonjs/Shaders/default.fragment" {
  41867. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41868. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41869. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41870. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41871. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41872. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41873. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41874. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41875. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41876. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41877. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41878. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41879. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41880. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41881. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41882. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41883. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41884. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41885. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41886. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41887. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41888. /** @hidden */
  41889. export var defaultPixelShader: {
  41890. name: string;
  41891. shader: string;
  41892. };
  41893. }
  41894. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41895. /** @hidden */
  41896. export var defaultVertexDeclaration: {
  41897. name: string;
  41898. shader: string;
  41899. };
  41900. }
  41901. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41902. /** @hidden */
  41903. export var bumpVertexDeclaration: {
  41904. name: string;
  41905. shader: string;
  41906. };
  41907. }
  41908. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41909. /** @hidden */
  41910. export var bumpVertex: {
  41911. name: string;
  41912. shader: string;
  41913. };
  41914. }
  41915. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41916. /** @hidden */
  41917. export var fogVertex: {
  41918. name: string;
  41919. shader: string;
  41920. };
  41921. }
  41922. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41923. /** @hidden */
  41924. export var shadowsVertex: {
  41925. name: string;
  41926. shader: string;
  41927. };
  41928. }
  41929. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41930. /** @hidden */
  41931. export var pointCloudVertex: {
  41932. name: string;
  41933. shader: string;
  41934. };
  41935. }
  41936. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41937. /** @hidden */
  41938. export var logDepthVertex: {
  41939. name: string;
  41940. shader: string;
  41941. };
  41942. }
  41943. declare module "babylonjs/Shaders/default.vertex" {
  41944. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41945. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41946. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41947. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41948. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41949. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41950. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41951. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41952. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41953. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41954. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41955. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41956. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41957. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41958. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41959. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41960. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41961. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41962. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41963. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41964. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41965. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41966. /** @hidden */
  41967. export var defaultVertexShader: {
  41968. name: string;
  41969. shader: string;
  41970. };
  41971. }
  41972. declare module "babylonjs/Materials/standardMaterial" {
  41973. import { SmartArray } from "babylonjs/Misc/smartArray";
  41974. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41975. import { Nullable } from "babylonjs/types";
  41976. import { Scene } from "babylonjs/scene";
  41977. import { Matrix } from "babylonjs/Maths/math.vector";
  41978. import { Color3 } from "babylonjs/Maths/math.color";
  41979. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41981. import { Mesh } from "babylonjs/Meshes/mesh";
  41982. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41983. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41984. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41985. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41986. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41987. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41988. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41989. import "babylonjs/Shaders/default.fragment";
  41990. import "babylonjs/Shaders/default.vertex";
  41991. /** @hidden */
  41992. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41993. MAINUV1: boolean;
  41994. MAINUV2: boolean;
  41995. DIFFUSE: boolean;
  41996. DIFFUSEDIRECTUV: number;
  41997. AMBIENT: boolean;
  41998. AMBIENTDIRECTUV: number;
  41999. OPACITY: boolean;
  42000. OPACITYDIRECTUV: number;
  42001. OPACITYRGB: boolean;
  42002. REFLECTION: boolean;
  42003. EMISSIVE: boolean;
  42004. EMISSIVEDIRECTUV: number;
  42005. SPECULAR: boolean;
  42006. SPECULARDIRECTUV: number;
  42007. BUMP: boolean;
  42008. BUMPDIRECTUV: number;
  42009. PARALLAX: boolean;
  42010. PARALLAXOCCLUSION: boolean;
  42011. SPECULAROVERALPHA: boolean;
  42012. CLIPPLANE: boolean;
  42013. CLIPPLANE2: boolean;
  42014. CLIPPLANE3: boolean;
  42015. CLIPPLANE4: boolean;
  42016. ALPHATEST: boolean;
  42017. DEPTHPREPASS: boolean;
  42018. ALPHAFROMDIFFUSE: boolean;
  42019. POINTSIZE: boolean;
  42020. FOG: boolean;
  42021. SPECULARTERM: boolean;
  42022. DIFFUSEFRESNEL: boolean;
  42023. OPACITYFRESNEL: boolean;
  42024. REFLECTIONFRESNEL: boolean;
  42025. REFRACTIONFRESNEL: boolean;
  42026. EMISSIVEFRESNEL: boolean;
  42027. FRESNEL: boolean;
  42028. NORMAL: boolean;
  42029. UV1: boolean;
  42030. UV2: boolean;
  42031. VERTEXCOLOR: boolean;
  42032. VERTEXALPHA: boolean;
  42033. NUM_BONE_INFLUENCERS: number;
  42034. BonesPerMesh: number;
  42035. BONETEXTURE: boolean;
  42036. INSTANCES: boolean;
  42037. GLOSSINESS: boolean;
  42038. ROUGHNESS: boolean;
  42039. EMISSIVEASILLUMINATION: boolean;
  42040. LINKEMISSIVEWITHDIFFUSE: boolean;
  42041. REFLECTIONFRESNELFROMSPECULAR: boolean;
  42042. LIGHTMAP: boolean;
  42043. LIGHTMAPDIRECTUV: number;
  42044. OBJECTSPACE_NORMALMAP: boolean;
  42045. USELIGHTMAPASSHADOWMAP: boolean;
  42046. REFLECTIONMAP_3D: boolean;
  42047. REFLECTIONMAP_SPHERICAL: boolean;
  42048. REFLECTIONMAP_PLANAR: boolean;
  42049. REFLECTIONMAP_CUBIC: boolean;
  42050. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  42051. REFLECTIONMAP_PROJECTION: boolean;
  42052. REFLECTIONMAP_SKYBOX: boolean;
  42053. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  42054. REFLECTIONMAP_EXPLICIT: boolean;
  42055. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  42056. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  42057. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  42058. INVERTCUBICMAP: boolean;
  42059. LOGARITHMICDEPTH: boolean;
  42060. REFRACTION: boolean;
  42061. REFRACTIONMAP_3D: boolean;
  42062. REFLECTIONOVERALPHA: boolean;
  42063. TWOSIDEDLIGHTING: boolean;
  42064. SHADOWFLOAT: boolean;
  42065. MORPHTARGETS: boolean;
  42066. MORPHTARGETS_NORMAL: boolean;
  42067. MORPHTARGETS_TANGENT: boolean;
  42068. MORPHTARGETS_UV: boolean;
  42069. NUM_MORPH_INFLUENCERS: number;
  42070. NONUNIFORMSCALING: boolean;
  42071. PREMULTIPLYALPHA: boolean;
  42072. IMAGEPROCESSING: boolean;
  42073. VIGNETTE: boolean;
  42074. VIGNETTEBLENDMODEMULTIPLY: boolean;
  42075. VIGNETTEBLENDMODEOPAQUE: boolean;
  42076. TONEMAPPING: boolean;
  42077. TONEMAPPING_ACES: boolean;
  42078. CONTRAST: boolean;
  42079. COLORCURVES: boolean;
  42080. COLORGRADING: boolean;
  42081. COLORGRADING3D: boolean;
  42082. SAMPLER3DGREENDEPTH: boolean;
  42083. SAMPLER3DBGRMAP: boolean;
  42084. IMAGEPROCESSINGPOSTPROCESS: boolean;
  42085. MULTIVIEW: boolean;
  42086. /**
  42087. * If the reflection texture on this material is in linear color space
  42088. * @hidden
  42089. */
  42090. IS_REFLECTION_LINEAR: boolean;
  42091. /**
  42092. * If the refraction texture on this material is in linear color space
  42093. * @hidden
  42094. */
  42095. IS_REFRACTION_LINEAR: boolean;
  42096. EXPOSURE: boolean;
  42097. constructor();
  42098. setReflectionMode(modeToEnable: string): void;
  42099. }
  42100. /**
  42101. * This is the default material used in Babylon. It is the best trade off between quality
  42102. * and performances.
  42103. * @see http://doc.babylonjs.com/babylon101/materials
  42104. */
  42105. export class StandardMaterial extends PushMaterial {
  42106. private _diffuseTexture;
  42107. /**
  42108. * The basic texture of the material as viewed under a light.
  42109. */
  42110. diffuseTexture: Nullable<BaseTexture>;
  42111. private _ambientTexture;
  42112. /**
  42113. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  42114. */
  42115. ambientTexture: Nullable<BaseTexture>;
  42116. private _opacityTexture;
  42117. /**
  42118. * Define the transparency of the material from a texture.
  42119. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  42120. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  42121. */
  42122. opacityTexture: Nullable<BaseTexture>;
  42123. private _reflectionTexture;
  42124. /**
  42125. * Define the texture used to display the reflection.
  42126. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42127. */
  42128. reflectionTexture: Nullable<BaseTexture>;
  42129. private _emissiveTexture;
  42130. /**
  42131. * Define texture of the material as if self lit.
  42132. * This will be mixed in the final result even in the absence of light.
  42133. */
  42134. emissiveTexture: Nullable<BaseTexture>;
  42135. private _specularTexture;
  42136. /**
  42137. * Define how the color and intensity of the highlight given by the light in the material.
  42138. */
  42139. specularTexture: Nullable<BaseTexture>;
  42140. private _bumpTexture;
  42141. /**
  42142. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  42143. * 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.
  42144. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  42145. */
  42146. bumpTexture: Nullable<BaseTexture>;
  42147. private _lightmapTexture;
  42148. /**
  42149. * Complex lighting can be computationally expensive to compute at runtime.
  42150. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  42151. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  42152. */
  42153. lightmapTexture: Nullable<BaseTexture>;
  42154. private _refractionTexture;
  42155. /**
  42156. * Define the texture used to display the refraction.
  42157. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42158. */
  42159. refractionTexture: Nullable<BaseTexture>;
  42160. /**
  42161. * The color of the material lit by the environmental background lighting.
  42162. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  42163. */
  42164. ambientColor: Color3;
  42165. /**
  42166. * The basic color of the material as viewed under a light.
  42167. */
  42168. diffuseColor: Color3;
  42169. /**
  42170. * Define how the color and intensity of the highlight given by the light in the material.
  42171. */
  42172. specularColor: Color3;
  42173. /**
  42174. * Define the color of the material as if self lit.
  42175. * This will be mixed in the final result even in the absence of light.
  42176. */
  42177. emissiveColor: Color3;
  42178. /**
  42179. * Defines how sharp are the highlights in the material.
  42180. * The bigger the value the sharper giving a more glossy feeling to the result.
  42181. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  42182. */
  42183. specularPower: number;
  42184. private _useAlphaFromDiffuseTexture;
  42185. /**
  42186. * Does the transparency come from the diffuse texture alpha channel.
  42187. */
  42188. useAlphaFromDiffuseTexture: boolean;
  42189. private _useEmissiveAsIllumination;
  42190. /**
  42191. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  42192. */
  42193. useEmissiveAsIllumination: boolean;
  42194. private _linkEmissiveWithDiffuse;
  42195. /**
  42196. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  42197. * the emissive level when the final color is close to one.
  42198. */
  42199. linkEmissiveWithDiffuse: boolean;
  42200. private _useSpecularOverAlpha;
  42201. /**
  42202. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42203. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42204. */
  42205. useSpecularOverAlpha: boolean;
  42206. private _useReflectionOverAlpha;
  42207. /**
  42208. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42209. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42210. */
  42211. useReflectionOverAlpha: boolean;
  42212. private _disableLighting;
  42213. /**
  42214. * Does lights from the scene impacts this material.
  42215. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  42216. */
  42217. disableLighting: boolean;
  42218. private _useObjectSpaceNormalMap;
  42219. /**
  42220. * Allows using an object space normal map (instead of tangent space).
  42221. */
  42222. useObjectSpaceNormalMap: boolean;
  42223. private _useParallax;
  42224. /**
  42225. * Is parallax enabled or not.
  42226. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42227. */
  42228. useParallax: boolean;
  42229. private _useParallaxOcclusion;
  42230. /**
  42231. * Is parallax occlusion enabled or not.
  42232. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  42233. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42234. */
  42235. useParallaxOcclusion: boolean;
  42236. /**
  42237. * 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.
  42238. */
  42239. parallaxScaleBias: number;
  42240. private _roughness;
  42241. /**
  42242. * Helps to define how blurry the reflections should appears in the material.
  42243. */
  42244. roughness: number;
  42245. /**
  42246. * In case of refraction, define the value of the index of refraction.
  42247. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42248. */
  42249. indexOfRefraction: number;
  42250. /**
  42251. * Invert the refraction texture alongside the y axis.
  42252. * It can be useful with procedural textures or probe for instance.
  42253. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42254. */
  42255. invertRefractionY: boolean;
  42256. /**
  42257. * Defines the alpha limits in alpha test mode.
  42258. */
  42259. alphaCutOff: number;
  42260. private _useLightmapAsShadowmap;
  42261. /**
  42262. * In case of light mapping, define whether the map contains light or shadow informations.
  42263. */
  42264. useLightmapAsShadowmap: boolean;
  42265. private _diffuseFresnelParameters;
  42266. /**
  42267. * Define the diffuse fresnel parameters of the material.
  42268. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42269. */
  42270. diffuseFresnelParameters: FresnelParameters;
  42271. private _opacityFresnelParameters;
  42272. /**
  42273. * Define the opacity fresnel parameters of the material.
  42274. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42275. */
  42276. opacityFresnelParameters: FresnelParameters;
  42277. private _reflectionFresnelParameters;
  42278. /**
  42279. * Define the reflection fresnel parameters of the material.
  42280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42281. */
  42282. reflectionFresnelParameters: FresnelParameters;
  42283. private _refractionFresnelParameters;
  42284. /**
  42285. * Define the refraction fresnel parameters of the material.
  42286. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42287. */
  42288. refractionFresnelParameters: FresnelParameters;
  42289. private _emissiveFresnelParameters;
  42290. /**
  42291. * Define the emissive fresnel parameters of the material.
  42292. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42293. */
  42294. emissiveFresnelParameters: FresnelParameters;
  42295. private _useReflectionFresnelFromSpecular;
  42296. /**
  42297. * If true automatically deducts the fresnels values from the material specularity.
  42298. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42299. */
  42300. useReflectionFresnelFromSpecular: boolean;
  42301. private _useGlossinessFromSpecularMapAlpha;
  42302. /**
  42303. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42304. */
  42305. useGlossinessFromSpecularMapAlpha: boolean;
  42306. private _maxSimultaneousLights;
  42307. /**
  42308. * Defines the maximum number of lights that can be used in the material
  42309. */
  42310. maxSimultaneousLights: number;
  42311. private _invertNormalMapX;
  42312. /**
  42313. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42314. */
  42315. invertNormalMapX: boolean;
  42316. private _invertNormalMapY;
  42317. /**
  42318. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42319. */
  42320. invertNormalMapY: boolean;
  42321. private _twoSidedLighting;
  42322. /**
  42323. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42324. */
  42325. twoSidedLighting: boolean;
  42326. /**
  42327. * Default configuration related to image processing available in the standard Material.
  42328. */
  42329. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42330. /**
  42331. * Gets the image processing configuration used either in this material.
  42332. */
  42333. /**
  42334. * Sets the Default image processing configuration used either in the this material.
  42335. *
  42336. * If sets to null, the scene one is in use.
  42337. */
  42338. imageProcessingConfiguration: ImageProcessingConfiguration;
  42339. /**
  42340. * Keep track of the image processing observer to allow dispose and replace.
  42341. */
  42342. private _imageProcessingObserver;
  42343. /**
  42344. * Attaches a new image processing configuration to the Standard Material.
  42345. * @param configuration
  42346. */
  42347. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42348. /**
  42349. * Gets wether the color curves effect is enabled.
  42350. */
  42351. /**
  42352. * Sets wether the color curves effect is enabled.
  42353. */
  42354. cameraColorCurvesEnabled: boolean;
  42355. /**
  42356. * Gets wether the color grading effect is enabled.
  42357. */
  42358. /**
  42359. * Gets wether the color grading effect is enabled.
  42360. */
  42361. cameraColorGradingEnabled: boolean;
  42362. /**
  42363. * Gets wether tonemapping is enabled or not.
  42364. */
  42365. /**
  42366. * Sets wether tonemapping is enabled or not
  42367. */
  42368. cameraToneMappingEnabled: boolean;
  42369. /**
  42370. * The camera exposure used on this material.
  42371. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42372. * This corresponds to a photographic exposure.
  42373. */
  42374. /**
  42375. * The camera exposure used on this material.
  42376. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42377. * This corresponds to a photographic exposure.
  42378. */
  42379. cameraExposure: number;
  42380. /**
  42381. * Gets The camera contrast used on this material.
  42382. */
  42383. /**
  42384. * Sets The camera contrast used on this material.
  42385. */
  42386. cameraContrast: number;
  42387. /**
  42388. * Gets the Color Grading 2D Lookup Texture.
  42389. */
  42390. /**
  42391. * Sets the Color Grading 2D Lookup Texture.
  42392. */
  42393. cameraColorGradingTexture: Nullable<BaseTexture>;
  42394. /**
  42395. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42396. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42397. * 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;
  42398. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42399. */
  42400. /**
  42401. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42402. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42403. * 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;
  42404. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42405. */
  42406. cameraColorCurves: Nullable<ColorCurves>;
  42407. /**
  42408. * Custom callback helping to override the default shader used in the material.
  42409. */
  42410. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42411. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42412. protected _worldViewProjectionMatrix: Matrix;
  42413. protected _globalAmbientColor: Color3;
  42414. protected _useLogarithmicDepth: boolean;
  42415. protected _rebuildInParallel: boolean;
  42416. /**
  42417. * Instantiates a new standard material.
  42418. * This is the default material used in Babylon. It is the best trade off between quality
  42419. * and performances.
  42420. * @see http://doc.babylonjs.com/babylon101/materials
  42421. * @param name Define the name of the material in the scene
  42422. * @param scene Define the scene the material belong to
  42423. */
  42424. constructor(name: string, scene: Scene);
  42425. /**
  42426. * Gets a boolean indicating that current material needs to register RTT
  42427. */
  42428. readonly hasRenderTargetTextures: boolean;
  42429. /**
  42430. * Gets the current class name of the material e.g. "StandardMaterial"
  42431. * Mainly use in serialization.
  42432. * @returns the class name
  42433. */
  42434. getClassName(): string;
  42435. /**
  42436. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42437. * You can try switching to logarithmic depth.
  42438. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42439. */
  42440. useLogarithmicDepth: boolean;
  42441. /**
  42442. * Specifies if the material will require alpha blending
  42443. * @returns a boolean specifying if alpha blending is needed
  42444. */
  42445. needAlphaBlending(): boolean;
  42446. /**
  42447. * Specifies if this material should be rendered in alpha test mode
  42448. * @returns a boolean specifying if an alpha test is needed.
  42449. */
  42450. needAlphaTesting(): boolean;
  42451. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42452. /**
  42453. * Get the texture used for alpha test purpose.
  42454. * @returns the diffuse texture in case of the standard material.
  42455. */
  42456. getAlphaTestTexture(): Nullable<BaseTexture>;
  42457. /**
  42458. * Get if the submesh is ready to be used and all its information available.
  42459. * Child classes can use it to update shaders
  42460. * @param mesh defines the mesh to check
  42461. * @param subMesh defines which submesh to check
  42462. * @param useInstances specifies that instances should be used
  42463. * @returns a boolean indicating that the submesh is ready or not
  42464. */
  42465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42466. /**
  42467. * Builds the material UBO layouts.
  42468. * Used internally during the effect preparation.
  42469. */
  42470. buildUniformLayout(): void;
  42471. /**
  42472. * Unbinds the material from the mesh
  42473. */
  42474. unbind(): void;
  42475. /**
  42476. * Binds the submesh to this material by preparing the effect and shader to draw
  42477. * @param world defines the world transformation matrix
  42478. * @param mesh defines the mesh containing the submesh
  42479. * @param subMesh defines the submesh to bind the material to
  42480. */
  42481. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42482. /**
  42483. * Get the list of animatables in the material.
  42484. * @returns the list of animatables object used in the material
  42485. */
  42486. getAnimatables(): IAnimatable[];
  42487. /**
  42488. * Gets the active textures from the material
  42489. * @returns an array of textures
  42490. */
  42491. getActiveTextures(): BaseTexture[];
  42492. /**
  42493. * Specifies if the material uses a texture
  42494. * @param texture defines the texture to check against the material
  42495. * @returns a boolean specifying if the material uses the texture
  42496. */
  42497. hasTexture(texture: BaseTexture): boolean;
  42498. /**
  42499. * Disposes the material
  42500. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42501. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42502. */
  42503. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42504. /**
  42505. * Makes a duplicate of the material, and gives it a new name
  42506. * @param name defines the new name for the duplicated material
  42507. * @returns the cloned material
  42508. */
  42509. clone(name: string): StandardMaterial;
  42510. /**
  42511. * Serializes this material in a JSON representation
  42512. * @returns the serialized material object
  42513. */
  42514. serialize(): any;
  42515. /**
  42516. * Creates a standard material from parsed material data
  42517. * @param source defines the JSON representation of the material
  42518. * @param scene defines the hosting scene
  42519. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42520. * @returns a new standard material
  42521. */
  42522. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42523. /**
  42524. * Are diffuse textures enabled in the application.
  42525. */
  42526. static DiffuseTextureEnabled: boolean;
  42527. /**
  42528. * Are ambient textures enabled in the application.
  42529. */
  42530. static AmbientTextureEnabled: boolean;
  42531. /**
  42532. * Are opacity textures enabled in the application.
  42533. */
  42534. static OpacityTextureEnabled: boolean;
  42535. /**
  42536. * Are reflection textures enabled in the application.
  42537. */
  42538. static ReflectionTextureEnabled: boolean;
  42539. /**
  42540. * Are emissive textures enabled in the application.
  42541. */
  42542. static EmissiveTextureEnabled: boolean;
  42543. /**
  42544. * Are specular textures enabled in the application.
  42545. */
  42546. static SpecularTextureEnabled: boolean;
  42547. /**
  42548. * Are bump textures enabled in the application.
  42549. */
  42550. static BumpTextureEnabled: boolean;
  42551. /**
  42552. * Are lightmap textures enabled in the application.
  42553. */
  42554. static LightmapTextureEnabled: boolean;
  42555. /**
  42556. * Are refraction textures enabled in the application.
  42557. */
  42558. static RefractionTextureEnabled: boolean;
  42559. /**
  42560. * Are color grading textures enabled in the application.
  42561. */
  42562. static ColorGradingTextureEnabled: boolean;
  42563. /**
  42564. * Are fresnels enabled in the application.
  42565. */
  42566. static FresnelEnabled: boolean;
  42567. }
  42568. }
  42569. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42570. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42571. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42572. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42573. /** @hidden */
  42574. export var imageProcessingPixelShader: {
  42575. name: string;
  42576. shader: string;
  42577. };
  42578. }
  42579. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42580. import { Nullable } from "babylonjs/types";
  42581. import { Color4 } from "babylonjs/Maths/math.color";
  42582. import { Camera } from "babylonjs/Cameras/camera";
  42583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42584. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42585. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42586. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42587. import { Engine } from "babylonjs/Engines/engine";
  42588. import "babylonjs/Shaders/imageProcessing.fragment";
  42589. import "babylonjs/Shaders/postprocess.vertex";
  42590. /**
  42591. * ImageProcessingPostProcess
  42592. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42593. */
  42594. export class ImageProcessingPostProcess extends PostProcess {
  42595. /**
  42596. * Default configuration related to image processing available in the PBR Material.
  42597. */
  42598. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42599. /**
  42600. * Gets the image processing configuration used either in this material.
  42601. */
  42602. /**
  42603. * Sets the Default image processing configuration used either in the this material.
  42604. *
  42605. * If sets to null, the scene one is in use.
  42606. */
  42607. imageProcessingConfiguration: ImageProcessingConfiguration;
  42608. /**
  42609. * Keep track of the image processing observer to allow dispose and replace.
  42610. */
  42611. private _imageProcessingObserver;
  42612. /**
  42613. * Attaches a new image processing configuration to the PBR Material.
  42614. * @param configuration
  42615. */
  42616. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42617. /**
  42618. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42619. */
  42620. /**
  42621. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42622. */
  42623. colorCurves: Nullable<ColorCurves>;
  42624. /**
  42625. * Gets wether the color curves effect is enabled.
  42626. */
  42627. /**
  42628. * Sets wether the color curves effect is enabled.
  42629. */
  42630. colorCurvesEnabled: boolean;
  42631. /**
  42632. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42633. */
  42634. /**
  42635. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42636. */
  42637. colorGradingTexture: Nullable<BaseTexture>;
  42638. /**
  42639. * Gets wether the color grading effect is enabled.
  42640. */
  42641. /**
  42642. * Gets wether the color grading effect is enabled.
  42643. */
  42644. colorGradingEnabled: boolean;
  42645. /**
  42646. * Gets exposure used in the effect.
  42647. */
  42648. /**
  42649. * Sets exposure used in the effect.
  42650. */
  42651. exposure: number;
  42652. /**
  42653. * Gets wether tonemapping is enabled or not.
  42654. */
  42655. /**
  42656. * Sets wether tonemapping is enabled or not
  42657. */
  42658. toneMappingEnabled: boolean;
  42659. /**
  42660. * Gets the type of tone mapping effect.
  42661. */
  42662. /**
  42663. * Sets the type of tone mapping effect.
  42664. */
  42665. toneMappingType: number;
  42666. /**
  42667. * Gets contrast used in the effect.
  42668. */
  42669. /**
  42670. * Sets contrast used in the effect.
  42671. */
  42672. contrast: number;
  42673. /**
  42674. * Gets Vignette stretch size.
  42675. */
  42676. /**
  42677. * Sets Vignette stretch size.
  42678. */
  42679. vignetteStretch: number;
  42680. /**
  42681. * Gets Vignette centre X Offset.
  42682. */
  42683. /**
  42684. * Sets Vignette centre X Offset.
  42685. */
  42686. vignetteCentreX: number;
  42687. /**
  42688. * Gets Vignette centre Y Offset.
  42689. */
  42690. /**
  42691. * Sets Vignette centre Y Offset.
  42692. */
  42693. vignetteCentreY: number;
  42694. /**
  42695. * Gets Vignette weight or intensity of the vignette effect.
  42696. */
  42697. /**
  42698. * Sets Vignette weight or intensity of the vignette effect.
  42699. */
  42700. vignetteWeight: number;
  42701. /**
  42702. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42703. * if vignetteEnabled is set to true.
  42704. */
  42705. /**
  42706. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42707. * if vignetteEnabled is set to true.
  42708. */
  42709. vignetteColor: Color4;
  42710. /**
  42711. * Gets Camera field of view used by the Vignette effect.
  42712. */
  42713. /**
  42714. * Sets Camera field of view used by the Vignette effect.
  42715. */
  42716. vignetteCameraFov: number;
  42717. /**
  42718. * Gets the vignette blend mode allowing different kind of effect.
  42719. */
  42720. /**
  42721. * Sets the vignette blend mode allowing different kind of effect.
  42722. */
  42723. vignetteBlendMode: number;
  42724. /**
  42725. * Gets wether the vignette effect is enabled.
  42726. */
  42727. /**
  42728. * Sets wether the vignette effect is enabled.
  42729. */
  42730. vignetteEnabled: boolean;
  42731. private _fromLinearSpace;
  42732. /**
  42733. * Gets wether the input of the processing is in Gamma or Linear Space.
  42734. */
  42735. /**
  42736. * Sets wether the input of the processing is in Gamma or Linear Space.
  42737. */
  42738. fromLinearSpace: boolean;
  42739. /**
  42740. * Defines cache preventing GC.
  42741. */
  42742. private _defines;
  42743. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42744. /**
  42745. * "ImageProcessingPostProcess"
  42746. * @returns "ImageProcessingPostProcess"
  42747. */
  42748. getClassName(): string;
  42749. protected _updateParameters(): void;
  42750. dispose(camera?: Camera): void;
  42751. }
  42752. }
  42753. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42754. import { Scene } from "babylonjs/scene";
  42755. import { Color3 } from "babylonjs/Maths/math.color";
  42756. import { Mesh } from "babylonjs/Meshes/mesh";
  42757. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42758. import { Nullable } from "babylonjs/types";
  42759. /**
  42760. * Class containing static functions to help procedurally build meshes
  42761. */
  42762. export class GroundBuilder {
  42763. /**
  42764. * Creates a ground mesh
  42765. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42766. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42768. * @param name defines the name of the mesh
  42769. * @param options defines the options used to create the mesh
  42770. * @param scene defines the hosting scene
  42771. * @returns the ground mesh
  42772. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42773. */
  42774. static CreateGround(name: string, options: {
  42775. width?: number;
  42776. height?: number;
  42777. subdivisions?: number;
  42778. subdivisionsX?: number;
  42779. subdivisionsY?: number;
  42780. updatable?: boolean;
  42781. }, scene: any): Mesh;
  42782. /**
  42783. * Creates a tiled ground mesh
  42784. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42785. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42786. * * 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
  42787. * * 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
  42788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42789. * @param name defines the name of the mesh
  42790. * @param options defines the options used to create the mesh
  42791. * @param scene defines the hosting scene
  42792. * @returns the tiled ground mesh
  42793. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42794. */
  42795. static CreateTiledGround(name: string, options: {
  42796. xmin: number;
  42797. zmin: number;
  42798. xmax: number;
  42799. zmax: number;
  42800. subdivisions?: {
  42801. w: number;
  42802. h: number;
  42803. };
  42804. precision?: {
  42805. w: number;
  42806. h: number;
  42807. };
  42808. updatable?: boolean;
  42809. }, scene?: Nullable<Scene>): Mesh;
  42810. /**
  42811. * Creates a ground mesh from a height map
  42812. * * The parameter `url` sets the URL of the height map image resource.
  42813. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42814. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42815. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42816. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42817. * * 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.
  42818. * * 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).
  42819. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42821. * @param name defines the name of the mesh
  42822. * @param url defines the url to the height map
  42823. * @param options defines the options used to create the mesh
  42824. * @param scene defines the hosting scene
  42825. * @returns the ground mesh
  42826. * @see https://doc.babylonjs.com/babylon101/height_map
  42827. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42828. */
  42829. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42830. width?: number;
  42831. height?: number;
  42832. subdivisions?: number;
  42833. minHeight?: number;
  42834. maxHeight?: number;
  42835. colorFilter?: Color3;
  42836. alphaFilter?: number;
  42837. updatable?: boolean;
  42838. onReady?: (mesh: GroundMesh) => void;
  42839. }, scene?: Nullable<Scene>): GroundMesh;
  42840. }
  42841. }
  42842. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42843. import { Vector4 } from "babylonjs/Maths/math.vector";
  42844. import { Mesh } from "babylonjs/Meshes/mesh";
  42845. /**
  42846. * Class containing static functions to help procedurally build meshes
  42847. */
  42848. export class TorusBuilder {
  42849. /**
  42850. * Creates a torus mesh
  42851. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42852. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42853. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42857. * @param name defines the name of the mesh
  42858. * @param options defines the options used to create the mesh
  42859. * @param scene defines the hosting scene
  42860. * @returns the torus mesh
  42861. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42862. */
  42863. static CreateTorus(name: string, options: {
  42864. diameter?: number;
  42865. thickness?: number;
  42866. tessellation?: number;
  42867. updatable?: boolean;
  42868. sideOrientation?: number;
  42869. frontUVs?: Vector4;
  42870. backUVs?: Vector4;
  42871. }, scene: any): Mesh;
  42872. }
  42873. }
  42874. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42875. import { Vector4 } from "babylonjs/Maths/math.vector";
  42876. import { Color4 } from "babylonjs/Maths/math.color";
  42877. import { Mesh } from "babylonjs/Meshes/mesh";
  42878. /**
  42879. * Class containing static functions to help procedurally build meshes
  42880. */
  42881. export class CylinderBuilder {
  42882. /**
  42883. * Creates a cylinder or a cone mesh
  42884. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42885. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42886. * * 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.
  42887. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42888. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42889. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42890. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42891. * * 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).
  42892. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42893. * * 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).
  42894. * * 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
  42895. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42896. * * 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
  42897. * * 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.
  42898. * * If `enclose` is false, a ring surface is one element.
  42899. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42900. * * 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
  42901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42904. * @param name defines the name of the mesh
  42905. * @param options defines the options used to create the mesh
  42906. * @param scene defines the hosting scene
  42907. * @returns the cylinder mesh
  42908. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42909. */
  42910. static CreateCylinder(name: string, options: {
  42911. height?: number;
  42912. diameterTop?: number;
  42913. diameterBottom?: number;
  42914. diameter?: number;
  42915. tessellation?: number;
  42916. subdivisions?: number;
  42917. arc?: number;
  42918. faceColors?: Color4[];
  42919. faceUV?: Vector4[];
  42920. updatable?: boolean;
  42921. hasRings?: boolean;
  42922. enclose?: boolean;
  42923. cap?: number;
  42924. sideOrientation?: number;
  42925. frontUVs?: Vector4;
  42926. backUVs?: Vector4;
  42927. }, scene: any): Mesh;
  42928. }
  42929. }
  42930. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42931. import { Observable } from "babylonjs/Misc/observable";
  42932. import { Nullable } from "babylonjs/types";
  42933. import { Camera } from "babylonjs/Cameras/camera";
  42934. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42935. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42936. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42937. import { Scene } from "babylonjs/scene";
  42938. import { Vector3 } from "babylonjs/Maths/math.vector";
  42939. import { Color3 } from "babylonjs/Maths/math.color";
  42940. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42942. import { Mesh } from "babylonjs/Meshes/mesh";
  42943. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42944. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42945. import "babylonjs/Meshes/Builders/groundBuilder";
  42946. import "babylonjs/Meshes/Builders/torusBuilder";
  42947. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42948. import "babylonjs/Gamepads/gamepadSceneComponent";
  42949. import "babylonjs/Animations/animatable";
  42950. /**
  42951. * Options to modify the vr teleportation behavior.
  42952. */
  42953. export interface VRTeleportationOptions {
  42954. /**
  42955. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42956. */
  42957. floorMeshName?: string;
  42958. /**
  42959. * A list of meshes to be used as the teleportation floor. (default: empty)
  42960. */
  42961. floorMeshes?: Mesh[];
  42962. }
  42963. /**
  42964. * Options to modify the vr experience helper's behavior.
  42965. */
  42966. export interface VRExperienceHelperOptions extends WebVROptions {
  42967. /**
  42968. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42969. */
  42970. createDeviceOrientationCamera?: boolean;
  42971. /**
  42972. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42973. */
  42974. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42975. /**
  42976. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42977. */
  42978. laserToggle?: boolean;
  42979. /**
  42980. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42981. */
  42982. floorMeshes?: Mesh[];
  42983. /**
  42984. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42985. */
  42986. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42987. }
  42988. /**
  42989. * Event containing information after VR has been entered
  42990. */
  42991. export class OnAfterEnteringVRObservableEvent {
  42992. /**
  42993. * If entering vr was successful
  42994. */
  42995. success: boolean;
  42996. }
  42997. /**
  42998. * Helps to quickly add VR support to an existing scene.
  42999. * See http://doc.babylonjs.com/how_to/webvr_helper
  43000. */
  43001. export class VRExperienceHelper {
  43002. /** Options to modify the vr experience helper's behavior. */
  43003. webVROptions: VRExperienceHelperOptions;
  43004. private _scene;
  43005. private _position;
  43006. private _btnVR;
  43007. private _btnVRDisplayed;
  43008. private _webVRsupported;
  43009. private _webVRready;
  43010. private _webVRrequesting;
  43011. private _webVRpresenting;
  43012. private _hasEnteredVR;
  43013. private _fullscreenVRpresenting;
  43014. private _inputElement;
  43015. private _webVRCamera;
  43016. private _vrDeviceOrientationCamera;
  43017. private _deviceOrientationCamera;
  43018. private _existingCamera;
  43019. private _onKeyDown;
  43020. private _onVrDisplayPresentChange;
  43021. private _onVRDisplayChanged;
  43022. private _onVRRequestPresentStart;
  43023. private _onVRRequestPresentComplete;
  43024. /**
  43025. * 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)
  43026. */
  43027. enableGazeEvenWhenNoPointerLock: boolean;
  43028. /**
  43029. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43030. */
  43031. exitVROnDoubleTap: boolean;
  43032. /**
  43033. * Observable raised right before entering VR.
  43034. */
  43035. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43036. /**
  43037. * Observable raised when entering VR has completed.
  43038. */
  43039. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43040. /**
  43041. * Observable raised when exiting VR.
  43042. */
  43043. onExitingVRObservable: Observable<VRExperienceHelper>;
  43044. /**
  43045. * Observable raised when controller mesh is loaded.
  43046. */
  43047. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43048. /** Return this.onEnteringVRObservable
  43049. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43050. */
  43051. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43052. /** Return this.onExitingVRObservable
  43053. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43054. */
  43055. readonly onExitingVR: Observable<VRExperienceHelper>;
  43056. /** Return this.onControllerMeshLoadedObservable
  43057. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43058. */
  43059. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43060. private _rayLength;
  43061. private _useCustomVRButton;
  43062. private _teleportationRequested;
  43063. private _teleportActive;
  43064. private _floorMeshName;
  43065. private _floorMeshesCollection;
  43066. private _rotationAllowed;
  43067. private _teleportBackwardsVector;
  43068. private _teleportationTarget;
  43069. private _isDefaultTeleportationTarget;
  43070. private _postProcessMove;
  43071. private _teleportationFillColor;
  43072. private _teleportationBorderColor;
  43073. private _rotationAngle;
  43074. private _haloCenter;
  43075. private _cameraGazer;
  43076. private _padSensibilityUp;
  43077. private _padSensibilityDown;
  43078. private _leftController;
  43079. private _rightController;
  43080. /**
  43081. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43082. */
  43083. onNewMeshSelected: Observable<AbstractMesh>;
  43084. /**
  43085. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43086. * This observable will provide the mesh and the controller used to select the mesh
  43087. */
  43088. onMeshSelectedWithController: Observable<{
  43089. mesh: AbstractMesh;
  43090. controller: WebVRController;
  43091. }>;
  43092. /**
  43093. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43094. */
  43095. onNewMeshPicked: Observable<PickingInfo>;
  43096. private _circleEase;
  43097. /**
  43098. * Observable raised before camera teleportation
  43099. */
  43100. onBeforeCameraTeleport: Observable<Vector3>;
  43101. /**
  43102. * Observable raised after camera teleportation
  43103. */
  43104. onAfterCameraTeleport: Observable<Vector3>;
  43105. /**
  43106. * Observable raised when current selected mesh gets unselected
  43107. */
  43108. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43109. private _raySelectionPredicate;
  43110. /**
  43111. * To be optionaly changed by user to define custom ray selection
  43112. */
  43113. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43114. /**
  43115. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43116. */
  43117. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43118. /**
  43119. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43120. */
  43121. teleportationEnabled: boolean;
  43122. private _defaultHeight;
  43123. private _teleportationInitialized;
  43124. private _interactionsEnabled;
  43125. private _interactionsRequested;
  43126. private _displayGaze;
  43127. private _displayLaserPointer;
  43128. /**
  43129. * The mesh used to display where the user is going to teleport.
  43130. */
  43131. /**
  43132. * Sets the mesh to be used to display where the user is going to teleport.
  43133. */
  43134. teleportationTarget: Mesh;
  43135. /**
  43136. * 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
  43137. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43138. * See http://doc.babylonjs.com/resources/baking_transformations
  43139. */
  43140. gazeTrackerMesh: Mesh;
  43141. /**
  43142. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43143. */
  43144. updateGazeTrackerScale: boolean;
  43145. /**
  43146. * If the gaze trackers color should be updated when selecting meshes
  43147. */
  43148. updateGazeTrackerColor: boolean;
  43149. /**
  43150. * If the controller laser color should be updated when selecting meshes
  43151. */
  43152. updateControllerLaserColor: boolean;
  43153. /**
  43154. * The gaze tracking mesh corresponding to the left controller
  43155. */
  43156. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43157. /**
  43158. * The gaze tracking mesh corresponding to the right controller
  43159. */
  43160. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43161. /**
  43162. * If the ray of the gaze should be displayed.
  43163. */
  43164. /**
  43165. * Sets if the ray of the gaze should be displayed.
  43166. */
  43167. displayGaze: boolean;
  43168. /**
  43169. * If the ray of the LaserPointer should be displayed.
  43170. */
  43171. /**
  43172. * Sets if the ray of the LaserPointer should be displayed.
  43173. */
  43174. displayLaserPointer: boolean;
  43175. /**
  43176. * The deviceOrientationCamera used as the camera when not in VR.
  43177. */
  43178. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43179. /**
  43180. * Based on the current WebVR support, returns the current VR camera used.
  43181. */
  43182. readonly currentVRCamera: Nullable<Camera>;
  43183. /**
  43184. * The webVRCamera which is used when in VR.
  43185. */
  43186. readonly webVRCamera: WebVRFreeCamera;
  43187. /**
  43188. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43189. */
  43190. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43191. /**
  43192. * The html button that is used to trigger entering into VR.
  43193. */
  43194. readonly vrButton: Nullable<HTMLButtonElement>;
  43195. private readonly _teleportationRequestInitiated;
  43196. /**
  43197. * Defines wether or not Pointer lock should be requested when switching to
  43198. * full screen.
  43199. */
  43200. requestPointerLockOnFullScreen: boolean;
  43201. /**
  43202. * Instantiates a VRExperienceHelper.
  43203. * Helps to quickly add VR support to an existing scene.
  43204. * @param scene The scene the VRExperienceHelper belongs to.
  43205. * @param webVROptions Options to modify the vr experience helper's behavior.
  43206. */
  43207. constructor(scene: Scene,
  43208. /** Options to modify the vr experience helper's behavior. */
  43209. webVROptions?: VRExperienceHelperOptions);
  43210. private _onDefaultMeshLoaded;
  43211. private _onResize;
  43212. private _onFullscreenChange;
  43213. /**
  43214. * Gets a value indicating if we are currently in VR mode.
  43215. */
  43216. readonly isInVRMode: boolean;
  43217. private onVrDisplayPresentChange;
  43218. private onVRDisplayChanged;
  43219. private moveButtonToBottomRight;
  43220. private displayVRButton;
  43221. private updateButtonVisibility;
  43222. private _cachedAngularSensibility;
  43223. /**
  43224. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43225. * Otherwise, will use the fullscreen API.
  43226. */
  43227. enterVR(): void;
  43228. /**
  43229. * Attempt to exit VR, or fullscreen.
  43230. */
  43231. exitVR(): void;
  43232. /**
  43233. * The position of the vr experience helper.
  43234. */
  43235. /**
  43236. * Sets the position of the vr experience helper.
  43237. */
  43238. position: Vector3;
  43239. /**
  43240. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43241. */
  43242. enableInteractions(): void;
  43243. private readonly _noControllerIsActive;
  43244. private beforeRender;
  43245. private _isTeleportationFloor;
  43246. /**
  43247. * Adds a floor mesh to be used for teleportation.
  43248. * @param floorMesh the mesh to be used for teleportation.
  43249. */
  43250. addFloorMesh(floorMesh: Mesh): void;
  43251. /**
  43252. * Removes a floor mesh from being used for teleportation.
  43253. * @param floorMesh the mesh to be removed.
  43254. */
  43255. removeFloorMesh(floorMesh: Mesh): void;
  43256. /**
  43257. * Enables interactions and teleportation using the VR controllers and gaze.
  43258. * @param vrTeleportationOptions options to modify teleportation behavior.
  43259. */
  43260. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43261. private _onNewGamepadConnected;
  43262. private _tryEnableInteractionOnController;
  43263. private _onNewGamepadDisconnected;
  43264. private _enableInteractionOnController;
  43265. private _checkTeleportWithRay;
  43266. private _checkRotate;
  43267. private _checkTeleportBackwards;
  43268. private _enableTeleportationOnController;
  43269. private _createTeleportationCircles;
  43270. private _displayTeleportationTarget;
  43271. private _hideTeleportationTarget;
  43272. private _rotateCamera;
  43273. private _moveTeleportationSelectorTo;
  43274. private _workingVector;
  43275. private _workingQuaternion;
  43276. private _workingMatrix;
  43277. /**
  43278. * Teleports the users feet to the desired location
  43279. * @param location The location where the user's feet should be placed
  43280. */
  43281. teleportCamera(location: Vector3): void;
  43282. private _convertNormalToDirectionOfRay;
  43283. private _castRayAndSelectObject;
  43284. private _notifySelectedMeshUnselected;
  43285. /**
  43286. * Sets the color of the laser ray from the vr controllers.
  43287. * @param color new color for the ray.
  43288. */
  43289. changeLaserColor(color: Color3): void;
  43290. /**
  43291. * Sets the color of the ray from the vr headsets gaze.
  43292. * @param color new color for the ray.
  43293. */
  43294. changeGazeColor(color: Color3): void;
  43295. /**
  43296. * Exits VR and disposes of the vr experience helper
  43297. */
  43298. dispose(): void;
  43299. /**
  43300. * Gets the name of the VRExperienceHelper class
  43301. * @returns "VRExperienceHelper"
  43302. */
  43303. getClassName(): string;
  43304. }
  43305. }
  43306. declare module "babylonjs/Cameras/VR/index" {
  43307. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43308. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43309. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43310. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43311. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43312. export * from "babylonjs/Cameras/VR/webVRCamera";
  43313. }
  43314. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43315. import { Nullable } from "babylonjs/types";
  43316. import { IDisposable } from "babylonjs/scene";
  43317. /**
  43318. * States of the webXR experience
  43319. */
  43320. export enum WebXRState {
  43321. /**
  43322. * Transitioning to being in XR mode
  43323. */
  43324. ENTERING_XR = 0,
  43325. /**
  43326. * Transitioning to non XR mode
  43327. */
  43328. EXITING_XR = 1,
  43329. /**
  43330. * In XR mode and presenting
  43331. */
  43332. IN_XR = 2,
  43333. /**
  43334. * Not entered XR mode
  43335. */
  43336. NOT_IN_XR = 3
  43337. }
  43338. /**
  43339. * Abstraction of the XR render target
  43340. */
  43341. export interface WebXRRenderTarget extends IDisposable {
  43342. /**
  43343. * xrpresent context of the canvas which can be used to display/mirror xr content
  43344. */
  43345. canvasContext: WebGLRenderingContext;
  43346. /**
  43347. * xr layer for the canvas
  43348. */
  43349. xrLayer: Nullable<XRWebGLLayer>;
  43350. /**
  43351. * Initializes the xr layer for the session
  43352. * @param xrSession xr session
  43353. * @returns a promise that will resolve once the XR Layer has been created
  43354. */
  43355. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43356. }
  43357. }
  43358. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43359. import { Nullable } from "babylonjs/types";
  43360. import { Observable } from "babylonjs/Misc/observable";
  43361. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43362. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43363. /**
  43364. * COnfiguration object for WebXR output canvas
  43365. */
  43366. export class WebXRManagedOutputCanvasOptions {
  43367. /**
  43368. * Options for this XR Layer output
  43369. */
  43370. canvasOptions: XRWebGLLayerOptions;
  43371. /**
  43372. * CSS styling for a newly created canvas (if not provided)
  43373. */
  43374. newCanvasCssStyle?: string;
  43375. /**
  43376. * Get the default values of the configuration object
  43377. * @returns default values of this configuration object
  43378. */
  43379. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43380. }
  43381. /**
  43382. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43383. */
  43384. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43385. private configuration;
  43386. private _engine;
  43387. private _canvas;
  43388. /**
  43389. * xrpresent context of the canvas which can be used to display/mirror xr content
  43390. */
  43391. canvasContext: WebGLRenderingContext;
  43392. /**
  43393. * xr layer for the canvas
  43394. */
  43395. xrLayer: Nullable<XRWebGLLayer>;
  43396. /**
  43397. * Initializes the xr layer for the session
  43398. * @param xrSession xr session
  43399. * @returns a promise that will resolve once the XR Layer has been created
  43400. */
  43401. initializeXRLayerAsync(xrSession: any): any;
  43402. /**
  43403. * Initializes the canvas to be added/removed upon entering/exiting xr
  43404. * @param engine the Babylon engine
  43405. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43406. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43407. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43408. */
  43409. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43410. /**
  43411. * Disposes of the object
  43412. */
  43413. dispose(): void;
  43414. private _setManagedOutputCanvas;
  43415. private _addCanvas;
  43416. private _removeCanvas;
  43417. }
  43418. }
  43419. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43420. import { Observable } from "babylonjs/Misc/observable";
  43421. import { Nullable } from "babylonjs/types";
  43422. import { IDisposable, Scene } from "babylonjs/scene";
  43423. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43424. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43425. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43426. /**
  43427. * Manages an XRSession to work with Babylon's engine
  43428. * @see https://doc.babylonjs.com/how_to/webxr
  43429. */
  43430. export class WebXRSessionManager implements IDisposable {
  43431. private scene;
  43432. /**
  43433. * Fires every time a new xrFrame arrives which can be used to update the camera
  43434. */
  43435. onXRFrameObservable: Observable<any>;
  43436. /**
  43437. * Fires when the xr session is ended either by the device or manually done
  43438. */
  43439. onXRSessionEnded: Observable<any>;
  43440. /**
  43441. * Underlying xr session
  43442. */
  43443. session: XRSession;
  43444. /**
  43445. * Type of reference space used when creating the session
  43446. */
  43447. referenceSpace: XRReferenceSpace;
  43448. /**
  43449. * Current XR frame
  43450. */
  43451. currentFrame: Nullable<XRFrame>;
  43452. private _xrNavigator;
  43453. private baseLayer;
  43454. private _rttProvider;
  43455. private _sessionEnded;
  43456. /**
  43457. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43458. * @param scene The scene which the session should be created for
  43459. */
  43460. constructor(scene: Scene);
  43461. /**
  43462. * Initializes the manager
  43463. * After initialization enterXR can be called to start an XR session
  43464. * @returns Promise which resolves after it is initialized
  43465. */
  43466. initializeAsync(): Promise<void>;
  43467. /**
  43468. * Initializes an xr session
  43469. * @param xrSessionMode mode to initialize
  43470. * @param optionalFeatures defines optional values to pass to the session builder
  43471. * @returns a promise which will resolve once the session has been initialized
  43472. */
  43473. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  43474. /**
  43475. * Sets the reference space on the xr session
  43476. * @param referenceSpace space to set
  43477. * @returns a promise that will resolve once the reference space has been set
  43478. */
  43479. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43480. /**
  43481. * Updates the render state of the session
  43482. * @param state state to set
  43483. * @returns a promise that resolves once the render state has been updated
  43484. */
  43485. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43486. /**
  43487. * Starts rendering to the xr layer
  43488. * @returns a promise that will resolve once rendering has started
  43489. */
  43490. startRenderingToXRAsync(): Promise<void>;
  43491. /**
  43492. * Gets the correct render target texture to be rendered this frame for this eye
  43493. * @param eye the eye for which to get the render target
  43494. * @returns the render target for the specified eye
  43495. */
  43496. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43497. /**
  43498. * Stops the xrSession and restores the renderloop
  43499. * @returns Promise which resolves after it exits XR
  43500. */
  43501. exitXRAsync(): Promise<void>;
  43502. /**
  43503. * Checks if a session would be supported for the creation options specified
  43504. * @param sessionMode session mode to check if supported eg. immersive-vr
  43505. * @returns true if supported
  43506. */
  43507. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43508. /**
  43509. * Creates a WebXRRenderTarget object for the XR session
  43510. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43511. * @param options optional options to provide when creating a new render target
  43512. * @returns a WebXR render target to which the session can render
  43513. */
  43514. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43515. /**
  43516. * @hidden
  43517. * Converts the render layer of xrSession to a render target
  43518. * @param session session to create render target for
  43519. * @param scene scene the new render target should be created for
  43520. */
  43521. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43522. /**
  43523. * Disposes of the session manager
  43524. */
  43525. dispose(): void;
  43526. }
  43527. }
  43528. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43529. import { Scene } from "babylonjs/scene";
  43530. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43531. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43532. /**
  43533. * WebXR Camera which holds the views for the xrSession
  43534. * @see https://doc.babylonjs.com/how_to/webxr
  43535. */
  43536. export class WebXRCamera extends FreeCamera {
  43537. private static _TmpMatrix;
  43538. /**
  43539. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43540. * @param name the name of the camera
  43541. * @param scene the scene to add the camera to
  43542. */
  43543. constructor(name: string, scene: Scene);
  43544. private _updateNumberOfRigCameras;
  43545. /** @hidden */
  43546. _updateForDualEyeDebugging(): void;
  43547. /**
  43548. * Updates the cameras position from the current pose information of the XR session
  43549. * @param xrSessionManager the session containing pose information
  43550. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43551. */
  43552. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43553. }
  43554. }
  43555. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43556. import { Observable } from "babylonjs/Misc/observable";
  43557. import { IDisposable, Scene } from "babylonjs/scene";
  43558. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43560. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43561. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43562. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43563. /**
  43564. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43565. * @see https://doc.babylonjs.com/how_to/webxr
  43566. */
  43567. export class WebXRExperienceHelper implements IDisposable {
  43568. private scene;
  43569. /**
  43570. * 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
  43571. */
  43572. container: AbstractMesh;
  43573. /**
  43574. * Camera used to render xr content
  43575. */
  43576. camera: WebXRCamera;
  43577. /**
  43578. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43579. */
  43580. state: WebXRState;
  43581. private _setState;
  43582. private static _TmpVector;
  43583. /**
  43584. * Fires when the state of the experience helper has changed
  43585. */
  43586. onStateChangedObservable: Observable<WebXRState>;
  43587. /** Session manager used to keep track of xr session */
  43588. sessionManager: WebXRSessionManager;
  43589. private _nonVRCamera;
  43590. private _originalSceneAutoClear;
  43591. private _supported;
  43592. /**
  43593. * Creates the experience helper
  43594. * @param scene the scene to attach the experience helper to
  43595. * @returns a promise for the experience helper
  43596. */
  43597. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43598. /**
  43599. * Creates a WebXRExperienceHelper
  43600. * @param scene The scene the helper should be created in
  43601. */
  43602. private constructor();
  43603. /**
  43604. * Exits XR mode and returns the scene to its original state
  43605. * @returns promise that resolves after xr mode has exited
  43606. */
  43607. exitXRAsync(): Promise<void>;
  43608. /**
  43609. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43610. * @param sessionMode options for the XR session
  43611. * @param referenceSpaceType frame of reference of the XR session
  43612. * @param renderTarget the output canvas that will be used to enter XR mode
  43613. * @returns promise that resolves after xr mode has entered
  43614. */
  43615. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  43616. /**
  43617. * Updates the global position of the camera by moving the camera's container
  43618. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43619. * @param position The desired global position of the camera
  43620. */
  43621. setPositionOfCameraUsingContainer(position: Vector3): void;
  43622. /**
  43623. * Rotates the xr camera by rotating the camera's container around the camera's position
  43624. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43625. * @param rotation the desired quaternion rotation to apply to the camera
  43626. */
  43627. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43628. /**
  43629. * Disposes of the experience helper
  43630. */
  43631. dispose(): void;
  43632. }
  43633. }
  43634. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43635. import { Nullable } from "babylonjs/types";
  43636. import { Observable } from "babylonjs/Misc/observable";
  43637. import { IDisposable, Scene } from "babylonjs/scene";
  43638. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43639. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43640. /**
  43641. * Button which can be used to enter a different mode of XR
  43642. */
  43643. export class WebXREnterExitUIButton {
  43644. /** button element */
  43645. element: HTMLElement;
  43646. /** XR initialization options for the button */
  43647. sessionMode: XRSessionMode;
  43648. /** Reference space type */
  43649. referenceSpaceType: XRReferenceSpaceType;
  43650. /**
  43651. * Creates a WebXREnterExitUIButton
  43652. * @param element button element
  43653. * @param sessionMode XR initialization session mode
  43654. * @param referenceSpaceType the type of reference space to be used
  43655. */
  43656. constructor(
  43657. /** button element */
  43658. element: HTMLElement,
  43659. /** XR initialization options for the button */
  43660. sessionMode: XRSessionMode,
  43661. /** Reference space type */
  43662. referenceSpaceType: XRReferenceSpaceType);
  43663. /**
  43664. * Overwritable function which can be used to update the button's visuals when the state changes
  43665. * @param activeButton the current active button in the UI
  43666. */
  43667. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43668. }
  43669. /**
  43670. * Options to create the webXR UI
  43671. */
  43672. export class WebXREnterExitUIOptions {
  43673. /**
  43674. * Context to enter xr with
  43675. */
  43676. renderTarget?: Nullable<WebXRRenderTarget>;
  43677. /**
  43678. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43679. */
  43680. customButtons?: Array<WebXREnterExitUIButton>;
  43681. }
  43682. /**
  43683. * UI to allow the user to enter/exit XR mode
  43684. */
  43685. export class WebXREnterExitUI implements IDisposable {
  43686. private scene;
  43687. private _overlay;
  43688. private _buttons;
  43689. private _activeButton;
  43690. /**
  43691. * Fired every time the active button is changed.
  43692. *
  43693. * When xr is entered via a button that launches xr that button will be the callback parameter
  43694. *
  43695. * When exiting xr the callback parameter will be null)
  43696. */
  43697. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43698. /**
  43699. * Creates UI to allow the user to enter/exit XR mode
  43700. * @param scene the scene to add the ui to
  43701. * @param helper the xr experience helper to enter/exit xr with
  43702. * @param options options to configure the UI
  43703. * @returns the created ui
  43704. */
  43705. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43706. private constructor();
  43707. private _updateButtons;
  43708. /**
  43709. * Disposes of the object
  43710. */
  43711. dispose(): void;
  43712. }
  43713. }
  43714. declare module "babylonjs/Cameras/XR/webXRController" {
  43715. import { Nullable } from "babylonjs/types";
  43716. import { Observable } from "babylonjs/Misc/observable";
  43717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43718. import { Ray } from "babylonjs/Culling/ray";
  43719. import { Scene } from "babylonjs/scene";
  43720. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43721. /**
  43722. * Represents an XR input
  43723. */
  43724. export class WebXRController {
  43725. private scene;
  43726. /** The underlying input source for the controller */
  43727. inputSource: XRInputSource;
  43728. private parentContainer;
  43729. /**
  43730. * 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
  43731. */
  43732. grip?: AbstractMesh;
  43733. /**
  43734. * Pointer which can be used to select objects or attach a visible laser to
  43735. */
  43736. pointer: AbstractMesh;
  43737. private _gamepadMode;
  43738. /**
  43739. * If available, this is the gamepad object related to this controller.
  43740. * Using this object it is possible to get click events and trackpad changes of the
  43741. * webxr controller that is currently being used.
  43742. */
  43743. gamepadController?: WebVRController;
  43744. /**
  43745. * Event that fires when the controller is removed/disposed
  43746. */
  43747. onDisposeObservable: Observable<{}>;
  43748. private _tmpMatrix;
  43749. private _tmpQuaternion;
  43750. private _tmpVector;
  43751. /**
  43752. * Creates the controller
  43753. * @see https://doc.babylonjs.com/how_to/webxr
  43754. * @param scene the scene which the controller should be associated to
  43755. * @param inputSource the underlying input source for the controller
  43756. * @param parentContainer parent that the controller meshes should be children of
  43757. */
  43758. constructor(scene: Scene,
  43759. /** The underlying input source for the controller */
  43760. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43761. /**
  43762. * Updates the controller pose based on the given XRFrame
  43763. * @param xrFrame xr frame to update the pose with
  43764. * @param referenceSpace reference space to use
  43765. */
  43766. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43767. /**
  43768. * Gets a world space ray coming from the controller
  43769. * @param result the resulting ray
  43770. */
  43771. getWorldPointerRayToRef(result: Ray): void;
  43772. /**
  43773. * Get the scene associated with this controller
  43774. * @returns the scene object
  43775. */
  43776. getScene(): Scene;
  43777. /**
  43778. * Disposes of the object
  43779. */
  43780. dispose(): void;
  43781. }
  43782. }
  43783. declare module "babylonjs/Cameras/XR/webXRInput" {
  43784. import { Observable } from "babylonjs/Misc/observable";
  43785. import { IDisposable } from "babylonjs/scene";
  43786. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43787. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43788. /**
  43789. * XR input used to track XR inputs such as controllers/rays
  43790. */
  43791. export class WebXRInput implements IDisposable {
  43792. /**
  43793. * Base experience the input listens to
  43794. */
  43795. baseExperience: WebXRExperienceHelper;
  43796. /**
  43797. * XR controllers being tracked
  43798. */
  43799. controllers: Array<WebXRController>;
  43800. private _frameObserver;
  43801. private _stateObserver;
  43802. /**
  43803. * Event when a controller has been connected/added
  43804. */
  43805. onControllerAddedObservable: Observable<WebXRController>;
  43806. /**
  43807. * Event when a controller has been removed/disconnected
  43808. */
  43809. onControllerRemovedObservable: Observable<WebXRController>;
  43810. /**
  43811. * Initializes the WebXRInput
  43812. * @param baseExperience experience helper which the input should be created for
  43813. */
  43814. constructor(
  43815. /**
  43816. * Base experience the input listens to
  43817. */
  43818. baseExperience: WebXRExperienceHelper);
  43819. private _onInputSourcesChange;
  43820. private _addAndRemoveControllers;
  43821. /**
  43822. * Disposes of the object
  43823. */
  43824. dispose(): void;
  43825. }
  43826. }
  43827. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43829. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43830. /**
  43831. * Enables teleportation
  43832. */
  43833. export class WebXRControllerTeleportation {
  43834. private _teleportationFillColor;
  43835. private _teleportationBorderColor;
  43836. private _tmpRay;
  43837. private _tmpVector;
  43838. /**
  43839. * Creates a WebXRControllerTeleportation
  43840. * @param input input manager to add teleportation to
  43841. * @param floorMeshes floormeshes which can be teleported to
  43842. */
  43843. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43844. }
  43845. }
  43846. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43847. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43848. /**
  43849. * Handles pointer input automatically for the pointer of XR controllers
  43850. */
  43851. export class WebXRControllerPointerSelection {
  43852. private static _idCounter;
  43853. private _tmpRay;
  43854. /**
  43855. * Creates a WebXRControllerPointerSelection
  43856. * @param input input manager to setup pointer selection
  43857. */
  43858. constructor(input: WebXRInput);
  43859. private _convertNormalToDirectionOfRay;
  43860. private _updatePointerDistance;
  43861. }
  43862. }
  43863. declare module "babylonjs/Loading/sceneLoader" {
  43864. import { Observable } from "babylonjs/Misc/observable";
  43865. import { Nullable } from "babylonjs/types";
  43866. import { Scene } from "babylonjs/scene";
  43867. import { Engine } from "babylonjs/Engines/engine";
  43868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43869. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43870. import { AssetContainer } from "babylonjs/assetContainer";
  43871. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43872. import { Skeleton } from "babylonjs/Bones/skeleton";
  43873. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43874. import { WebRequest } from "babylonjs/Misc/webRequest";
  43875. /**
  43876. * Class used to represent data loading progression
  43877. */
  43878. export class SceneLoaderProgressEvent {
  43879. /** defines if data length to load can be evaluated */
  43880. readonly lengthComputable: boolean;
  43881. /** defines the loaded data length */
  43882. readonly loaded: number;
  43883. /** defines the data length to load */
  43884. readonly total: number;
  43885. /**
  43886. * Create a new progress event
  43887. * @param lengthComputable defines if data length to load can be evaluated
  43888. * @param loaded defines the loaded data length
  43889. * @param total defines the data length to load
  43890. */
  43891. constructor(
  43892. /** defines if data length to load can be evaluated */
  43893. lengthComputable: boolean,
  43894. /** defines the loaded data length */
  43895. loaded: number,
  43896. /** defines the data length to load */
  43897. total: number);
  43898. /**
  43899. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43900. * @param event defines the source event
  43901. * @returns a new SceneLoaderProgressEvent
  43902. */
  43903. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43904. }
  43905. /**
  43906. * Interface used by SceneLoader plugins to define supported file extensions
  43907. */
  43908. export interface ISceneLoaderPluginExtensions {
  43909. /**
  43910. * Defines the list of supported extensions
  43911. */
  43912. [extension: string]: {
  43913. isBinary: boolean;
  43914. };
  43915. }
  43916. /**
  43917. * Interface used by SceneLoader plugin factory
  43918. */
  43919. export interface ISceneLoaderPluginFactory {
  43920. /**
  43921. * Defines the name of the factory
  43922. */
  43923. name: string;
  43924. /**
  43925. * Function called to create a new plugin
  43926. * @return the new plugin
  43927. */
  43928. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43929. /**
  43930. * The callback that returns true if the data can be directly loaded.
  43931. * @param data string containing the file data
  43932. * @returns if the data can be loaded directly
  43933. */
  43934. canDirectLoad?(data: string): boolean;
  43935. }
  43936. /**
  43937. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43938. */
  43939. export interface ISceneLoaderPluginBase {
  43940. /**
  43941. * The friendly name of this plugin.
  43942. */
  43943. name: string;
  43944. /**
  43945. * The file extensions supported by this plugin.
  43946. */
  43947. extensions: string | ISceneLoaderPluginExtensions;
  43948. /**
  43949. * The callback called when loading from a url.
  43950. * @param scene scene loading this url
  43951. * @param url url to load
  43952. * @param onSuccess callback called when the file successfully loads
  43953. * @param onProgress callback called while file is loading (if the server supports this mode)
  43954. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43955. * @param onError callback called when the file fails to load
  43956. * @returns a file request object
  43957. */
  43958. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43959. /**
  43960. * The callback called when loading from a file object.
  43961. * @param scene scene loading this file
  43962. * @param file defines the file to load
  43963. * @param onSuccess defines the callback to call when data is loaded
  43964. * @param onProgress defines the callback to call during loading process
  43965. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43966. * @param onError defines the callback to call when an error occurs
  43967. * @returns a file request object
  43968. */
  43969. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43970. /**
  43971. * The callback that returns true if the data can be directly loaded.
  43972. * @param data string containing the file data
  43973. * @returns if the data can be loaded directly
  43974. */
  43975. canDirectLoad?(data: string): boolean;
  43976. /**
  43977. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43978. * @param scene scene loading this data
  43979. * @param data string containing the data
  43980. * @returns data to pass to the plugin
  43981. */
  43982. directLoad?(scene: Scene, data: string): any;
  43983. /**
  43984. * The callback that allows custom handling of the root url based on the response url.
  43985. * @param rootUrl the original root url
  43986. * @param responseURL the response url if available
  43987. * @returns the new root url
  43988. */
  43989. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43990. }
  43991. /**
  43992. * Interface used to define a SceneLoader plugin
  43993. */
  43994. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43995. /**
  43996. * Import meshes into a scene.
  43997. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43998. * @param scene The scene to import into
  43999. * @param data The data to import
  44000. * @param rootUrl The root url for scene and resources
  44001. * @param meshes The meshes array to import into
  44002. * @param particleSystems The particle systems array to import into
  44003. * @param skeletons The skeletons array to import into
  44004. * @param onError The callback when import fails
  44005. * @returns True if successful or false otherwise
  44006. */
  44007. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44008. /**
  44009. * Load into a scene.
  44010. * @param scene The scene to load into
  44011. * @param data The data to import
  44012. * @param rootUrl The root url for scene and resources
  44013. * @param onError The callback when import fails
  44014. * @returns True if successful or false otherwise
  44015. */
  44016. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44017. /**
  44018. * Load into an asset container.
  44019. * @param scene The scene to load into
  44020. * @param data The data to import
  44021. * @param rootUrl The root url for scene and resources
  44022. * @param onError The callback when import fails
  44023. * @returns The loaded asset container
  44024. */
  44025. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44026. }
  44027. /**
  44028. * Interface used to define an async SceneLoader plugin
  44029. */
  44030. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44031. /**
  44032. * Import meshes into a scene.
  44033. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44034. * @param scene The scene to import into
  44035. * @param data The data to import
  44036. * @param rootUrl The root url for scene and resources
  44037. * @param onProgress The callback when the load progresses
  44038. * @param fileName Defines the name of the file to load
  44039. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44040. */
  44041. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44042. meshes: AbstractMesh[];
  44043. particleSystems: IParticleSystem[];
  44044. skeletons: Skeleton[];
  44045. animationGroups: AnimationGroup[];
  44046. }>;
  44047. /**
  44048. * Load into a scene.
  44049. * @param scene The scene to load into
  44050. * @param data The data to import
  44051. * @param rootUrl The root url for scene and resources
  44052. * @param onProgress The callback when the load progresses
  44053. * @param fileName Defines the name of the file to load
  44054. * @returns Nothing
  44055. */
  44056. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44057. /**
  44058. * Load into an asset container.
  44059. * @param scene The scene to load into
  44060. * @param data The data to import
  44061. * @param rootUrl The root url for scene and resources
  44062. * @param onProgress The callback when the load progresses
  44063. * @param fileName Defines the name of the file to load
  44064. * @returns The loaded asset container
  44065. */
  44066. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44067. }
  44068. /**
  44069. * Class used to load scene from various file formats using registered plugins
  44070. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44071. */
  44072. export class SceneLoader {
  44073. /**
  44074. * No logging while loading
  44075. */
  44076. static readonly NO_LOGGING: number;
  44077. /**
  44078. * Minimal logging while loading
  44079. */
  44080. static readonly MINIMAL_LOGGING: number;
  44081. /**
  44082. * Summary logging while loading
  44083. */
  44084. static readonly SUMMARY_LOGGING: number;
  44085. /**
  44086. * Detailled logging while loading
  44087. */
  44088. static readonly DETAILED_LOGGING: number;
  44089. /**
  44090. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44091. */
  44092. static ForceFullSceneLoadingForIncremental: boolean;
  44093. /**
  44094. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44095. */
  44096. static ShowLoadingScreen: boolean;
  44097. /**
  44098. * Defines the current logging level (while loading the scene)
  44099. * @ignorenaming
  44100. */
  44101. static loggingLevel: number;
  44102. /**
  44103. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44104. */
  44105. static CleanBoneMatrixWeights: boolean;
  44106. /**
  44107. * Event raised when a plugin is used to load a scene
  44108. */
  44109. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44110. private static _registeredPlugins;
  44111. private static _getDefaultPlugin;
  44112. private static _getPluginForExtension;
  44113. private static _getPluginForDirectLoad;
  44114. private static _getPluginForFilename;
  44115. private static _getDirectLoad;
  44116. private static _loadData;
  44117. private static _getFileInfo;
  44118. /**
  44119. * Gets a plugin that can load the given extension
  44120. * @param extension defines the extension to load
  44121. * @returns a plugin or null if none works
  44122. */
  44123. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44124. /**
  44125. * Gets a boolean indicating that the given extension can be loaded
  44126. * @param extension defines the extension to load
  44127. * @returns true if the extension is supported
  44128. */
  44129. static IsPluginForExtensionAvailable(extension: string): boolean;
  44130. /**
  44131. * Adds a new plugin to the list of registered plugins
  44132. * @param plugin defines the plugin to add
  44133. */
  44134. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44135. /**
  44136. * Import meshes into a scene
  44137. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44138. * @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)
  44139. * @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)
  44140. * @param scene the instance of BABYLON.Scene to append to
  44141. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44142. * @param onProgress a callback with a progress event for each file being loaded
  44143. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44144. * @param pluginExtension the extension used to determine the plugin
  44145. * @returns The loaded plugin
  44146. */
  44147. 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>;
  44148. /**
  44149. * Import meshes into a scene
  44150. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44151. * @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)
  44152. * @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)
  44153. * @param scene the instance of BABYLON.Scene to append to
  44154. * @param onProgress a callback with a progress event for each file being loaded
  44155. * @param pluginExtension the extension used to determine the plugin
  44156. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44157. */
  44158. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44159. meshes: AbstractMesh[];
  44160. particleSystems: IParticleSystem[];
  44161. skeletons: Skeleton[];
  44162. animationGroups: AnimationGroup[];
  44163. }>;
  44164. /**
  44165. * Load a scene
  44166. * @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)
  44167. * @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)
  44168. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44169. * @param onSuccess a callback with the scene when import succeeds
  44170. * @param onProgress a callback with a progress event for each file being loaded
  44171. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44172. * @param pluginExtension the extension used to determine the plugin
  44173. * @returns The loaded plugin
  44174. */
  44175. 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>;
  44176. /**
  44177. * Load a scene
  44178. * @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)
  44179. * @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)
  44180. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44181. * @param onProgress a callback with a progress event for each file being loaded
  44182. * @param pluginExtension the extension used to determine the plugin
  44183. * @returns The loaded scene
  44184. */
  44185. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44186. /**
  44187. * Append a scene
  44188. * @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)
  44189. * @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)
  44190. * @param scene is the instance of BABYLON.Scene to append to
  44191. * @param onSuccess a callback with the scene when import succeeds
  44192. * @param onProgress a callback with a progress event for each file being loaded
  44193. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44194. * @param pluginExtension the extension used to determine the plugin
  44195. * @returns The loaded plugin
  44196. */
  44197. 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>;
  44198. /**
  44199. * Append a scene
  44200. * @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)
  44201. * @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)
  44202. * @param scene is the instance of BABYLON.Scene to append to
  44203. * @param onProgress a callback with a progress event for each file being loaded
  44204. * @param pluginExtension the extension used to determine the plugin
  44205. * @returns The given scene
  44206. */
  44207. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44208. /**
  44209. * Load a scene into an asset container
  44210. * @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)
  44211. * @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)
  44212. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44213. * @param onSuccess a callback with the scene when import succeeds
  44214. * @param onProgress a callback with a progress event for each file being loaded
  44215. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44216. * @param pluginExtension the extension used to determine the plugin
  44217. * @returns The loaded plugin
  44218. */
  44219. 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>;
  44220. /**
  44221. * Load a scene into an asset container
  44222. * @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)
  44223. * @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)
  44224. * @param scene is the instance of Scene to append to
  44225. * @param onProgress a callback with a progress event for each file being loaded
  44226. * @param pluginExtension the extension used to determine the plugin
  44227. * @returns The loaded asset container
  44228. */
  44229. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44230. }
  44231. }
  44232. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44233. import { Scene } from "babylonjs/scene";
  44234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44235. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44236. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44237. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44238. /**
  44239. * Generic Controller
  44240. */
  44241. export class GenericController extends WebVRController {
  44242. /**
  44243. * Base Url for the controller model.
  44244. */
  44245. static readonly MODEL_BASE_URL: string;
  44246. /**
  44247. * File name for the controller model.
  44248. */
  44249. static readonly MODEL_FILENAME: string;
  44250. /**
  44251. * Creates a new GenericController from a gamepad
  44252. * @param vrGamepad the gamepad that the controller should be created from
  44253. */
  44254. constructor(vrGamepad: any);
  44255. /**
  44256. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44257. * @param scene scene in which to add meshes
  44258. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44259. */
  44260. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44261. /**
  44262. * Called once for each button that changed state since the last frame
  44263. * @param buttonIdx Which button index changed
  44264. * @param state New state of the button
  44265. * @param changes Which properties on the state changed since last frame
  44266. */
  44267. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44268. }
  44269. }
  44270. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44271. import { Observable } from "babylonjs/Misc/observable";
  44272. import { Scene } from "babylonjs/scene";
  44273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44274. import { Ray } from "babylonjs/Culling/ray";
  44275. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44276. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44277. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44278. /**
  44279. * Defines the WindowsMotionController object that the state of the windows motion controller
  44280. */
  44281. export class WindowsMotionController extends WebVRController {
  44282. /**
  44283. * The base url used to load the left and right controller models
  44284. */
  44285. static MODEL_BASE_URL: string;
  44286. /**
  44287. * The name of the left controller model file
  44288. */
  44289. static MODEL_LEFT_FILENAME: string;
  44290. /**
  44291. * The name of the right controller model file
  44292. */
  44293. static MODEL_RIGHT_FILENAME: string;
  44294. /**
  44295. * The controller name prefix for this controller type
  44296. */
  44297. static readonly GAMEPAD_ID_PREFIX: string;
  44298. /**
  44299. * The controller id pattern for this controller type
  44300. */
  44301. private static readonly GAMEPAD_ID_PATTERN;
  44302. private _loadedMeshInfo;
  44303. private readonly _mapping;
  44304. /**
  44305. * Fired when the trackpad on this controller is clicked
  44306. */
  44307. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44308. /**
  44309. * Fired when the trackpad on this controller is modified
  44310. */
  44311. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44312. /**
  44313. * The current x and y values of this controller's trackpad
  44314. */
  44315. trackpad: StickValues;
  44316. /**
  44317. * Creates a new WindowsMotionController from a gamepad
  44318. * @param vrGamepad the gamepad that the controller should be created from
  44319. */
  44320. constructor(vrGamepad: any);
  44321. /**
  44322. * Fired when the trigger on this controller is modified
  44323. */
  44324. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44325. /**
  44326. * Fired when the menu button on this controller is modified
  44327. */
  44328. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44329. /**
  44330. * Fired when the grip button on this controller is modified
  44331. */
  44332. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44333. /**
  44334. * Fired when the thumbstick button on this controller is modified
  44335. */
  44336. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44337. /**
  44338. * Fired when the touchpad button on this controller is modified
  44339. */
  44340. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44341. /**
  44342. * Fired when the touchpad values on this controller are modified
  44343. */
  44344. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44345. private _updateTrackpad;
  44346. /**
  44347. * Called once per frame by the engine.
  44348. */
  44349. update(): void;
  44350. /**
  44351. * Called once for each button that changed state since the last frame
  44352. * @param buttonIdx Which button index changed
  44353. * @param state New state of the button
  44354. * @param changes Which properties on the state changed since last frame
  44355. */
  44356. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44357. /**
  44358. * Moves the buttons on the controller mesh based on their current state
  44359. * @param buttonName the name of the button to move
  44360. * @param buttonValue the value of the button which determines the buttons new position
  44361. */
  44362. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44363. /**
  44364. * Moves the axis on the controller mesh based on its current state
  44365. * @param axis the index of the axis
  44366. * @param axisValue the value of the axis which determines the meshes new position
  44367. * @hidden
  44368. */
  44369. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44370. /**
  44371. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44372. * @param scene scene in which to add meshes
  44373. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44374. */
  44375. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44376. /**
  44377. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44378. * can be transformed by button presses and axes values, based on this._mapping.
  44379. *
  44380. * @param scene scene in which the meshes exist
  44381. * @param meshes list of meshes that make up the controller model to process
  44382. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44383. */
  44384. private processModel;
  44385. private createMeshInfo;
  44386. /**
  44387. * Gets the ray of the controller in the direction the controller is pointing
  44388. * @param length the length the resulting ray should be
  44389. * @returns a ray in the direction the controller is pointing
  44390. */
  44391. getForwardRay(length?: number): Ray;
  44392. /**
  44393. * Disposes of the controller
  44394. */
  44395. dispose(): void;
  44396. }
  44397. }
  44398. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44399. import { Observable } from "babylonjs/Misc/observable";
  44400. import { Scene } from "babylonjs/scene";
  44401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44402. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44403. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44404. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44405. /**
  44406. * Oculus Touch Controller
  44407. */
  44408. export class OculusTouchController extends WebVRController {
  44409. /**
  44410. * Base Url for the controller model.
  44411. */
  44412. static MODEL_BASE_URL: string;
  44413. /**
  44414. * File name for the left controller model.
  44415. */
  44416. static MODEL_LEFT_FILENAME: string;
  44417. /**
  44418. * File name for the right controller model.
  44419. */
  44420. static MODEL_RIGHT_FILENAME: string;
  44421. /**
  44422. * Base Url for the Quest controller model.
  44423. */
  44424. static QUEST_MODEL_BASE_URL: string;
  44425. /**
  44426. * @hidden
  44427. * If the controllers are running on a device that needs the updated Quest controller models
  44428. */
  44429. static _IsQuest: boolean;
  44430. /**
  44431. * Fired when the secondary trigger on this controller is modified
  44432. */
  44433. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44434. /**
  44435. * Fired when the thumb rest on this controller is modified
  44436. */
  44437. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44438. /**
  44439. * Creates a new OculusTouchController from a gamepad
  44440. * @param vrGamepad the gamepad that the controller should be created from
  44441. */
  44442. constructor(vrGamepad: any);
  44443. /**
  44444. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44445. * @param scene scene in which to add meshes
  44446. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44447. */
  44448. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44449. /**
  44450. * Fired when the A button on this controller is modified
  44451. */
  44452. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44453. /**
  44454. * Fired when the B button on this controller is modified
  44455. */
  44456. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44457. /**
  44458. * Fired when the X button on this controller is modified
  44459. */
  44460. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44461. /**
  44462. * Fired when the Y button on this controller is modified
  44463. */
  44464. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44465. /**
  44466. * Called once for each button that changed state since the last frame
  44467. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44468. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44469. * 2) secondary trigger (same)
  44470. * 3) A (right) X (left), touch, pressed = value
  44471. * 4) B / Y
  44472. * 5) thumb rest
  44473. * @param buttonIdx Which button index changed
  44474. * @param state New state of the button
  44475. * @param changes Which properties on the state changed since last frame
  44476. */
  44477. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44478. }
  44479. }
  44480. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44481. import { Scene } from "babylonjs/scene";
  44482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44483. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44484. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44485. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44486. import { Observable } from "babylonjs/Misc/observable";
  44487. /**
  44488. * Vive Controller
  44489. */
  44490. export class ViveController extends WebVRController {
  44491. /**
  44492. * Base Url for the controller model.
  44493. */
  44494. static MODEL_BASE_URL: string;
  44495. /**
  44496. * File name for the controller model.
  44497. */
  44498. static MODEL_FILENAME: string;
  44499. /**
  44500. * Creates a new ViveController from a gamepad
  44501. * @param vrGamepad the gamepad that the controller should be created from
  44502. */
  44503. constructor(vrGamepad: any);
  44504. /**
  44505. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44506. * @param scene scene in which to add meshes
  44507. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44508. */
  44509. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44510. /**
  44511. * Fired when the left button on this controller is modified
  44512. */
  44513. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44514. /**
  44515. * Fired when the right button on this controller is modified
  44516. */
  44517. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44518. /**
  44519. * Fired when the menu button on this controller is modified
  44520. */
  44521. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44522. /**
  44523. * Called once for each button that changed state since the last frame
  44524. * Vive mapping:
  44525. * 0: touchpad
  44526. * 1: trigger
  44527. * 2: left AND right buttons
  44528. * 3: menu button
  44529. * @param buttonIdx Which button index changed
  44530. * @param state New state of the button
  44531. * @param changes Which properties on the state changed since last frame
  44532. */
  44533. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44534. }
  44535. }
  44536. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44537. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44538. /**
  44539. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44540. */
  44541. export class WebXRControllerModelLoader {
  44542. /**
  44543. * Creates the WebXRControllerModelLoader
  44544. * @param input xr input that creates the controllers
  44545. */
  44546. constructor(input: WebXRInput);
  44547. }
  44548. }
  44549. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44550. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44551. import { Scene } from "babylonjs/scene";
  44552. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44553. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44554. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44555. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44556. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44557. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44559. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44560. /**
  44561. * Options for the default xr helper
  44562. */
  44563. export class WebXRDefaultExperienceOptions {
  44564. /**
  44565. * Floor meshes that should be used for teleporting
  44566. */
  44567. floorMeshes: Array<AbstractMesh>;
  44568. /**
  44569. * Enable or disable default UI to enter XR
  44570. */
  44571. disableDefaultUI: boolean;
  44572. /**
  44573. * optional configuration for the output canvas
  44574. */
  44575. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44576. }
  44577. /**
  44578. * Default experience which provides a similar setup to the previous webVRExperience
  44579. */
  44580. export class WebXRDefaultExperience {
  44581. /**
  44582. * Base experience
  44583. */
  44584. baseExperience: WebXRExperienceHelper;
  44585. /**
  44586. * Input experience extension
  44587. */
  44588. input: WebXRInput;
  44589. /**
  44590. * Loads the controller models
  44591. */
  44592. controllerModelLoader: WebXRControllerModelLoader;
  44593. /**
  44594. * Enables laser pointer and selection
  44595. */
  44596. pointerSelection: WebXRControllerPointerSelection;
  44597. /**
  44598. * Enables teleportation
  44599. */
  44600. teleportation: WebXRControllerTeleportation;
  44601. /**
  44602. * Enables ui for enetering/exiting xr
  44603. */
  44604. enterExitUI: WebXREnterExitUI;
  44605. /**
  44606. * Default target xr should render to
  44607. */
  44608. renderTarget: WebXRRenderTarget;
  44609. /**
  44610. * Creates the default xr experience
  44611. * @param scene scene
  44612. * @param options options for basic configuration
  44613. * @returns resulting WebXRDefaultExperience
  44614. */
  44615. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44616. private constructor();
  44617. /**
  44618. * DIsposes of the experience helper
  44619. */
  44620. dispose(): void;
  44621. }
  44622. }
  44623. declare module "babylonjs/Cameras/XR/index" {
  44624. export * from "babylonjs/Cameras/XR/webXRCamera";
  44625. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44626. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44627. export * from "babylonjs/Cameras/XR/webXRInput";
  44628. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44629. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44630. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44631. export * from "babylonjs/Cameras/XR/webXRController";
  44632. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44633. export * from "babylonjs/Cameras/XR/webXRTypes";
  44634. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44635. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44636. }
  44637. declare module "babylonjs/Cameras/RigModes/index" {
  44638. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44639. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44640. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44641. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44642. }
  44643. declare module "babylonjs/Cameras/index" {
  44644. export * from "babylonjs/Cameras/Inputs/index";
  44645. export * from "babylonjs/Cameras/cameraInputsManager";
  44646. export * from "babylonjs/Cameras/camera";
  44647. export * from "babylonjs/Cameras/targetCamera";
  44648. export * from "babylonjs/Cameras/freeCamera";
  44649. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44650. export * from "babylonjs/Cameras/touchCamera";
  44651. export * from "babylonjs/Cameras/arcRotateCamera";
  44652. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44653. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44654. export * from "babylonjs/Cameras/flyCamera";
  44655. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44656. export * from "babylonjs/Cameras/followCamera";
  44657. export * from "babylonjs/Cameras/followCameraInputsManager";
  44658. export * from "babylonjs/Cameras/gamepadCamera";
  44659. export * from "babylonjs/Cameras/Stereoscopic/index";
  44660. export * from "babylonjs/Cameras/universalCamera";
  44661. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44662. export * from "babylonjs/Cameras/VR/index";
  44663. export * from "babylonjs/Cameras/XR/index";
  44664. export * from "babylonjs/Cameras/RigModes/index";
  44665. }
  44666. declare module "babylonjs/Collisions/index" {
  44667. export * from "babylonjs/Collisions/collider";
  44668. export * from "babylonjs/Collisions/collisionCoordinator";
  44669. export * from "babylonjs/Collisions/pickingInfo";
  44670. export * from "babylonjs/Collisions/intersectionInfo";
  44671. export * from "babylonjs/Collisions/meshCollisionData";
  44672. }
  44673. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44674. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44675. import { Vector3 } from "babylonjs/Maths/math.vector";
  44676. import { Ray } from "babylonjs/Culling/ray";
  44677. import { Plane } from "babylonjs/Maths/math.plane";
  44678. /**
  44679. * Contains an array of blocks representing the octree
  44680. */
  44681. export interface IOctreeContainer<T> {
  44682. /**
  44683. * Blocks within the octree
  44684. */
  44685. blocks: Array<OctreeBlock<T>>;
  44686. }
  44687. /**
  44688. * Class used to store a cell in an octree
  44689. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44690. */
  44691. export class OctreeBlock<T> {
  44692. /**
  44693. * Gets the content of the current block
  44694. */
  44695. entries: T[];
  44696. /**
  44697. * Gets the list of block children
  44698. */
  44699. blocks: Array<OctreeBlock<T>>;
  44700. private _depth;
  44701. private _maxDepth;
  44702. private _capacity;
  44703. private _minPoint;
  44704. private _maxPoint;
  44705. private _boundingVectors;
  44706. private _creationFunc;
  44707. /**
  44708. * Creates a new block
  44709. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44710. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44711. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44712. * @param depth defines the current depth of this block in the octree
  44713. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44714. * @param creationFunc defines a callback to call when an element is added to the block
  44715. */
  44716. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44717. /**
  44718. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44719. */
  44720. readonly capacity: number;
  44721. /**
  44722. * Gets the minimum vector (in world space) of the block's bounding box
  44723. */
  44724. readonly minPoint: Vector3;
  44725. /**
  44726. * Gets the maximum vector (in world space) of the block's bounding box
  44727. */
  44728. readonly maxPoint: Vector3;
  44729. /**
  44730. * Add a new element to this block
  44731. * @param entry defines the element to add
  44732. */
  44733. addEntry(entry: T): void;
  44734. /**
  44735. * Remove an element from this block
  44736. * @param entry defines the element to remove
  44737. */
  44738. removeEntry(entry: T): void;
  44739. /**
  44740. * Add an array of elements to this block
  44741. * @param entries defines the array of elements to add
  44742. */
  44743. addEntries(entries: T[]): void;
  44744. /**
  44745. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44746. * @param frustumPlanes defines the frustum planes to test
  44747. * @param selection defines the array to store current content if selection is positive
  44748. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44749. */
  44750. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44751. /**
  44752. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44753. * @param sphereCenter defines the bounding sphere center
  44754. * @param sphereRadius defines the bounding sphere radius
  44755. * @param selection defines the array to store current content if selection is positive
  44756. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44757. */
  44758. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44759. /**
  44760. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44761. * @param ray defines the ray to test with
  44762. * @param selection defines the array to store current content if selection is positive
  44763. */
  44764. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44765. /**
  44766. * Subdivide the content into child blocks (this block will then be empty)
  44767. */
  44768. createInnerBlocks(): void;
  44769. /**
  44770. * @hidden
  44771. */
  44772. 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;
  44773. }
  44774. }
  44775. declare module "babylonjs/Culling/Octrees/octree" {
  44776. import { SmartArray } from "babylonjs/Misc/smartArray";
  44777. import { Vector3 } from "babylonjs/Maths/math.vector";
  44778. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44780. import { Ray } from "babylonjs/Culling/ray";
  44781. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44782. import { Plane } from "babylonjs/Maths/math.plane";
  44783. /**
  44784. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44785. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44786. */
  44787. export class Octree<T> {
  44788. /** 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.) */
  44789. maxDepth: number;
  44790. /**
  44791. * Blocks within the octree containing objects
  44792. */
  44793. blocks: Array<OctreeBlock<T>>;
  44794. /**
  44795. * Content stored in the octree
  44796. */
  44797. dynamicContent: T[];
  44798. private _maxBlockCapacity;
  44799. private _selectionContent;
  44800. private _creationFunc;
  44801. /**
  44802. * Creates a octree
  44803. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44804. * @param creationFunc function to be used to instatiate the octree
  44805. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44806. * @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.)
  44807. */
  44808. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44809. /** 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.) */
  44810. maxDepth?: number);
  44811. /**
  44812. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44813. * @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);
  44814. * @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);
  44815. * @param entries meshes to be added to the octree blocks
  44816. */
  44817. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44818. /**
  44819. * Adds a mesh to the octree
  44820. * @param entry Mesh to add to the octree
  44821. */
  44822. addMesh(entry: T): void;
  44823. /**
  44824. * Remove an element from the octree
  44825. * @param entry defines the element to remove
  44826. */
  44827. removeMesh(entry: T): void;
  44828. /**
  44829. * Selects an array of meshes within the frustum
  44830. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44831. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44832. * @returns array of meshes within the frustum
  44833. */
  44834. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44835. /**
  44836. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44837. * @param sphereCenter defines the bounding sphere center
  44838. * @param sphereRadius defines the bounding sphere radius
  44839. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44840. * @returns an array of objects that intersect the sphere
  44841. */
  44842. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44843. /**
  44844. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44845. * @param ray defines the ray to test with
  44846. * @returns array of intersected objects
  44847. */
  44848. intersectsRay(ray: Ray): SmartArray<T>;
  44849. /**
  44850. * Adds a mesh into the octree block if it intersects the block
  44851. */
  44852. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44853. /**
  44854. * Adds a submesh into the octree block if it intersects the block
  44855. */
  44856. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44857. }
  44858. }
  44859. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44860. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44861. import { Scene } from "babylonjs/scene";
  44862. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44864. import { Ray } from "babylonjs/Culling/ray";
  44865. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44866. import { Collider } from "babylonjs/Collisions/collider";
  44867. module "babylonjs/scene" {
  44868. interface Scene {
  44869. /**
  44870. * @hidden
  44871. * Backing Filed
  44872. */
  44873. _selectionOctree: Octree<AbstractMesh>;
  44874. /**
  44875. * Gets the octree used to boost mesh selection (picking)
  44876. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44877. */
  44878. selectionOctree: Octree<AbstractMesh>;
  44879. /**
  44880. * Creates or updates the octree used to boost selection (picking)
  44881. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44882. * @param maxCapacity defines the maximum capacity per leaf
  44883. * @param maxDepth defines the maximum depth of the octree
  44884. * @returns an octree of AbstractMesh
  44885. */
  44886. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44887. }
  44888. }
  44889. module "babylonjs/Meshes/abstractMesh" {
  44890. interface AbstractMesh {
  44891. /**
  44892. * @hidden
  44893. * Backing Field
  44894. */
  44895. _submeshesOctree: Octree<SubMesh>;
  44896. /**
  44897. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44898. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44899. * @param maxCapacity defines the maximum size of each block (64 by default)
  44900. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44901. * @returns the new octree
  44902. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44903. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44904. */
  44905. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44906. }
  44907. }
  44908. /**
  44909. * Defines the octree scene component responsible to manage any octrees
  44910. * in a given scene.
  44911. */
  44912. export class OctreeSceneComponent {
  44913. /**
  44914. * The component name help to identify the component in the list of scene components.
  44915. */
  44916. readonly name: string;
  44917. /**
  44918. * The scene the component belongs to.
  44919. */
  44920. scene: Scene;
  44921. /**
  44922. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44923. */
  44924. readonly checksIsEnabled: boolean;
  44925. /**
  44926. * Creates a new instance of the component for the given scene
  44927. * @param scene Defines the scene to register the component in
  44928. */
  44929. constructor(scene: Scene);
  44930. /**
  44931. * Registers the component in a given scene
  44932. */
  44933. register(): void;
  44934. /**
  44935. * Return the list of active meshes
  44936. * @returns the list of active meshes
  44937. */
  44938. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44939. /**
  44940. * Return the list of active sub meshes
  44941. * @param mesh The mesh to get the candidates sub meshes from
  44942. * @returns the list of active sub meshes
  44943. */
  44944. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44945. private _tempRay;
  44946. /**
  44947. * Return the list of sub meshes intersecting with a given local ray
  44948. * @param mesh defines the mesh to find the submesh for
  44949. * @param localRay defines the ray in local space
  44950. * @returns the list of intersecting sub meshes
  44951. */
  44952. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44953. /**
  44954. * Return the list of sub meshes colliding with a collider
  44955. * @param mesh defines the mesh to find the submesh for
  44956. * @param collider defines the collider to evaluate the collision against
  44957. * @returns the list of colliding sub meshes
  44958. */
  44959. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44960. /**
  44961. * Rebuilds the elements related to this component in case of
  44962. * context lost for instance.
  44963. */
  44964. rebuild(): void;
  44965. /**
  44966. * Disposes the component and the associated ressources.
  44967. */
  44968. dispose(): void;
  44969. }
  44970. }
  44971. declare module "babylonjs/Culling/Octrees/index" {
  44972. export * from "babylonjs/Culling/Octrees/octree";
  44973. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44974. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44975. }
  44976. declare module "babylonjs/Culling/index" {
  44977. export * from "babylonjs/Culling/boundingBox";
  44978. export * from "babylonjs/Culling/boundingInfo";
  44979. export * from "babylonjs/Culling/boundingSphere";
  44980. export * from "babylonjs/Culling/Octrees/index";
  44981. export * from "babylonjs/Culling/ray";
  44982. }
  44983. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44984. import { IDisposable, Scene } from "babylonjs/scene";
  44985. import { Nullable } from "babylonjs/types";
  44986. import { Observable } from "babylonjs/Misc/observable";
  44987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44988. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44989. import { Camera } from "babylonjs/Cameras/camera";
  44990. /**
  44991. * Renders a layer on top of an existing scene
  44992. */
  44993. export class UtilityLayerRenderer implements IDisposable {
  44994. /** the original scene that will be rendered on top of */
  44995. originalScene: Scene;
  44996. private _pointerCaptures;
  44997. private _lastPointerEvents;
  44998. private static _DefaultUtilityLayer;
  44999. private static _DefaultKeepDepthUtilityLayer;
  45000. private _sharedGizmoLight;
  45001. private _renderCamera;
  45002. /**
  45003. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45004. * @returns the camera that is used when rendering the utility layer
  45005. */
  45006. getRenderCamera(): Nullable<Camera>;
  45007. /**
  45008. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45009. * @param cam the camera that should be used when rendering the utility layer
  45010. */
  45011. setRenderCamera(cam: Nullable<Camera>): void;
  45012. /**
  45013. * @hidden
  45014. * Light which used by gizmos to get light shading
  45015. */
  45016. _getSharedGizmoLight(): HemisphericLight;
  45017. /**
  45018. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45019. */
  45020. pickUtilitySceneFirst: boolean;
  45021. /**
  45022. * 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)
  45023. */
  45024. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45025. /**
  45026. * 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)
  45027. */
  45028. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45029. /**
  45030. * The scene that is rendered on top of the original scene
  45031. */
  45032. utilityLayerScene: Scene;
  45033. /**
  45034. * If the utility layer should automatically be rendered on top of existing scene
  45035. */
  45036. shouldRender: boolean;
  45037. /**
  45038. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45039. */
  45040. onlyCheckPointerDownEvents: boolean;
  45041. /**
  45042. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45043. */
  45044. processAllEvents: boolean;
  45045. /**
  45046. * Observable raised when the pointer move from the utility layer scene to the main scene
  45047. */
  45048. onPointerOutObservable: Observable<number>;
  45049. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45050. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45051. private _afterRenderObserver;
  45052. private _sceneDisposeObserver;
  45053. private _originalPointerObserver;
  45054. /**
  45055. * Instantiates a UtilityLayerRenderer
  45056. * @param originalScene the original scene that will be rendered on top of
  45057. * @param handleEvents boolean indicating if the utility layer should handle events
  45058. */
  45059. constructor(
  45060. /** the original scene that will be rendered on top of */
  45061. originalScene: Scene, handleEvents?: boolean);
  45062. private _notifyObservers;
  45063. /**
  45064. * Renders the utility layers scene on top of the original scene
  45065. */
  45066. render(): void;
  45067. /**
  45068. * Disposes of the renderer
  45069. */
  45070. dispose(): void;
  45071. private _updateCamera;
  45072. }
  45073. }
  45074. declare module "babylonjs/Gizmos/gizmo" {
  45075. import { Nullable } from "babylonjs/types";
  45076. import { IDisposable } from "babylonjs/scene";
  45077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45078. import { Mesh } from "babylonjs/Meshes/mesh";
  45079. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45080. /**
  45081. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45082. */
  45083. export class Gizmo implements IDisposable {
  45084. /** The utility layer the gizmo will be added to */
  45085. gizmoLayer: UtilityLayerRenderer;
  45086. /**
  45087. * The root mesh of the gizmo
  45088. */
  45089. _rootMesh: Mesh;
  45090. private _attachedMesh;
  45091. /**
  45092. * Ratio for the scale of the gizmo (Default: 1)
  45093. */
  45094. scaleRatio: number;
  45095. /**
  45096. * If a custom mesh has been set (Default: false)
  45097. */
  45098. protected _customMeshSet: boolean;
  45099. /**
  45100. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45101. * * When set, interactions will be enabled
  45102. */
  45103. attachedMesh: Nullable<AbstractMesh>;
  45104. /**
  45105. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45106. * @param mesh The mesh to replace the default mesh of the gizmo
  45107. */
  45108. setCustomMesh(mesh: Mesh): void;
  45109. /**
  45110. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45111. */
  45112. updateGizmoRotationToMatchAttachedMesh: boolean;
  45113. /**
  45114. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45115. */
  45116. updateGizmoPositionToMatchAttachedMesh: boolean;
  45117. /**
  45118. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45119. */
  45120. updateScale: boolean;
  45121. protected _interactionsEnabled: boolean;
  45122. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45123. private _beforeRenderObserver;
  45124. private _tempVector;
  45125. /**
  45126. * Creates a gizmo
  45127. * @param gizmoLayer The utility layer the gizmo will be added to
  45128. */
  45129. constructor(
  45130. /** The utility layer the gizmo will be added to */
  45131. gizmoLayer?: UtilityLayerRenderer);
  45132. /**
  45133. * Updates the gizmo to match the attached mesh's position/rotation
  45134. */
  45135. protected _update(): void;
  45136. /**
  45137. * Disposes of the gizmo
  45138. */
  45139. dispose(): void;
  45140. }
  45141. }
  45142. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45143. import { Observable } from "babylonjs/Misc/observable";
  45144. import { Nullable } from "babylonjs/types";
  45145. import { Vector3 } from "babylonjs/Maths/math.vector";
  45146. import { Color3 } from "babylonjs/Maths/math.color";
  45147. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45149. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45150. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45151. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45152. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45153. import { Scene } from "babylonjs/scene";
  45154. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45155. /**
  45156. * Single plane drag gizmo
  45157. */
  45158. export class PlaneDragGizmo extends Gizmo {
  45159. /**
  45160. * Drag behavior responsible for the gizmos dragging interactions
  45161. */
  45162. dragBehavior: PointerDragBehavior;
  45163. private _pointerObserver;
  45164. /**
  45165. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45166. */
  45167. snapDistance: number;
  45168. /**
  45169. * Event that fires each time the gizmo snaps to a new location.
  45170. * * snapDistance is the the change in distance
  45171. */
  45172. onSnapObservable: Observable<{
  45173. snapDistance: number;
  45174. }>;
  45175. private _plane;
  45176. private _coloredMaterial;
  45177. private _hoverMaterial;
  45178. private _isEnabled;
  45179. private _parent;
  45180. /** @hidden */
  45181. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45182. /** @hidden */
  45183. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45184. /**
  45185. * Creates a PlaneDragGizmo
  45186. * @param gizmoLayer The utility layer the gizmo will be added to
  45187. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45188. * @param color The color of the gizmo
  45189. */
  45190. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45191. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45192. /**
  45193. * If the gizmo is enabled
  45194. */
  45195. isEnabled: boolean;
  45196. /**
  45197. * Disposes of the gizmo
  45198. */
  45199. dispose(): void;
  45200. }
  45201. }
  45202. declare module "babylonjs/Gizmos/positionGizmo" {
  45203. import { Observable } from "babylonjs/Misc/observable";
  45204. import { Nullable } from "babylonjs/types";
  45205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45206. import { Mesh } from "babylonjs/Meshes/mesh";
  45207. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45208. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45209. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45210. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45211. /**
  45212. * Gizmo that enables dragging a mesh along 3 axis
  45213. */
  45214. export class PositionGizmo extends Gizmo {
  45215. /**
  45216. * Internal gizmo used for interactions on the x axis
  45217. */
  45218. xGizmo: AxisDragGizmo;
  45219. /**
  45220. * Internal gizmo used for interactions on the y axis
  45221. */
  45222. yGizmo: AxisDragGizmo;
  45223. /**
  45224. * Internal gizmo used for interactions on the z axis
  45225. */
  45226. zGizmo: AxisDragGizmo;
  45227. /**
  45228. * Internal gizmo used for interactions on the yz plane
  45229. */
  45230. xPlaneGizmo: PlaneDragGizmo;
  45231. /**
  45232. * Internal gizmo used for interactions on the xz plane
  45233. */
  45234. yPlaneGizmo: PlaneDragGizmo;
  45235. /**
  45236. * Internal gizmo used for interactions on the xy plane
  45237. */
  45238. zPlaneGizmo: PlaneDragGizmo;
  45239. /**
  45240. * private variables
  45241. */
  45242. private _meshAttached;
  45243. private _updateGizmoRotationToMatchAttachedMesh;
  45244. private _snapDistance;
  45245. private _scaleRatio;
  45246. /** Fires an event when any of it's sub gizmos are dragged */
  45247. onDragStartObservable: Observable<unknown>;
  45248. /** Fires an event when any of it's sub gizmos are released from dragging */
  45249. onDragEndObservable: Observable<unknown>;
  45250. /**
  45251. * If set to true, planar drag is enabled
  45252. */
  45253. private _planarGizmoEnabled;
  45254. attachedMesh: Nullable<AbstractMesh>;
  45255. /**
  45256. * Creates a PositionGizmo
  45257. * @param gizmoLayer The utility layer the gizmo will be added to
  45258. */
  45259. constructor(gizmoLayer?: UtilityLayerRenderer);
  45260. /**
  45261. * If the planar drag gizmo is enabled
  45262. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45263. */
  45264. planarGizmoEnabled: boolean;
  45265. updateGizmoRotationToMatchAttachedMesh: boolean;
  45266. /**
  45267. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45268. */
  45269. snapDistance: number;
  45270. /**
  45271. * Ratio for the scale of the gizmo (Default: 1)
  45272. */
  45273. scaleRatio: number;
  45274. /**
  45275. * Disposes of the gizmo
  45276. */
  45277. dispose(): void;
  45278. /**
  45279. * CustomMeshes are not supported by this gizmo
  45280. * @param mesh The mesh to replace the default mesh of the gizmo
  45281. */
  45282. setCustomMesh(mesh: Mesh): void;
  45283. }
  45284. }
  45285. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45286. import { Observable } from "babylonjs/Misc/observable";
  45287. import { Nullable } from "babylonjs/types";
  45288. import { Vector3 } from "babylonjs/Maths/math.vector";
  45289. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45291. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45292. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45293. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45294. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45295. import { Scene } from "babylonjs/scene";
  45296. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45297. import { Color3 } from "babylonjs/Maths/math.color";
  45298. /**
  45299. * Single axis drag gizmo
  45300. */
  45301. export class AxisDragGizmo extends Gizmo {
  45302. /**
  45303. * Drag behavior responsible for the gizmos dragging interactions
  45304. */
  45305. dragBehavior: PointerDragBehavior;
  45306. private _pointerObserver;
  45307. /**
  45308. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45309. */
  45310. snapDistance: number;
  45311. /**
  45312. * Event that fires each time the gizmo snaps to a new location.
  45313. * * snapDistance is the the change in distance
  45314. */
  45315. onSnapObservable: Observable<{
  45316. snapDistance: number;
  45317. }>;
  45318. private _isEnabled;
  45319. private _parent;
  45320. private _arrow;
  45321. private _coloredMaterial;
  45322. private _hoverMaterial;
  45323. /** @hidden */
  45324. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45325. /** @hidden */
  45326. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45327. /**
  45328. * Creates an AxisDragGizmo
  45329. * @param gizmoLayer The utility layer the gizmo will be added to
  45330. * @param dragAxis The axis which the gizmo will be able to drag on
  45331. * @param color The color of the gizmo
  45332. */
  45333. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45334. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45335. /**
  45336. * If the gizmo is enabled
  45337. */
  45338. isEnabled: boolean;
  45339. /**
  45340. * Disposes of the gizmo
  45341. */
  45342. dispose(): void;
  45343. }
  45344. }
  45345. declare module "babylonjs/Debug/axesViewer" {
  45346. import { Vector3 } from "babylonjs/Maths/math.vector";
  45347. import { Nullable } from "babylonjs/types";
  45348. import { Scene } from "babylonjs/scene";
  45349. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45350. /**
  45351. * The Axes viewer will show 3 axes in a specific point in space
  45352. */
  45353. export class AxesViewer {
  45354. private _xAxis;
  45355. private _yAxis;
  45356. private _zAxis;
  45357. private _scaleLinesFactor;
  45358. private _instanced;
  45359. /**
  45360. * Gets the hosting scene
  45361. */
  45362. scene: Scene;
  45363. /**
  45364. * Gets or sets a number used to scale line length
  45365. */
  45366. scaleLines: number;
  45367. /** Gets the node hierarchy used to render x-axis */
  45368. readonly xAxis: TransformNode;
  45369. /** Gets the node hierarchy used to render y-axis */
  45370. readonly yAxis: TransformNode;
  45371. /** Gets the node hierarchy used to render z-axis */
  45372. readonly zAxis: TransformNode;
  45373. /**
  45374. * Creates a new AxesViewer
  45375. * @param scene defines the hosting scene
  45376. * @param scaleLines defines a number used to scale line length (1 by default)
  45377. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45378. * @param xAxis defines the node hierarchy used to render the x-axis
  45379. * @param yAxis defines the node hierarchy used to render the y-axis
  45380. * @param zAxis defines the node hierarchy used to render the z-axis
  45381. */
  45382. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45383. /**
  45384. * Force the viewer to update
  45385. * @param position defines the position of the viewer
  45386. * @param xaxis defines the x axis of the viewer
  45387. * @param yaxis defines the y axis of the viewer
  45388. * @param zaxis defines the z axis of the viewer
  45389. */
  45390. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45391. /**
  45392. * Creates an instance of this axes viewer.
  45393. * @returns a new axes viewer with instanced meshes
  45394. */
  45395. createInstance(): AxesViewer;
  45396. /** Releases resources */
  45397. dispose(): void;
  45398. private static _SetRenderingGroupId;
  45399. }
  45400. }
  45401. declare module "babylonjs/Debug/boneAxesViewer" {
  45402. import { Nullable } from "babylonjs/types";
  45403. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45404. import { Vector3 } from "babylonjs/Maths/math.vector";
  45405. import { Mesh } from "babylonjs/Meshes/mesh";
  45406. import { Bone } from "babylonjs/Bones/bone";
  45407. import { Scene } from "babylonjs/scene";
  45408. /**
  45409. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45410. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45411. */
  45412. export class BoneAxesViewer extends AxesViewer {
  45413. /**
  45414. * Gets or sets the target mesh where to display the axes viewer
  45415. */
  45416. mesh: Nullable<Mesh>;
  45417. /**
  45418. * Gets or sets the target bone where to display the axes viewer
  45419. */
  45420. bone: Nullable<Bone>;
  45421. /** Gets current position */
  45422. pos: Vector3;
  45423. /** Gets direction of X axis */
  45424. xaxis: Vector3;
  45425. /** Gets direction of Y axis */
  45426. yaxis: Vector3;
  45427. /** Gets direction of Z axis */
  45428. zaxis: Vector3;
  45429. /**
  45430. * Creates a new BoneAxesViewer
  45431. * @param scene defines the hosting scene
  45432. * @param bone defines the target bone
  45433. * @param mesh defines the target mesh
  45434. * @param scaleLines defines a scaling factor for line length (1 by default)
  45435. */
  45436. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45437. /**
  45438. * Force the viewer to update
  45439. */
  45440. update(): void;
  45441. /** Releases resources */
  45442. dispose(): void;
  45443. }
  45444. }
  45445. declare module "babylonjs/Debug/debugLayer" {
  45446. import { Scene } from "babylonjs/scene";
  45447. /**
  45448. * Interface used to define scene explorer extensibility option
  45449. */
  45450. export interface IExplorerExtensibilityOption {
  45451. /**
  45452. * Define the option label
  45453. */
  45454. label: string;
  45455. /**
  45456. * Defines the action to execute on click
  45457. */
  45458. action: (entity: any) => void;
  45459. }
  45460. /**
  45461. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45462. */
  45463. export interface IExplorerExtensibilityGroup {
  45464. /**
  45465. * Defines a predicate to test if a given type mut be extended
  45466. */
  45467. predicate: (entity: any) => boolean;
  45468. /**
  45469. * Gets the list of options added to a type
  45470. */
  45471. entries: IExplorerExtensibilityOption[];
  45472. }
  45473. /**
  45474. * Interface used to define the options to use to create the Inspector
  45475. */
  45476. export interface IInspectorOptions {
  45477. /**
  45478. * Display in overlay mode (default: false)
  45479. */
  45480. overlay?: boolean;
  45481. /**
  45482. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45483. */
  45484. globalRoot?: HTMLElement;
  45485. /**
  45486. * Display the Scene explorer
  45487. */
  45488. showExplorer?: boolean;
  45489. /**
  45490. * Display the property inspector
  45491. */
  45492. showInspector?: boolean;
  45493. /**
  45494. * Display in embed mode (both panes on the right)
  45495. */
  45496. embedMode?: boolean;
  45497. /**
  45498. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45499. */
  45500. handleResize?: boolean;
  45501. /**
  45502. * Allow the panes to popup (default: true)
  45503. */
  45504. enablePopup?: boolean;
  45505. /**
  45506. * Allow the panes to be closed by users (default: true)
  45507. */
  45508. enableClose?: boolean;
  45509. /**
  45510. * Optional list of extensibility entries
  45511. */
  45512. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45513. /**
  45514. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45515. */
  45516. inspectorURL?: string;
  45517. }
  45518. module "babylonjs/scene" {
  45519. interface Scene {
  45520. /**
  45521. * @hidden
  45522. * Backing field
  45523. */
  45524. _debugLayer: DebugLayer;
  45525. /**
  45526. * Gets the debug layer (aka Inspector) associated with the scene
  45527. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45528. */
  45529. debugLayer: DebugLayer;
  45530. }
  45531. }
  45532. /**
  45533. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45534. * what is happening in your scene
  45535. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45536. */
  45537. export class DebugLayer {
  45538. /**
  45539. * Define the url to get the inspector script from.
  45540. * By default it uses the babylonjs CDN.
  45541. * @ignoreNaming
  45542. */
  45543. static InspectorURL: string;
  45544. private _scene;
  45545. private BJSINSPECTOR;
  45546. private _onPropertyChangedObservable?;
  45547. /**
  45548. * Observable triggered when a property is changed through the inspector.
  45549. */
  45550. readonly onPropertyChangedObservable: any;
  45551. /**
  45552. * Instantiates a new debug layer.
  45553. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45554. * what is happening in your scene
  45555. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45556. * @param scene Defines the scene to inspect
  45557. */
  45558. constructor(scene: Scene);
  45559. /** Creates the inspector window. */
  45560. private _createInspector;
  45561. /**
  45562. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45563. * @param entity defines the entity to select
  45564. * @param lineContainerTitle defines the specific block to highlight
  45565. */
  45566. select(entity: any, lineContainerTitle?: string): void;
  45567. /** Get the inspector from bundle or global */
  45568. private _getGlobalInspector;
  45569. /**
  45570. * Get if the inspector is visible or not.
  45571. * @returns true if visible otherwise, false
  45572. */
  45573. isVisible(): boolean;
  45574. /**
  45575. * Hide the inspector and close its window.
  45576. */
  45577. hide(): void;
  45578. /**
  45579. * Launch the debugLayer.
  45580. * @param config Define the configuration of the inspector
  45581. * @return a promise fulfilled when the debug layer is visible
  45582. */
  45583. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45584. }
  45585. }
  45586. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45587. import { Nullable } from "babylonjs/types";
  45588. import { Scene } from "babylonjs/scene";
  45589. import { Vector4 } from "babylonjs/Maths/math.vector";
  45590. import { Color4 } from "babylonjs/Maths/math.color";
  45591. import { Mesh } from "babylonjs/Meshes/mesh";
  45592. /**
  45593. * Class containing static functions to help procedurally build meshes
  45594. */
  45595. export class BoxBuilder {
  45596. /**
  45597. * Creates a box mesh
  45598. * * The parameter `size` sets the size (float) of each box side (default 1)
  45599. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45600. * * 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)
  45601. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45605. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45606. * @param name defines the name of the mesh
  45607. * @param options defines the options used to create the mesh
  45608. * @param scene defines the hosting scene
  45609. * @returns the box mesh
  45610. */
  45611. static CreateBox(name: string, options: {
  45612. size?: number;
  45613. width?: number;
  45614. height?: number;
  45615. depth?: number;
  45616. faceUV?: Vector4[];
  45617. faceColors?: Color4[];
  45618. sideOrientation?: number;
  45619. frontUVs?: Vector4;
  45620. backUVs?: Vector4;
  45621. wrap?: boolean;
  45622. topBaseAt?: number;
  45623. bottomBaseAt?: number;
  45624. updatable?: boolean;
  45625. }, scene?: Nullable<Scene>): Mesh;
  45626. }
  45627. }
  45628. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45629. import { Vector4 } from "babylonjs/Maths/math.vector";
  45630. import { Mesh } from "babylonjs/Meshes/mesh";
  45631. import { Scene } from "babylonjs/scene";
  45632. import { Nullable } from "babylonjs/types";
  45633. /**
  45634. * Class containing static functions to help procedurally build meshes
  45635. */
  45636. export class SphereBuilder {
  45637. /**
  45638. * Creates a sphere mesh
  45639. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45640. * * 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`)
  45641. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45642. * * 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
  45643. * * 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)
  45644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45647. * @param name defines the name of the mesh
  45648. * @param options defines the options used to create the mesh
  45649. * @param scene defines the hosting scene
  45650. * @returns the sphere mesh
  45651. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45652. */
  45653. static CreateSphere(name: string, options: {
  45654. segments?: number;
  45655. diameter?: number;
  45656. diameterX?: number;
  45657. diameterY?: number;
  45658. diameterZ?: number;
  45659. arc?: number;
  45660. slice?: number;
  45661. sideOrientation?: number;
  45662. frontUVs?: Vector4;
  45663. backUVs?: Vector4;
  45664. updatable?: boolean;
  45665. }, scene?: Nullable<Scene>): Mesh;
  45666. }
  45667. }
  45668. declare module "babylonjs/Debug/physicsViewer" {
  45669. import { Nullable } from "babylonjs/types";
  45670. import { Scene } from "babylonjs/scene";
  45671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45672. import { Mesh } from "babylonjs/Meshes/mesh";
  45673. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45674. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45675. /**
  45676. * Used to show the physics impostor around the specific mesh
  45677. */
  45678. export class PhysicsViewer {
  45679. /** @hidden */
  45680. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45681. /** @hidden */
  45682. protected _meshes: Array<Nullable<AbstractMesh>>;
  45683. /** @hidden */
  45684. protected _scene: Nullable<Scene>;
  45685. /** @hidden */
  45686. protected _numMeshes: number;
  45687. /** @hidden */
  45688. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45689. private _renderFunction;
  45690. private _utilityLayer;
  45691. private _debugBoxMesh;
  45692. private _debugSphereMesh;
  45693. private _debugCylinderMesh;
  45694. private _debugMaterial;
  45695. private _debugMeshMeshes;
  45696. /**
  45697. * Creates a new PhysicsViewer
  45698. * @param scene defines the hosting scene
  45699. */
  45700. constructor(scene: Scene);
  45701. /** @hidden */
  45702. protected _updateDebugMeshes(): void;
  45703. /**
  45704. * Renders a specified physic impostor
  45705. * @param impostor defines the impostor to render
  45706. * @param targetMesh defines the mesh represented by the impostor
  45707. * @returns the new debug mesh used to render the impostor
  45708. */
  45709. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45710. /**
  45711. * Hides a specified physic impostor
  45712. * @param impostor defines the impostor to hide
  45713. */
  45714. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45715. private _getDebugMaterial;
  45716. private _getDebugBoxMesh;
  45717. private _getDebugSphereMesh;
  45718. private _getDebugCylinderMesh;
  45719. private _getDebugMeshMesh;
  45720. private _getDebugMesh;
  45721. /** Releases all resources */
  45722. dispose(): void;
  45723. }
  45724. }
  45725. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45726. import { Vector3 } from "babylonjs/Maths/math.vector";
  45727. import { Color4 } from "babylonjs/Maths/math.color";
  45728. import { Nullable } from "babylonjs/types";
  45729. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45730. import { Scene } from "babylonjs/scene";
  45731. /**
  45732. * Class containing static functions to help procedurally build meshes
  45733. */
  45734. export class LinesBuilder {
  45735. /**
  45736. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45737. * * 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
  45738. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45739. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45740. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45741. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45742. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45743. * * 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
  45744. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45747. * @param name defines the name of the new line system
  45748. * @param options defines the options used to create the line system
  45749. * @param scene defines the hosting scene
  45750. * @returns a new line system mesh
  45751. */
  45752. static CreateLineSystem(name: string, options: {
  45753. lines: Vector3[][];
  45754. updatable?: boolean;
  45755. instance?: Nullable<LinesMesh>;
  45756. colors?: Nullable<Color4[][]>;
  45757. useVertexAlpha?: boolean;
  45758. }, scene: Nullable<Scene>): LinesMesh;
  45759. /**
  45760. * Creates a line mesh
  45761. * 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
  45762. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45763. * * The parameter `points` is an array successive Vector3
  45764. * * 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
  45765. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45766. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45767. * * When updating an instance, remember that only point positions can change, not the number of points
  45768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45769. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45770. * @param name defines the name of the new line system
  45771. * @param options defines the options used to create the line system
  45772. * @param scene defines the hosting scene
  45773. * @returns a new line mesh
  45774. */
  45775. static CreateLines(name: string, options: {
  45776. points: Vector3[];
  45777. updatable?: boolean;
  45778. instance?: Nullable<LinesMesh>;
  45779. colors?: Color4[];
  45780. useVertexAlpha?: boolean;
  45781. }, scene?: Nullable<Scene>): LinesMesh;
  45782. /**
  45783. * Creates a dashed line mesh
  45784. * * 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
  45785. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45786. * * The parameter `points` is an array successive Vector3
  45787. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45788. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45789. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45790. * * 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
  45791. * * When updating an instance, remember that only point positions can change, not the number of points
  45792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45793. * @param name defines the name of the mesh
  45794. * @param options defines the options used to create the mesh
  45795. * @param scene defines the hosting scene
  45796. * @returns the dashed line mesh
  45797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45798. */
  45799. static CreateDashedLines(name: string, options: {
  45800. points: Vector3[];
  45801. dashSize?: number;
  45802. gapSize?: number;
  45803. dashNb?: number;
  45804. updatable?: boolean;
  45805. instance?: LinesMesh;
  45806. }, scene?: Nullable<Scene>): LinesMesh;
  45807. }
  45808. }
  45809. declare module "babylonjs/Debug/rayHelper" {
  45810. import { Nullable } from "babylonjs/types";
  45811. import { Ray } from "babylonjs/Culling/ray";
  45812. import { Vector3 } from "babylonjs/Maths/math.vector";
  45813. import { Color3 } from "babylonjs/Maths/math.color";
  45814. import { Scene } from "babylonjs/scene";
  45815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45816. import "babylonjs/Meshes/Builders/linesBuilder";
  45817. /**
  45818. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45819. * in order to better appreciate the issue one might have.
  45820. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45821. */
  45822. export class RayHelper {
  45823. /**
  45824. * Defines the ray we are currently tryin to visualize.
  45825. */
  45826. ray: Nullable<Ray>;
  45827. private _renderPoints;
  45828. private _renderLine;
  45829. private _renderFunction;
  45830. private _scene;
  45831. private _updateToMeshFunction;
  45832. private _attachedToMesh;
  45833. private _meshSpaceDirection;
  45834. private _meshSpaceOrigin;
  45835. /**
  45836. * Helper function to create a colored helper in a scene in one line.
  45837. * @param ray Defines the ray we are currently tryin to visualize
  45838. * @param scene Defines the scene the ray is used in
  45839. * @param color Defines the color we want to see the ray in
  45840. * @returns The newly created ray helper.
  45841. */
  45842. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45843. /**
  45844. * Instantiate a new ray helper.
  45845. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45846. * in order to better appreciate the issue one might have.
  45847. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45848. * @param ray Defines the ray we are currently tryin to visualize
  45849. */
  45850. constructor(ray: Ray);
  45851. /**
  45852. * Shows the ray we are willing to debug.
  45853. * @param scene Defines the scene the ray needs to be rendered in
  45854. * @param color Defines the color the ray needs to be rendered in
  45855. */
  45856. show(scene: Scene, color?: Color3): void;
  45857. /**
  45858. * Hides the ray we are debugging.
  45859. */
  45860. hide(): void;
  45861. private _render;
  45862. /**
  45863. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45864. * @param mesh Defines the mesh we want the helper attached to
  45865. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45866. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45867. * @param length Defines the length of the ray
  45868. */
  45869. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45870. /**
  45871. * Detach the ray helper from the mesh it has previously been attached to.
  45872. */
  45873. detachFromMesh(): void;
  45874. private _updateToMesh;
  45875. /**
  45876. * Dispose the helper and release its associated resources.
  45877. */
  45878. dispose(): void;
  45879. }
  45880. }
  45881. declare module "babylonjs/Debug/skeletonViewer" {
  45882. import { Color3 } from "babylonjs/Maths/math.color";
  45883. import { Scene } from "babylonjs/scene";
  45884. import { Nullable } from "babylonjs/types";
  45885. import { Skeleton } from "babylonjs/Bones/skeleton";
  45886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45887. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45888. /**
  45889. * Class used to render a debug view of a given skeleton
  45890. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45891. */
  45892. export class SkeletonViewer {
  45893. /** defines the skeleton to render */
  45894. skeleton: Skeleton;
  45895. /** defines the mesh attached to the skeleton */
  45896. mesh: AbstractMesh;
  45897. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45898. autoUpdateBonesMatrices: boolean;
  45899. /** defines the rendering group id to use with the viewer */
  45900. renderingGroupId: number;
  45901. /** Gets or sets the color used to render the skeleton */
  45902. color: Color3;
  45903. private _scene;
  45904. private _debugLines;
  45905. private _debugMesh;
  45906. private _isEnabled;
  45907. private _renderFunction;
  45908. private _utilityLayer;
  45909. /**
  45910. * Returns the mesh used to render the bones
  45911. */
  45912. readonly debugMesh: Nullable<LinesMesh>;
  45913. /**
  45914. * Creates a new SkeletonViewer
  45915. * @param skeleton defines the skeleton to render
  45916. * @param mesh defines the mesh attached to the skeleton
  45917. * @param scene defines the hosting scene
  45918. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45919. * @param renderingGroupId defines the rendering group id to use with the viewer
  45920. */
  45921. constructor(
  45922. /** defines the skeleton to render */
  45923. skeleton: Skeleton,
  45924. /** defines the mesh attached to the skeleton */
  45925. mesh: AbstractMesh, scene: Scene,
  45926. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45927. autoUpdateBonesMatrices?: boolean,
  45928. /** defines the rendering group id to use with the viewer */
  45929. renderingGroupId?: number);
  45930. /** Gets or sets a boolean indicating if the viewer is enabled */
  45931. isEnabled: boolean;
  45932. private _getBonePosition;
  45933. private _getLinesForBonesWithLength;
  45934. private _getLinesForBonesNoLength;
  45935. /** Update the viewer to sync with current skeleton state */
  45936. update(): void;
  45937. /** Release associated resources */
  45938. dispose(): void;
  45939. }
  45940. }
  45941. declare module "babylonjs/Debug/index" {
  45942. export * from "babylonjs/Debug/axesViewer";
  45943. export * from "babylonjs/Debug/boneAxesViewer";
  45944. export * from "babylonjs/Debug/debugLayer";
  45945. export * from "babylonjs/Debug/physicsViewer";
  45946. export * from "babylonjs/Debug/rayHelper";
  45947. export * from "babylonjs/Debug/skeletonViewer";
  45948. }
  45949. declare module "babylonjs/Engines/nullEngine" {
  45950. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45951. import { Scene } from "babylonjs/scene";
  45952. import { Engine } from "babylonjs/Engines/engine";
  45953. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45954. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45955. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45956. import { Effect } from "babylonjs/Materials/effect";
  45957. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45958. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45959. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45960. /**
  45961. * Options to create the null engine
  45962. */
  45963. export class NullEngineOptions {
  45964. /**
  45965. * Render width (Default: 512)
  45966. */
  45967. renderWidth: number;
  45968. /**
  45969. * Render height (Default: 256)
  45970. */
  45971. renderHeight: number;
  45972. /**
  45973. * Texture size (Default: 512)
  45974. */
  45975. textureSize: number;
  45976. /**
  45977. * If delta time between frames should be constant
  45978. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45979. */
  45980. deterministicLockstep: boolean;
  45981. /**
  45982. * Maximum about of steps between frames (Default: 4)
  45983. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45984. */
  45985. lockstepMaxSteps: number;
  45986. }
  45987. /**
  45988. * The null engine class provides support for headless version of babylon.js.
  45989. * This can be used in server side scenario or for testing purposes
  45990. */
  45991. export class NullEngine extends Engine {
  45992. private _options;
  45993. /**
  45994. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45995. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45996. * @returns true if engine is in deterministic lock step mode
  45997. */
  45998. isDeterministicLockStep(): boolean;
  45999. /**
  46000. * Gets the max steps when engine is running in deterministic lock step
  46001. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46002. * @returns the max steps
  46003. */
  46004. getLockstepMaxSteps(): number;
  46005. /**
  46006. * Gets the current hardware scaling level.
  46007. * By default the hardware scaling level is computed from the window device ratio.
  46008. * 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.
  46009. * @returns a number indicating the current hardware scaling level
  46010. */
  46011. getHardwareScalingLevel(): number;
  46012. constructor(options?: NullEngineOptions);
  46013. /**
  46014. * Creates a vertex buffer
  46015. * @param vertices the data for the vertex buffer
  46016. * @returns the new WebGL static buffer
  46017. */
  46018. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46019. /**
  46020. * Creates a new index buffer
  46021. * @param indices defines the content of the index buffer
  46022. * @param updatable defines if the index buffer must be updatable
  46023. * @returns a new webGL buffer
  46024. */
  46025. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46026. /**
  46027. * Clear the current render buffer or the current render target (if any is set up)
  46028. * @param color defines the color to use
  46029. * @param backBuffer defines if the back buffer must be cleared
  46030. * @param depth defines if the depth buffer must be cleared
  46031. * @param stencil defines if the stencil buffer must be cleared
  46032. */
  46033. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46034. /**
  46035. * Gets the current render width
  46036. * @param useScreen defines if screen size must be used (or the current render target if any)
  46037. * @returns a number defining the current render width
  46038. */
  46039. getRenderWidth(useScreen?: boolean): number;
  46040. /**
  46041. * Gets the current render height
  46042. * @param useScreen defines if screen size must be used (or the current render target if any)
  46043. * @returns a number defining the current render height
  46044. */
  46045. getRenderHeight(useScreen?: boolean): number;
  46046. /**
  46047. * Set the WebGL's viewport
  46048. * @param viewport defines the viewport element to be used
  46049. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46050. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46051. */
  46052. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46053. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46054. /**
  46055. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46056. * @param pipelineContext defines the pipeline context to use
  46057. * @param uniformsNames defines the list of uniform names
  46058. * @returns an array of webGL uniform locations
  46059. */
  46060. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46061. /**
  46062. * Gets the lsit of active attributes for a given webGL program
  46063. * @param pipelineContext defines the pipeline context to use
  46064. * @param attributesNames defines the list of attribute names to get
  46065. * @returns an array of indices indicating the offset of each attribute
  46066. */
  46067. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46068. /**
  46069. * Binds an effect to the webGL context
  46070. * @param effect defines the effect to bind
  46071. */
  46072. bindSamplers(effect: Effect): void;
  46073. /**
  46074. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46075. * @param effect defines the effect to activate
  46076. */
  46077. enableEffect(effect: Effect): void;
  46078. /**
  46079. * Set various states to the webGL context
  46080. * @param culling defines backface culling state
  46081. * @param zOffset defines the value to apply to zOffset (0 by default)
  46082. * @param force defines if states must be applied even if cache is up to date
  46083. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46084. */
  46085. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46086. /**
  46087. * Set the value of an uniform to an array of int32
  46088. * @param uniform defines the webGL uniform location where to store the value
  46089. * @param array defines the array of int32 to store
  46090. */
  46091. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46092. /**
  46093. * Set the value of an uniform to an array of int32 (stored as vec2)
  46094. * @param uniform defines the webGL uniform location where to store the value
  46095. * @param array defines the array of int32 to store
  46096. */
  46097. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46098. /**
  46099. * Set the value of an uniform to an array of int32 (stored as vec3)
  46100. * @param uniform defines the webGL uniform location where to store the value
  46101. * @param array defines the array of int32 to store
  46102. */
  46103. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46104. /**
  46105. * Set the value of an uniform to an array of int32 (stored as vec4)
  46106. * @param uniform defines the webGL uniform location where to store the value
  46107. * @param array defines the array of int32 to store
  46108. */
  46109. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46110. /**
  46111. * Set the value of an uniform to an array of float32
  46112. * @param uniform defines the webGL uniform location where to store the value
  46113. * @param array defines the array of float32 to store
  46114. */
  46115. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46116. /**
  46117. * Set the value of an uniform to an array of float32 (stored as vec2)
  46118. * @param uniform defines the webGL uniform location where to store the value
  46119. * @param array defines the array of float32 to store
  46120. */
  46121. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46122. /**
  46123. * Set the value of an uniform to an array of float32 (stored as vec3)
  46124. * @param uniform defines the webGL uniform location where to store the value
  46125. * @param array defines the array of float32 to store
  46126. */
  46127. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46128. /**
  46129. * Set the value of an uniform to an array of float32 (stored as vec4)
  46130. * @param uniform defines the webGL uniform location where to store the value
  46131. * @param array defines the array of float32 to store
  46132. */
  46133. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46134. /**
  46135. * Set the value of an uniform to an array of number
  46136. * @param uniform defines the webGL uniform location where to store the value
  46137. * @param array defines the array of number to store
  46138. */
  46139. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46140. /**
  46141. * Set the value of an uniform to an array of number (stored as vec2)
  46142. * @param uniform defines the webGL uniform location where to store the value
  46143. * @param array defines the array of number to store
  46144. */
  46145. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46146. /**
  46147. * Set the value of an uniform to an array of number (stored as vec3)
  46148. * @param uniform defines the webGL uniform location where to store the value
  46149. * @param array defines the array of number to store
  46150. */
  46151. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46152. /**
  46153. * Set the value of an uniform to an array of number (stored as vec4)
  46154. * @param uniform defines the webGL uniform location where to store the value
  46155. * @param array defines the array of number to store
  46156. */
  46157. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46158. /**
  46159. * Set the value of an uniform to an array of float32 (stored as matrices)
  46160. * @param uniform defines the webGL uniform location where to store the value
  46161. * @param matrices defines the array of float32 to store
  46162. */
  46163. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46164. /**
  46165. * Set the value of an uniform to a matrix (3x3)
  46166. * @param uniform defines the webGL uniform location where to store the value
  46167. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46168. */
  46169. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46170. /**
  46171. * Set the value of an uniform to a matrix (2x2)
  46172. * @param uniform defines the webGL uniform location where to store the value
  46173. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46174. */
  46175. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46176. /**
  46177. * Set the value of an uniform to a number (float)
  46178. * @param uniform defines the webGL uniform location where to store the value
  46179. * @param value defines the float number to store
  46180. */
  46181. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46182. /**
  46183. * Set the value of an uniform to a vec2
  46184. * @param uniform defines the webGL uniform location where to store the value
  46185. * @param x defines the 1st component of the value
  46186. * @param y defines the 2nd component of the value
  46187. */
  46188. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46189. /**
  46190. * Set the value of an uniform to a vec3
  46191. * @param uniform defines the webGL uniform location where to store the value
  46192. * @param x defines the 1st component of the value
  46193. * @param y defines the 2nd component of the value
  46194. * @param z defines the 3rd component of the value
  46195. */
  46196. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46197. /**
  46198. * Set the value of an uniform to a boolean
  46199. * @param uniform defines the webGL uniform location where to store the value
  46200. * @param bool defines the boolean to store
  46201. */
  46202. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46203. /**
  46204. * Set the value of an uniform to a vec4
  46205. * @param uniform defines the webGL uniform location where to store the value
  46206. * @param x defines the 1st component of the value
  46207. * @param y defines the 2nd component of the value
  46208. * @param z defines the 3rd component of the value
  46209. * @param w defines the 4th component of the value
  46210. */
  46211. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46212. /**
  46213. * Sets the current alpha mode
  46214. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46215. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46216. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46217. */
  46218. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46219. /**
  46220. * Bind webGl buffers directly to the webGL context
  46221. * @param vertexBuffers defines the vertex buffer to bind
  46222. * @param indexBuffer defines the index buffer to bind
  46223. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46224. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46225. * @param effect defines the effect associated with the vertex buffer
  46226. */
  46227. bindBuffers(vertexBuffers: {
  46228. [key: string]: VertexBuffer;
  46229. }, indexBuffer: DataBuffer, effect: Effect): void;
  46230. /**
  46231. * Force the entire cache to be cleared
  46232. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46233. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46234. */
  46235. wipeCaches(bruteForce?: boolean): void;
  46236. /**
  46237. * Send a draw order
  46238. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46239. * @param indexStart defines the starting index
  46240. * @param indexCount defines the number of index to draw
  46241. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46242. */
  46243. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46244. /**
  46245. * Draw a list of indexed primitives
  46246. * @param fillMode defines the primitive to use
  46247. * @param indexStart defines the starting index
  46248. * @param indexCount defines the number of index to draw
  46249. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46250. */
  46251. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46252. /**
  46253. * Draw a list of unindexed primitives
  46254. * @param fillMode defines the primitive to use
  46255. * @param verticesStart defines the index of first vertex to draw
  46256. * @param verticesCount defines the count of vertices to draw
  46257. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46258. */
  46259. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46260. /** @hidden */
  46261. _createTexture(): WebGLTexture;
  46262. /** @hidden */
  46263. _releaseTexture(texture: InternalTexture): void;
  46264. /**
  46265. * Usually called from Texture.ts.
  46266. * Passed information to create a WebGLTexture
  46267. * @param urlArg defines a value which contains one of the following:
  46268. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46269. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46270. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46271. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46272. * @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)
  46273. * @param scene needed for loading to the correct scene
  46274. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46275. * @param onLoad optional callback to be called upon successful completion
  46276. * @param onError optional callback to be called upon failure
  46277. * @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
  46278. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46279. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46280. * @param forcedExtension defines the extension to use to pick the right loader
  46281. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46282. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46283. */
  46284. 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;
  46285. /**
  46286. * Creates a new render target texture
  46287. * @param size defines the size of the texture
  46288. * @param options defines the options used to create the texture
  46289. * @returns a new render target texture stored in an InternalTexture
  46290. */
  46291. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46292. /**
  46293. * Update the sampling mode of a given texture
  46294. * @param samplingMode defines the required sampling mode
  46295. * @param texture defines the texture to update
  46296. */
  46297. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46298. /**
  46299. * Binds the frame buffer to the specified texture.
  46300. * @param texture The texture to render to or null for the default canvas
  46301. * @param faceIndex The face of the texture to render to in case of cube texture
  46302. * @param requiredWidth The width of the target to render to
  46303. * @param requiredHeight The height of the target to render to
  46304. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46305. * @param depthStencilTexture The depth stencil texture to use to render
  46306. * @param lodLevel defines le lod level to bind to the frame buffer
  46307. */
  46308. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46309. /**
  46310. * Unbind the current render target texture from the webGL context
  46311. * @param texture defines the render target texture to unbind
  46312. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46313. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46314. */
  46315. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46316. /**
  46317. * Creates a dynamic vertex buffer
  46318. * @param vertices the data for the dynamic vertex buffer
  46319. * @returns the new WebGL dynamic buffer
  46320. */
  46321. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46322. /**
  46323. * Update the content of a dynamic texture
  46324. * @param texture defines the texture to update
  46325. * @param canvas defines the canvas containing the source
  46326. * @param invertY defines if data must be stored with Y axis inverted
  46327. * @param premulAlpha defines if alpha is stored as premultiplied
  46328. * @param format defines the format of the data
  46329. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46330. */
  46331. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46332. /**
  46333. * Gets a boolean indicating if all created effects are ready
  46334. * @returns true if all effects are ready
  46335. */
  46336. areAllEffectsReady(): boolean;
  46337. /**
  46338. * @hidden
  46339. * Get the current error code of the webGL context
  46340. * @returns the error code
  46341. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46342. */
  46343. getError(): number;
  46344. /** @hidden */
  46345. _getUnpackAlignement(): number;
  46346. /** @hidden */
  46347. _unpackFlipY(value: boolean): void;
  46348. /**
  46349. * Update a dynamic index buffer
  46350. * @param indexBuffer defines the target index buffer
  46351. * @param indices defines the data to update
  46352. * @param offset defines the offset in the target index buffer where update should start
  46353. */
  46354. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46355. /**
  46356. * Updates a dynamic vertex buffer.
  46357. * @param vertexBuffer the vertex buffer to update
  46358. * @param vertices the data used to update the vertex buffer
  46359. * @param byteOffset the byte offset of the data (optional)
  46360. * @param byteLength the byte length of the data (optional)
  46361. */
  46362. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46363. /** @hidden */
  46364. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46365. /** @hidden */
  46366. _bindTexture(channel: number, texture: InternalTexture): void;
  46367. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46368. /**
  46369. * 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
  46370. */
  46371. releaseEffects(): void;
  46372. displayLoadingUI(): void;
  46373. hideLoadingUI(): void;
  46374. /** @hidden */
  46375. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46376. /** @hidden */
  46377. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46378. /** @hidden */
  46379. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46380. /** @hidden */
  46381. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46382. }
  46383. }
  46384. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46385. import { Nullable, int } from "babylonjs/types";
  46386. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46387. /** @hidden */
  46388. export class _OcclusionDataStorage {
  46389. /** @hidden */
  46390. occlusionInternalRetryCounter: number;
  46391. /** @hidden */
  46392. isOcclusionQueryInProgress: boolean;
  46393. /** @hidden */
  46394. isOccluded: boolean;
  46395. /** @hidden */
  46396. occlusionRetryCount: number;
  46397. /** @hidden */
  46398. occlusionType: number;
  46399. /** @hidden */
  46400. occlusionQueryAlgorithmType: number;
  46401. }
  46402. module "babylonjs/Engines/engine" {
  46403. interface Engine {
  46404. /**
  46405. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46406. * @return the new query
  46407. */
  46408. createQuery(): WebGLQuery;
  46409. /**
  46410. * Delete and release a webGL query
  46411. * @param query defines the query to delete
  46412. * @return the current engine
  46413. */
  46414. deleteQuery(query: WebGLQuery): Engine;
  46415. /**
  46416. * Check if a given query has resolved and got its value
  46417. * @param query defines the query to check
  46418. * @returns true if the query got its value
  46419. */
  46420. isQueryResultAvailable(query: WebGLQuery): boolean;
  46421. /**
  46422. * Gets the value of a given query
  46423. * @param query defines the query to check
  46424. * @returns the value of the query
  46425. */
  46426. getQueryResult(query: WebGLQuery): number;
  46427. /**
  46428. * Initiates an occlusion query
  46429. * @param algorithmType defines the algorithm to use
  46430. * @param query defines the query to use
  46431. * @returns the current engine
  46432. * @see http://doc.babylonjs.com/features/occlusionquery
  46433. */
  46434. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46435. /**
  46436. * Ends an occlusion query
  46437. * @see http://doc.babylonjs.com/features/occlusionquery
  46438. * @param algorithmType defines the algorithm to use
  46439. * @returns the current engine
  46440. */
  46441. endOcclusionQuery(algorithmType: number): Engine;
  46442. /**
  46443. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46444. * Please note that only one query can be issued at a time
  46445. * @returns a time token used to track the time span
  46446. */
  46447. startTimeQuery(): Nullable<_TimeToken>;
  46448. /**
  46449. * Ends a time query
  46450. * @param token defines the token used to measure the time span
  46451. * @returns the time spent (in ns)
  46452. */
  46453. endTimeQuery(token: _TimeToken): int;
  46454. /** @hidden */
  46455. _currentNonTimestampToken: Nullable<_TimeToken>;
  46456. /** @hidden */
  46457. _createTimeQuery(): WebGLQuery;
  46458. /** @hidden */
  46459. _deleteTimeQuery(query: WebGLQuery): void;
  46460. /** @hidden */
  46461. _getGlAlgorithmType(algorithmType: number): number;
  46462. /** @hidden */
  46463. _getTimeQueryResult(query: WebGLQuery): any;
  46464. /** @hidden */
  46465. _getTimeQueryAvailability(query: WebGLQuery): any;
  46466. }
  46467. }
  46468. module "babylonjs/Meshes/abstractMesh" {
  46469. interface AbstractMesh {
  46470. /**
  46471. * Backing filed
  46472. * @hidden
  46473. */
  46474. __occlusionDataStorage: _OcclusionDataStorage;
  46475. /**
  46476. * Access property
  46477. * @hidden
  46478. */
  46479. _occlusionDataStorage: _OcclusionDataStorage;
  46480. /**
  46481. * 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.
  46482. * The default value is -1 which means don't break the query and wait till the result
  46483. * @see http://doc.babylonjs.com/features/occlusionquery
  46484. */
  46485. occlusionRetryCount: number;
  46486. /**
  46487. * 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:
  46488. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46489. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46490. * * 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.
  46491. * @see http://doc.babylonjs.com/features/occlusionquery
  46492. */
  46493. occlusionType: number;
  46494. /**
  46495. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46496. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46497. * * 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.
  46498. * @see http://doc.babylonjs.com/features/occlusionquery
  46499. */
  46500. occlusionQueryAlgorithmType: number;
  46501. /**
  46502. * 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
  46503. * @see http://doc.babylonjs.com/features/occlusionquery
  46504. */
  46505. isOccluded: boolean;
  46506. /**
  46507. * Flag to check the progress status of the query
  46508. * @see http://doc.babylonjs.com/features/occlusionquery
  46509. */
  46510. isOcclusionQueryInProgress: boolean;
  46511. }
  46512. }
  46513. }
  46514. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46515. import { Nullable } from "babylonjs/types";
  46516. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46517. /** @hidden */
  46518. export var _forceTransformFeedbackToBundle: boolean;
  46519. module "babylonjs/Engines/engine" {
  46520. interface Engine {
  46521. /**
  46522. * Creates a webGL transform feedback object
  46523. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46524. * @returns the webGL transform feedback object
  46525. */
  46526. createTransformFeedback(): WebGLTransformFeedback;
  46527. /**
  46528. * Delete a webGL transform feedback object
  46529. * @param value defines the webGL transform feedback object to delete
  46530. */
  46531. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46532. /**
  46533. * Bind a webGL transform feedback object to the webgl context
  46534. * @param value defines the webGL transform feedback object to bind
  46535. */
  46536. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46537. /**
  46538. * Begins a transform feedback operation
  46539. * @param usePoints defines if points or triangles must be used
  46540. */
  46541. beginTransformFeedback(usePoints: boolean): void;
  46542. /**
  46543. * Ends a transform feedback operation
  46544. */
  46545. endTransformFeedback(): void;
  46546. /**
  46547. * Specify the varyings to use with transform feedback
  46548. * @param program defines the associated webGL program
  46549. * @param value defines the list of strings representing the varying names
  46550. */
  46551. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46552. /**
  46553. * Bind a webGL buffer for a transform feedback operation
  46554. * @param value defines the webGL buffer to bind
  46555. */
  46556. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46557. }
  46558. }
  46559. }
  46560. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46561. import { Scene } from "babylonjs/scene";
  46562. import { Engine } from "babylonjs/Engines/engine";
  46563. import { Texture } from "babylonjs/Materials/Textures/texture";
  46564. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46565. import "babylonjs/Engines/Extensions/engine.multiRender";
  46566. /**
  46567. * Creation options of the multi render target texture.
  46568. */
  46569. export interface IMultiRenderTargetOptions {
  46570. /**
  46571. * Define if the texture needs to create mip maps after render.
  46572. */
  46573. generateMipMaps?: boolean;
  46574. /**
  46575. * Define the types of all the draw buffers we want to create
  46576. */
  46577. types?: number[];
  46578. /**
  46579. * Define the sampling modes of all the draw buffers we want to create
  46580. */
  46581. samplingModes?: number[];
  46582. /**
  46583. * Define if a depth buffer is required
  46584. */
  46585. generateDepthBuffer?: boolean;
  46586. /**
  46587. * Define if a stencil buffer is required
  46588. */
  46589. generateStencilBuffer?: boolean;
  46590. /**
  46591. * Define if a depth texture is required instead of a depth buffer
  46592. */
  46593. generateDepthTexture?: boolean;
  46594. /**
  46595. * Define the number of desired draw buffers
  46596. */
  46597. textureCount?: number;
  46598. /**
  46599. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46600. */
  46601. doNotChangeAspectRatio?: boolean;
  46602. /**
  46603. * Define the default type of the buffers we are creating
  46604. */
  46605. defaultType?: number;
  46606. }
  46607. /**
  46608. * A multi render target, like a render target provides the ability to render to a texture.
  46609. * Unlike the render target, it can render to several draw buffers in one draw.
  46610. * This is specially interesting in deferred rendering or for any effects requiring more than
  46611. * just one color from a single pass.
  46612. */
  46613. export class MultiRenderTarget extends RenderTargetTexture {
  46614. private _internalTextures;
  46615. private _textures;
  46616. private _multiRenderTargetOptions;
  46617. /**
  46618. * Get if draw buffers are currently supported by the used hardware and browser.
  46619. */
  46620. readonly isSupported: boolean;
  46621. /**
  46622. * Get the list of textures generated by the multi render target.
  46623. */
  46624. readonly textures: Texture[];
  46625. /**
  46626. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46627. */
  46628. readonly depthTexture: Texture;
  46629. /**
  46630. * Set the wrapping mode on U of all the textures we are rendering to.
  46631. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46632. */
  46633. wrapU: number;
  46634. /**
  46635. * Set the wrapping mode on V of all the textures we are rendering to.
  46636. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46637. */
  46638. wrapV: number;
  46639. /**
  46640. * Instantiate a new multi render target texture.
  46641. * A multi render target, like a render target provides the ability to render to a texture.
  46642. * Unlike the render target, it can render to several draw buffers in one draw.
  46643. * This is specially interesting in deferred rendering or for any effects requiring more than
  46644. * just one color from a single pass.
  46645. * @param name Define the name of the texture
  46646. * @param size Define the size of the buffers to render to
  46647. * @param count Define the number of target we are rendering into
  46648. * @param scene Define the scene the texture belongs to
  46649. * @param options Define the options used to create the multi render target
  46650. */
  46651. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46652. /** @hidden */
  46653. _rebuild(): void;
  46654. private _createInternalTextures;
  46655. private _createTextures;
  46656. /**
  46657. * Define the number of samples used if MSAA is enabled.
  46658. */
  46659. samples: number;
  46660. /**
  46661. * Resize all the textures in the multi render target.
  46662. * Be carrefull as it will recreate all the data in the new texture.
  46663. * @param size Define the new size
  46664. */
  46665. resize(size: any): void;
  46666. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46667. /**
  46668. * Dispose the render targets and their associated resources
  46669. */
  46670. dispose(): void;
  46671. /**
  46672. * Release all the underlying texture used as draw buffers.
  46673. */
  46674. releaseInternalTextures(): void;
  46675. }
  46676. }
  46677. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46678. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46679. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46680. import { Nullable } from "babylonjs/types";
  46681. module "babylonjs/Engines/thinEngine" {
  46682. interface ThinEngine {
  46683. /**
  46684. * Unbind a list of render target textures from the webGL context
  46685. * This is used only when drawBuffer extension or webGL2 are active
  46686. * @param textures defines the render target textures to unbind
  46687. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46688. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46689. */
  46690. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46691. /**
  46692. * Create a multi render target texture
  46693. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46694. * @param size defines the size of the texture
  46695. * @param options defines the creation options
  46696. * @returns the cube texture as an InternalTexture
  46697. */
  46698. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46699. /**
  46700. * Update the sample count for a given multiple render target texture
  46701. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46702. * @param textures defines the textures to update
  46703. * @param samples defines the sample count to set
  46704. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46705. */
  46706. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46707. }
  46708. }
  46709. }
  46710. declare module "babylonjs/Engines/Extensions/engine.views" {
  46711. import { Camera } from "babylonjs/Cameras/camera";
  46712. import { Nullable } from "babylonjs/types";
  46713. /**
  46714. * Class used to define an additional view for the engine
  46715. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46716. */
  46717. export class EngineView {
  46718. /** Defines the canvas where to render the view */
  46719. target: HTMLCanvasElement;
  46720. /** Defines an optional camera used to render the view (will use active camera else) */
  46721. camera?: Camera;
  46722. }
  46723. module "babylonjs/Engines/engine" {
  46724. interface Engine {
  46725. /**
  46726. * Gets or sets the HTML element to use for attaching events
  46727. */
  46728. inputElement: Nullable<HTMLElement>;
  46729. /**
  46730. * Gets the current engine view
  46731. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46732. */
  46733. activeView: Nullable<EngineView>;
  46734. /** Gets or sets the list of views */
  46735. views: EngineView[];
  46736. /**
  46737. * Register a new child canvas
  46738. * @param canvas defines the canvas to register
  46739. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46740. * @returns the associated view
  46741. */
  46742. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46743. /**
  46744. * Remove a registered child canvas
  46745. * @param canvas defines the canvas to remove
  46746. * @returns the current engine
  46747. */
  46748. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46749. }
  46750. }
  46751. }
  46752. declare module "babylonjs/Engines/Extensions/index" {
  46753. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46754. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46755. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46756. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46757. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46758. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46759. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46760. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46761. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46762. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46763. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46764. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46765. export * from "babylonjs/Engines/Extensions/engine.views";
  46766. }
  46767. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46768. import { Nullable } from "babylonjs/types";
  46769. /**
  46770. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46771. */
  46772. export interface CubeMapInfo {
  46773. /**
  46774. * The pixel array for the front face.
  46775. * This is stored in format, left to right, up to down format.
  46776. */
  46777. front: Nullable<ArrayBufferView>;
  46778. /**
  46779. * The pixel array for the back face.
  46780. * This is stored in format, left to right, up to down format.
  46781. */
  46782. back: Nullable<ArrayBufferView>;
  46783. /**
  46784. * The pixel array for the left face.
  46785. * This is stored in format, left to right, up to down format.
  46786. */
  46787. left: Nullable<ArrayBufferView>;
  46788. /**
  46789. * The pixel array for the right face.
  46790. * This is stored in format, left to right, up to down format.
  46791. */
  46792. right: Nullable<ArrayBufferView>;
  46793. /**
  46794. * The pixel array for the up face.
  46795. * This is stored in format, left to right, up to down format.
  46796. */
  46797. up: Nullable<ArrayBufferView>;
  46798. /**
  46799. * The pixel array for the down face.
  46800. * This is stored in format, left to right, up to down format.
  46801. */
  46802. down: Nullable<ArrayBufferView>;
  46803. /**
  46804. * The size of the cubemap stored.
  46805. *
  46806. * Each faces will be size * size pixels.
  46807. */
  46808. size: number;
  46809. /**
  46810. * The format of the texture.
  46811. *
  46812. * RGBA, RGB.
  46813. */
  46814. format: number;
  46815. /**
  46816. * The type of the texture data.
  46817. *
  46818. * UNSIGNED_INT, FLOAT.
  46819. */
  46820. type: number;
  46821. /**
  46822. * Specifies whether the texture is in gamma space.
  46823. */
  46824. gammaSpace: boolean;
  46825. }
  46826. /**
  46827. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46828. */
  46829. export class PanoramaToCubeMapTools {
  46830. private static FACE_FRONT;
  46831. private static FACE_BACK;
  46832. private static FACE_RIGHT;
  46833. private static FACE_LEFT;
  46834. private static FACE_DOWN;
  46835. private static FACE_UP;
  46836. /**
  46837. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46838. *
  46839. * @param float32Array The source data.
  46840. * @param inputWidth The width of the input panorama.
  46841. * @param inputHeight The height of the input panorama.
  46842. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46843. * @return The cubemap data
  46844. */
  46845. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46846. private static CreateCubemapTexture;
  46847. private static CalcProjectionSpherical;
  46848. }
  46849. }
  46850. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46851. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46852. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46853. import { Nullable } from "babylonjs/types";
  46854. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46855. /**
  46856. * Helper class dealing with the extraction of spherical polynomial dataArray
  46857. * from a cube map.
  46858. */
  46859. export class CubeMapToSphericalPolynomialTools {
  46860. private static FileFaces;
  46861. /**
  46862. * Converts a texture to the according Spherical Polynomial data.
  46863. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46864. *
  46865. * @param texture The texture to extract the information from.
  46866. * @return The Spherical Polynomial data.
  46867. */
  46868. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46869. /**
  46870. * Converts a cubemap to the according Spherical Polynomial data.
  46871. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46872. *
  46873. * @param cubeInfo The Cube map to extract the information from.
  46874. * @return The Spherical Polynomial data.
  46875. */
  46876. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46877. }
  46878. }
  46879. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46880. import { Nullable } from "babylonjs/types";
  46881. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46882. module "babylonjs/Materials/Textures/baseTexture" {
  46883. interface BaseTexture {
  46884. /**
  46885. * Get the polynomial representation of the texture data.
  46886. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46887. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46888. */
  46889. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46890. }
  46891. }
  46892. }
  46893. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46894. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46895. /** @hidden */
  46896. export var rgbdEncodePixelShader: {
  46897. name: string;
  46898. shader: string;
  46899. };
  46900. }
  46901. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46902. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46903. /** @hidden */
  46904. export var rgbdDecodePixelShader: {
  46905. name: string;
  46906. shader: string;
  46907. };
  46908. }
  46909. declare module "babylonjs/Misc/environmentTextureTools" {
  46910. import { Nullable } from "babylonjs/types";
  46911. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46912. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46913. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46914. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46915. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46916. import "babylonjs/Shaders/rgbdEncode.fragment";
  46917. import "babylonjs/Shaders/rgbdDecode.fragment";
  46918. /**
  46919. * Raw texture data and descriptor sufficient for WebGL texture upload
  46920. */
  46921. export interface EnvironmentTextureInfo {
  46922. /**
  46923. * Version of the environment map
  46924. */
  46925. version: number;
  46926. /**
  46927. * Width of image
  46928. */
  46929. width: number;
  46930. /**
  46931. * Irradiance information stored in the file.
  46932. */
  46933. irradiance: any;
  46934. /**
  46935. * Specular information stored in the file.
  46936. */
  46937. specular: any;
  46938. }
  46939. /**
  46940. * Defines One Image in the file. It requires only the position in the file
  46941. * as well as the length.
  46942. */
  46943. interface BufferImageData {
  46944. /**
  46945. * Length of the image data.
  46946. */
  46947. length: number;
  46948. /**
  46949. * Position of the data from the null terminator delimiting the end of the JSON.
  46950. */
  46951. position: number;
  46952. }
  46953. /**
  46954. * Defines the specular data enclosed in the file.
  46955. * This corresponds to the version 1 of the data.
  46956. */
  46957. export interface EnvironmentTextureSpecularInfoV1 {
  46958. /**
  46959. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46960. */
  46961. specularDataPosition?: number;
  46962. /**
  46963. * This contains all the images data needed to reconstruct the cubemap.
  46964. */
  46965. mipmaps: Array<BufferImageData>;
  46966. /**
  46967. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46968. */
  46969. lodGenerationScale: number;
  46970. }
  46971. /**
  46972. * Sets of helpers addressing the serialization and deserialization of environment texture
  46973. * stored in a BabylonJS env file.
  46974. * Those files are usually stored as .env files.
  46975. */
  46976. export class EnvironmentTextureTools {
  46977. /**
  46978. * Magic number identifying the env file.
  46979. */
  46980. private static _MagicBytes;
  46981. /**
  46982. * Gets the environment info from an env file.
  46983. * @param data The array buffer containing the .env bytes.
  46984. * @returns the environment file info (the json header) if successfully parsed.
  46985. */
  46986. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46987. /**
  46988. * Creates an environment texture from a loaded cube texture.
  46989. * @param texture defines the cube texture to convert in env file
  46990. * @return a promise containing the environment data if succesfull.
  46991. */
  46992. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46993. /**
  46994. * Creates a JSON representation of the spherical data.
  46995. * @param texture defines the texture containing the polynomials
  46996. * @return the JSON representation of the spherical info
  46997. */
  46998. private static _CreateEnvTextureIrradiance;
  46999. /**
  47000. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47001. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47002. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47003. * @return the views described by info providing access to the underlying buffer
  47004. */
  47005. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47006. /**
  47007. * Uploads the texture info contained in the env file to the GPU.
  47008. * @param texture defines the internal texture to upload to
  47009. * @param arrayBuffer defines the buffer cotaining the data to load
  47010. * @param info defines the texture info retrieved through the GetEnvInfo method
  47011. * @returns a promise
  47012. */
  47013. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47014. private static _OnImageReadyAsync;
  47015. /**
  47016. * Uploads the levels of image data to the GPU.
  47017. * @param texture defines the internal texture to upload to
  47018. * @param imageData defines the array buffer views of image data [mipmap][face]
  47019. * @returns a promise
  47020. */
  47021. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47022. /**
  47023. * Uploads spherical polynomials information to the texture.
  47024. * @param texture defines the texture we are trying to upload the information to
  47025. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47026. */
  47027. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47028. /** @hidden */
  47029. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47030. }
  47031. }
  47032. declare module "babylonjs/Maths/math.vertexFormat" {
  47033. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47034. /**
  47035. * Contains position and normal vectors for a vertex
  47036. */
  47037. export class PositionNormalVertex {
  47038. /** the position of the vertex (defaut: 0,0,0) */
  47039. position: Vector3;
  47040. /** the normal of the vertex (defaut: 0,1,0) */
  47041. normal: Vector3;
  47042. /**
  47043. * Creates a PositionNormalVertex
  47044. * @param position the position of the vertex (defaut: 0,0,0)
  47045. * @param normal the normal of the vertex (defaut: 0,1,0)
  47046. */
  47047. constructor(
  47048. /** the position of the vertex (defaut: 0,0,0) */
  47049. position?: Vector3,
  47050. /** the normal of the vertex (defaut: 0,1,0) */
  47051. normal?: Vector3);
  47052. /**
  47053. * Clones the PositionNormalVertex
  47054. * @returns the cloned PositionNormalVertex
  47055. */
  47056. clone(): PositionNormalVertex;
  47057. }
  47058. /**
  47059. * Contains position, normal and uv vectors for a vertex
  47060. */
  47061. export class PositionNormalTextureVertex {
  47062. /** the position of the vertex (defaut: 0,0,0) */
  47063. position: Vector3;
  47064. /** the normal of the vertex (defaut: 0,1,0) */
  47065. normal: Vector3;
  47066. /** the uv of the vertex (default: 0,0) */
  47067. uv: Vector2;
  47068. /**
  47069. * Creates a PositionNormalTextureVertex
  47070. * @param position the position of the vertex (defaut: 0,0,0)
  47071. * @param normal the normal of the vertex (defaut: 0,1,0)
  47072. * @param uv the uv of the vertex (default: 0,0)
  47073. */
  47074. constructor(
  47075. /** the position of the vertex (defaut: 0,0,0) */
  47076. position?: Vector3,
  47077. /** the normal of the vertex (defaut: 0,1,0) */
  47078. normal?: Vector3,
  47079. /** the uv of the vertex (default: 0,0) */
  47080. uv?: Vector2);
  47081. /**
  47082. * Clones the PositionNormalTextureVertex
  47083. * @returns the cloned PositionNormalTextureVertex
  47084. */
  47085. clone(): PositionNormalTextureVertex;
  47086. }
  47087. }
  47088. declare module "babylonjs/Maths/math" {
  47089. export * from "babylonjs/Maths/math.axis";
  47090. export * from "babylonjs/Maths/math.color";
  47091. export * from "babylonjs/Maths/math.constants";
  47092. export * from "babylonjs/Maths/math.frustum";
  47093. export * from "babylonjs/Maths/math.path";
  47094. export * from "babylonjs/Maths/math.plane";
  47095. export * from "babylonjs/Maths/math.size";
  47096. export * from "babylonjs/Maths/math.vector";
  47097. export * from "babylonjs/Maths/math.vertexFormat";
  47098. export * from "babylonjs/Maths/math.viewport";
  47099. }
  47100. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47101. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47102. /** @hidden */
  47103. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47104. private _genericAttributeLocation;
  47105. private _varyingLocationCount;
  47106. private _varyingLocationMap;
  47107. private _replacements;
  47108. private _textureCount;
  47109. private _uniforms;
  47110. lineProcessor(line: string): string;
  47111. attributeProcessor(attribute: string): string;
  47112. varyingProcessor(varying: string, isFragment: boolean): string;
  47113. uniformProcessor(uniform: string): string;
  47114. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47115. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47116. }
  47117. }
  47118. declare module "babylonjs/Engines/nativeEngine" {
  47119. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47120. import { Engine } from "babylonjs/Engines/engine";
  47121. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47123. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47124. import { Effect } from "babylonjs/Materials/effect";
  47125. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47126. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47127. import { IColor4Like } from "babylonjs/Maths/math.like";
  47128. import { Scene } from "babylonjs/scene";
  47129. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47130. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47131. /**
  47132. * Container for accessors for natively-stored mesh data buffers.
  47133. */
  47134. class NativeDataBuffer extends DataBuffer {
  47135. /**
  47136. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47137. */
  47138. nativeIndexBuffer?: any;
  47139. /**
  47140. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47141. */
  47142. nativeVertexBuffer?: any;
  47143. }
  47144. /** @hidden */
  47145. class NativeTexture extends InternalTexture {
  47146. getInternalTexture(): InternalTexture;
  47147. getViewCount(): number;
  47148. }
  47149. /** @hidden */
  47150. export class NativeEngine extends Engine {
  47151. private readonly _native;
  47152. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47153. private readonly INVALID_HANDLE;
  47154. getHardwareScalingLevel(): number;
  47155. constructor();
  47156. /**
  47157. * Can be used to override the current requestAnimationFrame requester.
  47158. * @hidden
  47159. */
  47160. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47161. /**
  47162. * Override default engine behavior.
  47163. * @param color
  47164. * @param backBuffer
  47165. * @param depth
  47166. * @param stencil
  47167. */
  47168. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47169. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47170. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47171. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47172. recordVertexArrayObject(vertexBuffers: {
  47173. [key: string]: VertexBuffer;
  47174. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47175. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47176. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47177. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47178. /**
  47179. * Draw a list of indexed primitives
  47180. * @param fillMode defines the primitive to use
  47181. * @param indexStart defines the starting index
  47182. * @param indexCount defines the number of index to draw
  47183. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47184. */
  47185. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47186. /**
  47187. * Draw a list of unindexed primitives
  47188. * @param fillMode defines the primitive to use
  47189. * @param verticesStart defines the index of first vertex to draw
  47190. * @param verticesCount defines the count of vertices to draw
  47191. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47192. */
  47193. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47194. createPipelineContext(): IPipelineContext;
  47195. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47196. /** @hidden */
  47197. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47198. /** @hidden */
  47199. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47200. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47201. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47202. protected _setProgram(program: WebGLProgram): void;
  47203. _releaseEffect(effect: Effect): void;
  47204. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47205. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47206. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47207. bindSamplers(effect: Effect): void;
  47208. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47209. getRenderWidth(useScreen?: boolean): number;
  47210. getRenderHeight(useScreen?: boolean): number;
  47211. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47212. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47213. /**
  47214. * Set the z offset to apply to current rendering
  47215. * @param value defines the offset to apply
  47216. */
  47217. setZOffset(value: number): void;
  47218. /**
  47219. * Gets the current value of the zOffset
  47220. * @returns the current zOffset state
  47221. */
  47222. getZOffset(): number;
  47223. /**
  47224. * Enable or disable depth buffering
  47225. * @param enable defines the state to set
  47226. */
  47227. setDepthBuffer(enable: boolean): void;
  47228. /**
  47229. * Gets a boolean indicating if depth writing is enabled
  47230. * @returns the current depth writing state
  47231. */
  47232. getDepthWrite(): boolean;
  47233. /**
  47234. * Enable or disable depth writing
  47235. * @param enable defines the state to set
  47236. */
  47237. setDepthWrite(enable: boolean): void;
  47238. /**
  47239. * Enable or disable color writing
  47240. * @param enable defines the state to set
  47241. */
  47242. setColorWrite(enable: boolean): void;
  47243. /**
  47244. * Gets a boolean indicating if color writing is enabled
  47245. * @returns the current color writing state
  47246. */
  47247. getColorWrite(): boolean;
  47248. /**
  47249. * Sets alpha constants used by some alpha blending modes
  47250. * @param r defines the red component
  47251. * @param g defines the green component
  47252. * @param b defines the blue component
  47253. * @param a defines the alpha component
  47254. */
  47255. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47256. /**
  47257. * Sets the current alpha mode
  47258. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47259. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47260. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47261. */
  47262. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47263. /**
  47264. * Gets the current alpha mode
  47265. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47266. * @returns the current alpha mode
  47267. */
  47268. getAlphaMode(): number;
  47269. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47270. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47271. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47272. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47273. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47274. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47275. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47276. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47277. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47278. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47279. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47280. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47281. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47282. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47283. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47284. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47285. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47286. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47287. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47288. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47289. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47290. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47291. wipeCaches(bruteForce?: boolean): void;
  47292. _createTexture(): WebGLTexture;
  47293. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47294. /**
  47295. * Usually called from BABYLON.Texture.ts.
  47296. * Passed information to create a WebGLTexture
  47297. * @param urlArg defines a value which contains one of the following:
  47298. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47299. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47300. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47301. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47302. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47303. * @param scene needed for loading to the correct scene
  47304. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47305. * @param onLoad optional callback to be called upon successful completion
  47306. * @param onError optional callback to be called upon failure
  47307. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47308. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47309. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47310. * @param forcedExtension defines the extension to use to pick the right loader
  47311. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47312. */
  47313. 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;
  47314. /**
  47315. * Creates a cube texture
  47316. * @param rootUrl defines the url where the files to load is located
  47317. * @param scene defines the current scene
  47318. * @param files defines the list of files to load (1 per face)
  47319. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47320. * @param onLoad defines an optional callback raised when the texture is loaded
  47321. * @param onError defines an optional callback raised if there is an issue to load the texture
  47322. * @param format defines the format of the data
  47323. * @param forcedExtension defines the extension to use to pick the right loader
  47324. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47325. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47326. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47327. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47328. * @returns the cube texture as an InternalTexture
  47329. */
  47330. 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;
  47331. private _getSamplingFilter;
  47332. private static _GetNativeTextureFormat;
  47333. createRenderTargetTexture(size: number | {
  47334. width: number;
  47335. height: number;
  47336. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47337. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47338. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47339. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47340. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47341. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47342. /**
  47343. * Updates a dynamic vertex buffer.
  47344. * @param vertexBuffer the vertex buffer to update
  47345. * @param data the data used to update the vertex buffer
  47346. * @param byteOffset the byte offset of the data (optional)
  47347. * @param byteLength the byte length of the data (optional)
  47348. */
  47349. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47350. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47351. private _updateAnisotropicLevel;
  47352. private _getAddressMode;
  47353. /** @hidden */
  47354. _bindTexture(channel: number, texture: InternalTexture): void;
  47355. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47356. releaseEffects(): void;
  47357. /** @hidden */
  47358. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47359. /** @hidden */
  47360. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47361. /** @hidden */
  47362. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47363. /** @hidden */
  47364. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47365. }
  47366. }
  47367. declare module "babylonjs/Engines/index" {
  47368. export * from "babylonjs/Engines/constants";
  47369. export * from "babylonjs/Engines/engineCapabilities";
  47370. export * from "babylonjs/Engines/instancingAttributeInfo";
  47371. export * from "babylonjs/Engines/thinEngine";
  47372. export * from "babylonjs/Engines/engine";
  47373. export * from "babylonjs/Engines/engineStore";
  47374. export * from "babylonjs/Engines/nullEngine";
  47375. export * from "babylonjs/Engines/Extensions/index";
  47376. export * from "babylonjs/Engines/IPipelineContext";
  47377. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47378. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47379. export * from "babylonjs/Engines/nativeEngine";
  47380. }
  47381. declare module "babylonjs/Events/clipboardEvents" {
  47382. /**
  47383. * Gather the list of clipboard event types as constants.
  47384. */
  47385. export class ClipboardEventTypes {
  47386. /**
  47387. * The clipboard event is fired when a copy command is active (pressed).
  47388. */
  47389. static readonly COPY: number;
  47390. /**
  47391. * The clipboard event is fired when a cut command is active (pressed).
  47392. */
  47393. static readonly CUT: number;
  47394. /**
  47395. * The clipboard event is fired when a paste command is active (pressed).
  47396. */
  47397. static readonly PASTE: number;
  47398. }
  47399. /**
  47400. * This class is used to store clipboard related info for the onClipboardObservable event.
  47401. */
  47402. export class ClipboardInfo {
  47403. /**
  47404. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47405. */
  47406. type: number;
  47407. /**
  47408. * Defines the related dom event
  47409. */
  47410. event: ClipboardEvent;
  47411. /**
  47412. *Creates an instance of ClipboardInfo.
  47413. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47414. * @param event Defines the related dom event
  47415. */
  47416. constructor(
  47417. /**
  47418. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47419. */
  47420. type: number,
  47421. /**
  47422. * Defines the related dom event
  47423. */
  47424. event: ClipboardEvent);
  47425. /**
  47426. * Get the clipboard event's type from the keycode.
  47427. * @param keyCode Defines the keyCode for the current keyboard event.
  47428. * @return {number}
  47429. */
  47430. static GetTypeFromCharacter(keyCode: number): number;
  47431. }
  47432. }
  47433. declare module "babylonjs/Events/index" {
  47434. export * from "babylonjs/Events/keyboardEvents";
  47435. export * from "babylonjs/Events/pointerEvents";
  47436. export * from "babylonjs/Events/clipboardEvents";
  47437. }
  47438. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47439. import { Scene } from "babylonjs/scene";
  47440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47441. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47442. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47443. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47444. /**
  47445. * Google Daydream controller
  47446. */
  47447. export class DaydreamController extends WebVRController {
  47448. /**
  47449. * Base Url for the controller model.
  47450. */
  47451. static MODEL_BASE_URL: string;
  47452. /**
  47453. * File name for the controller model.
  47454. */
  47455. static MODEL_FILENAME: string;
  47456. /**
  47457. * Gamepad Id prefix used to identify Daydream Controller.
  47458. */
  47459. static readonly GAMEPAD_ID_PREFIX: string;
  47460. /**
  47461. * Creates a new DaydreamController from a gamepad
  47462. * @param vrGamepad the gamepad that the controller should be created from
  47463. */
  47464. constructor(vrGamepad: any);
  47465. /**
  47466. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47467. * @param scene scene in which to add meshes
  47468. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47469. */
  47470. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47471. /**
  47472. * Called once for each button that changed state since the last frame
  47473. * @param buttonIdx Which button index changed
  47474. * @param state New state of the button
  47475. * @param changes Which properties on the state changed since last frame
  47476. */
  47477. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47478. }
  47479. }
  47480. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47481. import { Scene } from "babylonjs/scene";
  47482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47483. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47484. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47485. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47486. /**
  47487. * Gear VR Controller
  47488. */
  47489. export class GearVRController extends WebVRController {
  47490. /**
  47491. * Base Url for the controller model.
  47492. */
  47493. static MODEL_BASE_URL: string;
  47494. /**
  47495. * File name for the controller model.
  47496. */
  47497. static MODEL_FILENAME: string;
  47498. /**
  47499. * Gamepad Id prefix used to identify this controller.
  47500. */
  47501. static readonly GAMEPAD_ID_PREFIX: string;
  47502. private readonly _buttonIndexToObservableNameMap;
  47503. /**
  47504. * Creates a new GearVRController from a gamepad
  47505. * @param vrGamepad the gamepad that the controller should be created from
  47506. */
  47507. constructor(vrGamepad: any);
  47508. /**
  47509. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47510. * @param scene scene in which to add meshes
  47511. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47512. */
  47513. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47514. /**
  47515. * Called once for each button that changed state since the last frame
  47516. * @param buttonIdx Which button index changed
  47517. * @param state New state of the button
  47518. * @param changes Which properties on the state changed since last frame
  47519. */
  47520. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47521. }
  47522. }
  47523. declare module "babylonjs/Gamepads/Controllers/index" {
  47524. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47525. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47526. export * from "babylonjs/Gamepads/Controllers/genericController";
  47527. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47528. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47529. export * from "babylonjs/Gamepads/Controllers/viveController";
  47530. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47531. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47532. }
  47533. declare module "babylonjs/Gamepads/index" {
  47534. export * from "babylonjs/Gamepads/Controllers/index";
  47535. export * from "babylonjs/Gamepads/gamepad";
  47536. export * from "babylonjs/Gamepads/gamepadManager";
  47537. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47538. export * from "babylonjs/Gamepads/xboxGamepad";
  47539. export * from "babylonjs/Gamepads/dualShockGamepad";
  47540. }
  47541. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47542. import { Scene } from "babylonjs/scene";
  47543. import { Vector4 } from "babylonjs/Maths/math.vector";
  47544. import { Color4 } from "babylonjs/Maths/math.color";
  47545. import { Mesh } from "babylonjs/Meshes/mesh";
  47546. import { Nullable } from "babylonjs/types";
  47547. /**
  47548. * Class containing static functions to help procedurally build meshes
  47549. */
  47550. export class PolyhedronBuilder {
  47551. /**
  47552. * Creates a polyhedron mesh
  47553. * * 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
  47554. * * The parameter `size` (positive float, default 1) sets the polygon size
  47555. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47556. * * 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`
  47557. * * 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
  47558. * * 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)`)
  47559. * * 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
  47560. * * 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
  47561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47564. * @param name defines the name of the mesh
  47565. * @param options defines the options used to create the mesh
  47566. * @param scene defines the hosting scene
  47567. * @returns the polyhedron mesh
  47568. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47569. */
  47570. static CreatePolyhedron(name: string, options: {
  47571. type?: number;
  47572. size?: number;
  47573. sizeX?: number;
  47574. sizeY?: number;
  47575. sizeZ?: number;
  47576. custom?: any;
  47577. faceUV?: Vector4[];
  47578. faceColors?: Color4[];
  47579. flat?: boolean;
  47580. updatable?: boolean;
  47581. sideOrientation?: number;
  47582. frontUVs?: Vector4;
  47583. backUVs?: Vector4;
  47584. }, scene?: Nullable<Scene>): Mesh;
  47585. }
  47586. }
  47587. declare module "babylonjs/Gizmos/scaleGizmo" {
  47588. import { Observable } from "babylonjs/Misc/observable";
  47589. import { Nullable } from "babylonjs/types";
  47590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47591. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47592. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47593. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47594. /**
  47595. * Gizmo that enables scaling a mesh along 3 axis
  47596. */
  47597. export class ScaleGizmo extends Gizmo {
  47598. /**
  47599. * Internal gizmo used for interactions on the x axis
  47600. */
  47601. xGizmo: AxisScaleGizmo;
  47602. /**
  47603. * Internal gizmo used for interactions on the y axis
  47604. */
  47605. yGizmo: AxisScaleGizmo;
  47606. /**
  47607. * Internal gizmo used for interactions on the z axis
  47608. */
  47609. zGizmo: AxisScaleGizmo;
  47610. /**
  47611. * Internal gizmo used to scale all axis equally
  47612. */
  47613. uniformScaleGizmo: AxisScaleGizmo;
  47614. private _meshAttached;
  47615. private _updateGizmoRotationToMatchAttachedMesh;
  47616. private _snapDistance;
  47617. private _scaleRatio;
  47618. private _uniformScalingMesh;
  47619. private _octahedron;
  47620. /** Fires an event when any of it's sub gizmos are dragged */
  47621. onDragStartObservable: Observable<unknown>;
  47622. /** Fires an event when any of it's sub gizmos are released from dragging */
  47623. onDragEndObservable: Observable<unknown>;
  47624. attachedMesh: Nullable<AbstractMesh>;
  47625. /**
  47626. * Creates a ScaleGizmo
  47627. * @param gizmoLayer The utility layer the gizmo will be added to
  47628. */
  47629. constructor(gizmoLayer?: UtilityLayerRenderer);
  47630. updateGizmoRotationToMatchAttachedMesh: boolean;
  47631. /**
  47632. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47633. */
  47634. snapDistance: number;
  47635. /**
  47636. * Ratio for the scale of the gizmo (Default: 1)
  47637. */
  47638. scaleRatio: number;
  47639. /**
  47640. * Disposes of the gizmo
  47641. */
  47642. dispose(): void;
  47643. }
  47644. }
  47645. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47646. import { Observable } from "babylonjs/Misc/observable";
  47647. import { Nullable } from "babylonjs/types";
  47648. import { Vector3 } from "babylonjs/Maths/math.vector";
  47649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47650. import { Mesh } from "babylonjs/Meshes/mesh";
  47651. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47652. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47653. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47654. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47655. import { Color3 } from "babylonjs/Maths/math.color";
  47656. /**
  47657. * Single axis scale gizmo
  47658. */
  47659. export class AxisScaleGizmo extends Gizmo {
  47660. /**
  47661. * Drag behavior responsible for the gizmos dragging interactions
  47662. */
  47663. dragBehavior: PointerDragBehavior;
  47664. private _pointerObserver;
  47665. /**
  47666. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47667. */
  47668. snapDistance: number;
  47669. /**
  47670. * Event that fires each time the gizmo snaps to a new location.
  47671. * * snapDistance is the the change in distance
  47672. */
  47673. onSnapObservable: Observable<{
  47674. snapDistance: number;
  47675. }>;
  47676. /**
  47677. * If the scaling operation should be done on all axis (default: false)
  47678. */
  47679. uniformScaling: boolean;
  47680. private _isEnabled;
  47681. private _parent;
  47682. private _arrow;
  47683. private _coloredMaterial;
  47684. private _hoverMaterial;
  47685. /**
  47686. * Creates an AxisScaleGizmo
  47687. * @param gizmoLayer The utility layer the gizmo will be added to
  47688. * @param dragAxis The axis which the gizmo will be able to scale on
  47689. * @param color The color of the gizmo
  47690. */
  47691. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47692. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47693. /**
  47694. * If the gizmo is enabled
  47695. */
  47696. isEnabled: boolean;
  47697. /**
  47698. * Disposes of the gizmo
  47699. */
  47700. dispose(): void;
  47701. /**
  47702. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47703. * @param mesh The mesh to replace the default mesh of the gizmo
  47704. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47705. */
  47706. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47707. }
  47708. }
  47709. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47710. import { Observable } from "babylonjs/Misc/observable";
  47711. import { Nullable } from "babylonjs/types";
  47712. import { Vector3 } from "babylonjs/Maths/math.vector";
  47713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47714. import { Mesh } from "babylonjs/Meshes/mesh";
  47715. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47716. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47717. import { Color3 } from "babylonjs/Maths/math.color";
  47718. import "babylonjs/Meshes/Builders/boxBuilder";
  47719. /**
  47720. * Bounding box gizmo
  47721. */
  47722. export class BoundingBoxGizmo extends Gizmo {
  47723. private _lineBoundingBox;
  47724. private _rotateSpheresParent;
  47725. private _scaleBoxesParent;
  47726. private _boundingDimensions;
  47727. private _renderObserver;
  47728. private _pointerObserver;
  47729. private _scaleDragSpeed;
  47730. private _tmpQuaternion;
  47731. private _tmpVector;
  47732. private _tmpRotationMatrix;
  47733. /**
  47734. * 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)
  47735. */
  47736. ignoreChildren: boolean;
  47737. /**
  47738. * 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)
  47739. */
  47740. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47741. /**
  47742. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47743. */
  47744. rotationSphereSize: number;
  47745. /**
  47746. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47747. */
  47748. scaleBoxSize: number;
  47749. /**
  47750. * 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)
  47751. */
  47752. fixedDragMeshScreenSize: boolean;
  47753. /**
  47754. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47755. */
  47756. fixedDragMeshScreenSizeDistanceFactor: number;
  47757. /**
  47758. * Fired when a rotation sphere or scale box is dragged
  47759. */
  47760. onDragStartObservable: Observable<{}>;
  47761. /**
  47762. * Fired when a scale box is dragged
  47763. */
  47764. onScaleBoxDragObservable: Observable<{}>;
  47765. /**
  47766. * Fired when a scale box drag is ended
  47767. */
  47768. onScaleBoxDragEndObservable: Observable<{}>;
  47769. /**
  47770. * Fired when a rotation sphere is dragged
  47771. */
  47772. onRotationSphereDragObservable: Observable<{}>;
  47773. /**
  47774. * Fired when a rotation sphere drag is ended
  47775. */
  47776. onRotationSphereDragEndObservable: Observable<{}>;
  47777. /**
  47778. * 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)
  47779. */
  47780. scalePivot: Nullable<Vector3>;
  47781. /**
  47782. * Mesh used as a pivot to rotate the attached mesh
  47783. */
  47784. private _anchorMesh;
  47785. private _existingMeshScale;
  47786. private _dragMesh;
  47787. private pointerDragBehavior;
  47788. private coloredMaterial;
  47789. private hoverColoredMaterial;
  47790. /**
  47791. * Sets the color of the bounding box gizmo
  47792. * @param color the color to set
  47793. */
  47794. setColor(color: Color3): void;
  47795. /**
  47796. * Creates an BoundingBoxGizmo
  47797. * @param gizmoLayer The utility layer the gizmo will be added to
  47798. * @param color The color of the gizmo
  47799. */
  47800. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47801. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47802. private _selectNode;
  47803. /**
  47804. * Updates the bounding box information for the Gizmo
  47805. */
  47806. updateBoundingBox(): void;
  47807. private _updateRotationSpheres;
  47808. private _updateScaleBoxes;
  47809. /**
  47810. * Enables rotation on the specified axis and disables rotation on the others
  47811. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47812. */
  47813. setEnabledRotationAxis(axis: string): void;
  47814. /**
  47815. * Enables/disables scaling
  47816. * @param enable if scaling should be enabled
  47817. */
  47818. setEnabledScaling(enable: boolean): void;
  47819. private _updateDummy;
  47820. /**
  47821. * Enables a pointer drag behavior on the bounding box of the gizmo
  47822. */
  47823. enableDragBehavior(): void;
  47824. /**
  47825. * Disposes of the gizmo
  47826. */
  47827. dispose(): void;
  47828. /**
  47829. * 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)
  47830. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47831. * @returns the bounding box mesh with the passed in mesh as a child
  47832. */
  47833. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47834. /**
  47835. * CustomMeshes are not supported by this gizmo
  47836. * @param mesh The mesh to replace the default mesh of the gizmo
  47837. */
  47838. setCustomMesh(mesh: Mesh): void;
  47839. }
  47840. }
  47841. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47842. import { Observable } from "babylonjs/Misc/observable";
  47843. import { Nullable } from "babylonjs/types";
  47844. import { Vector3 } from "babylonjs/Maths/math.vector";
  47845. import { Color3 } from "babylonjs/Maths/math.color";
  47846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47847. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47848. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47849. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47850. import "babylonjs/Meshes/Builders/linesBuilder";
  47851. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47852. /**
  47853. * Single plane rotation gizmo
  47854. */
  47855. export class PlaneRotationGizmo extends Gizmo {
  47856. /**
  47857. * Drag behavior responsible for the gizmos dragging interactions
  47858. */
  47859. dragBehavior: PointerDragBehavior;
  47860. private _pointerObserver;
  47861. /**
  47862. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47863. */
  47864. snapDistance: number;
  47865. /**
  47866. * Event that fires each time the gizmo snaps to a new location.
  47867. * * snapDistance is the the change in distance
  47868. */
  47869. onSnapObservable: Observable<{
  47870. snapDistance: number;
  47871. }>;
  47872. private _isEnabled;
  47873. private _parent;
  47874. /**
  47875. * Creates a PlaneRotationGizmo
  47876. * @param gizmoLayer The utility layer the gizmo will be added to
  47877. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47878. * @param color The color of the gizmo
  47879. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47880. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47881. */
  47882. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47883. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47884. /**
  47885. * If the gizmo is enabled
  47886. */
  47887. isEnabled: boolean;
  47888. /**
  47889. * Disposes of the gizmo
  47890. */
  47891. dispose(): void;
  47892. }
  47893. }
  47894. declare module "babylonjs/Gizmos/rotationGizmo" {
  47895. import { Observable } from "babylonjs/Misc/observable";
  47896. import { Nullable } from "babylonjs/types";
  47897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47898. import { Mesh } from "babylonjs/Meshes/mesh";
  47899. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47900. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47901. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47902. /**
  47903. * Gizmo that enables rotating a mesh along 3 axis
  47904. */
  47905. export class RotationGizmo extends Gizmo {
  47906. /**
  47907. * Internal gizmo used for interactions on the x axis
  47908. */
  47909. xGizmo: PlaneRotationGizmo;
  47910. /**
  47911. * Internal gizmo used for interactions on the y axis
  47912. */
  47913. yGizmo: PlaneRotationGizmo;
  47914. /**
  47915. * Internal gizmo used for interactions on the z axis
  47916. */
  47917. zGizmo: PlaneRotationGizmo;
  47918. /** Fires an event when any of it's sub gizmos are dragged */
  47919. onDragStartObservable: Observable<unknown>;
  47920. /** Fires an event when any of it's sub gizmos are released from dragging */
  47921. onDragEndObservable: Observable<unknown>;
  47922. private _meshAttached;
  47923. attachedMesh: Nullable<AbstractMesh>;
  47924. /**
  47925. * Creates a RotationGizmo
  47926. * @param gizmoLayer The utility layer the gizmo will be added to
  47927. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47928. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47929. */
  47930. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47931. updateGizmoRotationToMatchAttachedMesh: boolean;
  47932. /**
  47933. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47934. */
  47935. snapDistance: number;
  47936. /**
  47937. * Ratio for the scale of the gizmo (Default: 1)
  47938. */
  47939. scaleRatio: number;
  47940. /**
  47941. * Disposes of the gizmo
  47942. */
  47943. dispose(): void;
  47944. /**
  47945. * CustomMeshes are not supported by this gizmo
  47946. * @param mesh The mesh to replace the default mesh of the gizmo
  47947. */
  47948. setCustomMesh(mesh: Mesh): void;
  47949. }
  47950. }
  47951. declare module "babylonjs/Gizmos/gizmoManager" {
  47952. import { Observable } from "babylonjs/Misc/observable";
  47953. import { Nullable } from "babylonjs/types";
  47954. import { Scene, IDisposable } from "babylonjs/scene";
  47955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47956. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47957. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47958. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47959. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47960. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47961. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47962. /**
  47963. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47964. */
  47965. export class GizmoManager implements IDisposable {
  47966. private scene;
  47967. /**
  47968. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47969. */
  47970. gizmos: {
  47971. positionGizmo: Nullable<PositionGizmo>;
  47972. rotationGizmo: Nullable<RotationGizmo>;
  47973. scaleGizmo: Nullable<ScaleGizmo>;
  47974. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47975. };
  47976. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47977. clearGizmoOnEmptyPointerEvent: boolean;
  47978. /** Fires an event when the manager is attached to a mesh */
  47979. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47980. private _gizmosEnabled;
  47981. private _pointerObserver;
  47982. private _attachedMesh;
  47983. private _boundingBoxColor;
  47984. private _defaultUtilityLayer;
  47985. private _defaultKeepDepthUtilityLayer;
  47986. /**
  47987. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47988. */
  47989. boundingBoxDragBehavior: SixDofDragBehavior;
  47990. /**
  47991. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47992. */
  47993. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47994. /**
  47995. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47996. */
  47997. usePointerToAttachGizmos: boolean;
  47998. /**
  47999. * Utility layer that the bounding box gizmo belongs to
  48000. */
  48001. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48002. /**
  48003. * Utility layer that all gizmos besides bounding box belong to
  48004. */
  48005. readonly utilityLayer: UtilityLayerRenderer;
  48006. /**
  48007. * Instatiates a gizmo manager
  48008. * @param scene the scene to overlay the gizmos on top of
  48009. */
  48010. constructor(scene: Scene);
  48011. /**
  48012. * Attaches a set of gizmos to the specified mesh
  48013. * @param mesh The mesh the gizmo's should be attached to
  48014. */
  48015. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48016. /**
  48017. * If the position gizmo is enabled
  48018. */
  48019. positionGizmoEnabled: boolean;
  48020. /**
  48021. * If the rotation gizmo is enabled
  48022. */
  48023. rotationGizmoEnabled: boolean;
  48024. /**
  48025. * If the scale gizmo is enabled
  48026. */
  48027. scaleGizmoEnabled: boolean;
  48028. /**
  48029. * If the boundingBox gizmo is enabled
  48030. */
  48031. boundingBoxGizmoEnabled: boolean;
  48032. /**
  48033. * Disposes of the gizmo manager
  48034. */
  48035. dispose(): void;
  48036. }
  48037. }
  48038. declare module "babylonjs/Lights/directionalLight" {
  48039. import { Camera } from "babylonjs/Cameras/camera";
  48040. import { Scene } from "babylonjs/scene";
  48041. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48043. import { Light } from "babylonjs/Lights/light";
  48044. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48045. import { Effect } from "babylonjs/Materials/effect";
  48046. /**
  48047. * A directional light is defined by a direction (what a surprise!).
  48048. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48049. * 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.
  48050. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48051. */
  48052. export class DirectionalLight extends ShadowLight {
  48053. private _shadowFrustumSize;
  48054. /**
  48055. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48056. */
  48057. /**
  48058. * Specifies a fix frustum size for the shadow generation.
  48059. */
  48060. shadowFrustumSize: number;
  48061. private _shadowOrthoScale;
  48062. /**
  48063. * Gets the shadow projection scale against the optimal computed one.
  48064. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48065. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48066. */
  48067. /**
  48068. * Sets the shadow projection scale against the optimal computed one.
  48069. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48070. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48071. */
  48072. shadowOrthoScale: number;
  48073. /**
  48074. * Automatically compute the projection matrix to best fit (including all the casters)
  48075. * on each frame.
  48076. */
  48077. autoUpdateExtends: boolean;
  48078. private _orthoLeft;
  48079. private _orthoRight;
  48080. private _orthoTop;
  48081. private _orthoBottom;
  48082. /**
  48083. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48084. * The directional light is emitted from everywhere in the given direction.
  48085. * It can cast shadows.
  48086. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48087. * @param name The friendly name of the light
  48088. * @param direction The direction of the light
  48089. * @param scene The scene the light belongs to
  48090. */
  48091. constructor(name: string, direction: Vector3, scene: Scene);
  48092. /**
  48093. * Returns the string "DirectionalLight".
  48094. * @return The class name
  48095. */
  48096. getClassName(): string;
  48097. /**
  48098. * Returns the integer 1.
  48099. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48100. */
  48101. getTypeID(): number;
  48102. /**
  48103. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48104. * Returns the DirectionalLight Shadow projection matrix.
  48105. */
  48106. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48107. /**
  48108. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48109. * Returns the DirectionalLight Shadow projection matrix.
  48110. */
  48111. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48112. /**
  48113. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48114. * Returns the DirectionalLight Shadow projection matrix.
  48115. */
  48116. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48117. protected _buildUniformLayout(): void;
  48118. /**
  48119. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48120. * @param effect The effect to update
  48121. * @param lightIndex The index of the light in the effect to update
  48122. * @returns The directional light
  48123. */
  48124. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48125. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48126. /**
  48127. * Gets the minZ used for shadow according to both the scene and the light.
  48128. *
  48129. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48130. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48131. * @param activeCamera The camera we are returning the min for
  48132. * @returns the depth min z
  48133. */
  48134. getDepthMinZ(activeCamera: Camera): number;
  48135. /**
  48136. * Gets the maxZ used for shadow according to both the scene and the light.
  48137. *
  48138. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48139. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48140. * @param activeCamera The camera we are returning the max for
  48141. * @returns the depth max z
  48142. */
  48143. getDepthMaxZ(activeCamera: Camera): number;
  48144. /**
  48145. * Prepares the list of defines specific to the light type.
  48146. * @param defines the list of defines
  48147. * @param lightIndex defines the index of the light for the effect
  48148. */
  48149. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48150. }
  48151. }
  48152. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48153. import { Mesh } from "babylonjs/Meshes/mesh";
  48154. /**
  48155. * Class containing static functions to help procedurally build meshes
  48156. */
  48157. export class HemisphereBuilder {
  48158. /**
  48159. * Creates a hemisphere mesh
  48160. * @param name defines the name of the mesh
  48161. * @param options defines the options used to create the mesh
  48162. * @param scene defines the hosting scene
  48163. * @returns the hemisphere mesh
  48164. */
  48165. static CreateHemisphere(name: string, options: {
  48166. segments?: number;
  48167. diameter?: number;
  48168. sideOrientation?: number;
  48169. }, scene: any): Mesh;
  48170. }
  48171. }
  48172. declare module "babylonjs/Lights/spotLight" {
  48173. import { Nullable } from "babylonjs/types";
  48174. import { Scene } from "babylonjs/scene";
  48175. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48177. import { Effect } from "babylonjs/Materials/effect";
  48178. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48179. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48180. /**
  48181. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48182. * These values define a cone of light starting from the position, emitting toward the direction.
  48183. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48184. * and the exponent defines the speed of the decay of the light with distance (reach).
  48185. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48186. */
  48187. export class SpotLight extends ShadowLight {
  48188. private _angle;
  48189. private _innerAngle;
  48190. private _cosHalfAngle;
  48191. private _lightAngleScale;
  48192. private _lightAngleOffset;
  48193. /**
  48194. * Gets the cone angle of the spot light in Radians.
  48195. */
  48196. /**
  48197. * Sets the cone angle of the spot light in Radians.
  48198. */
  48199. angle: number;
  48200. /**
  48201. * Only used in gltf falloff mode, this defines the angle where
  48202. * the directional falloff will start before cutting at angle which could be seen
  48203. * as outer angle.
  48204. */
  48205. /**
  48206. * Only used in gltf falloff mode, this defines the angle where
  48207. * the directional falloff will start before cutting at angle which could be seen
  48208. * as outer angle.
  48209. */
  48210. innerAngle: number;
  48211. private _shadowAngleScale;
  48212. /**
  48213. * Allows scaling the angle of the light for shadow generation only.
  48214. */
  48215. /**
  48216. * Allows scaling the angle of the light for shadow generation only.
  48217. */
  48218. shadowAngleScale: number;
  48219. /**
  48220. * The light decay speed with the distance from the emission spot.
  48221. */
  48222. exponent: number;
  48223. private _projectionTextureMatrix;
  48224. /**
  48225. * Allows reading the projecton texture
  48226. */
  48227. readonly projectionTextureMatrix: Matrix;
  48228. protected _projectionTextureLightNear: number;
  48229. /**
  48230. * Gets the near clip of the Spotlight for texture projection.
  48231. */
  48232. /**
  48233. * Sets the near clip of the Spotlight for texture projection.
  48234. */
  48235. projectionTextureLightNear: number;
  48236. protected _projectionTextureLightFar: number;
  48237. /**
  48238. * Gets the far clip of the Spotlight for texture projection.
  48239. */
  48240. /**
  48241. * Sets the far clip of the Spotlight for texture projection.
  48242. */
  48243. projectionTextureLightFar: number;
  48244. protected _projectionTextureUpDirection: Vector3;
  48245. /**
  48246. * Gets the Up vector of the Spotlight for texture projection.
  48247. */
  48248. /**
  48249. * Sets the Up vector of the Spotlight for texture projection.
  48250. */
  48251. projectionTextureUpDirection: Vector3;
  48252. private _projectionTexture;
  48253. /**
  48254. * Gets the projection texture of the light.
  48255. */
  48256. /**
  48257. * Sets the projection texture of the light.
  48258. */
  48259. projectionTexture: Nullable<BaseTexture>;
  48260. private _projectionTextureViewLightDirty;
  48261. private _projectionTextureProjectionLightDirty;
  48262. private _projectionTextureDirty;
  48263. private _projectionTextureViewTargetVector;
  48264. private _projectionTextureViewLightMatrix;
  48265. private _projectionTextureProjectionLightMatrix;
  48266. private _projectionTextureScalingMatrix;
  48267. /**
  48268. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48269. * It can cast shadows.
  48270. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48271. * @param name The light friendly name
  48272. * @param position The position of the spot light in the scene
  48273. * @param direction The direction of the light in the scene
  48274. * @param angle The cone angle of the light in Radians
  48275. * @param exponent The light decay speed with the distance from the emission spot
  48276. * @param scene The scene the lights belongs to
  48277. */
  48278. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48279. /**
  48280. * Returns the string "SpotLight".
  48281. * @returns the class name
  48282. */
  48283. getClassName(): string;
  48284. /**
  48285. * Returns the integer 2.
  48286. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48287. */
  48288. getTypeID(): number;
  48289. /**
  48290. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48291. */
  48292. protected _setDirection(value: Vector3): void;
  48293. /**
  48294. * Overrides the position setter to recompute the projection texture view light Matrix.
  48295. */
  48296. protected _setPosition(value: Vector3): void;
  48297. /**
  48298. * 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.
  48299. * Returns the SpotLight.
  48300. */
  48301. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48302. protected _computeProjectionTextureViewLightMatrix(): void;
  48303. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48304. /**
  48305. * Main function for light texture projection matrix computing.
  48306. */
  48307. protected _computeProjectionTextureMatrix(): void;
  48308. protected _buildUniformLayout(): void;
  48309. private _computeAngleValues;
  48310. /**
  48311. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48312. * @param effect The effect to update
  48313. * @param lightIndex The index of the light in the effect to update
  48314. * @returns The spot light
  48315. */
  48316. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48317. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48318. /**
  48319. * Disposes the light and the associated resources.
  48320. */
  48321. dispose(): void;
  48322. /**
  48323. * Prepares the list of defines specific to the light type.
  48324. * @param defines the list of defines
  48325. * @param lightIndex defines the index of the light for the effect
  48326. */
  48327. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48328. }
  48329. }
  48330. declare module "babylonjs/Gizmos/lightGizmo" {
  48331. import { Nullable } from "babylonjs/types";
  48332. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48333. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48334. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48335. import { Light } from "babylonjs/Lights/light";
  48336. /**
  48337. * Gizmo that enables viewing a light
  48338. */
  48339. export class LightGizmo extends Gizmo {
  48340. private _lightMesh;
  48341. private _material;
  48342. private cachedPosition;
  48343. private cachedForward;
  48344. /**
  48345. * Creates a LightGizmo
  48346. * @param gizmoLayer The utility layer the gizmo will be added to
  48347. */
  48348. constructor(gizmoLayer?: UtilityLayerRenderer);
  48349. private _light;
  48350. /**
  48351. * The light that the gizmo is attached to
  48352. */
  48353. light: Nullable<Light>;
  48354. /**
  48355. * Gets the material used to render the light gizmo
  48356. */
  48357. readonly material: StandardMaterial;
  48358. /**
  48359. * @hidden
  48360. * Updates the gizmo to match the attached mesh's position/rotation
  48361. */
  48362. protected _update(): void;
  48363. private static _Scale;
  48364. /**
  48365. * Creates the lines for a light mesh
  48366. */
  48367. private static _createLightLines;
  48368. /**
  48369. * Disposes of the light gizmo
  48370. */
  48371. dispose(): void;
  48372. private static _CreateHemisphericLightMesh;
  48373. private static _CreatePointLightMesh;
  48374. private static _CreateSpotLightMesh;
  48375. private static _CreateDirectionalLightMesh;
  48376. }
  48377. }
  48378. declare module "babylonjs/Gizmos/index" {
  48379. export * from "babylonjs/Gizmos/axisDragGizmo";
  48380. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48381. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48382. export * from "babylonjs/Gizmos/gizmo";
  48383. export * from "babylonjs/Gizmos/gizmoManager";
  48384. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48385. export * from "babylonjs/Gizmos/positionGizmo";
  48386. export * from "babylonjs/Gizmos/rotationGizmo";
  48387. export * from "babylonjs/Gizmos/scaleGizmo";
  48388. export * from "babylonjs/Gizmos/lightGizmo";
  48389. export * from "babylonjs/Gizmos/planeDragGizmo";
  48390. }
  48391. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48392. /** @hidden */
  48393. export var backgroundFragmentDeclaration: {
  48394. name: string;
  48395. shader: string;
  48396. };
  48397. }
  48398. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48399. /** @hidden */
  48400. export var backgroundUboDeclaration: {
  48401. name: string;
  48402. shader: string;
  48403. };
  48404. }
  48405. declare module "babylonjs/Shaders/background.fragment" {
  48406. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48407. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48408. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48409. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48410. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48411. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48412. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48413. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48414. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48415. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48416. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48417. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48418. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48419. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48420. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48421. /** @hidden */
  48422. export var backgroundPixelShader: {
  48423. name: string;
  48424. shader: string;
  48425. };
  48426. }
  48427. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48428. /** @hidden */
  48429. export var backgroundVertexDeclaration: {
  48430. name: string;
  48431. shader: string;
  48432. };
  48433. }
  48434. declare module "babylonjs/Shaders/background.vertex" {
  48435. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48436. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48437. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48438. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48439. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48440. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48441. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48442. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48443. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48444. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48445. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48446. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48447. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48448. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48449. /** @hidden */
  48450. export var backgroundVertexShader: {
  48451. name: string;
  48452. shader: string;
  48453. };
  48454. }
  48455. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48456. import { Nullable, int, float } from "babylonjs/types";
  48457. import { Scene } from "babylonjs/scene";
  48458. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48459. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48461. import { Mesh } from "babylonjs/Meshes/mesh";
  48462. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48463. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48464. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48466. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48467. import { Color3 } from "babylonjs/Maths/math.color";
  48468. import "babylonjs/Shaders/background.fragment";
  48469. import "babylonjs/Shaders/background.vertex";
  48470. /**
  48471. * Background material used to create an efficient environement around your scene.
  48472. */
  48473. export class BackgroundMaterial extends PushMaterial {
  48474. /**
  48475. * Standard reflectance value at parallel view angle.
  48476. */
  48477. static StandardReflectance0: number;
  48478. /**
  48479. * Standard reflectance value at grazing angle.
  48480. */
  48481. static StandardReflectance90: number;
  48482. protected _primaryColor: Color3;
  48483. /**
  48484. * Key light Color (multiply against the environement texture)
  48485. */
  48486. primaryColor: Color3;
  48487. protected __perceptualColor: Nullable<Color3>;
  48488. /**
  48489. * Experimental Internal Use Only.
  48490. *
  48491. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48492. * This acts as a helper to set the primary color to a more "human friendly" value.
  48493. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48494. * output color as close as possible from the chosen value.
  48495. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48496. * part of lighting setup.)
  48497. */
  48498. _perceptualColor: Nullable<Color3>;
  48499. protected _primaryColorShadowLevel: float;
  48500. /**
  48501. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48502. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48503. */
  48504. primaryColorShadowLevel: float;
  48505. protected _primaryColorHighlightLevel: float;
  48506. /**
  48507. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48508. * The primary color is used at the level chosen to define what the white area would look.
  48509. */
  48510. primaryColorHighlightLevel: float;
  48511. protected _reflectionTexture: Nullable<BaseTexture>;
  48512. /**
  48513. * Reflection Texture used in the material.
  48514. * Should be author in a specific way for the best result (refer to the documentation).
  48515. */
  48516. reflectionTexture: Nullable<BaseTexture>;
  48517. protected _reflectionBlur: float;
  48518. /**
  48519. * Reflection Texture level of blur.
  48520. *
  48521. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48522. * texture twice.
  48523. */
  48524. reflectionBlur: float;
  48525. protected _diffuseTexture: Nullable<BaseTexture>;
  48526. /**
  48527. * Diffuse Texture used in the material.
  48528. * Should be author in a specific way for the best result (refer to the documentation).
  48529. */
  48530. diffuseTexture: Nullable<BaseTexture>;
  48531. protected _shadowLights: Nullable<IShadowLight[]>;
  48532. /**
  48533. * Specify the list of lights casting shadow on the material.
  48534. * All scene shadow lights will be included if null.
  48535. */
  48536. shadowLights: Nullable<IShadowLight[]>;
  48537. protected _shadowLevel: float;
  48538. /**
  48539. * Helps adjusting the shadow to a softer level if required.
  48540. * 0 means black shadows and 1 means no shadows.
  48541. */
  48542. shadowLevel: float;
  48543. protected _sceneCenter: Vector3;
  48544. /**
  48545. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48546. * It is usually zero but might be interesting to modify according to your setup.
  48547. */
  48548. sceneCenter: Vector3;
  48549. protected _opacityFresnel: boolean;
  48550. /**
  48551. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48552. * This helps ensuring a nice transition when the camera goes under the ground.
  48553. */
  48554. opacityFresnel: boolean;
  48555. protected _reflectionFresnel: boolean;
  48556. /**
  48557. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48558. * This helps adding a mirror texture on the ground.
  48559. */
  48560. reflectionFresnel: boolean;
  48561. protected _reflectionFalloffDistance: number;
  48562. /**
  48563. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48564. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48565. */
  48566. reflectionFalloffDistance: number;
  48567. protected _reflectionAmount: number;
  48568. /**
  48569. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48570. */
  48571. reflectionAmount: number;
  48572. protected _reflectionReflectance0: number;
  48573. /**
  48574. * This specifies the weight of the reflection at grazing angle.
  48575. */
  48576. reflectionReflectance0: number;
  48577. protected _reflectionReflectance90: number;
  48578. /**
  48579. * This specifies the weight of the reflection at a perpendicular point of view.
  48580. */
  48581. reflectionReflectance90: number;
  48582. /**
  48583. * Sets the reflection reflectance fresnel values according to the default standard
  48584. * empirically know to work well :-)
  48585. */
  48586. reflectionStandardFresnelWeight: number;
  48587. protected _useRGBColor: boolean;
  48588. /**
  48589. * Helps to directly use the maps channels instead of their level.
  48590. */
  48591. useRGBColor: boolean;
  48592. protected _enableNoise: boolean;
  48593. /**
  48594. * This helps reducing the banding effect that could occur on the background.
  48595. */
  48596. enableNoise: boolean;
  48597. /**
  48598. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48599. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48600. * Recommended to be keep at 1.0 except for special cases.
  48601. */
  48602. fovMultiplier: number;
  48603. private _fovMultiplier;
  48604. /**
  48605. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48606. */
  48607. useEquirectangularFOV: boolean;
  48608. private _maxSimultaneousLights;
  48609. /**
  48610. * Number of Simultaneous lights allowed on the material.
  48611. */
  48612. maxSimultaneousLights: int;
  48613. /**
  48614. * Default configuration related to image processing available in the Background Material.
  48615. */
  48616. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48617. /**
  48618. * Keep track of the image processing observer to allow dispose and replace.
  48619. */
  48620. private _imageProcessingObserver;
  48621. /**
  48622. * Attaches a new image processing configuration to the PBR Material.
  48623. * @param configuration (if null the scene configuration will be use)
  48624. */
  48625. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48626. /**
  48627. * Gets the image processing configuration used either in this material.
  48628. */
  48629. /**
  48630. * Sets the Default image processing configuration used either in the this material.
  48631. *
  48632. * If sets to null, the scene one is in use.
  48633. */
  48634. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48635. /**
  48636. * Gets wether the color curves effect is enabled.
  48637. */
  48638. /**
  48639. * Sets wether the color curves effect is enabled.
  48640. */
  48641. cameraColorCurvesEnabled: boolean;
  48642. /**
  48643. * Gets wether the color grading effect is enabled.
  48644. */
  48645. /**
  48646. * Gets wether the color grading effect is enabled.
  48647. */
  48648. cameraColorGradingEnabled: boolean;
  48649. /**
  48650. * Gets wether tonemapping is enabled or not.
  48651. */
  48652. /**
  48653. * Sets wether tonemapping is enabled or not
  48654. */
  48655. cameraToneMappingEnabled: boolean;
  48656. /**
  48657. * The camera exposure used on this material.
  48658. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48659. * This corresponds to a photographic exposure.
  48660. */
  48661. /**
  48662. * The camera exposure used on this material.
  48663. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48664. * This corresponds to a photographic exposure.
  48665. */
  48666. cameraExposure: float;
  48667. /**
  48668. * Gets The camera contrast used on this material.
  48669. */
  48670. /**
  48671. * Sets The camera contrast used on this material.
  48672. */
  48673. cameraContrast: float;
  48674. /**
  48675. * Gets the Color Grading 2D Lookup Texture.
  48676. */
  48677. /**
  48678. * Sets the Color Grading 2D Lookup Texture.
  48679. */
  48680. cameraColorGradingTexture: Nullable<BaseTexture>;
  48681. /**
  48682. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48683. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48684. * 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;
  48685. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48686. */
  48687. /**
  48688. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48689. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48690. * 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;
  48691. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48692. */
  48693. cameraColorCurves: Nullable<ColorCurves>;
  48694. /**
  48695. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48696. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48697. */
  48698. switchToBGR: boolean;
  48699. private _renderTargets;
  48700. private _reflectionControls;
  48701. private _white;
  48702. private _primaryShadowColor;
  48703. private _primaryHighlightColor;
  48704. /**
  48705. * Instantiates a Background Material in the given scene
  48706. * @param name The friendly name of the material
  48707. * @param scene The scene to add the material to
  48708. */
  48709. constructor(name: string, scene: Scene);
  48710. /**
  48711. * Gets a boolean indicating that current material needs to register RTT
  48712. */
  48713. readonly hasRenderTargetTextures: boolean;
  48714. /**
  48715. * The entire material has been created in order to prevent overdraw.
  48716. * @returns false
  48717. */
  48718. needAlphaTesting(): boolean;
  48719. /**
  48720. * The entire material has been created in order to prevent overdraw.
  48721. * @returns true if blending is enable
  48722. */
  48723. needAlphaBlending(): boolean;
  48724. /**
  48725. * Checks wether the material is ready to be rendered for a given mesh.
  48726. * @param mesh The mesh to render
  48727. * @param subMesh The submesh to check against
  48728. * @param useInstances Specify wether or not the material is used with instances
  48729. * @returns true if all the dependencies are ready (Textures, Effects...)
  48730. */
  48731. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48732. /**
  48733. * Compute the primary color according to the chosen perceptual color.
  48734. */
  48735. private _computePrimaryColorFromPerceptualColor;
  48736. /**
  48737. * Compute the highlights and shadow colors according to their chosen levels.
  48738. */
  48739. private _computePrimaryColors;
  48740. /**
  48741. * Build the uniform buffer used in the material.
  48742. */
  48743. buildUniformLayout(): void;
  48744. /**
  48745. * Unbind the material.
  48746. */
  48747. unbind(): void;
  48748. /**
  48749. * Bind only the world matrix to the material.
  48750. * @param world The world matrix to bind.
  48751. */
  48752. bindOnlyWorldMatrix(world: Matrix): void;
  48753. /**
  48754. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48755. * @param world The world matrix to bind.
  48756. * @param subMesh The submesh to bind for.
  48757. */
  48758. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48759. /**
  48760. * Checks to see if a texture is used in the material.
  48761. * @param texture - Base texture to use.
  48762. * @returns - Boolean specifying if a texture is used in the material.
  48763. */
  48764. hasTexture(texture: BaseTexture): boolean;
  48765. /**
  48766. * Dispose the material.
  48767. * @param forceDisposeEffect Force disposal of the associated effect.
  48768. * @param forceDisposeTextures Force disposal of the associated textures.
  48769. */
  48770. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48771. /**
  48772. * Clones the material.
  48773. * @param name The cloned name.
  48774. * @returns The cloned material.
  48775. */
  48776. clone(name: string): BackgroundMaterial;
  48777. /**
  48778. * Serializes the current material to its JSON representation.
  48779. * @returns The JSON representation.
  48780. */
  48781. serialize(): any;
  48782. /**
  48783. * Gets the class name of the material
  48784. * @returns "BackgroundMaterial"
  48785. */
  48786. getClassName(): string;
  48787. /**
  48788. * Parse a JSON input to create back a background material.
  48789. * @param source The JSON data to parse
  48790. * @param scene The scene to create the parsed material in
  48791. * @param rootUrl The root url of the assets the material depends upon
  48792. * @returns the instantiated BackgroundMaterial.
  48793. */
  48794. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48795. }
  48796. }
  48797. declare module "babylonjs/Helpers/environmentHelper" {
  48798. import { Observable } from "babylonjs/Misc/observable";
  48799. import { Nullable } from "babylonjs/types";
  48800. import { Scene } from "babylonjs/scene";
  48801. import { Vector3 } from "babylonjs/Maths/math.vector";
  48802. import { Color3 } from "babylonjs/Maths/math.color";
  48803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48804. import { Mesh } from "babylonjs/Meshes/mesh";
  48805. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48806. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48807. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48808. import "babylonjs/Meshes/Builders/planeBuilder";
  48809. import "babylonjs/Meshes/Builders/boxBuilder";
  48810. /**
  48811. * Represents the different options available during the creation of
  48812. * a Environment helper.
  48813. *
  48814. * This can control the default ground, skybox and image processing setup of your scene.
  48815. */
  48816. export interface IEnvironmentHelperOptions {
  48817. /**
  48818. * Specifies wether or not to create a ground.
  48819. * True by default.
  48820. */
  48821. createGround: boolean;
  48822. /**
  48823. * Specifies the ground size.
  48824. * 15 by default.
  48825. */
  48826. groundSize: number;
  48827. /**
  48828. * The texture used on the ground for the main color.
  48829. * Comes from the BabylonJS CDN by default.
  48830. *
  48831. * Remarks: Can be either a texture or a url.
  48832. */
  48833. groundTexture: string | BaseTexture;
  48834. /**
  48835. * The color mixed in the ground texture by default.
  48836. * BabylonJS clearColor by default.
  48837. */
  48838. groundColor: Color3;
  48839. /**
  48840. * Specifies the ground opacity.
  48841. * 1 by default.
  48842. */
  48843. groundOpacity: number;
  48844. /**
  48845. * Enables the ground to receive shadows.
  48846. * True by default.
  48847. */
  48848. enableGroundShadow: boolean;
  48849. /**
  48850. * Helps preventing the shadow to be fully black on the ground.
  48851. * 0.5 by default.
  48852. */
  48853. groundShadowLevel: number;
  48854. /**
  48855. * Creates a mirror texture attach to the ground.
  48856. * false by default.
  48857. */
  48858. enableGroundMirror: boolean;
  48859. /**
  48860. * Specifies the ground mirror size ratio.
  48861. * 0.3 by default as the default kernel is 64.
  48862. */
  48863. groundMirrorSizeRatio: number;
  48864. /**
  48865. * Specifies the ground mirror blur kernel size.
  48866. * 64 by default.
  48867. */
  48868. groundMirrorBlurKernel: number;
  48869. /**
  48870. * Specifies the ground mirror visibility amount.
  48871. * 1 by default
  48872. */
  48873. groundMirrorAmount: number;
  48874. /**
  48875. * Specifies the ground mirror reflectance weight.
  48876. * This uses the standard weight of the background material to setup the fresnel effect
  48877. * of the mirror.
  48878. * 1 by default.
  48879. */
  48880. groundMirrorFresnelWeight: number;
  48881. /**
  48882. * Specifies the ground mirror Falloff distance.
  48883. * This can helps reducing the size of the reflection.
  48884. * 0 by Default.
  48885. */
  48886. groundMirrorFallOffDistance: number;
  48887. /**
  48888. * Specifies the ground mirror texture type.
  48889. * Unsigned Int by Default.
  48890. */
  48891. groundMirrorTextureType: number;
  48892. /**
  48893. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48894. * the shown objects.
  48895. */
  48896. groundYBias: number;
  48897. /**
  48898. * Specifies wether or not to create a skybox.
  48899. * True by default.
  48900. */
  48901. createSkybox: boolean;
  48902. /**
  48903. * Specifies the skybox size.
  48904. * 20 by default.
  48905. */
  48906. skyboxSize: number;
  48907. /**
  48908. * The texture used on the skybox for the main color.
  48909. * Comes from the BabylonJS CDN by default.
  48910. *
  48911. * Remarks: Can be either a texture or a url.
  48912. */
  48913. skyboxTexture: string | BaseTexture;
  48914. /**
  48915. * The color mixed in the skybox texture by default.
  48916. * BabylonJS clearColor by default.
  48917. */
  48918. skyboxColor: Color3;
  48919. /**
  48920. * The background rotation around the Y axis of the scene.
  48921. * This helps aligning the key lights of your scene with the background.
  48922. * 0 by default.
  48923. */
  48924. backgroundYRotation: number;
  48925. /**
  48926. * Compute automatically the size of the elements to best fit with the scene.
  48927. */
  48928. sizeAuto: boolean;
  48929. /**
  48930. * Default position of the rootMesh if autoSize is not true.
  48931. */
  48932. rootPosition: Vector3;
  48933. /**
  48934. * Sets up the image processing in the scene.
  48935. * true by default.
  48936. */
  48937. setupImageProcessing: boolean;
  48938. /**
  48939. * The texture used as your environment texture in the scene.
  48940. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48941. *
  48942. * Remarks: Can be either a texture or a url.
  48943. */
  48944. environmentTexture: string | BaseTexture;
  48945. /**
  48946. * The value of the exposure to apply to the scene.
  48947. * 0.6 by default if setupImageProcessing is true.
  48948. */
  48949. cameraExposure: number;
  48950. /**
  48951. * The value of the contrast to apply to the scene.
  48952. * 1.6 by default if setupImageProcessing is true.
  48953. */
  48954. cameraContrast: number;
  48955. /**
  48956. * Specifies wether or not tonemapping should be enabled in the scene.
  48957. * true by default if setupImageProcessing is true.
  48958. */
  48959. toneMappingEnabled: boolean;
  48960. }
  48961. /**
  48962. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48963. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48964. * It also helps with the default setup of your imageProcessing configuration.
  48965. */
  48966. export class EnvironmentHelper {
  48967. /**
  48968. * Default ground texture URL.
  48969. */
  48970. private static _groundTextureCDNUrl;
  48971. /**
  48972. * Default skybox texture URL.
  48973. */
  48974. private static _skyboxTextureCDNUrl;
  48975. /**
  48976. * Default environment texture URL.
  48977. */
  48978. private static _environmentTextureCDNUrl;
  48979. /**
  48980. * Creates the default options for the helper.
  48981. */
  48982. private static _getDefaultOptions;
  48983. private _rootMesh;
  48984. /**
  48985. * Gets the root mesh created by the helper.
  48986. */
  48987. readonly rootMesh: Mesh;
  48988. private _skybox;
  48989. /**
  48990. * Gets the skybox created by the helper.
  48991. */
  48992. readonly skybox: Nullable<Mesh>;
  48993. private _skyboxTexture;
  48994. /**
  48995. * Gets the skybox texture created by the helper.
  48996. */
  48997. readonly skyboxTexture: Nullable<BaseTexture>;
  48998. private _skyboxMaterial;
  48999. /**
  49000. * Gets the skybox material created by the helper.
  49001. */
  49002. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49003. private _ground;
  49004. /**
  49005. * Gets the ground mesh created by the helper.
  49006. */
  49007. readonly ground: Nullable<Mesh>;
  49008. private _groundTexture;
  49009. /**
  49010. * Gets the ground texture created by the helper.
  49011. */
  49012. readonly groundTexture: Nullable<BaseTexture>;
  49013. private _groundMirror;
  49014. /**
  49015. * Gets the ground mirror created by the helper.
  49016. */
  49017. readonly groundMirror: Nullable<MirrorTexture>;
  49018. /**
  49019. * Gets the ground mirror render list to helps pushing the meshes
  49020. * you wish in the ground reflection.
  49021. */
  49022. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49023. private _groundMaterial;
  49024. /**
  49025. * Gets the ground material created by the helper.
  49026. */
  49027. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49028. /**
  49029. * Stores the creation options.
  49030. */
  49031. private readonly _scene;
  49032. private _options;
  49033. /**
  49034. * This observable will be notified with any error during the creation of the environment,
  49035. * mainly texture creation errors.
  49036. */
  49037. onErrorObservable: Observable<{
  49038. message?: string;
  49039. exception?: any;
  49040. }>;
  49041. /**
  49042. * constructor
  49043. * @param options Defines the options we want to customize the helper
  49044. * @param scene The scene to add the material to
  49045. */
  49046. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49047. /**
  49048. * Updates the background according to the new options
  49049. * @param options
  49050. */
  49051. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49052. /**
  49053. * Sets the primary color of all the available elements.
  49054. * @param color the main color to affect to the ground and the background
  49055. */
  49056. setMainColor(color: Color3): void;
  49057. /**
  49058. * Setup the image processing according to the specified options.
  49059. */
  49060. private _setupImageProcessing;
  49061. /**
  49062. * Setup the environment texture according to the specified options.
  49063. */
  49064. private _setupEnvironmentTexture;
  49065. /**
  49066. * Setup the background according to the specified options.
  49067. */
  49068. private _setupBackground;
  49069. /**
  49070. * Get the scene sizes according to the setup.
  49071. */
  49072. private _getSceneSize;
  49073. /**
  49074. * Setup the ground according to the specified options.
  49075. */
  49076. private _setupGround;
  49077. /**
  49078. * Setup the ground material according to the specified options.
  49079. */
  49080. private _setupGroundMaterial;
  49081. /**
  49082. * Setup the ground diffuse texture according to the specified options.
  49083. */
  49084. private _setupGroundDiffuseTexture;
  49085. /**
  49086. * Setup the ground mirror texture according to the specified options.
  49087. */
  49088. private _setupGroundMirrorTexture;
  49089. /**
  49090. * Setup the ground to receive the mirror texture.
  49091. */
  49092. private _setupMirrorInGroundMaterial;
  49093. /**
  49094. * Setup the skybox according to the specified options.
  49095. */
  49096. private _setupSkybox;
  49097. /**
  49098. * Setup the skybox material according to the specified options.
  49099. */
  49100. private _setupSkyboxMaterial;
  49101. /**
  49102. * Setup the skybox reflection texture according to the specified options.
  49103. */
  49104. private _setupSkyboxReflectionTexture;
  49105. private _errorHandler;
  49106. /**
  49107. * Dispose all the elements created by the Helper.
  49108. */
  49109. dispose(): void;
  49110. }
  49111. }
  49112. declare module "babylonjs/Helpers/photoDome" {
  49113. import { Observable } from "babylonjs/Misc/observable";
  49114. import { Nullable } from "babylonjs/types";
  49115. import { Scene } from "babylonjs/scene";
  49116. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49117. import { Mesh } from "babylonjs/Meshes/mesh";
  49118. import { Texture } from "babylonjs/Materials/Textures/texture";
  49119. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49120. import "babylonjs/Meshes/Builders/sphereBuilder";
  49121. /**
  49122. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49123. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49124. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49125. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49126. */
  49127. export class PhotoDome extends TransformNode {
  49128. /**
  49129. * Define the image as a Monoscopic panoramic 360 image.
  49130. */
  49131. static readonly MODE_MONOSCOPIC: number;
  49132. /**
  49133. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49134. */
  49135. static readonly MODE_TOPBOTTOM: number;
  49136. /**
  49137. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49138. */
  49139. static readonly MODE_SIDEBYSIDE: number;
  49140. private _useDirectMapping;
  49141. /**
  49142. * The texture being displayed on the sphere
  49143. */
  49144. protected _photoTexture: Texture;
  49145. /**
  49146. * Gets or sets the texture being displayed on the sphere
  49147. */
  49148. photoTexture: Texture;
  49149. /**
  49150. * Observable raised when an error occured while loading the 360 image
  49151. */
  49152. onLoadErrorObservable: Observable<string>;
  49153. /**
  49154. * The skybox material
  49155. */
  49156. protected _material: BackgroundMaterial;
  49157. /**
  49158. * The surface used for the skybox
  49159. */
  49160. protected _mesh: Mesh;
  49161. /**
  49162. * Gets the mesh used for the skybox.
  49163. */
  49164. readonly mesh: Mesh;
  49165. /**
  49166. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49167. * Also see the options.resolution property.
  49168. */
  49169. fovMultiplier: number;
  49170. private _imageMode;
  49171. /**
  49172. * Gets or set the current video mode for the video. It can be:
  49173. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49174. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49175. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49176. */
  49177. imageMode: number;
  49178. /**
  49179. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49180. * @param name Element's name, child elements will append suffixes for their own names.
  49181. * @param urlsOfPhoto defines the url of the photo to display
  49182. * @param options defines an object containing optional or exposed sub element properties
  49183. * @param onError defines a callback called when an error occured while loading the texture
  49184. */
  49185. constructor(name: string, urlOfPhoto: string, options: {
  49186. resolution?: number;
  49187. size?: number;
  49188. useDirectMapping?: boolean;
  49189. faceForward?: boolean;
  49190. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49191. private _onBeforeCameraRenderObserver;
  49192. private _changeImageMode;
  49193. /**
  49194. * Releases resources associated with this node.
  49195. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49196. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49197. */
  49198. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49199. }
  49200. }
  49201. declare module "babylonjs/Misc/rgbdTextureTools" {
  49202. import "babylonjs/Shaders/rgbdDecode.fragment";
  49203. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49204. import { Texture } from "babylonjs/Materials/Textures/texture";
  49205. /**
  49206. * Class used to host RGBD texture specific utilities
  49207. */
  49208. export class RGBDTextureTools {
  49209. /**
  49210. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49211. * @param texture the texture to expand.
  49212. */
  49213. static ExpandRGBDTexture(texture: Texture): void;
  49214. }
  49215. }
  49216. declare module "babylonjs/Misc/brdfTextureTools" {
  49217. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49218. import { Scene } from "babylonjs/scene";
  49219. /**
  49220. * Class used to host texture specific utilities
  49221. */
  49222. export class BRDFTextureTools {
  49223. /**
  49224. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49225. * @param scene defines the hosting scene
  49226. * @returns the environment BRDF texture
  49227. */
  49228. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49229. private static _environmentBRDFBase64Texture;
  49230. }
  49231. }
  49232. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49233. import { Nullable } from "babylonjs/types";
  49234. import { Color3 } from "babylonjs/Maths/math.color";
  49235. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49236. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49237. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49238. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49239. import { Engine } from "babylonjs/Engines/engine";
  49240. import { Scene } from "babylonjs/scene";
  49241. /**
  49242. * @hidden
  49243. */
  49244. export interface IMaterialClearCoatDefines {
  49245. CLEARCOAT: boolean;
  49246. CLEARCOAT_DEFAULTIOR: boolean;
  49247. CLEARCOAT_TEXTURE: boolean;
  49248. CLEARCOAT_TEXTUREDIRECTUV: number;
  49249. CLEARCOAT_BUMP: boolean;
  49250. CLEARCOAT_BUMPDIRECTUV: number;
  49251. CLEARCOAT_TINT: boolean;
  49252. CLEARCOAT_TINT_TEXTURE: boolean;
  49253. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49254. /** @hidden */
  49255. _areTexturesDirty: boolean;
  49256. }
  49257. /**
  49258. * Define the code related to the clear coat parameters of the pbr material.
  49259. */
  49260. export class PBRClearCoatConfiguration {
  49261. /**
  49262. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49263. * The default fits with a polyurethane material.
  49264. */
  49265. private static readonly _DefaultIndexOfRefraction;
  49266. private _isEnabled;
  49267. /**
  49268. * Defines if the clear coat is enabled in the material.
  49269. */
  49270. isEnabled: boolean;
  49271. /**
  49272. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49273. */
  49274. intensity: number;
  49275. /**
  49276. * Defines the clear coat layer roughness.
  49277. */
  49278. roughness: number;
  49279. private _indexOfRefraction;
  49280. /**
  49281. * Defines the index of refraction of the clear coat.
  49282. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49283. * The default fits with a polyurethane material.
  49284. * Changing the default value is more performance intensive.
  49285. */
  49286. indexOfRefraction: number;
  49287. private _texture;
  49288. /**
  49289. * Stores the clear coat values in a texture.
  49290. */
  49291. texture: Nullable<BaseTexture>;
  49292. private _bumpTexture;
  49293. /**
  49294. * Define the clear coat specific bump texture.
  49295. */
  49296. bumpTexture: Nullable<BaseTexture>;
  49297. private _isTintEnabled;
  49298. /**
  49299. * Defines if the clear coat tint is enabled in the material.
  49300. */
  49301. isTintEnabled: boolean;
  49302. /**
  49303. * Defines the clear coat tint of the material.
  49304. * This is only use if tint is enabled
  49305. */
  49306. tintColor: Color3;
  49307. /**
  49308. * Defines the distance at which the tint color should be found in the
  49309. * clear coat media.
  49310. * This is only use if tint is enabled
  49311. */
  49312. tintColorAtDistance: number;
  49313. /**
  49314. * Defines the clear coat layer thickness.
  49315. * This is only use if tint is enabled
  49316. */
  49317. tintThickness: number;
  49318. private _tintTexture;
  49319. /**
  49320. * Stores the clear tint values in a texture.
  49321. * rgb is tint
  49322. * a is a thickness factor
  49323. */
  49324. tintTexture: Nullable<BaseTexture>;
  49325. /** @hidden */
  49326. private _internalMarkAllSubMeshesAsTexturesDirty;
  49327. /** @hidden */
  49328. _markAllSubMeshesAsTexturesDirty(): void;
  49329. /**
  49330. * Instantiate a new istance of clear coat configuration.
  49331. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49332. */
  49333. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49334. /**
  49335. * Gets wehter the submesh is ready to be used or not.
  49336. * @param defines the list of "defines" to update.
  49337. * @param scene defines the scene the material belongs to.
  49338. * @param engine defines the engine the material belongs to.
  49339. * @param disableBumpMap defines wether the material disables bump or not.
  49340. * @returns - boolean indicating that the submesh is ready or not.
  49341. */
  49342. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49343. /**
  49344. * Checks to see if a texture is used in the material.
  49345. * @param defines the list of "defines" to update.
  49346. * @param scene defines the scene to the material belongs to.
  49347. */
  49348. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49349. /**
  49350. * Binds the material data.
  49351. * @param uniformBuffer defines the Uniform buffer to fill in.
  49352. * @param scene defines the scene the material belongs to.
  49353. * @param engine defines the engine the material belongs to.
  49354. * @param disableBumpMap defines wether the material disables bump or not.
  49355. * @param isFrozen defines wether the material is frozen or not.
  49356. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49357. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49358. */
  49359. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49360. /**
  49361. * Checks to see if a texture is used in the material.
  49362. * @param texture - Base texture to use.
  49363. * @returns - Boolean specifying if a texture is used in the material.
  49364. */
  49365. hasTexture(texture: BaseTexture): boolean;
  49366. /**
  49367. * Returns an array of the actively used textures.
  49368. * @param activeTextures Array of BaseTextures
  49369. */
  49370. getActiveTextures(activeTextures: BaseTexture[]): void;
  49371. /**
  49372. * Returns the animatable textures.
  49373. * @param animatables Array of animatable textures.
  49374. */
  49375. getAnimatables(animatables: IAnimatable[]): void;
  49376. /**
  49377. * Disposes the resources of the material.
  49378. * @param forceDisposeTextures - Forces the disposal of all textures.
  49379. */
  49380. dispose(forceDisposeTextures?: boolean): void;
  49381. /**
  49382. * Get the current class name of the texture useful for serialization or dynamic coding.
  49383. * @returns "PBRClearCoatConfiguration"
  49384. */
  49385. getClassName(): string;
  49386. /**
  49387. * Add fallbacks to the effect fallbacks list.
  49388. * @param defines defines the Base texture to use.
  49389. * @param fallbacks defines the current fallback list.
  49390. * @param currentRank defines the current fallback rank.
  49391. * @returns the new fallback rank.
  49392. */
  49393. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49394. /**
  49395. * Add the required uniforms to the current list.
  49396. * @param uniforms defines the current uniform list.
  49397. */
  49398. static AddUniforms(uniforms: string[]): void;
  49399. /**
  49400. * Add the required samplers to the current list.
  49401. * @param samplers defines the current sampler list.
  49402. */
  49403. static AddSamplers(samplers: string[]): void;
  49404. /**
  49405. * Add the required uniforms to the current buffer.
  49406. * @param uniformBuffer defines the current uniform buffer.
  49407. */
  49408. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49409. /**
  49410. * Makes a duplicate of the current configuration into another one.
  49411. * @param clearCoatConfiguration define the config where to copy the info
  49412. */
  49413. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49414. /**
  49415. * Serializes this clear coat configuration.
  49416. * @returns - An object with the serialized config.
  49417. */
  49418. serialize(): any;
  49419. /**
  49420. * Parses a anisotropy Configuration from a serialized object.
  49421. * @param source - Serialized object.
  49422. * @param scene Defines the scene we are parsing for
  49423. * @param rootUrl Defines the rootUrl to load from
  49424. */
  49425. parse(source: any, scene: Scene, rootUrl: string): void;
  49426. }
  49427. }
  49428. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49429. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49431. import { Vector2 } from "babylonjs/Maths/math.vector";
  49432. import { Scene } from "babylonjs/scene";
  49433. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49434. import { Nullable } from "babylonjs/types";
  49435. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49436. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49437. /**
  49438. * @hidden
  49439. */
  49440. export interface IMaterialAnisotropicDefines {
  49441. ANISOTROPIC: boolean;
  49442. ANISOTROPIC_TEXTURE: boolean;
  49443. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49444. MAINUV1: boolean;
  49445. _areTexturesDirty: boolean;
  49446. _needUVs: boolean;
  49447. }
  49448. /**
  49449. * Define the code related to the anisotropic parameters of the pbr material.
  49450. */
  49451. export class PBRAnisotropicConfiguration {
  49452. private _isEnabled;
  49453. /**
  49454. * Defines if the anisotropy is enabled in the material.
  49455. */
  49456. isEnabled: boolean;
  49457. /**
  49458. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49459. */
  49460. intensity: number;
  49461. /**
  49462. * Defines if the effect is along the tangents, bitangents or in between.
  49463. * By default, the effect is "strectching" the highlights along the tangents.
  49464. */
  49465. direction: Vector2;
  49466. private _texture;
  49467. /**
  49468. * Stores the anisotropy values in a texture.
  49469. * rg is direction (like normal from -1 to 1)
  49470. * b is a intensity
  49471. */
  49472. texture: Nullable<BaseTexture>;
  49473. /** @hidden */
  49474. private _internalMarkAllSubMeshesAsTexturesDirty;
  49475. /** @hidden */
  49476. _markAllSubMeshesAsTexturesDirty(): void;
  49477. /**
  49478. * Instantiate a new istance of anisotropy configuration.
  49479. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49480. */
  49481. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49482. /**
  49483. * Specifies that the submesh is ready to be used.
  49484. * @param defines the list of "defines" to update.
  49485. * @param scene defines the scene the material belongs to.
  49486. * @returns - boolean indicating that the submesh is ready or not.
  49487. */
  49488. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49489. /**
  49490. * Checks to see if a texture is used in the material.
  49491. * @param defines the list of "defines" to update.
  49492. * @param mesh the mesh we are preparing the defines for.
  49493. * @param scene defines the scene the material belongs to.
  49494. */
  49495. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49496. /**
  49497. * Binds the material data.
  49498. * @param uniformBuffer defines the Uniform buffer to fill in.
  49499. * @param scene defines the scene the material belongs to.
  49500. * @param isFrozen defines wether the material is frozen or not.
  49501. */
  49502. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49503. /**
  49504. * Checks to see if a texture is used in the material.
  49505. * @param texture - Base texture to use.
  49506. * @returns - Boolean specifying if a texture is used in the material.
  49507. */
  49508. hasTexture(texture: BaseTexture): boolean;
  49509. /**
  49510. * Returns an array of the actively used textures.
  49511. * @param activeTextures Array of BaseTextures
  49512. */
  49513. getActiveTextures(activeTextures: BaseTexture[]): void;
  49514. /**
  49515. * Returns the animatable textures.
  49516. * @param animatables Array of animatable textures.
  49517. */
  49518. getAnimatables(animatables: IAnimatable[]): void;
  49519. /**
  49520. * Disposes the resources of the material.
  49521. * @param forceDisposeTextures - Forces the disposal of all textures.
  49522. */
  49523. dispose(forceDisposeTextures?: boolean): void;
  49524. /**
  49525. * Get the current class name of the texture useful for serialization or dynamic coding.
  49526. * @returns "PBRAnisotropicConfiguration"
  49527. */
  49528. getClassName(): string;
  49529. /**
  49530. * Add fallbacks to the effect fallbacks list.
  49531. * @param defines defines the Base texture to use.
  49532. * @param fallbacks defines the current fallback list.
  49533. * @param currentRank defines the current fallback rank.
  49534. * @returns the new fallback rank.
  49535. */
  49536. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49537. /**
  49538. * Add the required uniforms to the current list.
  49539. * @param uniforms defines the current uniform list.
  49540. */
  49541. static AddUniforms(uniforms: string[]): void;
  49542. /**
  49543. * Add the required uniforms to the current buffer.
  49544. * @param uniformBuffer defines the current uniform buffer.
  49545. */
  49546. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49547. /**
  49548. * Add the required samplers to the current list.
  49549. * @param samplers defines the current sampler list.
  49550. */
  49551. static AddSamplers(samplers: string[]): void;
  49552. /**
  49553. * Makes a duplicate of the current configuration into another one.
  49554. * @param anisotropicConfiguration define the config where to copy the info
  49555. */
  49556. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49557. /**
  49558. * Serializes this anisotropy configuration.
  49559. * @returns - An object with the serialized config.
  49560. */
  49561. serialize(): any;
  49562. /**
  49563. * Parses a anisotropy Configuration from a serialized object.
  49564. * @param source - Serialized object.
  49565. * @param scene Defines the scene we are parsing for
  49566. * @param rootUrl Defines the rootUrl to load from
  49567. */
  49568. parse(source: any, scene: Scene, rootUrl: string): void;
  49569. }
  49570. }
  49571. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49572. import { Scene } from "babylonjs/scene";
  49573. /**
  49574. * @hidden
  49575. */
  49576. export interface IMaterialBRDFDefines {
  49577. BRDF_V_HEIGHT_CORRELATED: boolean;
  49578. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49579. SPHERICAL_HARMONICS: boolean;
  49580. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49581. /** @hidden */
  49582. _areMiscDirty: boolean;
  49583. }
  49584. /**
  49585. * Define the code related to the BRDF parameters of the pbr material.
  49586. */
  49587. export class PBRBRDFConfiguration {
  49588. /**
  49589. * Default value used for the energy conservation.
  49590. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49591. */
  49592. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49593. /**
  49594. * Default value used for the Smith Visibility Height Correlated mode.
  49595. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49596. */
  49597. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49598. /**
  49599. * Default value used for the IBL diffuse part.
  49600. * This can help switching back to the polynomials mode globally which is a tiny bit
  49601. * less GPU intensive at the drawback of a lower quality.
  49602. */
  49603. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49604. /**
  49605. * Default value used for activating energy conservation for the specular workflow.
  49606. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49607. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49608. */
  49609. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49610. private _useEnergyConservation;
  49611. /**
  49612. * Defines if the material uses energy conservation.
  49613. */
  49614. useEnergyConservation: boolean;
  49615. private _useSmithVisibilityHeightCorrelated;
  49616. /**
  49617. * LEGACY Mode set to false
  49618. * Defines if the material uses height smith correlated visibility term.
  49619. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49620. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49621. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49622. * Not relying on height correlated will also disable energy conservation.
  49623. */
  49624. useSmithVisibilityHeightCorrelated: boolean;
  49625. private _useSphericalHarmonics;
  49626. /**
  49627. * LEGACY Mode set to false
  49628. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49629. * diffuse part of the IBL.
  49630. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49631. * to the ground truth.
  49632. */
  49633. useSphericalHarmonics: boolean;
  49634. private _useSpecularGlossinessInputEnergyConservation;
  49635. /**
  49636. * Defines if the material uses energy conservation, when the specular workflow is active.
  49637. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49638. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49639. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49640. */
  49641. useSpecularGlossinessInputEnergyConservation: boolean;
  49642. /** @hidden */
  49643. private _internalMarkAllSubMeshesAsMiscDirty;
  49644. /** @hidden */
  49645. _markAllSubMeshesAsMiscDirty(): void;
  49646. /**
  49647. * Instantiate a new istance of clear coat configuration.
  49648. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49649. */
  49650. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49651. /**
  49652. * Checks to see if a texture is used in the material.
  49653. * @param defines the list of "defines" to update.
  49654. */
  49655. prepareDefines(defines: IMaterialBRDFDefines): void;
  49656. /**
  49657. * Get the current class name of the texture useful for serialization or dynamic coding.
  49658. * @returns "PBRClearCoatConfiguration"
  49659. */
  49660. getClassName(): string;
  49661. /**
  49662. * Makes a duplicate of the current configuration into another one.
  49663. * @param brdfConfiguration define the config where to copy the info
  49664. */
  49665. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49666. /**
  49667. * Serializes this BRDF configuration.
  49668. * @returns - An object with the serialized config.
  49669. */
  49670. serialize(): any;
  49671. /**
  49672. * Parses a anisotropy Configuration from a serialized object.
  49673. * @param source - Serialized object.
  49674. * @param scene Defines the scene we are parsing for
  49675. * @param rootUrl Defines the rootUrl to load from
  49676. */
  49677. parse(source: any, scene: Scene, rootUrl: string): void;
  49678. }
  49679. }
  49680. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49681. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49682. import { Color3 } from "babylonjs/Maths/math.color";
  49683. import { Scene } from "babylonjs/scene";
  49684. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49685. import { Nullable } from "babylonjs/types";
  49686. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49687. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49688. /**
  49689. * @hidden
  49690. */
  49691. export interface IMaterialSheenDefines {
  49692. SHEEN: boolean;
  49693. SHEEN_TEXTURE: boolean;
  49694. SHEEN_TEXTUREDIRECTUV: number;
  49695. SHEEN_LINKWITHALBEDO: boolean;
  49696. /** @hidden */
  49697. _areTexturesDirty: boolean;
  49698. }
  49699. /**
  49700. * Define the code related to the Sheen parameters of the pbr material.
  49701. */
  49702. export class PBRSheenConfiguration {
  49703. private _isEnabled;
  49704. /**
  49705. * Defines if the material uses sheen.
  49706. */
  49707. isEnabled: boolean;
  49708. private _linkSheenWithAlbedo;
  49709. /**
  49710. * Defines if the sheen is linked to the sheen color.
  49711. */
  49712. linkSheenWithAlbedo: boolean;
  49713. /**
  49714. * Defines the sheen intensity.
  49715. */
  49716. intensity: number;
  49717. /**
  49718. * Defines the sheen color.
  49719. */
  49720. color: Color3;
  49721. private _texture;
  49722. /**
  49723. * Stores the sheen tint values in a texture.
  49724. * rgb is tint
  49725. * a is a intensity
  49726. */
  49727. texture: Nullable<BaseTexture>;
  49728. /** @hidden */
  49729. private _internalMarkAllSubMeshesAsTexturesDirty;
  49730. /** @hidden */
  49731. _markAllSubMeshesAsTexturesDirty(): void;
  49732. /**
  49733. * Instantiate a new istance of clear coat configuration.
  49734. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49735. */
  49736. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49737. /**
  49738. * Specifies that the submesh is ready to be used.
  49739. * @param defines the list of "defines" to update.
  49740. * @param scene defines the scene the material belongs to.
  49741. * @returns - boolean indicating that the submesh is ready or not.
  49742. */
  49743. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49744. /**
  49745. * Checks to see if a texture is used in the material.
  49746. * @param defines the list of "defines" to update.
  49747. * @param scene defines the scene the material belongs to.
  49748. */
  49749. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49750. /**
  49751. * Binds the material data.
  49752. * @param uniformBuffer defines the Uniform buffer to fill in.
  49753. * @param scene defines the scene the material belongs to.
  49754. * @param isFrozen defines wether the material is frozen or not.
  49755. */
  49756. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49757. /**
  49758. * Checks to see if a texture is used in the material.
  49759. * @param texture - Base texture to use.
  49760. * @returns - Boolean specifying if a texture is used in the material.
  49761. */
  49762. hasTexture(texture: BaseTexture): boolean;
  49763. /**
  49764. * Returns an array of the actively used textures.
  49765. * @param activeTextures Array of BaseTextures
  49766. */
  49767. getActiveTextures(activeTextures: BaseTexture[]): void;
  49768. /**
  49769. * Returns the animatable textures.
  49770. * @param animatables Array of animatable textures.
  49771. */
  49772. getAnimatables(animatables: IAnimatable[]): void;
  49773. /**
  49774. * Disposes the resources of the material.
  49775. * @param forceDisposeTextures - Forces the disposal of all textures.
  49776. */
  49777. dispose(forceDisposeTextures?: boolean): void;
  49778. /**
  49779. * Get the current class name of the texture useful for serialization or dynamic coding.
  49780. * @returns "PBRSheenConfiguration"
  49781. */
  49782. getClassName(): string;
  49783. /**
  49784. * Add fallbacks to the effect fallbacks list.
  49785. * @param defines defines the Base texture to use.
  49786. * @param fallbacks defines the current fallback list.
  49787. * @param currentRank defines the current fallback rank.
  49788. * @returns the new fallback rank.
  49789. */
  49790. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49791. /**
  49792. * Add the required uniforms to the current list.
  49793. * @param uniforms defines the current uniform list.
  49794. */
  49795. static AddUniforms(uniforms: string[]): void;
  49796. /**
  49797. * Add the required uniforms to the current buffer.
  49798. * @param uniformBuffer defines the current uniform buffer.
  49799. */
  49800. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49801. /**
  49802. * Add the required samplers to the current list.
  49803. * @param samplers defines the current sampler list.
  49804. */
  49805. static AddSamplers(samplers: string[]): void;
  49806. /**
  49807. * Makes a duplicate of the current configuration into another one.
  49808. * @param sheenConfiguration define the config where to copy the info
  49809. */
  49810. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49811. /**
  49812. * Serializes this BRDF configuration.
  49813. * @returns - An object with the serialized config.
  49814. */
  49815. serialize(): any;
  49816. /**
  49817. * Parses a anisotropy Configuration from a serialized object.
  49818. * @param source - Serialized object.
  49819. * @param scene Defines the scene we are parsing for
  49820. * @param rootUrl Defines the rootUrl to load from
  49821. */
  49822. parse(source: any, scene: Scene, rootUrl: string): void;
  49823. }
  49824. }
  49825. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49826. import { Nullable } from "babylonjs/types";
  49827. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49828. import { Color3 } from "babylonjs/Maths/math.color";
  49829. import { SmartArray } from "babylonjs/Misc/smartArray";
  49830. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49831. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49832. import { Effect } from "babylonjs/Materials/effect";
  49833. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49834. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49835. import { Engine } from "babylonjs/Engines/engine";
  49836. import { Scene } from "babylonjs/scene";
  49837. /**
  49838. * @hidden
  49839. */
  49840. export interface IMaterialSubSurfaceDefines {
  49841. SUBSURFACE: boolean;
  49842. SS_REFRACTION: boolean;
  49843. SS_TRANSLUCENCY: boolean;
  49844. SS_SCATERRING: boolean;
  49845. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49846. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49847. SS_REFRACTIONMAP_3D: boolean;
  49848. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49849. SS_LODINREFRACTIONALPHA: boolean;
  49850. SS_GAMMAREFRACTION: boolean;
  49851. SS_RGBDREFRACTION: boolean;
  49852. SS_LINEARSPECULARREFRACTION: boolean;
  49853. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49854. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49855. /** @hidden */
  49856. _areTexturesDirty: boolean;
  49857. }
  49858. /**
  49859. * Define the code related to the sub surface parameters of the pbr material.
  49860. */
  49861. export class PBRSubSurfaceConfiguration {
  49862. private _isRefractionEnabled;
  49863. /**
  49864. * Defines if the refraction is enabled in the material.
  49865. */
  49866. isRefractionEnabled: boolean;
  49867. private _isTranslucencyEnabled;
  49868. /**
  49869. * Defines if the translucency is enabled in the material.
  49870. */
  49871. isTranslucencyEnabled: boolean;
  49872. private _isScatteringEnabled;
  49873. /**
  49874. * Defines the refraction intensity of the material.
  49875. * The refraction when enabled replaces the Diffuse part of the material.
  49876. * The intensity helps transitionning between diffuse and refraction.
  49877. */
  49878. refractionIntensity: number;
  49879. /**
  49880. * Defines the translucency intensity of the material.
  49881. * When translucency has been enabled, this defines how much of the "translucency"
  49882. * is addded to the diffuse part of the material.
  49883. */
  49884. translucencyIntensity: number;
  49885. /**
  49886. * Defines the scattering intensity of the material.
  49887. * When scattering has been enabled, this defines how much of the "scattered light"
  49888. * is addded to the diffuse part of the material.
  49889. */
  49890. scatteringIntensity: number;
  49891. private _thicknessTexture;
  49892. /**
  49893. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49894. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49895. * 0 would mean minimumThickness
  49896. * 1 would mean maximumThickness
  49897. * The other channels might be use as a mask to vary the different effects intensity.
  49898. */
  49899. thicknessTexture: Nullable<BaseTexture>;
  49900. private _refractionTexture;
  49901. /**
  49902. * Defines the texture to use for refraction.
  49903. */
  49904. refractionTexture: Nullable<BaseTexture>;
  49905. private _indexOfRefraction;
  49906. /**
  49907. * Defines the index of refraction used in the material.
  49908. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49909. */
  49910. indexOfRefraction: number;
  49911. private _invertRefractionY;
  49912. /**
  49913. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49914. */
  49915. invertRefractionY: boolean;
  49916. private _linkRefractionWithTransparency;
  49917. /**
  49918. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49919. * Materials half opaque for instance using refraction could benefit from this control.
  49920. */
  49921. linkRefractionWithTransparency: boolean;
  49922. /**
  49923. * Defines the minimum thickness stored in the thickness map.
  49924. * If no thickness map is defined, this value will be used to simulate thickness.
  49925. */
  49926. minimumThickness: number;
  49927. /**
  49928. * Defines the maximum thickness stored in the thickness map.
  49929. */
  49930. maximumThickness: number;
  49931. /**
  49932. * Defines the volume tint of the material.
  49933. * This is used for both translucency and scattering.
  49934. */
  49935. tintColor: Color3;
  49936. /**
  49937. * Defines the distance at which the tint color should be found in the media.
  49938. * This is used for refraction only.
  49939. */
  49940. tintColorAtDistance: number;
  49941. /**
  49942. * Defines how far each channel transmit through the media.
  49943. * It is defined as a color to simplify it selection.
  49944. */
  49945. diffusionDistance: Color3;
  49946. private _useMaskFromThicknessTexture;
  49947. /**
  49948. * Stores the intensity of the different subsurface effects in the thickness texture.
  49949. * * the green channel is the translucency intensity.
  49950. * * the blue channel is the scattering intensity.
  49951. * * the alpha channel is the refraction intensity.
  49952. */
  49953. useMaskFromThicknessTexture: boolean;
  49954. /** @hidden */
  49955. private _internalMarkAllSubMeshesAsTexturesDirty;
  49956. /** @hidden */
  49957. _markAllSubMeshesAsTexturesDirty(): void;
  49958. /**
  49959. * Instantiate a new istance of sub surface configuration.
  49960. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49961. */
  49962. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49963. /**
  49964. * Gets wehter the submesh is ready to be used or not.
  49965. * @param defines the list of "defines" to update.
  49966. * @param scene defines the scene the material belongs to.
  49967. * @returns - boolean indicating that the submesh is ready or not.
  49968. */
  49969. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49970. /**
  49971. * Checks to see if a texture is used in the material.
  49972. * @param defines the list of "defines" to update.
  49973. * @param scene defines the scene to the material belongs to.
  49974. */
  49975. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49976. /**
  49977. * Binds the material data.
  49978. * @param uniformBuffer defines the Uniform buffer to fill in.
  49979. * @param scene defines the scene the material belongs to.
  49980. * @param engine defines the engine the material belongs to.
  49981. * @param isFrozen defines wether the material is frozen or not.
  49982. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49983. */
  49984. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49985. /**
  49986. * Unbinds the material from the mesh.
  49987. * @param activeEffect defines the effect that should be unbound from.
  49988. * @returns true if unbound, otherwise false
  49989. */
  49990. unbind(activeEffect: Effect): boolean;
  49991. /**
  49992. * Returns the texture used for refraction or null if none is used.
  49993. * @param scene defines the scene the material belongs to.
  49994. * @returns - Refraction texture if present. If no refraction texture and refraction
  49995. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49996. */
  49997. private _getRefractionTexture;
  49998. /**
  49999. * Returns true if alpha blending should be disabled.
  50000. */
  50001. readonly disableAlphaBlending: boolean;
  50002. /**
  50003. * Fills the list of render target textures.
  50004. * @param renderTargets the list of render targets to update
  50005. */
  50006. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50007. /**
  50008. * Checks to see if a texture is used in the material.
  50009. * @param texture - Base texture to use.
  50010. * @returns - Boolean specifying if a texture is used in the material.
  50011. */
  50012. hasTexture(texture: BaseTexture): boolean;
  50013. /**
  50014. * Gets a boolean indicating that current material needs to register RTT
  50015. * @returns true if this uses a render target otherwise false.
  50016. */
  50017. hasRenderTargetTextures(): boolean;
  50018. /**
  50019. * Returns an array of the actively used textures.
  50020. * @param activeTextures Array of BaseTextures
  50021. */
  50022. getActiveTextures(activeTextures: BaseTexture[]): void;
  50023. /**
  50024. * Returns the animatable textures.
  50025. * @param animatables Array of animatable textures.
  50026. */
  50027. getAnimatables(animatables: IAnimatable[]): void;
  50028. /**
  50029. * Disposes the resources of the material.
  50030. * @param forceDisposeTextures - Forces the disposal of all textures.
  50031. */
  50032. dispose(forceDisposeTextures?: boolean): void;
  50033. /**
  50034. * Get the current class name of the texture useful for serialization or dynamic coding.
  50035. * @returns "PBRSubSurfaceConfiguration"
  50036. */
  50037. getClassName(): string;
  50038. /**
  50039. * Add fallbacks to the effect fallbacks list.
  50040. * @param defines defines the Base texture to use.
  50041. * @param fallbacks defines the current fallback list.
  50042. * @param currentRank defines the current fallback rank.
  50043. * @returns the new fallback rank.
  50044. */
  50045. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50046. /**
  50047. * Add the required uniforms to the current list.
  50048. * @param uniforms defines the current uniform list.
  50049. */
  50050. static AddUniforms(uniforms: string[]): void;
  50051. /**
  50052. * Add the required samplers to the current list.
  50053. * @param samplers defines the current sampler list.
  50054. */
  50055. static AddSamplers(samplers: string[]): void;
  50056. /**
  50057. * Add the required uniforms to the current buffer.
  50058. * @param uniformBuffer defines the current uniform buffer.
  50059. */
  50060. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50061. /**
  50062. * Makes a duplicate of the current configuration into another one.
  50063. * @param configuration define the config where to copy the info
  50064. */
  50065. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50066. /**
  50067. * Serializes this Sub Surface configuration.
  50068. * @returns - An object with the serialized config.
  50069. */
  50070. serialize(): any;
  50071. /**
  50072. * Parses a anisotropy Configuration from a serialized object.
  50073. * @param source - Serialized object.
  50074. * @param scene Defines the scene we are parsing for
  50075. * @param rootUrl Defines the rootUrl to load from
  50076. */
  50077. parse(source: any, scene: Scene, rootUrl: string): void;
  50078. }
  50079. }
  50080. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50081. /** @hidden */
  50082. export var pbrFragmentDeclaration: {
  50083. name: string;
  50084. shader: string;
  50085. };
  50086. }
  50087. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50088. /** @hidden */
  50089. export var pbrUboDeclaration: {
  50090. name: string;
  50091. shader: string;
  50092. };
  50093. }
  50094. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50095. /** @hidden */
  50096. export var pbrFragmentExtraDeclaration: {
  50097. name: string;
  50098. shader: string;
  50099. };
  50100. }
  50101. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50102. /** @hidden */
  50103. export var pbrFragmentSamplersDeclaration: {
  50104. name: string;
  50105. shader: string;
  50106. };
  50107. }
  50108. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50109. /** @hidden */
  50110. export var pbrHelperFunctions: {
  50111. name: string;
  50112. shader: string;
  50113. };
  50114. }
  50115. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50116. /** @hidden */
  50117. export var harmonicsFunctions: {
  50118. name: string;
  50119. shader: string;
  50120. };
  50121. }
  50122. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50123. /** @hidden */
  50124. export var pbrDirectLightingSetupFunctions: {
  50125. name: string;
  50126. shader: string;
  50127. };
  50128. }
  50129. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50130. /** @hidden */
  50131. export var pbrDirectLightingFalloffFunctions: {
  50132. name: string;
  50133. shader: string;
  50134. };
  50135. }
  50136. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50137. /** @hidden */
  50138. export var pbrBRDFFunctions: {
  50139. name: string;
  50140. shader: string;
  50141. };
  50142. }
  50143. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50144. /** @hidden */
  50145. export var pbrDirectLightingFunctions: {
  50146. name: string;
  50147. shader: string;
  50148. };
  50149. }
  50150. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50151. /** @hidden */
  50152. export var pbrIBLFunctions: {
  50153. name: string;
  50154. shader: string;
  50155. };
  50156. }
  50157. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50158. /** @hidden */
  50159. export var pbrDebug: {
  50160. name: string;
  50161. shader: string;
  50162. };
  50163. }
  50164. declare module "babylonjs/Shaders/pbr.fragment" {
  50165. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50166. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50167. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50168. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50169. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50170. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50171. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50172. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50173. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50174. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50175. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50176. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50177. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50178. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50179. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50180. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50181. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50182. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50183. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50184. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50185. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50186. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50187. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50188. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50189. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50190. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50191. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50192. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50193. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50194. /** @hidden */
  50195. export var pbrPixelShader: {
  50196. name: string;
  50197. shader: string;
  50198. };
  50199. }
  50200. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50201. /** @hidden */
  50202. export var pbrVertexDeclaration: {
  50203. name: string;
  50204. shader: string;
  50205. };
  50206. }
  50207. declare module "babylonjs/Shaders/pbr.vertex" {
  50208. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50209. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50210. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50211. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50212. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50213. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50214. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50215. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50216. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50217. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50218. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50219. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50220. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50221. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50222. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50223. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50224. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50225. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50226. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50227. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50228. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50229. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50230. /** @hidden */
  50231. export var pbrVertexShader: {
  50232. name: string;
  50233. shader: string;
  50234. };
  50235. }
  50236. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50237. import { Nullable } from "babylonjs/types";
  50238. import { Scene } from "babylonjs/scene";
  50239. import { Matrix } from "babylonjs/Maths/math.vector";
  50240. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50242. import { Mesh } from "babylonjs/Meshes/mesh";
  50243. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50244. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50245. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50246. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50247. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50248. import { Color3 } from "babylonjs/Maths/math.color";
  50249. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50250. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50251. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50252. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50253. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50254. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50255. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50256. import "babylonjs/Shaders/pbr.fragment";
  50257. import "babylonjs/Shaders/pbr.vertex";
  50258. /**
  50259. * Manages the defines for the PBR Material.
  50260. * @hidden
  50261. */
  50262. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50263. PBR: boolean;
  50264. MAINUV1: boolean;
  50265. MAINUV2: boolean;
  50266. UV1: boolean;
  50267. UV2: boolean;
  50268. ALBEDO: boolean;
  50269. ALBEDODIRECTUV: number;
  50270. VERTEXCOLOR: boolean;
  50271. AMBIENT: boolean;
  50272. AMBIENTDIRECTUV: number;
  50273. AMBIENTINGRAYSCALE: boolean;
  50274. OPACITY: boolean;
  50275. VERTEXALPHA: boolean;
  50276. OPACITYDIRECTUV: number;
  50277. OPACITYRGB: boolean;
  50278. ALPHATEST: boolean;
  50279. DEPTHPREPASS: boolean;
  50280. ALPHABLEND: boolean;
  50281. ALPHAFROMALBEDO: boolean;
  50282. ALPHATESTVALUE: string;
  50283. SPECULAROVERALPHA: boolean;
  50284. RADIANCEOVERALPHA: boolean;
  50285. ALPHAFRESNEL: boolean;
  50286. LINEARALPHAFRESNEL: boolean;
  50287. PREMULTIPLYALPHA: boolean;
  50288. EMISSIVE: boolean;
  50289. EMISSIVEDIRECTUV: number;
  50290. REFLECTIVITY: boolean;
  50291. REFLECTIVITYDIRECTUV: number;
  50292. SPECULARTERM: boolean;
  50293. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50294. MICROSURFACEAUTOMATIC: boolean;
  50295. LODBASEDMICROSFURACE: boolean;
  50296. MICROSURFACEMAP: boolean;
  50297. MICROSURFACEMAPDIRECTUV: number;
  50298. METALLICWORKFLOW: boolean;
  50299. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50300. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50301. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50302. AOSTOREINMETALMAPRED: boolean;
  50303. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50304. ENVIRONMENTBRDF: boolean;
  50305. ENVIRONMENTBRDF_RGBD: boolean;
  50306. NORMAL: boolean;
  50307. TANGENT: boolean;
  50308. BUMP: boolean;
  50309. BUMPDIRECTUV: number;
  50310. OBJECTSPACE_NORMALMAP: boolean;
  50311. PARALLAX: boolean;
  50312. PARALLAXOCCLUSION: boolean;
  50313. NORMALXYSCALE: boolean;
  50314. LIGHTMAP: boolean;
  50315. LIGHTMAPDIRECTUV: number;
  50316. USELIGHTMAPASSHADOWMAP: boolean;
  50317. GAMMALIGHTMAP: boolean;
  50318. RGBDLIGHTMAP: boolean;
  50319. REFLECTION: boolean;
  50320. REFLECTIONMAP_3D: boolean;
  50321. REFLECTIONMAP_SPHERICAL: boolean;
  50322. REFLECTIONMAP_PLANAR: boolean;
  50323. REFLECTIONMAP_CUBIC: boolean;
  50324. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50325. REFLECTIONMAP_PROJECTION: boolean;
  50326. REFLECTIONMAP_SKYBOX: boolean;
  50327. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50328. REFLECTIONMAP_EXPLICIT: boolean;
  50329. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50330. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50331. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50332. INVERTCUBICMAP: boolean;
  50333. USESPHERICALFROMREFLECTIONMAP: boolean;
  50334. USEIRRADIANCEMAP: boolean;
  50335. SPHERICAL_HARMONICS: boolean;
  50336. USESPHERICALINVERTEX: boolean;
  50337. REFLECTIONMAP_OPPOSITEZ: boolean;
  50338. LODINREFLECTIONALPHA: boolean;
  50339. GAMMAREFLECTION: boolean;
  50340. RGBDREFLECTION: boolean;
  50341. LINEARSPECULARREFLECTION: boolean;
  50342. RADIANCEOCCLUSION: boolean;
  50343. HORIZONOCCLUSION: boolean;
  50344. INSTANCES: boolean;
  50345. NUM_BONE_INFLUENCERS: number;
  50346. BonesPerMesh: number;
  50347. BONETEXTURE: boolean;
  50348. NONUNIFORMSCALING: boolean;
  50349. MORPHTARGETS: boolean;
  50350. MORPHTARGETS_NORMAL: boolean;
  50351. MORPHTARGETS_TANGENT: boolean;
  50352. MORPHTARGETS_UV: boolean;
  50353. NUM_MORPH_INFLUENCERS: number;
  50354. IMAGEPROCESSING: boolean;
  50355. VIGNETTE: boolean;
  50356. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50357. VIGNETTEBLENDMODEOPAQUE: boolean;
  50358. TONEMAPPING: boolean;
  50359. TONEMAPPING_ACES: boolean;
  50360. CONTRAST: boolean;
  50361. COLORCURVES: boolean;
  50362. COLORGRADING: boolean;
  50363. COLORGRADING3D: boolean;
  50364. SAMPLER3DGREENDEPTH: boolean;
  50365. SAMPLER3DBGRMAP: boolean;
  50366. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50367. EXPOSURE: boolean;
  50368. MULTIVIEW: boolean;
  50369. USEPHYSICALLIGHTFALLOFF: boolean;
  50370. USEGLTFLIGHTFALLOFF: boolean;
  50371. TWOSIDEDLIGHTING: boolean;
  50372. SHADOWFLOAT: boolean;
  50373. CLIPPLANE: boolean;
  50374. CLIPPLANE2: boolean;
  50375. CLIPPLANE3: boolean;
  50376. CLIPPLANE4: boolean;
  50377. POINTSIZE: boolean;
  50378. FOG: boolean;
  50379. LOGARITHMICDEPTH: boolean;
  50380. FORCENORMALFORWARD: boolean;
  50381. SPECULARAA: boolean;
  50382. CLEARCOAT: boolean;
  50383. CLEARCOAT_DEFAULTIOR: boolean;
  50384. CLEARCOAT_TEXTURE: boolean;
  50385. CLEARCOAT_TEXTUREDIRECTUV: number;
  50386. CLEARCOAT_BUMP: boolean;
  50387. CLEARCOAT_BUMPDIRECTUV: number;
  50388. CLEARCOAT_TINT: boolean;
  50389. CLEARCOAT_TINT_TEXTURE: boolean;
  50390. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50391. ANISOTROPIC: boolean;
  50392. ANISOTROPIC_TEXTURE: boolean;
  50393. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50394. BRDF_V_HEIGHT_CORRELATED: boolean;
  50395. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50396. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50397. SHEEN: boolean;
  50398. SHEEN_TEXTURE: boolean;
  50399. SHEEN_TEXTUREDIRECTUV: number;
  50400. SHEEN_LINKWITHALBEDO: boolean;
  50401. SUBSURFACE: boolean;
  50402. SS_REFRACTION: boolean;
  50403. SS_TRANSLUCENCY: boolean;
  50404. SS_SCATERRING: boolean;
  50405. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50406. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50407. SS_REFRACTIONMAP_3D: boolean;
  50408. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50409. SS_LODINREFRACTIONALPHA: boolean;
  50410. SS_GAMMAREFRACTION: boolean;
  50411. SS_RGBDREFRACTION: boolean;
  50412. SS_LINEARSPECULARREFRACTION: boolean;
  50413. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50414. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50415. UNLIT: boolean;
  50416. DEBUGMODE: number;
  50417. /**
  50418. * Initializes the PBR Material defines.
  50419. */
  50420. constructor();
  50421. /**
  50422. * Resets the PBR Material defines.
  50423. */
  50424. reset(): void;
  50425. }
  50426. /**
  50427. * The Physically based material base class of BJS.
  50428. *
  50429. * This offers the main features of a standard PBR material.
  50430. * For more information, please refer to the documentation :
  50431. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50432. */
  50433. export abstract class PBRBaseMaterial extends PushMaterial {
  50434. /**
  50435. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50436. */
  50437. static readonly PBRMATERIAL_OPAQUE: number;
  50438. /**
  50439. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50440. */
  50441. static readonly PBRMATERIAL_ALPHATEST: number;
  50442. /**
  50443. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50444. */
  50445. static readonly PBRMATERIAL_ALPHABLEND: number;
  50446. /**
  50447. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50448. * They are also discarded below the alpha cutoff threshold to improve performances.
  50449. */
  50450. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50451. /**
  50452. * Defines the default value of how much AO map is occluding the analytical lights
  50453. * (point spot...).
  50454. */
  50455. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50456. /**
  50457. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50458. */
  50459. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50460. /**
  50461. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50462. * to enhance interoperability with other engines.
  50463. */
  50464. static readonly LIGHTFALLOFF_GLTF: number;
  50465. /**
  50466. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50467. * to enhance interoperability with other materials.
  50468. */
  50469. static readonly LIGHTFALLOFF_STANDARD: number;
  50470. /**
  50471. * Intensity of the direct lights e.g. the four lights available in your scene.
  50472. * This impacts both the direct diffuse and specular highlights.
  50473. */
  50474. protected _directIntensity: number;
  50475. /**
  50476. * Intensity of the emissive part of the material.
  50477. * This helps controlling the emissive effect without modifying the emissive color.
  50478. */
  50479. protected _emissiveIntensity: number;
  50480. /**
  50481. * Intensity of the environment e.g. how much the environment will light the object
  50482. * either through harmonics for rough material or through the refelction for shiny ones.
  50483. */
  50484. protected _environmentIntensity: number;
  50485. /**
  50486. * This is a special control allowing the reduction of the specular highlights coming from the
  50487. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50488. */
  50489. protected _specularIntensity: number;
  50490. /**
  50491. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50492. */
  50493. private _lightingInfos;
  50494. /**
  50495. * Debug Control allowing disabling the bump map on this material.
  50496. */
  50497. protected _disableBumpMap: boolean;
  50498. /**
  50499. * AKA Diffuse Texture in standard nomenclature.
  50500. */
  50501. protected _albedoTexture: Nullable<BaseTexture>;
  50502. /**
  50503. * AKA Occlusion Texture in other nomenclature.
  50504. */
  50505. protected _ambientTexture: Nullable<BaseTexture>;
  50506. /**
  50507. * AKA Occlusion Texture Intensity in other nomenclature.
  50508. */
  50509. protected _ambientTextureStrength: number;
  50510. /**
  50511. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50512. * 1 means it completely occludes it
  50513. * 0 mean it has no impact
  50514. */
  50515. protected _ambientTextureImpactOnAnalyticalLights: number;
  50516. /**
  50517. * Stores the alpha values in a texture.
  50518. */
  50519. protected _opacityTexture: Nullable<BaseTexture>;
  50520. /**
  50521. * Stores the reflection values in a texture.
  50522. */
  50523. protected _reflectionTexture: Nullable<BaseTexture>;
  50524. /**
  50525. * Stores the emissive values in a texture.
  50526. */
  50527. protected _emissiveTexture: Nullable<BaseTexture>;
  50528. /**
  50529. * AKA Specular texture in other nomenclature.
  50530. */
  50531. protected _reflectivityTexture: Nullable<BaseTexture>;
  50532. /**
  50533. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50534. */
  50535. protected _metallicTexture: Nullable<BaseTexture>;
  50536. /**
  50537. * Specifies the metallic scalar of the metallic/roughness workflow.
  50538. * Can also be used to scale the metalness values of the metallic texture.
  50539. */
  50540. protected _metallic: Nullable<number>;
  50541. /**
  50542. * Specifies the roughness scalar of the metallic/roughness workflow.
  50543. * Can also be used to scale the roughness values of the metallic texture.
  50544. */
  50545. protected _roughness: Nullable<number>;
  50546. /**
  50547. * Specifies the an F0 factor to help configuring the material F0.
  50548. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50549. * to 0.5 the previously hard coded value stays the same.
  50550. * Can also be used to scale the F0 values of the metallic texture.
  50551. */
  50552. protected _metallicF0Factor: number;
  50553. /**
  50554. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50555. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50556. * your expectation as it multiplies with the texture data.
  50557. */
  50558. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50559. /**
  50560. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50561. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50562. */
  50563. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50564. /**
  50565. * Stores surface normal data used to displace a mesh in a texture.
  50566. */
  50567. protected _bumpTexture: Nullable<BaseTexture>;
  50568. /**
  50569. * Stores the pre-calculated light information of a mesh in a texture.
  50570. */
  50571. protected _lightmapTexture: Nullable<BaseTexture>;
  50572. /**
  50573. * The color of a material in ambient lighting.
  50574. */
  50575. protected _ambientColor: Color3;
  50576. /**
  50577. * AKA Diffuse Color in other nomenclature.
  50578. */
  50579. protected _albedoColor: Color3;
  50580. /**
  50581. * AKA Specular Color in other nomenclature.
  50582. */
  50583. protected _reflectivityColor: Color3;
  50584. /**
  50585. * The color applied when light is reflected from a material.
  50586. */
  50587. protected _reflectionColor: Color3;
  50588. /**
  50589. * The color applied when light is emitted from a material.
  50590. */
  50591. protected _emissiveColor: Color3;
  50592. /**
  50593. * AKA Glossiness in other nomenclature.
  50594. */
  50595. protected _microSurface: number;
  50596. /**
  50597. * Specifies that the material will use the light map as a show map.
  50598. */
  50599. protected _useLightmapAsShadowmap: boolean;
  50600. /**
  50601. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50602. * makes the reflect vector face the model (under horizon).
  50603. */
  50604. protected _useHorizonOcclusion: boolean;
  50605. /**
  50606. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50607. * too much the area relying on ambient texture to define their ambient occlusion.
  50608. */
  50609. protected _useRadianceOcclusion: boolean;
  50610. /**
  50611. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50612. */
  50613. protected _useAlphaFromAlbedoTexture: boolean;
  50614. /**
  50615. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50616. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50617. */
  50618. protected _useSpecularOverAlpha: boolean;
  50619. /**
  50620. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50621. */
  50622. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50623. /**
  50624. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50625. */
  50626. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50627. /**
  50628. * Specifies if the metallic texture contains the roughness information in its green channel.
  50629. */
  50630. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50631. /**
  50632. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50633. */
  50634. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50635. /**
  50636. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50637. */
  50638. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50639. /**
  50640. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50641. */
  50642. protected _useAmbientInGrayScale: boolean;
  50643. /**
  50644. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50645. * The material will try to infer what glossiness each pixel should be.
  50646. */
  50647. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50648. /**
  50649. * Defines the falloff type used in this material.
  50650. * It by default is Physical.
  50651. */
  50652. protected _lightFalloff: number;
  50653. /**
  50654. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50655. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50656. */
  50657. protected _useRadianceOverAlpha: boolean;
  50658. /**
  50659. * Allows using an object space normal map (instead of tangent space).
  50660. */
  50661. protected _useObjectSpaceNormalMap: boolean;
  50662. /**
  50663. * Allows using the bump map in parallax mode.
  50664. */
  50665. protected _useParallax: boolean;
  50666. /**
  50667. * Allows using the bump map in parallax occlusion mode.
  50668. */
  50669. protected _useParallaxOcclusion: boolean;
  50670. /**
  50671. * Controls the scale bias of the parallax mode.
  50672. */
  50673. protected _parallaxScaleBias: number;
  50674. /**
  50675. * If sets to true, disables all the lights affecting the material.
  50676. */
  50677. protected _disableLighting: boolean;
  50678. /**
  50679. * Number of Simultaneous lights allowed on the material.
  50680. */
  50681. protected _maxSimultaneousLights: number;
  50682. /**
  50683. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50684. */
  50685. protected _invertNormalMapX: boolean;
  50686. /**
  50687. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50688. */
  50689. protected _invertNormalMapY: boolean;
  50690. /**
  50691. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50692. */
  50693. protected _twoSidedLighting: boolean;
  50694. /**
  50695. * Defines the alpha limits in alpha test mode.
  50696. */
  50697. protected _alphaCutOff: number;
  50698. /**
  50699. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50700. */
  50701. protected _forceAlphaTest: boolean;
  50702. /**
  50703. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50704. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50705. */
  50706. protected _useAlphaFresnel: boolean;
  50707. /**
  50708. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50709. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50710. */
  50711. protected _useLinearAlphaFresnel: boolean;
  50712. /**
  50713. * The transparency mode of the material.
  50714. */
  50715. protected _transparencyMode: Nullable<number>;
  50716. /**
  50717. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50718. * from cos thetav and roughness:
  50719. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50720. */
  50721. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50722. /**
  50723. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50724. */
  50725. protected _forceIrradianceInFragment: boolean;
  50726. /**
  50727. * Force normal to face away from face.
  50728. */
  50729. protected _forceNormalForward: boolean;
  50730. /**
  50731. * Enables specular anti aliasing in the PBR shader.
  50732. * It will both interacts on the Geometry for analytical and IBL lighting.
  50733. * It also prefilter the roughness map based on the bump values.
  50734. */
  50735. protected _enableSpecularAntiAliasing: boolean;
  50736. /**
  50737. * Default configuration related to image processing available in the PBR Material.
  50738. */
  50739. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50740. /**
  50741. * Keep track of the image processing observer to allow dispose and replace.
  50742. */
  50743. private _imageProcessingObserver;
  50744. /**
  50745. * Attaches a new image processing configuration to the PBR Material.
  50746. * @param configuration
  50747. */
  50748. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50749. /**
  50750. * Stores the available render targets.
  50751. */
  50752. private _renderTargets;
  50753. /**
  50754. * Sets the global ambient color for the material used in lighting calculations.
  50755. */
  50756. private _globalAmbientColor;
  50757. /**
  50758. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50759. */
  50760. private _useLogarithmicDepth;
  50761. /**
  50762. * If set to true, no lighting calculations will be applied.
  50763. */
  50764. private _unlit;
  50765. private _debugMode;
  50766. /**
  50767. * @hidden
  50768. * This is reserved for the inspector.
  50769. * Defines the material debug mode.
  50770. * It helps seeing only some components of the material while troubleshooting.
  50771. */
  50772. debugMode: number;
  50773. /**
  50774. * @hidden
  50775. * This is reserved for the inspector.
  50776. * Specify from where on screen the debug mode should start.
  50777. * The value goes from -1 (full screen) to 1 (not visible)
  50778. * It helps with side by side comparison against the final render
  50779. * This defaults to -1
  50780. */
  50781. private debugLimit;
  50782. /**
  50783. * @hidden
  50784. * This is reserved for the inspector.
  50785. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50786. * You can use the factor to better multiply the final value.
  50787. */
  50788. private debugFactor;
  50789. /**
  50790. * Defines the clear coat layer parameters for the material.
  50791. */
  50792. readonly clearCoat: PBRClearCoatConfiguration;
  50793. /**
  50794. * Defines the anisotropic parameters for the material.
  50795. */
  50796. readonly anisotropy: PBRAnisotropicConfiguration;
  50797. /**
  50798. * Defines the BRDF parameters for the material.
  50799. */
  50800. readonly brdf: PBRBRDFConfiguration;
  50801. /**
  50802. * Defines the Sheen parameters for the material.
  50803. */
  50804. readonly sheen: PBRSheenConfiguration;
  50805. /**
  50806. * Defines the SubSurface parameters for the material.
  50807. */
  50808. readonly subSurface: PBRSubSurfaceConfiguration;
  50809. /**
  50810. * Custom callback helping to override the default shader used in the material.
  50811. */
  50812. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50813. protected _rebuildInParallel: boolean;
  50814. /**
  50815. * Instantiates a new PBRMaterial instance.
  50816. *
  50817. * @param name The material name
  50818. * @param scene The scene the material will be use in.
  50819. */
  50820. constructor(name: string, scene: Scene);
  50821. /**
  50822. * Gets a boolean indicating that current material needs to register RTT
  50823. */
  50824. readonly hasRenderTargetTextures: boolean;
  50825. /**
  50826. * Gets the name of the material class.
  50827. */
  50828. getClassName(): string;
  50829. /**
  50830. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50831. */
  50832. /**
  50833. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50834. */
  50835. useLogarithmicDepth: boolean;
  50836. /**
  50837. * Gets the current transparency mode.
  50838. */
  50839. /**
  50840. * Sets the transparency mode of the material.
  50841. *
  50842. * | Value | Type | Description |
  50843. * | ----- | ----------------------------------- | ----------- |
  50844. * | 0 | OPAQUE | |
  50845. * | 1 | ALPHATEST | |
  50846. * | 2 | ALPHABLEND | |
  50847. * | 3 | ALPHATESTANDBLEND | |
  50848. *
  50849. */
  50850. transparencyMode: Nullable<number>;
  50851. /**
  50852. * Returns true if alpha blending should be disabled.
  50853. */
  50854. private readonly _disableAlphaBlending;
  50855. /**
  50856. * Specifies whether or not this material should be rendered in alpha blend mode.
  50857. */
  50858. needAlphaBlending(): boolean;
  50859. /**
  50860. * Specifies if the mesh will require alpha blending.
  50861. * @param mesh - BJS mesh.
  50862. */
  50863. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50864. /**
  50865. * Specifies whether or not this material should be rendered in alpha test mode.
  50866. */
  50867. needAlphaTesting(): boolean;
  50868. /**
  50869. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50870. */
  50871. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50872. /**
  50873. * Gets the texture used for the alpha test.
  50874. */
  50875. getAlphaTestTexture(): Nullable<BaseTexture>;
  50876. /**
  50877. * Specifies that the submesh is ready to be used.
  50878. * @param mesh - BJS mesh.
  50879. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50880. * @param useInstances - Specifies that instances should be used.
  50881. * @returns - boolean indicating that the submesh is ready or not.
  50882. */
  50883. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50884. /**
  50885. * Specifies if the material uses metallic roughness workflow.
  50886. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50887. */
  50888. isMetallicWorkflow(): boolean;
  50889. private _prepareEffect;
  50890. private _prepareDefines;
  50891. /**
  50892. * Force shader compilation
  50893. */
  50894. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50895. /**
  50896. * Initializes the uniform buffer layout for the shader.
  50897. */
  50898. buildUniformLayout(): void;
  50899. /**
  50900. * Unbinds the material from the mesh
  50901. */
  50902. unbind(): void;
  50903. /**
  50904. * Binds the submesh data.
  50905. * @param world - The world matrix.
  50906. * @param mesh - The BJS mesh.
  50907. * @param subMesh - A submesh of the BJS mesh.
  50908. */
  50909. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50910. /**
  50911. * Returns the animatable textures.
  50912. * @returns - Array of animatable textures.
  50913. */
  50914. getAnimatables(): IAnimatable[];
  50915. /**
  50916. * Returns the texture used for reflections.
  50917. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50918. */
  50919. private _getReflectionTexture;
  50920. /**
  50921. * Returns an array of the actively used textures.
  50922. * @returns - Array of BaseTextures
  50923. */
  50924. getActiveTextures(): BaseTexture[];
  50925. /**
  50926. * Checks to see if a texture is used in the material.
  50927. * @param texture - Base texture to use.
  50928. * @returns - Boolean specifying if a texture is used in the material.
  50929. */
  50930. hasTexture(texture: BaseTexture): boolean;
  50931. /**
  50932. * Disposes the resources of the material.
  50933. * @param forceDisposeEffect - Forces the disposal of effects.
  50934. * @param forceDisposeTextures - Forces the disposal of all textures.
  50935. */
  50936. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50937. }
  50938. }
  50939. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50940. import { Nullable } from "babylonjs/types";
  50941. import { Scene } from "babylonjs/scene";
  50942. import { Color3 } from "babylonjs/Maths/math.color";
  50943. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50944. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50945. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50946. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50947. /**
  50948. * The Physically based material of BJS.
  50949. *
  50950. * This offers the main features of a standard PBR material.
  50951. * For more information, please refer to the documentation :
  50952. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50953. */
  50954. export class PBRMaterial extends PBRBaseMaterial {
  50955. /**
  50956. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50957. */
  50958. static readonly PBRMATERIAL_OPAQUE: number;
  50959. /**
  50960. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50961. */
  50962. static readonly PBRMATERIAL_ALPHATEST: number;
  50963. /**
  50964. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50965. */
  50966. static readonly PBRMATERIAL_ALPHABLEND: number;
  50967. /**
  50968. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50969. * They are also discarded below the alpha cutoff threshold to improve performances.
  50970. */
  50971. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50972. /**
  50973. * Defines the default value of how much AO map is occluding the analytical lights
  50974. * (point spot...).
  50975. */
  50976. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50977. /**
  50978. * Intensity of the direct lights e.g. the four lights available in your scene.
  50979. * This impacts both the direct diffuse and specular highlights.
  50980. */
  50981. directIntensity: number;
  50982. /**
  50983. * Intensity of the emissive part of the material.
  50984. * This helps controlling the emissive effect without modifying the emissive color.
  50985. */
  50986. emissiveIntensity: number;
  50987. /**
  50988. * Intensity of the environment e.g. how much the environment will light the object
  50989. * either through harmonics for rough material or through the refelction for shiny ones.
  50990. */
  50991. environmentIntensity: number;
  50992. /**
  50993. * This is a special control allowing the reduction of the specular highlights coming from the
  50994. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50995. */
  50996. specularIntensity: number;
  50997. /**
  50998. * Debug Control allowing disabling the bump map on this material.
  50999. */
  51000. disableBumpMap: boolean;
  51001. /**
  51002. * AKA Diffuse Texture in standard nomenclature.
  51003. */
  51004. albedoTexture: BaseTexture;
  51005. /**
  51006. * AKA Occlusion Texture in other nomenclature.
  51007. */
  51008. ambientTexture: BaseTexture;
  51009. /**
  51010. * AKA Occlusion Texture Intensity in other nomenclature.
  51011. */
  51012. ambientTextureStrength: number;
  51013. /**
  51014. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51015. * 1 means it completely occludes it
  51016. * 0 mean it has no impact
  51017. */
  51018. ambientTextureImpactOnAnalyticalLights: number;
  51019. /**
  51020. * Stores the alpha values in a texture.
  51021. */
  51022. opacityTexture: BaseTexture;
  51023. /**
  51024. * Stores the reflection values in a texture.
  51025. */
  51026. reflectionTexture: Nullable<BaseTexture>;
  51027. /**
  51028. * Stores the emissive values in a texture.
  51029. */
  51030. emissiveTexture: BaseTexture;
  51031. /**
  51032. * AKA Specular texture in other nomenclature.
  51033. */
  51034. reflectivityTexture: BaseTexture;
  51035. /**
  51036. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51037. */
  51038. metallicTexture: BaseTexture;
  51039. /**
  51040. * Specifies the metallic scalar of the metallic/roughness workflow.
  51041. * Can also be used to scale the metalness values of the metallic texture.
  51042. */
  51043. metallic: Nullable<number>;
  51044. /**
  51045. * Specifies the roughness scalar of the metallic/roughness workflow.
  51046. * Can also be used to scale the roughness values of the metallic texture.
  51047. */
  51048. roughness: Nullable<number>;
  51049. /**
  51050. * Specifies the an F0 factor to help configuring the material F0.
  51051. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51052. * to 0.5 the previously hard coded value stays the same.
  51053. * Can also be used to scale the F0 values of the metallic texture.
  51054. */
  51055. metallicF0Factor: number;
  51056. /**
  51057. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51058. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51059. * your expectation as it multiplies with the texture data.
  51060. */
  51061. useMetallicF0FactorFromMetallicTexture: boolean;
  51062. /**
  51063. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51064. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51065. */
  51066. microSurfaceTexture: BaseTexture;
  51067. /**
  51068. * Stores surface normal data used to displace a mesh in a texture.
  51069. */
  51070. bumpTexture: BaseTexture;
  51071. /**
  51072. * Stores the pre-calculated light information of a mesh in a texture.
  51073. */
  51074. lightmapTexture: BaseTexture;
  51075. /**
  51076. * Stores the refracted light information in a texture.
  51077. */
  51078. refractionTexture: Nullable<BaseTexture>;
  51079. /**
  51080. * The color of a material in ambient lighting.
  51081. */
  51082. ambientColor: Color3;
  51083. /**
  51084. * AKA Diffuse Color in other nomenclature.
  51085. */
  51086. albedoColor: Color3;
  51087. /**
  51088. * AKA Specular Color in other nomenclature.
  51089. */
  51090. reflectivityColor: Color3;
  51091. /**
  51092. * The color reflected from the material.
  51093. */
  51094. reflectionColor: Color3;
  51095. /**
  51096. * The color emitted from the material.
  51097. */
  51098. emissiveColor: Color3;
  51099. /**
  51100. * AKA Glossiness in other nomenclature.
  51101. */
  51102. microSurface: number;
  51103. /**
  51104. * source material index of refraction (IOR)' / 'destination material IOR.
  51105. */
  51106. indexOfRefraction: number;
  51107. /**
  51108. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51109. */
  51110. invertRefractionY: boolean;
  51111. /**
  51112. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51113. * Materials half opaque for instance using refraction could benefit from this control.
  51114. */
  51115. linkRefractionWithTransparency: boolean;
  51116. /**
  51117. * If true, the light map contains occlusion information instead of lighting info.
  51118. */
  51119. useLightmapAsShadowmap: boolean;
  51120. /**
  51121. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51122. */
  51123. useAlphaFromAlbedoTexture: boolean;
  51124. /**
  51125. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51126. */
  51127. forceAlphaTest: boolean;
  51128. /**
  51129. * Defines the alpha limits in alpha test mode.
  51130. */
  51131. alphaCutOff: number;
  51132. /**
  51133. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51134. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51135. */
  51136. useSpecularOverAlpha: boolean;
  51137. /**
  51138. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51139. */
  51140. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51141. /**
  51142. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51143. */
  51144. useRoughnessFromMetallicTextureAlpha: boolean;
  51145. /**
  51146. * Specifies if the metallic texture contains the roughness information in its green channel.
  51147. */
  51148. useRoughnessFromMetallicTextureGreen: boolean;
  51149. /**
  51150. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51151. */
  51152. useMetallnessFromMetallicTextureBlue: boolean;
  51153. /**
  51154. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51155. */
  51156. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51157. /**
  51158. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51159. */
  51160. useAmbientInGrayScale: boolean;
  51161. /**
  51162. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51163. * The material will try to infer what glossiness each pixel should be.
  51164. */
  51165. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51166. /**
  51167. * BJS is using an harcoded light falloff based on a manually sets up range.
  51168. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51169. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51170. */
  51171. /**
  51172. * BJS is using an harcoded light falloff based on a manually sets up range.
  51173. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51174. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51175. */
  51176. usePhysicalLightFalloff: boolean;
  51177. /**
  51178. * In order to support the falloff compatibility with gltf, a special mode has been added
  51179. * to reproduce the gltf light falloff.
  51180. */
  51181. /**
  51182. * In order to support the falloff compatibility with gltf, a special mode has been added
  51183. * to reproduce the gltf light falloff.
  51184. */
  51185. useGLTFLightFalloff: boolean;
  51186. /**
  51187. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51188. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51189. */
  51190. useRadianceOverAlpha: boolean;
  51191. /**
  51192. * Allows using an object space normal map (instead of tangent space).
  51193. */
  51194. useObjectSpaceNormalMap: boolean;
  51195. /**
  51196. * Allows using the bump map in parallax mode.
  51197. */
  51198. useParallax: boolean;
  51199. /**
  51200. * Allows using the bump map in parallax occlusion mode.
  51201. */
  51202. useParallaxOcclusion: boolean;
  51203. /**
  51204. * Controls the scale bias of the parallax mode.
  51205. */
  51206. parallaxScaleBias: number;
  51207. /**
  51208. * If sets to true, disables all the lights affecting the material.
  51209. */
  51210. disableLighting: boolean;
  51211. /**
  51212. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51213. */
  51214. forceIrradianceInFragment: boolean;
  51215. /**
  51216. * Number of Simultaneous lights allowed on the material.
  51217. */
  51218. maxSimultaneousLights: number;
  51219. /**
  51220. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51221. */
  51222. invertNormalMapX: boolean;
  51223. /**
  51224. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51225. */
  51226. invertNormalMapY: boolean;
  51227. /**
  51228. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51229. */
  51230. twoSidedLighting: boolean;
  51231. /**
  51232. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51233. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51234. */
  51235. useAlphaFresnel: boolean;
  51236. /**
  51237. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51238. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51239. */
  51240. useLinearAlphaFresnel: boolean;
  51241. /**
  51242. * Let user defines the brdf lookup texture used for IBL.
  51243. * A default 8bit version is embedded but you could point at :
  51244. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51245. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51246. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51247. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51248. */
  51249. environmentBRDFTexture: Nullable<BaseTexture>;
  51250. /**
  51251. * Force normal to face away from face.
  51252. */
  51253. forceNormalForward: boolean;
  51254. /**
  51255. * Enables specular anti aliasing in the PBR shader.
  51256. * It will both interacts on the Geometry for analytical and IBL lighting.
  51257. * It also prefilter the roughness map based on the bump values.
  51258. */
  51259. enableSpecularAntiAliasing: boolean;
  51260. /**
  51261. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51262. * makes the reflect vector face the model (under horizon).
  51263. */
  51264. useHorizonOcclusion: boolean;
  51265. /**
  51266. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51267. * too much the area relying on ambient texture to define their ambient occlusion.
  51268. */
  51269. useRadianceOcclusion: boolean;
  51270. /**
  51271. * If set to true, no lighting calculations will be applied.
  51272. */
  51273. unlit: boolean;
  51274. /**
  51275. * Gets the image processing configuration used either in this material.
  51276. */
  51277. /**
  51278. * Sets the Default image processing configuration used either in the this material.
  51279. *
  51280. * If sets to null, the scene one is in use.
  51281. */
  51282. imageProcessingConfiguration: ImageProcessingConfiguration;
  51283. /**
  51284. * Gets wether the color curves effect is enabled.
  51285. */
  51286. /**
  51287. * Sets wether the color curves effect is enabled.
  51288. */
  51289. cameraColorCurvesEnabled: boolean;
  51290. /**
  51291. * Gets wether the color grading effect is enabled.
  51292. */
  51293. /**
  51294. * Gets wether the color grading effect is enabled.
  51295. */
  51296. cameraColorGradingEnabled: boolean;
  51297. /**
  51298. * Gets wether tonemapping is enabled or not.
  51299. */
  51300. /**
  51301. * Sets wether tonemapping is enabled or not
  51302. */
  51303. cameraToneMappingEnabled: boolean;
  51304. /**
  51305. * The camera exposure used on this material.
  51306. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51307. * This corresponds to a photographic exposure.
  51308. */
  51309. /**
  51310. * The camera exposure used on this material.
  51311. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51312. * This corresponds to a photographic exposure.
  51313. */
  51314. cameraExposure: number;
  51315. /**
  51316. * Gets The camera contrast used on this material.
  51317. */
  51318. /**
  51319. * Sets The camera contrast used on this material.
  51320. */
  51321. cameraContrast: number;
  51322. /**
  51323. * Gets the Color Grading 2D Lookup Texture.
  51324. */
  51325. /**
  51326. * Sets the Color Grading 2D Lookup Texture.
  51327. */
  51328. cameraColorGradingTexture: Nullable<BaseTexture>;
  51329. /**
  51330. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51331. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51332. * 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;
  51333. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51334. */
  51335. /**
  51336. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51337. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51338. * 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;
  51339. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51340. */
  51341. cameraColorCurves: Nullable<ColorCurves>;
  51342. /**
  51343. * Instantiates a new PBRMaterial instance.
  51344. *
  51345. * @param name The material name
  51346. * @param scene The scene the material will be use in.
  51347. */
  51348. constructor(name: string, scene: Scene);
  51349. /**
  51350. * Returns the name of this material class.
  51351. */
  51352. getClassName(): string;
  51353. /**
  51354. * Makes a duplicate of the current material.
  51355. * @param name - name to use for the new material.
  51356. */
  51357. clone(name: string): PBRMaterial;
  51358. /**
  51359. * Serializes this PBR Material.
  51360. * @returns - An object with the serialized material.
  51361. */
  51362. serialize(): any;
  51363. /**
  51364. * Parses a PBR Material from a serialized object.
  51365. * @param source - Serialized object.
  51366. * @param scene - BJS scene instance.
  51367. * @param rootUrl - url for the scene object
  51368. * @returns - PBRMaterial
  51369. */
  51370. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51371. }
  51372. }
  51373. declare module "babylonjs/Misc/dds" {
  51374. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51375. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51376. import { Nullable } from "babylonjs/types";
  51377. import { Scene } from "babylonjs/scene";
  51378. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51379. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51380. /**
  51381. * Direct draw surface info
  51382. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51383. */
  51384. export interface DDSInfo {
  51385. /**
  51386. * Width of the texture
  51387. */
  51388. width: number;
  51389. /**
  51390. * Width of the texture
  51391. */
  51392. height: number;
  51393. /**
  51394. * Number of Mipmaps for the texture
  51395. * @see https://en.wikipedia.org/wiki/Mipmap
  51396. */
  51397. mipmapCount: number;
  51398. /**
  51399. * If the textures format is a known fourCC format
  51400. * @see https://www.fourcc.org/
  51401. */
  51402. isFourCC: boolean;
  51403. /**
  51404. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51405. */
  51406. isRGB: boolean;
  51407. /**
  51408. * If the texture is a lumincance format
  51409. */
  51410. isLuminance: boolean;
  51411. /**
  51412. * If this is a cube texture
  51413. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51414. */
  51415. isCube: boolean;
  51416. /**
  51417. * If the texture is a compressed format eg. FOURCC_DXT1
  51418. */
  51419. isCompressed: boolean;
  51420. /**
  51421. * The dxgiFormat of the texture
  51422. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51423. */
  51424. dxgiFormat: number;
  51425. /**
  51426. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51427. */
  51428. textureType: number;
  51429. /**
  51430. * Sphericle polynomial created for the dds texture
  51431. */
  51432. sphericalPolynomial?: SphericalPolynomial;
  51433. }
  51434. /**
  51435. * Class used to provide DDS decompression tools
  51436. */
  51437. export class DDSTools {
  51438. /**
  51439. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51440. */
  51441. static StoreLODInAlphaChannel: boolean;
  51442. /**
  51443. * Gets DDS information from an array buffer
  51444. * @param arrayBuffer defines the array buffer to read data from
  51445. * @returns the DDS information
  51446. */
  51447. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51448. private static _FloatView;
  51449. private static _Int32View;
  51450. private static _ToHalfFloat;
  51451. private static _FromHalfFloat;
  51452. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51453. private static _GetHalfFloatRGBAArrayBuffer;
  51454. private static _GetFloatRGBAArrayBuffer;
  51455. private static _GetFloatAsUIntRGBAArrayBuffer;
  51456. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51457. private static _GetRGBAArrayBuffer;
  51458. private static _ExtractLongWordOrder;
  51459. private static _GetRGBArrayBuffer;
  51460. private static _GetLuminanceArrayBuffer;
  51461. /**
  51462. * Uploads DDS Levels to a Babylon Texture
  51463. * @hidden
  51464. */
  51465. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51466. }
  51467. module "babylonjs/Engines/thinEngine" {
  51468. interface ThinEngine {
  51469. /**
  51470. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51471. * @param rootUrl defines the url where the file to load is located
  51472. * @param scene defines the current scene
  51473. * @param lodScale defines scale to apply to the mip map selection
  51474. * @param lodOffset defines offset to apply to the mip map selection
  51475. * @param onLoad defines an optional callback raised when the texture is loaded
  51476. * @param onError defines an optional callback raised if there is an issue to load the texture
  51477. * @param format defines the format of the data
  51478. * @param forcedExtension defines the extension to use to pick the right loader
  51479. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51480. * @returns the cube texture as an InternalTexture
  51481. */
  51482. 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;
  51483. }
  51484. }
  51485. }
  51486. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51487. import { Nullable } from "babylonjs/types";
  51488. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51489. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51490. /**
  51491. * Implementation of the DDS Texture Loader.
  51492. * @hidden
  51493. */
  51494. export class _DDSTextureLoader implements IInternalTextureLoader {
  51495. /**
  51496. * Defines wether the loader supports cascade loading the different faces.
  51497. */
  51498. readonly supportCascades: boolean;
  51499. /**
  51500. * This returns if the loader support the current file information.
  51501. * @param extension defines the file extension of the file being loaded
  51502. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51503. * @param fallback defines the fallback internal texture if any
  51504. * @param isBase64 defines whether the texture is encoded as a base64
  51505. * @param isBuffer defines whether the texture data are stored as a buffer
  51506. * @returns true if the loader can load the specified file
  51507. */
  51508. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51509. /**
  51510. * Transform the url before loading if required.
  51511. * @param rootUrl the url of the texture
  51512. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51513. * @returns the transformed texture
  51514. */
  51515. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51516. /**
  51517. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51518. * @param rootUrl the url of the texture
  51519. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51520. * @returns the fallback texture
  51521. */
  51522. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51523. /**
  51524. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51525. * @param data contains the texture data
  51526. * @param texture defines the BabylonJS internal texture
  51527. * @param createPolynomials will be true if polynomials have been requested
  51528. * @param onLoad defines the callback to trigger once the texture is ready
  51529. * @param onError defines the callback to trigger in case of error
  51530. */
  51531. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51532. /**
  51533. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51534. * @param data contains the texture data
  51535. * @param texture defines the BabylonJS internal texture
  51536. * @param callback defines the method to call once ready to upload
  51537. */
  51538. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51539. }
  51540. }
  51541. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51542. import { Nullable } from "babylonjs/types";
  51543. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51544. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51545. /**
  51546. * Implementation of the ENV Texture Loader.
  51547. * @hidden
  51548. */
  51549. export class _ENVTextureLoader implements IInternalTextureLoader {
  51550. /**
  51551. * Defines wether the loader supports cascade loading the different faces.
  51552. */
  51553. readonly supportCascades: boolean;
  51554. /**
  51555. * This returns if the loader support the current file information.
  51556. * @param extension defines the file extension of the file being loaded
  51557. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51558. * @param fallback defines the fallback internal texture if any
  51559. * @param isBase64 defines whether the texture is encoded as a base64
  51560. * @param isBuffer defines whether the texture data are stored as a buffer
  51561. * @returns true if the loader can load the specified file
  51562. */
  51563. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51564. /**
  51565. * Transform the url before loading if required.
  51566. * @param rootUrl the url of the texture
  51567. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51568. * @returns the transformed texture
  51569. */
  51570. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51571. /**
  51572. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51573. * @param rootUrl the url of the texture
  51574. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51575. * @returns the fallback texture
  51576. */
  51577. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51578. /**
  51579. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51580. * @param data contains the texture data
  51581. * @param texture defines the BabylonJS internal texture
  51582. * @param createPolynomials will be true if polynomials have been requested
  51583. * @param onLoad defines the callback to trigger once the texture is ready
  51584. * @param onError defines the callback to trigger in case of error
  51585. */
  51586. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51587. /**
  51588. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51589. * @param data contains the texture data
  51590. * @param texture defines the BabylonJS internal texture
  51591. * @param callback defines the method to call once ready to upload
  51592. */
  51593. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51594. }
  51595. }
  51596. declare module "babylonjs/Misc/khronosTextureContainer" {
  51597. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51598. /**
  51599. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51600. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51601. */
  51602. export class KhronosTextureContainer {
  51603. /** contents of the KTX container file */
  51604. arrayBuffer: any;
  51605. private static HEADER_LEN;
  51606. private static COMPRESSED_2D;
  51607. private static COMPRESSED_3D;
  51608. private static TEX_2D;
  51609. private static TEX_3D;
  51610. /**
  51611. * Gets the openGL type
  51612. */
  51613. glType: number;
  51614. /**
  51615. * Gets the openGL type size
  51616. */
  51617. glTypeSize: number;
  51618. /**
  51619. * Gets the openGL format
  51620. */
  51621. glFormat: number;
  51622. /**
  51623. * Gets the openGL internal format
  51624. */
  51625. glInternalFormat: number;
  51626. /**
  51627. * Gets the base internal format
  51628. */
  51629. glBaseInternalFormat: number;
  51630. /**
  51631. * Gets image width in pixel
  51632. */
  51633. pixelWidth: number;
  51634. /**
  51635. * Gets image height in pixel
  51636. */
  51637. pixelHeight: number;
  51638. /**
  51639. * Gets image depth in pixels
  51640. */
  51641. pixelDepth: number;
  51642. /**
  51643. * Gets the number of array elements
  51644. */
  51645. numberOfArrayElements: number;
  51646. /**
  51647. * Gets the number of faces
  51648. */
  51649. numberOfFaces: number;
  51650. /**
  51651. * Gets the number of mipmap levels
  51652. */
  51653. numberOfMipmapLevels: number;
  51654. /**
  51655. * Gets the bytes of key value data
  51656. */
  51657. bytesOfKeyValueData: number;
  51658. /**
  51659. * Gets the load type
  51660. */
  51661. loadType: number;
  51662. /**
  51663. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51664. */
  51665. isInvalid: boolean;
  51666. /**
  51667. * Creates a new KhronosTextureContainer
  51668. * @param arrayBuffer contents of the KTX container file
  51669. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51670. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51671. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51672. */
  51673. constructor(
  51674. /** contents of the KTX container file */
  51675. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51676. /**
  51677. * Uploads KTX content to a Babylon Texture.
  51678. * It is assumed that the texture has already been created & is currently bound
  51679. * @hidden
  51680. */
  51681. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51682. private _upload2DCompressedLevels;
  51683. }
  51684. }
  51685. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51686. import { Nullable } from "babylonjs/types";
  51687. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51688. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51689. /**
  51690. * Implementation of the KTX Texture Loader.
  51691. * @hidden
  51692. */
  51693. export class _KTXTextureLoader implements IInternalTextureLoader {
  51694. /**
  51695. * Defines wether the loader supports cascade loading the different faces.
  51696. */
  51697. readonly supportCascades: boolean;
  51698. /**
  51699. * This returns if the loader support the current file information.
  51700. * @param extension defines the file extension of the file being loaded
  51701. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51702. * @param fallback defines the fallback internal texture if any
  51703. * @param isBase64 defines whether the texture is encoded as a base64
  51704. * @param isBuffer defines whether the texture data are stored as a buffer
  51705. * @returns true if the loader can load the specified file
  51706. */
  51707. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51708. /**
  51709. * Transform the url before loading if required.
  51710. * @param rootUrl the url of the texture
  51711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51712. * @returns the transformed texture
  51713. */
  51714. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51715. /**
  51716. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51717. * @param rootUrl the url of the texture
  51718. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51719. * @returns the fallback texture
  51720. */
  51721. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51722. /**
  51723. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51724. * @param data contains the texture data
  51725. * @param texture defines the BabylonJS internal texture
  51726. * @param createPolynomials will be true if polynomials have been requested
  51727. * @param onLoad defines the callback to trigger once the texture is ready
  51728. * @param onError defines the callback to trigger in case of error
  51729. */
  51730. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51731. /**
  51732. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51733. * @param data contains the texture data
  51734. * @param texture defines the BabylonJS internal texture
  51735. * @param callback defines the method to call once ready to upload
  51736. */
  51737. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51738. }
  51739. }
  51740. declare module "babylonjs/Helpers/sceneHelpers" {
  51741. import { Nullable } from "babylonjs/types";
  51742. import { Mesh } from "babylonjs/Meshes/mesh";
  51743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51744. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51745. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51746. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51747. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51748. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51749. import "babylonjs/Meshes/Builders/boxBuilder";
  51750. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51751. /** @hidden */
  51752. export var _forceSceneHelpersToBundle: boolean;
  51753. module "babylonjs/scene" {
  51754. interface Scene {
  51755. /**
  51756. * Creates a default light for the scene.
  51757. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51758. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51759. */
  51760. createDefaultLight(replace?: boolean): void;
  51761. /**
  51762. * Creates a default camera for the scene.
  51763. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51764. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51765. * @param replace has default false, when true replaces the active camera in the scene
  51766. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51767. */
  51768. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51769. /**
  51770. * Creates a default camera and a default light.
  51771. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51772. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51773. * @param replace has the default false, when true replaces the active camera/light in the scene
  51774. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51775. */
  51776. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51777. /**
  51778. * Creates a new sky box
  51779. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51780. * @param environmentTexture defines the texture to use as environment texture
  51781. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51782. * @param scale defines the overall scale of the skybox
  51783. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51784. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51785. * @returns a new mesh holding the sky box
  51786. */
  51787. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51788. /**
  51789. * Creates a new environment
  51790. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51791. * @param options defines the options you can use to configure the environment
  51792. * @returns the new EnvironmentHelper
  51793. */
  51794. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51795. /**
  51796. * Creates a new VREXperienceHelper
  51797. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51798. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51799. * @returns a new VREXperienceHelper
  51800. */
  51801. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51802. /**
  51803. * Creates a new WebXRDefaultExperience
  51804. * @see http://doc.babylonjs.com/how_to/webxr
  51805. * @param options experience options
  51806. * @returns a promise for a new WebXRDefaultExperience
  51807. */
  51808. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51809. }
  51810. }
  51811. }
  51812. declare module "babylonjs/Helpers/videoDome" {
  51813. import { Scene } from "babylonjs/scene";
  51814. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51815. import { Mesh } from "babylonjs/Meshes/mesh";
  51816. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51817. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51818. import "babylonjs/Meshes/Builders/sphereBuilder";
  51819. /**
  51820. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51821. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51822. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51823. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51824. */
  51825. export class VideoDome extends TransformNode {
  51826. /**
  51827. * Define the video source as a Monoscopic panoramic 360 video.
  51828. */
  51829. static readonly MODE_MONOSCOPIC: number;
  51830. /**
  51831. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51832. */
  51833. static readonly MODE_TOPBOTTOM: number;
  51834. /**
  51835. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51836. */
  51837. static readonly MODE_SIDEBYSIDE: number;
  51838. private _halfDome;
  51839. private _useDirectMapping;
  51840. /**
  51841. * The video texture being displayed on the sphere
  51842. */
  51843. protected _videoTexture: VideoTexture;
  51844. /**
  51845. * Gets the video texture being displayed on the sphere
  51846. */
  51847. readonly videoTexture: VideoTexture;
  51848. /**
  51849. * The skybox material
  51850. */
  51851. protected _material: BackgroundMaterial;
  51852. /**
  51853. * The surface used for the skybox
  51854. */
  51855. protected _mesh: Mesh;
  51856. /**
  51857. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51858. */
  51859. private _halfDomeMask;
  51860. /**
  51861. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51862. * Also see the options.resolution property.
  51863. */
  51864. fovMultiplier: number;
  51865. private _videoMode;
  51866. /**
  51867. * Gets or set the current video mode for the video. It can be:
  51868. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51869. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51870. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51871. */
  51872. videoMode: number;
  51873. /**
  51874. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51875. *
  51876. */
  51877. /**
  51878. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51879. */
  51880. halfDome: boolean;
  51881. /**
  51882. * Oberserver used in Stereoscopic VR Mode.
  51883. */
  51884. private _onBeforeCameraRenderObserver;
  51885. /**
  51886. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51887. * @param name Element's name, child elements will append suffixes for their own names.
  51888. * @param urlsOrVideo defines the url(s) or the video element to use
  51889. * @param options An object containing optional or exposed sub element properties
  51890. */
  51891. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51892. resolution?: number;
  51893. clickToPlay?: boolean;
  51894. autoPlay?: boolean;
  51895. loop?: boolean;
  51896. size?: number;
  51897. poster?: string;
  51898. faceForward?: boolean;
  51899. useDirectMapping?: boolean;
  51900. halfDomeMode?: boolean;
  51901. }, scene: Scene);
  51902. private _changeVideoMode;
  51903. /**
  51904. * Releases resources associated with this node.
  51905. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51906. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51907. */
  51908. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51909. }
  51910. }
  51911. declare module "babylonjs/Helpers/index" {
  51912. export * from "babylonjs/Helpers/environmentHelper";
  51913. export * from "babylonjs/Helpers/photoDome";
  51914. export * from "babylonjs/Helpers/sceneHelpers";
  51915. export * from "babylonjs/Helpers/videoDome";
  51916. }
  51917. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51918. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51919. import { IDisposable } from "babylonjs/scene";
  51920. import { Engine } from "babylonjs/Engines/engine";
  51921. /**
  51922. * This class can be used to get instrumentation data from a Babylon engine
  51923. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51924. */
  51925. export class EngineInstrumentation implements IDisposable {
  51926. /**
  51927. * Define the instrumented engine.
  51928. */
  51929. engine: Engine;
  51930. private _captureGPUFrameTime;
  51931. private _gpuFrameTimeToken;
  51932. private _gpuFrameTime;
  51933. private _captureShaderCompilationTime;
  51934. private _shaderCompilationTime;
  51935. private _onBeginFrameObserver;
  51936. private _onEndFrameObserver;
  51937. private _onBeforeShaderCompilationObserver;
  51938. private _onAfterShaderCompilationObserver;
  51939. /**
  51940. * Gets the perf counter used for GPU frame time
  51941. */
  51942. readonly gpuFrameTimeCounter: PerfCounter;
  51943. /**
  51944. * Gets the GPU frame time capture status
  51945. */
  51946. /**
  51947. * Enable or disable the GPU frame time capture
  51948. */
  51949. captureGPUFrameTime: boolean;
  51950. /**
  51951. * Gets the perf counter used for shader compilation time
  51952. */
  51953. readonly shaderCompilationTimeCounter: PerfCounter;
  51954. /**
  51955. * Gets the shader compilation time capture status
  51956. */
  51957. /**
  51958. * Enable or disable the shader compilation time capture
  51959. */
  51960. captureShaderCompilationTime: boolean;
  51961. /**
  51962. * Instantiates a new engine instrumentation.
  51963. * This class can be used to get instrumentation data from a Babylon engine
  51964. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51965. * @param engine Defines the engine to instrument
  51966. */
  51967. constructor(
  51968. /**
  51969. * Define the instrumented engine.
  51970. */
  51971. engine: Engine);
  51972. /**
  51973. * Dispose and release associated resources.
  51974. */
  51975. dispose(): void;
  51976. }
  51977. }
  51978. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51979. import { Scene, IDisposable } from "babylonjs/scene";
  51980. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51981. /**
  51982. * This class can be used to get instrumentation data from a Babylon engine
  51983. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51984. */
  51985. export class SceneInstrumentation implements IDisposable {
  51986. /**
  51987. * Defines the scene to instrument
  51988. */
  51989. scene: Scene;
  51990. private _captureActiveMeshesEvaluationTime;
  51991. private _activeMeshesEvaluationTime;
  51992. private _captureRenderTargetsRenderTime;
  51993. private _renderTargetsRenderTime;
  51994. private _captureFrameTime;
  51995. private _frameTime;
  51996. private _captureRenderTime;
  51997. private _renderTime;
  51998. private _captureInterFrameTime;
  51999. private _interFrameTime;
  52000. private _captureParticlesRenderTime;
  52001. private _particlesRenderTime;
  52002. private _captureSpritesRenderTime;
  52003. private _spritesRenderTime;
  52004. private _capturePhysicsTime;
  52005. private _physicsTime;
  52006. private _captureAnimationsTime;
  52007. private _animationsTime;
  52008. private _captureCameraRenderTime;
  52009. private _cameraRenderTime;
  52010. private _onBeforeActiveMeshesEvaluationObserver;
  52011. private _onAfterActiveMeshesEvaluationObserver;
  52012. private _onBeforeRenderTargetsRenderObserver;
  52013. private _onAfterRenderTargetsRenderObserver;
  52014. private _onAfterRenderObserver;
  52015. private _onBeforeDrawPhaseObserver;
  52016. private _onAfterDrawPhaseObserver;
  52017. private _onBeforeAnimationsObserver;
  52018. private _onBeforeParticlesRenderingObserver;
  52019. private _onAfterParticlesRenderingObserver;
  52020. private _onBeforeSpritesRenderingObserver;
  52021. private _onAfterSpritesRenderingObserver;
  52022. private _onBeforePhysicsObserver;
  52023. private _onAfterPhysicsObserver;
  52024. private _onAfterAnimationsObserver;
  52025. private _onBeforeCameraRenderObserver;
  52026. private _onAfterCameraRenderObserver;
  52027. /**
  52028. * Gets the perf counter used for active meshes evaluation time
  52029. */
  52030. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52031. /**
  52032. * Gets the active meshes evaluation time capture status
  52033. */
  52034. /**
  52035. * Enable or disable the active meshes evaluation time capture
  52036. */
  52037. captureActiveMeshesEvaluationTime: boolean;
  52038. /**
  52039. * Gets the perf counter used for render targets render time
  52040. */
  52041. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52042. /**
  52043. * Gets the render targets render time capture status
  52044. */
  52045. /**
  52046. * Enable or disable the render targets render time capture
  52047. */
  52048. captureRenderTargetsRenderTime: boolean;
  52049. /**
  52050. * Gets the perf counter used for particles render time
  52051. */
  52052. readonly particlesRenderTimeCounter: PerfCounter;
  52053. /**
  52054. * Gets the particles render time capture status
  52055. */
  52056. /**
  52057. * Enable or disable the particles render time capture
  52058. */
  52059. captureParticlesRenderTime: boolean;
  52060. /**
  52061. * Gets the perf counter used for sprites render time
  52062. */
  52063. readonly spritesRenderTimeCounter: PerfCounter;
  52064. /**
  52065. * Gets the sprites render time capture status
  52066. */
  52067. /**
  52068. * Enable or disable the sprites render time capture
  52069. */
  52070. captureSpritesRenderTime: boolean;
  52071. /**
  52072. * Gets the perf counter used for physics time
  52073. */
  52074. readonly physicsTimeCounter: PerfCounter;
  52075. /**
  52076. * Gets the physics time capture status
  52077. */
  52078. /**
  52079. * Enable or disable the physics time capture
  52080. */
  52081. capturePhysicsTime: boolean;
  52082. /**
  52083. * Gets the perf counter used for animations time
  52084. */
  52085. readonly animationsTimeCounter: PerfCounter;
  52086. /**
  52087. * Gets the animations time capture status
  52088. */
  52089. /**
  52090. * Enable or disable the animations time capture
  52091. */
  52092. captureAnimationsTime: boolean;
  52093. /**
  52094. * Gets the perf counter used for frame time capture
  52095. */
  52096. readonly frameTimeCounter: PerfCounter;
  52097. /**
  52098. * Gets the frame time capture status
  52099. */
  52100. /**
  52101. * Enable or disable the frame time capture
  52102. */
  52103. captureFrameTime: boolean;
  52104. /**
  52105. * Gets the perf counter used for inter-frames time capture
  52106. */
  52107. readonly interFrameTimeCounter: PerfCounter;
  52108. /**
  52109. * Gets the inter-frames time capture status
  52110. */
  52111. /**
  52112. * Enable or disable the inter-frames time capture
  52113. */
  52114. captureInterFrameTime: boolean;
  52115. /**
  52116. * Gets the perf counter used for render time capture
  52117. */
  52118. readonly renderTimeCounter: PerfCounter;
  52119. /**
  52120. * Gets the render time capture status
  52121. */
  52122. /**
  52123. * Enable or disable the render time capture
  52124. */
  52125. captureRenderTime: boolean;
  52126. /**
  52127. * Gets the perf counter used for camera render time capture
  52128. */
  52129. readonly cameraRenderTimeCounter: PerfCounter;
  52130. /**
  52131. * Gets the camera render time capture status
  52132. */
  52133. /**
  52134. * Enable or disable the camera render time capture
  52135. */
  52136. captureCameraRenderTime: boolean;
  52137. /**
  52138. * Gets the perf counter used for draw calls
  52139. */
  52140. readonly drawCallsCounter: PerfCounter;
  52141. /**
  52142. * Instantiates a new scene instrumentation.
  52143. * This class can be used to get instrumentation data from a Babylon engine
  52144. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52145. * @param scene Defines the scene to instrument
  52146. */
  52147. constructor(
  52148. /**
  52149. * Defines the scene to instrument
  52150. */
  52151. scene: Scene);
  52152. /**
  52153. * Dispose and release associated resources.
  52154. */
  52155. dispose(): void;
  52156. }
  52157. }
  52158. declare module "babylonjs/Instrumentation/index" {
  52159. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52160. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52161. export * from "babylonjs/Instrumentation/timeToken";
  52162. }
  52163. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52164. /** @hidden */
  52165. export var glowMapGenerationPixelShader: {
  52166. name: string;
  52167. shader: string;
  52168. };
  52169. }
  52170. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52171. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52172. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52173. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52174. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52175. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52176. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52177. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52178. /** @hidden */
  52179. export var glowMapGenerationVertexShader: {
  52180. name: string;
  52181. shader: string;
  52182. };
  52183. }
  52184. declare module "babylonjs/Layers/effectLayer" {
  52185. import { Observable } from "babylonjs/Misc/observable";
  52186. import { Nullable } from "babylonjs/types";
  52187. import { Camera } from "babylonjs/Cameras/camera";
  52188. import { Scene } from "babylonjs/scene";
  52189. import { ISize } from "babylonjs/Maths/math.size";
  52190. import { Color4 } from "babylonjs/Maths/math.color";
  52191. import { Engine } from "babylonjs/Engines/engine";
  52192. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52194. import { Mesh } from "babylonjs/Meshes/mesh";
  52195. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52196. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52197. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52198. import { Effect } from "babylonjs/Materials/effect";
  52199. import { Material } from "babylonjs/Materials/material";
  52200. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52201. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52202. /**
  52203. * Effect layer options. This helps customizing the behaviour
  52204. * of the effect layer.
  52205. */
  52206. export interface IEffectLayerOptions {
  52207. /**
  52208. * Multiplication factor apply to the canvas size to compute the render target size
  52209. * used to generated the objects (the smaller the faster).
  52210. */
  52211. mainTextureRatio: number;
  52212. /**
  52213. * Enforces a fixed size texture to ensure effect stability across devices.
  52214. */
  52215. mainTextureFixedSize?: number;
  52216. /**
  52217. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52218. */
  52219. alphaBlendingMode: number;
  52220. /**
  52221. * The camera attached to the layer.
  52222. */
  52223. camera: Nullable<Camera>;
  52224. /**
  52225. * The rendering group to draw the layer in.
  52226. */
  52227. renderingGroupId: number;
  52228. }
  52229. /**
  52230. * The effect layer Helps adding post process effect blended with the main pass.
  52231. *
  52232. * This can be for instance use to generate glow or higlight effects on the scene.
  52233. *
  52234. * The effect layer class can not be used directly and is intented to inherited from to be
  52235. * customized per effects.
  52236. */
  52237. export abstract class EffectLayer {
  52238. private _vertexBuffers;
  52239. private _indexBuffer;
  52240. private _cachedDefines;
  52241. private _effectLayerMapGenerationEffect;
  52242. private _effectLayerOptions;
  52243. private _mergeEffect;
  52244. protected _scene: Scene;
  52245. protected _engine: Engine;
  52246. protected _maxSize: number;
  52247. protected _mainTextureDesiredSize: ISize;
  52248. protected _mainTexture: RenderTargetTexture;
  52249. protected _shouldRender: boolean;
  52250. protected _postProcesses: PostProcess[];
  52251. protected _textures: BaseTexture[];
  52252. protected _emissiveTextureAndColor: {
  52253. texture: Nullable<BaseTexture>;
  52254. color: Color4;
  52255. };
  52256. /**
  52257. * The name of the layer
  52258. */
  52259. name: string;
  52260. /**
  52261. * The clear color of the texture used to generate the glow map.
  52262. */
  52263. neutralColor: Color4;
  52264. /**
  52265. * Specifies wether the highlight layer is enabled or not.
  52266. */
  52267. isEnabled: boolean;
  52268. /**
  52269. * Gets the camera attached to the layer.
  52270. */
  52271. readonly camera: Nullable<Camera>;
  52272. /**
  52273. * Gets the rendering group id the layer should render in.
  52274. */
  52275. renderingGroupId: number;
  52276. /**
  52277. * An event triggered when the effect layer has been disposed.
  52278. */
  52279. onDisposeObservable: Observable<EffectLayer>;
  52280. /**
  52281. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52282. */
  52283. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52284. /**
  52285. * An event triggered when the generated texture is being merged in the scene.
  52286. */
  52287. onBeforeComposeObservable: Observable<EffectLayer>;
  52288. /**
  52289. * An event triggered when the mesh is rendered into the effect render target.
  52290. */
  52291. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52292. /**
  52293. * An event triggered after the mesh has been rendered into the effect render target.
  52294. */
  52295. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52296. /**
  52297. * An event triggered when the generated texture has been merged in the scene.
  52298. */
  52299. onAfterComposeObservable: Observable<EffectLayer>;
  52300. /**
  52301. * An event triggered when the efffect layer changes its size.
  52302. */
  52303. onSizeChangedObservable: Observable<EffectLayer>;
  52304. /** @hidden */
  52305. static _SceneComponentInitialization: (scene: Scene) => void;
  52306. /**
  52307. * Instantiates a new effect Layer and references it in the scene.
  52308. * @param name The name of the layer
  52309. * @param scene The scene to use the layer in
  52310. */
  52311. constructor(
  52312. /** The Friendly of the effect in the scene */
  52313. name: string, scene: Scene);
  52314. /**
  52315. * Get the effect name of the layer.
  52316. * @return The effect name
  52317. */
  52318. abstract getEffectName(): string;
  52319. /**
  52320. * Checks for the readiness of the element composing the layer.
  52321. * @param subMesh the mesh to check for
  52322. * @param useInstances specify wether or not to use instances to render the mesh
  52323. * @return true if ready otherwise, false
  52324. */
  52325. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52326. /**
  52327. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52328. * @returns true if the effect requires stencil during the main canvas render pass.
  52329. */
  52330. abstract needStencil(): boolean;
  52331. /**
  52332. * Create the merge effect. This is the shader use to blit the information back
  52333. * to the main canvas at the end of the scene rendering.
  52334. * @returns The effect containing the shader used to merge the effect on the main canvas
  52335. */
  52336. protected abstract _createMergeEffect(): Effect;
  52337. /**
  52338. * Creates the render target textures and post processes used in the effect layer.
  52339. */
  52340. protected abstract _createTextureAndPostProcesses(): void;
  52341. /**
  52342. * Implementation specific of rendering the generating effect on the main canvas.
  52343. * @param effect The effect used to render through
  52344. */
  52345. protected abstract _internalRender(effect: Effect): void;
  52346. /**
  52347. * Sets the required values for both the emissive texture and and the main color.
  52348. */
  52349. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52350. /**
  52351. * Free any resources and references associated to a mesh.
  52352. * Internal use
  52353. * @param mesh The mesh to free.
  52354. */
  52355. abstract _disposeMesh(mesh: Mesh): void;
  52356. /**
  52357. * Serializes this layer (Glow or Highlight for example)
  52358. * @returns a serialized layer object
  52359. */
  52360. abstract serialize?(): any;
  52361. /**
  52362. * Initializes the effect layer with the required options.
  52363. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52364. */
  52365. protected _init(options: Partial<IEffectLayerOptions>): void;
  52366. /**
  52367. * Generates the index buffer of the full screen quad blending to the main canvas.
  52368. */
  52369. private _generateIndexBuffer;
  52370. /**
  52371. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52372. */
  52373. private _generateVertexBuffer;
  52374. /**
  52375. * Sets the main texture desired size which is the closest power of two
  52376. * of the engine canvas size.
  52377. */
  52378. private _setMainTextureSize;
  52379. /**
  52380. * Creates the main texture for the effect layer.
  52381. */
  52382. protected _createMainTexture(): void;
  52383. /**
  52384. * Adds specific effects defines.
  52385. * @param defines The defines to add specifics to.
  52386. */
  52387. protected _addCustomEffectDefines(defines: string[]): void;
  52388. /**
  52389. * Checks for the readiness of the element composing the layer.
  52390. * @param subMesh the mesh to check for
  52391. * @param useInstances specify wether or not to use instances to render the mesh
  52392. * @param emissiveTexture the associated emissive texture used to generate the glow
  52393. * @return true if ready otherwise, false
  52394. */
  52395. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52396. /**
  52397. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52398. */
  52399. render(): void;
  52400. /**
  52401. * Determine if a given mesh will be used in the current effect.
  52402. * @param mesh mesh to test
  52403. * @returns true if the mesh will be used
  52404. */
  52405. hasMesh(mesh: AbstractMesh): boolean;
  52406. /**
  52407. * Returns true if the layer contains information to display, otherwise false.
  52408. * @returns true if the glow layer should be rendered
  52409. */
  52410. shouldRender(): boolean;
  52411. /**
  52412. * Returns true if the mesh should render, otherwise false.
  52413. * @param mesh The mesh to render
  52414. * @returns true if it should render otherwise false
  52415. */
  52416. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52417. /**
  52418. * Returns true if the mesh can be rendered, otherwise false.
  52419. * @param mesh The mesh to render
  52420. * @param material The material used on the mesh
  52421. * @returns true if it can be rendered otherwise false
  52422. */
  52423. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52424. /**
  52425. * Returns true if the mesh should render, otherwise false.
  52426. * @param mesh The mesh to render
  52427. * @returns true if it should render otherwise false
  52428. */
  52429. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52430. /**
  52431. * Renders the submesh passed in parameter to the generation map.
  52432. */
  52433. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52434. /**
  52435. * Defines wether the current material of the mesh should be use to render the effect.
  52436. * @param mesh defines the current mesh to render
  52437. */
  52438. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52439. /**
  52440. * Rebuild the required buffers.
  52441. * @hidden Internal use only.
  52442. */
  52443. _rebuild(): void;
  52444. /**
  52445. * Dispose only the render target textures and post process.
  52446. */
  52447. private _disposeTextureAndPostProcesses;
  52448. /**
  52449. * Dispose the highlight layer and free resources.
  52450. */
  52451. dispose(): void;
  52452. /**
  52453. * Gets the class name of the effect layer
  52454. * @returns the string with the class name of the effect layer
  52455. */
  52456. getClassName(): string;
  52457. /**
  52458. * Creates an effect layer from parsed effect layer data
  52459. * @param parsedEffectLayer defines effect layer data
  52460. * @param scene defines the current scene
  52461. * @param rootUrl defines the root URL containing the effect layer information
  52462. * @returns a parsed effect Layer
  52463. */
  52464. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52465. }
  52466. }
  52467. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52468. import { Scene } from "babylonjs/scene";
  52469. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52470. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52471. import { AbstractScene } from "babylonjs/abstractScene";
  52472. module "babylonjs/abstractScene" {
  52473. interface AbstractScene {
  52474. /**
  52475. * The list of effect layers (highlights/glow) added to the scene
  52476. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52477. * @see http://doc.babylonjs.com/how_to/glow_layer
  52478. */
  52479. effectLayers: Array<EffectLayer>;
  52480. /**
  52481. * Removes the given effect layer from this scene.
  52482. * @param toRemove defines the effect layer to remove
  52483. * @returns the index of the removed effect layer
  52484. */
  52485. removeEffectLayer(toRemove: EffectLayer): number;
  52486. /**
  52487. * Adds the given effect layer to this scene
  52488. * @param newEffectLayer defines the effect layer to add
  52489. */
  52490. addEffectLayer(newEffectLayer: EffectLayer): void;
  52491. }
  52492. }
  52493. /**
  52494. * Defines the layer scene component responsible to manage any effect layers
  52495. * in a given scene.
  52496. */
  52497. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52498. /**
  52499. * The component name helpfull to identify the component in the list of scene components.
  52500. */
  52501. readonly name: string;
  52502. /**
  52503. * The scene the component belongs to.
  52504. */
  52505. scene: Scene;
  52506. private _engine;
  52507. private _renderEffects;
  52508. private _needStencil;
  52509. private _previousStencilState;
  52510. /**
  52511. * Creates a new instance of the component for the given scene
  52512. * @param scene Defines the scene to register the component in
  52513. */
  52514. constructor(scene: Scene);
  52515. /**
  52516. * Registers the component in a given scene
  52517. */
  52518. register(): void;
  52519. /**
  52520. * Rebuilds the elements related to this component in case of
  52521. * context lost for instance.
  52522. */
  52523. rebuild(): void;
  52524. /**
  52525. * Serializes the component data to the specified json object
  52526. * @param serializationObject The object to serialize to
  52527. */
  52528. serialize(serializationObject: any): void;
  52529. /**
  52530. * Adds all the elements from the container to the scene
  52531. * @param container the container holding the elements
  52532. */
  52533. addFromContainer(container: AbstractScene): void;
  52534. /**
  52535. * Removes all the elements in the container from the scene
  52536. * @param container contains the elements to remove
  52537. * @param dispose if the removed element should be disposed (default: false)
  52538. */
  52539. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52540. /**
  52541. * Disposes the component and the associated ressources.
  52542. */
  52543. dispose(): void;
  52544. private _isReadyForMesh;
  52545. private _renderMainTexture;
  52546. private _setStencil;
  52547. private _setStencilBack;
  52548. private _draw;
  52549. private _drawCamera;
  52550. private _drawRenderingGroup;
  52551. }
  52552. }
  52553. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52554. /** @hidden */
  52555. export var glowMapMergePixelShader: {
  52556. name: string;
  52557. shader: string;
  52558. };
  52559. }
  52560. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52561. /** @hidden */
  52562. export var glowMapMergeVertexShader: {
  52563. name: string;
  52564. shader: string;
  52565. };
  52566. }
  52567. declare module "babylonjs/Layers/glowLayer" {
  52568. import { Nullable } from "babylonjs/types";
  52569. import { Camera } from "babylonjs/Cameras/camera";
  52570. import { Scene } from "babylonjs/scene";
  52571. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52573. import { Mesh } from "babylonjs/Meshes/mesh";
  52574. import { Texture } from "babylonjs/Materials/Textures/texture";
  52575. import { Effect } from "babylonjs/Materials/effect";
  52576. import { Material } from "babylonjs/Materials/material";
  52577. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52578. import { Color4 } from "babylonjs/Maths/math.color";
  52579. import "babylonjs/Shaders/glowMapMerge.fragment";
  52580. import "babylonjs/Shaders/glowMapMerge.vertex";
  52581. import "babylonjs/Layers/effectLayerSceneComponent";
  52582. module "babylonjs/abstractScene" {
  52583. interface AbstractScene {
  52584. /**
  52585. * Return a the first highlight layer of the scene with a given name.
  52586. * @param name The name of the highlight layer to look for.
  52587. * @return The highlight layer if found otherwise null.
  52588. */
  52589. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52590. }
  52591. }
  52592. /**
  52593. * Glow layer options. This helps customizing the behaviour
  52594. * of the glow layer.
  52595. */
  52596. export interface IGlowLayerOptions {
  52597. /**
  52598. * Multiplication factor apply to the canvas size to compute the render target size
  52599. * used to generated the glowing objects (the smaller the faster).
  52600. */
  52601. mainTextureRatio: number;
  52602. /**
  52603. * Enforces a fixed size texture to ensure resize independant blur.
  52604. */
  52605. mainTextureFixedSize?: number;
  52606. /**
  52607. * How big is the kernel of the blur texture.
  52608. */
  52609. blurKernelSize: number;
  52610. /**
  52611. * The camera attached to the layer.
  52612. */
  52613. camera: Nullable<Camera>;
  52614. /**
  52615. * Enable MSAA by chosing the number of samples.
  52616. */
  52617. mainTextureSamples?: number;
  52618. /**
  52619. * The rendering group to draw the layer in.
  52620. */
  52621. renderingGroupId: number;
  52622. }
  52623. /**
  52624. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52625. *
  52626. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52627. *
  52628. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52629. */
  52630. export class GlowLayer extends EffectLayer {
  52631. /**
  52632. * Effect Name of the layer.
  52633. */
  52634. static readonly EffectName: string;
  52635. /**
  52636. * The default blur kernel size used for the glow.
  52637. */
  52638. static DefaultBlurKernelSize: number;
  52639. /**
  52640. * The default texture size ratio used for the glow.
  52641. */
  52642. static DefaultTextureRatio: number;
  52643. /**
  52644. * Sets the kernel size of the blur.
  52645. */
  52646. /**
  52647. * Gets the kernel size of the blur.
  52648. */
  52649. blurKernelSize: number;
  52650. /**
  52651. * Sets the glow intensity.
  52652. */
  52653. /**
  52654. * Gets the glow intensity.
  52655. */
  52656. intensity: number;
  52657. private _options;
  52658. private _intensity;
  52659. private _horizontalBlurPostprocess1;
  52660. private _verticalBlurPostprocess1;
  52661. private _horizontalBlurPostprocess2;
  52662. private _verticalBlurPostprocess2;
  52663. private _blurTexture1;
  52664. private _blurTexture2;
  52665. private _postProcesses1;
  52666. private _postProcesses2;
  52667. private _includedOnlyMeshes;
  52668. private _excludedMeshes;
  52669. private _meshesUsingTheirOwnMaterials;
  52670. /**
  52671. * Callback used to let the user override the color selection on a per mesh basis
  52672. */
  52673. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52674. /**
  52675. * Callback used to let the user override the texture selection on a per mesh basis
  52676. */
  52677. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52678. /**
  52679. * Instantiates a new glow Layer and references it to the scene.
  52680. * @param name The name of the layer
  52681. * @param scene The scene to use the layer in
  52682. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52683. */
  52684. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52685. /**
  52686. * Get the effect name of the layer.
  52687. * @return The effect name
  52688. */
  52689. getEffectName(): string;
  52690. /**
  52691. * Create the merge effect. This is the shader use to blit the information back
  52692. * to the main canvas at the end of the scene rendering.
  52693. */
  52694. protected _createMergeEffect(): Effect;
  52695. /**
  52696. * Creates the render target textures and post processes used in the glow layer.
  52697. */
  52698. protected _createTextureAndPostProcesses(): void;
  52699. /**
  52700. * Checks for the readiness of the element composing the layer.
  52701. * @param subMesh the mesh to check for
  52702. * @param useInstances specify wether or not to use instances to render the mesh
  52703. * @param emissiveTexture the associated emissive texture used to generate the glow
  52704. * @return true if ready otherwise, false
  52705. */
  52706. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52707. /**
  52708. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52709. */
  52710. needStencil(): boolean;
  52711. /**
  52712. * Returns true if the mesh can be rendered, otherwise false.
  52713. * @param mesh The mesh to render
  52714. * @param material The material used on the mesh
  52715. * @returns true if it can be rendered otherwise false
  52716. */
  52717. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52718. /**
  52719. * Implementation specific of rendering the generating effect on the main canvas.
  52720. * @param effect The effect used to render through
  52721. */
  52722. protected _internalRender(effect: Effect): void;
  52723. /**
  52724. * Sets the required values for both the emissive texture and and the main color.
  52725. */
  52726. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52727. /**
  52728. * Returns true if the mesh should render, otherwise false.
  52729. * @param mesh The mesh to render
  52730. * @returns true if it should render otherwise false
  52731. */
  52732. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52733. /**
  52734. * Adds specific effects defines.
  52735. * @param defines The defines to add specifics to.
  52736. */
  52737. protected _addCustomEffectDefines(defines: string[]): void;
  52738. /**
  52739. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52740. * @param mesh The mesh to exclude from the glow layer
  52741. */
  52742. addExcludedMesh(mesh: Mesh): void;
  52743. /**
  52744. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52745. * @param mesh The mesh to remove
  52746. */
  52747. removeExcludedMesh(mesh: Mesh): void;
  52748. /**
  52749. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52750. * @param mesh The mesh to include in the glow layer
  52751. */
  52752. addIncludedOnlyMesh(mesh: Mesh): void;
  52753. /**
  52754. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52755. * @param mesh The mesh to remove
  52756. */
  52757. removeIncludedOnlyMesh(mesh: Mesh): void;
  52758. /**
  52759. * Determine if a given mesh will be used in the glow layer
  52760. * @param mesh The mesh to test
  52761. * @returns true if the mesh will be highlighted by the current glow layer
  52762. */
  52763. hasMesh(mesh: AbstractMesh): boolean;
  52764. /**
  52765. * Defines wether the current material of the mesh should be use to render the effect.
  52766. * @param mesh defines the current mesh to render
  52767. */
  52768. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52769. /**
  52770. * Add a mesh to be rendered through its own material and not with emissive only.
  52771. * @param mesh The mesh for which we need to use its material
  52772. */
  52773. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52774. /**
  52775. * Remove a mesh from being rendered through its own material and not with emissive only.
  52776. * @param mesh The mesh for which we need to not use its material
  52777. */
  52778. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52779. /**
  52780. * Free any resources and references associated to a mesh.
  52781. * Internal use
  52782. * @param mesh The mesh to free.
  52783. * @hidden
  52784. */
  52785. _disposeMesh(mesh: Mesh): void;
  52786. /**
  52787. * Gets the class name of the effect layer
  52788. * @returns the string with the class name of the effect layer
  52789. */
  52790. getClassName(): string;
  52791. /**
  52792. * Serializes this glow layer
  52793. * @returns a serialized glow layer object
  52794. */
  52795. serialize(): any;
  52796. /**
  52797. * Creates a Glow Layer from parsed glow layer data
  52798. * @param parsedGlowLayer defines glow layer data
  52799. * @param scene defines the current scene
  52800. * @param rootUrl defines the root URL containing the glow layer information
  52801. * @returns a parsed Glow Layer
  52802. */
  52803. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52804. }
  52805. }
  52806. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52807. /** @hidden */
  52808. export var glowBlurPostProcessPixelShader: {
  52809. name: string;
  52810. shader: string;
  52811. };
  52812. }
  52813. declare module "babylonjs/Layers/highlightLayer" {
  52814. import { Observable } from "babylonjs/Misc/observable";
  52815. import { Nullable } from "babylonjs/types";
  52816. import { Camera } from "babylonjs/Cameras/camera";
  52817. import { Scene } from "babylonjs/scene";
  52818. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52820. import { Mesh } from "babylonjs/Meshes/mesh";
  52821. import { Effect } from "babylonjs/Materials/effect";
  52822. import { Material } from "babylonjs/Materials/material";
  52823. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52824. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52825. import "babylonjs/Shaders/glowMapMerge.fragment";
  52826. import "babylonjs/Shaders/glowMapMerge.vertex";
  52827. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52828. module "babylonjs/abstractScene" {
  52829. interface AbstractScene {
  52830. /**
  52831. * Return a the first highlight layer of the scene with a given name.
  52832. * @param name The name of the highlight layer to look for.
  52833. * @return The highlight layer if found otherwise null.
  52834. */
  52835. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52836. }
  52837. }
  52838. /**
  52839. * Highlight layer options. This helps customizing the behaviour
  52840. * of the highlight layer.
  52841. */
  52842. export interface IHighlightLayerOptions {
  52843. /**
  52844. * Multiplication factor apply to the canvas size to compute the render target size
  52845. * used to generated the glowing objects (the smaller the faster).
  52846. */
  52847. mainTextureRatio: number;
  52848. /**
  52849. * Enforces a fixed size texture to ensure resize independant blur.
  52850. */
  52851. mainTextureFixedSize?: number;
  52852. /**
  52853. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52854. * of the picture to blur (the smaller the faster).
  52855. */
  52856. blurTextureSizeRatio: number;
  52857. /**
  52858. * How big in texel of the blur texture is the vertical blur.
  52859. */
  52860. blurVerticalSize: number;
  52861. /**
  52862. * How big in texel of the blur texture is the horizontal blur.
  52863. */
  52864. blurHorizontalSize: number;
  52865. /**
  52866. * Alpha blending mode used to apply the blur. Default is combine.
  52867. */
  52868. alphaBlendingMode: number;
  52869. /**
  52870. * The camera attached to the layer.
  52871. */
  52872. camera: Nullable<Camera>;
  52873. /**
  52874. * Should we display highlight as a solid stroke?
  52875. */
  52876. isStroke?: boolean;
  52877. /**
  52878. * The rendering group to draw the layer in.
  52879. */
  52880. renderingGroupId: number;
  52881. }
  52882. /**
  52883. * The highlight layer Helps adding a glow effect around a mesh.
  52884. *
  52885. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52886. * glowy meshes to your scene.
  52887. *
  52888. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52889. */
  52890. export class HighlightLayer extends EffectLayer {
  52891. name: string;
  52892. /**
  52893. * Effect Name of the highlight layer.
  52894. */
  52895. static readonly EffectName: string;
  52896. /**
  52897. * The neutral color used during the preparation of the glow effect.
  52898. * This is black by default as the blend operation is a blend operation.
  52899. */
  52900. static NeutralColor: Color4;
  52901. /**
  52902. * Stencil value used for glowing meshes.
  52903. */
  52904. static GlowingMeshStencilReference: number;
  52905. /**
  52906. * Stencil value used for the other meshes in the scene.
  52907. */
  52908. static NormalMeshStencilReference: number;
  52909. /**
  52910. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52911. */
  52912. innerGlow: boolean;
  52913. /**
  52914. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52915. */
  52916. outerGlow: boolean;
  52917. /**
  52918. * Specifies the horizontal size of the blur.
  52919. */
  52920. /**
  52921. * Gets the horizontal size of the blur.
  52922. */
  52923. blurHorizontalSize: number;
  52924. /**
  52925. * Specifies the vertical size of the blur.
  52926. */
  52927. /**
  52928. * Gets the vertical size of the blur.
  52929. */
  52930. blurVerticalSize: number;
  52931. /**
  52932. * An event triggered when the highlight layer is being blurred.
  52933. */
  52934. onBeforeBlurObservable: Observable<HighlightLayer>;
  52935. /**
  52936. * An event triggered when the highlight layer has been blurred.
  52937. */
  52938. onAfterBlurObservable: Observable<HighlightLayer>;
  52939. private _instanceGlowingMeshStencilReference;
  52940. private _options;
  52941. private _downSamplePostprocess;
  52942. private _horizontalBlurPostprocess;
  52943. private _verticalBlurPostprocess;
  52944. private _blurTexture;
  52945. private _meshes;
  52946. private _excludedMeshes;
  52947. /**
  52948. * Instantiates a new highlight Layer and references it to the scene..
  52949. * @param name The name of the layer
  52950. * @param scene The scene to use the layer in
  52951. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52952. */
  52953. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52954. /**
  52955. * Get the effect name of the layer.
  52956. * @return The effect name
  52957. */
  52958. getEffectName(): string;
  52959. /**
  52960. * Create the merge effect. This is the shader use to blit the information back
  52961. * to the main canvas at the end of the scene rendering.
  52962. */
  52963. protected _createMergeEffect(): Effect;
  52964. /**
  52965. * Creates the render target textures and post processes used in the highlight layer.
  52966. */
  52967. protected _createTextureAndPostProcesses(): void;
  52968. /**
  52969. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52970. */
  52971. needStencil(): boolean;
  52972. /**
  52973. * Checks for the readiness of the element composing the layer.
  52974. * @param subMesh the mesh to check for
  52975. * @param useInstances specify wether or not to use instances to render the mesh
  52976. * @param emissiveTexture the associated emissive texture used to generate the glow
  52977. * @return true if ready otherwise, false
  52978. */
  52979. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52980. /**
  52981. * Implementation specific of rendering the generating effect on the main canvas.
  52982. * @param effect The effect used to render through
  52983. */
  52984. protected _internalRender(effect: Effect): void;
  52985. /**
  52986. * Returns true if the layer contains information to display, otherwise false.
  52987. */
  52988. shouldRender(): boolean;
  52989. /**
  52990. * Returns true if the mesh should render, otherwise false.
  52991. * @param mesh The mesh to render
  52992. * @returns true if it should render otherwise false
  52993. */
  52994. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52995. /**
  52996. * Sets the required values for both the emissive texture and and the main color.
  52997. */
  52998. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52999. /**
  53000. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53001. * @param mesh The mesh to exclude from the highlight layer
  53002. */
  53003. addExcludedMesh(mesh: Mesh): void;
  53004. /**
  53005. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53006. * @param mesh The mesh to highlight
  53007. */
  53008. removeExcludedMesh(mesh: Mesh): void;
  53009. /**
  53010. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53011. * @param mesh mesh to test
  53012. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53013. */
  53014. hasMesh(mesh: AbstractMesh): boolean;
  53015. /**
  53016. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53017. * @param mesh The mesh to highlight
  53018. * @param color The color of the highlight
  53019. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53020. */
  53021. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53022. /**
  53023. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53024. * @param mesh The mesh to highlight
  53025. */
  53026. removeMesh(mesh: Mesh): void;
  53027. /**
  53028. * Force the stencil to the normal expected value for none glowing parts
  53029. */
  53030. private _defaultStencilReference;
  53031. /**
  53032. * Free any resources and references associated to a mesh.
  53033. * Internal use
  53034. * @param mesh The mesh to free.
  53035. * @hidden
  53036. */
  53037. _disposeMesh(mesh: Mesh): void;
  53038. /**
  53039. * Dispose the highlight layer and free resources.
  53040. */
  53041. dispose(): void;
  53042. /**
  53043. * Gets the class name of the effect layer
  53044. * @returns the string with the class name of the effect layer
  53045. */
  53046. getClassName(): string;
  53047. /**
  53048. * Serializes this Highlight layer
  53049. * @returns a serialized Highlight layer object
  53050. */
  53051. serialize(): any;
  53052. /**
  53053. * Creates a Highlight layer from parsed Highlight layer data
  53054. * @param parsedHightlightLayer defines the Highlight layer data
  53055. * @param scene defines the current scene
  53056. * @param rootUrl defines the root URL containing the Highlight layer information
  53057. * @returns a parsed Highlight layer
  53058. */
  53059. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53060. }
  53061. }
  53062. declare module "babylonjs/Layers/layerSceneComponent" {
  53063. import { Scene } from "babylonjs/scene";
  53064. import { ISceneComponent } from "babylonjs/sceneComponent";
  53065. import { Layer } from "babylonjs/Layers/layer";
  53066. import { AbstractScene } from "babylonjs/abstractScene";
  53067. module "babylonjs/abstractScene" {
  53068. interface AbstractScene {
  53069. /**
  53070. * The list of layers (background and foreground) of the scene
  53071. */
  53072. layers: Array<Layer>;
  53073. }
  53074. }
  53075. /**
  53076. * Defines the layer scene component responsible to manage any layers
  53077. * in a given scene.
  53078. */
  53079. export class LayerSceneComponent implements ISceneComponent {
  53080. /**
  53081. * The component name helpfull to identify the component in the list of scene components.
  53082. */
  53083. readonly name: string;
  53084. /**
  53085. * The scene the component belongs to.
  53086. */
  53087. scene: Scene;
  53088. private _engine;
  53089. /**
  53090. * Creates a new instance of the component for the given scene
  53091. * @param scene Defines the scene to register the component in
  53092. */
  53093. constructor(scene: Scene);
  53094. /**
  53095. * Registers the component in a given scene
  53096. */
  53097. register(): void;
  53098. /**
  53099. * Rebuilds the elements related to this component in case of
  53100. * context lost for instance.
  53101. */
  53102. rebuild(): void;
  53103. /**
  53104. * Disposes the component and the associated ressources.
  53105. */
  53106. dispose(): void;
  53107. private _draw;
  53108. private _drawCameraPredicate;
  53109. private _drawCameraBackground;
  53110. private _drawCameraForeground;
  53111. private _drawRenderTargetPredicate;
  53112. private _drawRenderTargetBackground;
  53113. private _drawRenderTargetForeground;
  53114. /**
  53115. * Adds all the elements from the container to the scene
  53116. * @param container the container holding the elements
  53117. */
  53118. addFromContainer(container: AbstractScene): void;
  53119. /**
  53120. * Removes all the elements in the container from the scene
  53121. * @param container contains the elements to remove
  53122. * @param dispose if the removed element should be disposed (default: false)
  53123. */
  53124. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53125. }
  53126. }
  53127. declare module "babylonjs/Shaders/layer.fragment" {
  53128. /** @hidden */
  53129. export var layerPixelShader: {
  53130. name: string;
  53131. shader: string;
  53132. };
  53133. }
  53134. declare module "babylonjs/Shaders/layer.vertex" {
  53135. /** @hidden */
  53136. export var layerVertexShader: {
  53137. name: string;
  53138. shader: string;
  53139. };
  53140. }
  53141. declare module "babylonjs/Layers/layer" {
  53142. import { Observable } from "babylonjs/Misc/observable";
  53143. import { Nullable } from "babylonjs/types";
  53144. import { Scene } from "babylonjs/scene";
  53145. import { Vector2 } from "babylonjs/Maths/math.vector";
  53146. import { Color4 } from "babylonjs/Maths/math.color";
  53147. import { Texture } from "babylonjs/Materials/Textures/texture";
  53148. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53149. import "babylonjs/Shaders/layer.fragment";
  53150. import "babylonjs/Shaders/layer.vertex";
  53151. /**
  53152. * This represents a full screen 2d layer.
  53153. * This can be useful to display a picture in the background of your scene for instance.
  53154. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53155. */
  53156. export class Layer {
  53157. /**
  53158. * Define the name of the layer.
  53159. */
  53160. name: string;
  53161. /**
  53162. * Define the texture the layer should display.
  53163. */
  53164. texture: Nullable<Texture>;
  53165. /**
  53166. * Is the layer in background or foreground.
  53167. */
  53168. isBackground: boolean;
  53169. /**
  53170. * Define the color of the layer (instead of texture).
  53171. */
  53172. color: Color4;
  53173. /**
  53174. * Define the scale of the layer in order to zoom in out of the texture.
  53175. */
  53176. scale: Vector2;
  53177. /**
  53178. * Define an offset for the layer in order to shift the texture.
  53179. */
  53180. offset: Vector2;
  53181. /**
  53182. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53183. */
  53184. alphaBlendingMode: number;
  53185. /**
  53186. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53187. * Alpha test will not mix with the background color in case of transparency.
  53188. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53189. */
  53190. alphaTest: boolean;
  53191. /**
  53192. * Define a mask to restrict the layer to only some of the scene cameras.
  53193. */
  53194. layerMask: number;
  53195. /**
  53196. * Define the list of render target the layer is visible into.
  53197. */
  53198. renderTargetTextures: RenderTargetTexture[];
  53199. /**
  53200. * Define if the layer is only used in renderTarget or if it also
  53201. * renders in the main frame buffer of the canvas.
  53202. */
  53203. renderOnlyInRenderTargetTextures: boolean;
  53204. private _scene;
  53205. private _vertexBuffers;
  53206. private _indexBuffer;
  53207. private _effect;
  53208. private _alphaTestEffect;
  53209. /**
  53210. * An event triggered when the layer is disposed.
  53211. */
  53212. onDisposeObservable: Observable<Layer>;
  53213. private _onDisposeObserver;
  53214. /**
  53215. * Back compatibility with callback before the onDisposeObservable existed.
  53216. * The set callback will be triggered when the layer has been disposed.
  53217. */
  53218. onDispose: () => void;
  53219. /**
  53220. * An event triggered before rendering the scene
  53221. */
  53222. onBeforeRenderObservable: Observable<Layer>;
  53223. private _onBeforeRenderObserver;
  53224. /**
  53225. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53226. * The set callback will be triggered just before rendering the layer.
  53227. */
  53228. onBeforeRender: () => void;
  53229. /**
  53230. * An event triggered after rendering the scene
  53231. */
  53232. onAfterRenderObservable: Observable<Layer>;
  53233. private _onAfterRenderObserver;
  53234. /**
  53235. * Back compatibility with callback before the onAfterRenderObservable existed.
  53236. * The set callback will be triggered just after rendering the layer.
  53237. */
  53238. onAfterRender: () => void;
  53239. /**
  53240. * Instantiates a new layer.
  53241. * This represents a full screen 2d layer.
  53242. * This can be useful to display a picture in the background of your scene for instance.
  53243. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53244. * @param name Define the name of the layer in the scene
  53245. * @param imgUrl Define the url of the texture to display in the layer
  53246. * @param scene Define the scene the layer belongs to
  53247. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53248. * @param color Defines a color for the layer
  53249. */
  53250. constructor(
  53251. /**
  53252. * Define the name of the layer.
  53253. */
  53254. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53255. private _createIndexBuffer;
  53256. /** @hidden */
  53257. _rebuild(): void;
  53258. /**
  53259. * Renders the layer in the scene.
  53260. */
  53261. render(): void;
  53262. /**
  53263. * Disposes and releases the associated ressources.
  53264. */
  53265. dispose(): void;
  53266. }
  53267. }
  53268. declare module "babylonjs/Layers/index" {
  53269. export * from "babylonjs/Layers/effectLayer";
  53270. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53271. export * from "babylonjs/Layers/glowLayer";
  53272. export * from "babylonjs/Layers/highlightLayer";
  53273. export * from "babylonjs/Layers/layer";
  53274. export * from "babylonjs/Layers/layerSceneComponent";
  53275. }
  53276. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53277. /** @hidden */
  53278. export var lensFlarePixelShader: {
  53279. name: string;
  53280. shader: string;
  53281. };
  53282. }
  53283. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53284. /** @hidden */
  53285. export var lensFlareVertexShader: {
  53286. name: string;
  53287. shader: string;
  53288. };
  53289. }
  53290. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53291. import { Scene } from "babylonjs/scene";
  53292. import { Vector3 } from "babylonjs/Maths/math.vector";
  53293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53294. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53295. import "babylonjs/Shaders/lensFlare.fragment";
  53296. import "babylonjs/Shaders/lensFlare.vertex";
  53297. import { Viewport } from "babylonjs/Maths/math.viewport";
  53298. /**
  53299. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53300. * It is usually composed of several `lensFlare`.
  53301. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53302. */
  53303. export class LensFlareSystem {
  53304. /**
  53305. * Define the name of the lens flare system
  53306. */
  53307. name: string;
  53308. /**
  53309. * List of lens flares used in this system.
  53310. */
  53311. lensFlares: LensFlare[];
  53312. /**
  53313. * Define a limit from the border the lens flare can be visible.
  53314. */
  53315. borderLimit: number;
  53316. /**
  53317. * Define a viewport border we do not want to see the lens flare in.
  53318. */
  53319. viewportBorder: number;
  53320. /**
  53321. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53322. */
  53323. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53324. /**
  53325. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53326. */
  53327. layerMask: number;
  53328. /**
  53329. * Define the id of the lens flare system in the scene.
  53330. * (equal to name by default)
  53331. */
  53332. id: string;
  53333. private _scene;
  53334. private _emitter;
  53335. private _vertexBuffers;
  53336. private _indexBuffer;
  53337. private _effect;
  53338. private _positionX;
  53339. private _positionY;
  53340. private _isEnabled;
  53341. /** @hidden */
  53342. static _SceneComponentInitialization: (scene: Scene) => void;
  53343. /**
  53344. * Instantiates a lens flare system.
  53345. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53346. * It is usually composed of several `lensFlare`.
  53347. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53348. * @param name Define the name of the lens flare system in the scene
  53349. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53350. * @param scene Define the scene the lens flare system belongs to
  53351. */
  53352. constructor(
  53353. /**
  53354. * Define the name of the lens flare system
  53355. */
  53356. name: string, emitter: any, scene: Scene);
  53357. /**
  53358. * Define if the lens flare system is enabled.
  53359. */
  53360. isEnabled: boolean;
  53361. /**
  53362. * Get the scene the effects belongs to.
  53363. * @returns the scene holding the lens flare system
  53364. */
  53365. getScene(): Scene;
  53366. /**
  53367. * Get the emitter of the lens flare system.
  53368. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53369. * @returns the emitter of the lens flare system
  53370. */
  53371. getEmitter(): any;
  53372. /**
  53373. * Set the emitter of the lens flare system.
  53374. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53375. * @param newEmitter Define the new emitter of the system
  53376. */
  53377. setEmitter(newEmitter: any): void;
  53378. /**
  53379. * Get the lens flare system emitter position.
  53380. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53381. * @returns the position
  53382. */
  53383. getEmitterPosition(): Vector3;
  53384. /**
  53385. * @hidden
  53386. */
  53387. computeEffectivePosition(globalViewport: Viewport): boolean;
  53388. /** @hidden */
  53389. _isVisible(): boolean;
  53390. /**
  53391. * @hidden
  53392. */
  53393. render(): boolean;
  53394. /**
  53395. * Dispose and release the lens flare with its associated resources.
  53396. */
  53397. dispose(): void;
  53398. /**
  53399. * Parse a lens flare system from a JSON repressentation
  53400. * @param parsedLensFlareSystem Define the JSON to parse
  53401. * @param scene Define the scene the parsed system should be instantiated in
  53402. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53403. * @returns the parsed system
  53404. */
  53405. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53406. /**
  53407. * Serialize the current Lens Flare System into a JSON representation.
  53408. * @returns the serialized JSON
  53409. */
  53410. serialize(): any;
  53411. }
  53412. }
  53413. declare module "babylonjs/LensFlares/lensFlare" {
  53414. import { Nullable } from "babylonjs/types";
  53415. import { Color3 } from "babylonjs/Maths/math.color";
  53416. import { Texture } from "babylonjs/Materials/Textures/texture";
  53417. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53418. /**
  53419. * This represents one of the lens effect in a `lensFlareSystem`.
  53420. * It controls one of the indiviual texture used in the effect.
  53421. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53422. */
  53423. export class LensFlare {
  53424. /**
  53425. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53426. */
  53427. size: number;
  53428. /**
  53429. * 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.
  53430. */
  53431. position: number;
  53432. /**
  53433. * Define the lens color.
  53434. */
  53435. color: Color3;
  53436. /**
  53437. * Define the lens texture.
  53438. */
  53439. texture: Nullable<Texture>;
  53440. /**
  53441. * Define the alpha mode to render this particular lens.
  53442. */
  53443. alphaMode: number;
  53444. private _system;
  53445. /**
  53446. * Creates a new Lens Flare.
  53447. * This represents one of the lens effect in a `lensFlareSystem`.
  53448. * It controls one of the indiviual texture used in the effect.
  53449. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53450. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53451. * @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.
  53452. * @param color Define the lens color
  53453. * @param imgUrl Define the lens texture url
  53454. * @param system Define the `lensFlareSystem` this flare is part of
  53455. * @returns The newly created Lens Flare
  53456. */
  53457. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53458. /**
  53459. * Instantiates a new Lens Flare.
  53460. * This represents one of the lens effect in a `lensFlareSystem`.
  53461. * It controls one of the indiviual texture used in the effect.
  53462. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53463. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53464. * @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.
  53465. * @param color Define the lens color
  53466. * @param imgUrl Define the lens texture url
  53467. * @param system Define the `lensFlareSystem` this flare is part of
  53468. */
  53469. constructor(
  53470. /**
  53471. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53472. */
  53473. size: number,
  53474. /**
  53475. * 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.
  53476. */
  53477. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53478. /**
  53479. * Dispose and release the lens flare with its associated resources.
  53480. */
  53481. dispose(): void;
  53482. }
  53483. }
  53484. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53485. import { Nullable } from "babylonjs/types";
  53486. import { Scene } from "babylonjs/scene";
  53487. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53488. import { AbstractScene } from "babylonjs/abstractScene";
  53489. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53490. module "babylonjs/abstractScene" {
  53491. interface AbstractScene {
  53492. /**
  53493. * The list of lens flare system added to the scene
  53494. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53495. */
  53496. lensFlareSystems: Array<LensFlareSystem>;
  53497. /**
  53498. * Removes the given lens flare system from this scene.
  53499. * @param toRemove The lens flare system to remove
  53500. * @returns The index of the removed lens flare system
  53501. */
  53502. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53503. /**
  53504. * Adds the given lens flare system to this scene
  53505. * @param newLensFlareSystem The lens flare system to add
  53506. */
  53507. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53508. /**
  53509. * Gets a lens flare system using its name
  53510. * @param name defines the name to look for
  53511. * @returns the lens flare system or null if not found
  53512. */
  53513. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53514. /**
  53515. * Gets a lens flare system using its id
  53516. * @param id defines the id to look for
  53517. * @returns the lens flare system or null if not found
  53518. */
  53519. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53520. }
  53521. }
  53522. /**
  53523. * Defines the lens flare scene component responsible to manage any lens flares
  53524. * in a given scene.
  53525. */
  53526. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53527. /**
  53528. * The component name helpfull to identify the component in the list of scene components.
  53529. */
  53530. readonly name: string;
  53531. /**
  53532. * The scene the component belongs to.
  53533. */
  53534. scene: Scene;
  53535. /**
  53536. * Creates a new instance of the component for the given scene
  53537. * @param scene Defines the scene to register the component in
  53538. */
  53539. constructor(scene: Scene);
  53540. /**
  53541. * Registers the component in a given scene
  53542. */
  53543. register(): void;
  53544. /**
  53545. * Rebuilds the elements related to this component in case of
  53546. * context lost for instance.
  53547. */
  53548. rebuild(): void;
  53549. /**
  53550. * Adds all the elements from the container to the scene
  53551. * @param container the container holding the elements
  53552. */
  53553. addFromContainer(container: AbstractScene): void;
  53554. /**
  53555. * Removes all the elements in the container from the scene
  53556. * @param container contains the elements to remove
  53557. * @param dispose if the removed element should be disposed (default: false)
  53558. */
  53559. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53560. /**
  53561. * Serializes the component data to the specified json object
  53562. * @param serializationObject The object to serialize to
  53563. */
  53564. serialize(serializationObject: any): void;
  53565. /**
  53566. * Disposes the component and the associated ressources.
  53567. */
  53568. dispose(): void;
  53569. private _draw;
  53570. }
  53571. }
  53572. declare module "babylonjs/LensFlares/index" {
  53573. export * from "babylonjs/LensFlares/lensFlare";
  53574. export * from "babylonjs/LensFlares/lensFlareSystem";
  53575. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53576. }
  53577. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53578. import { Scene } from "babylonjs/scene";
  53579. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53580. import { AbstractScene } from "babylonjs/abstractScene";
  53581. /**
  53582. * Defines the shadow generator component responsible to manage any shadow generators
  53583. * in a given scene.
  53584. */
  53585. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53586. /**
  53587. * The component name helpfull to identify the component in the list of scene components.
  53588. */
  53589. readonly name: string;
  53590. /**
  53591. * The scene the component belongs to.
  53592. */
  53593. scene: Scene;
  53594. /**
  53595. * Creates a new instance of the component for the given scene
  53596. * @param scene Defines the scene to register the component in
  53597. */
  53598. constructor(scene: Scene);
  53599. /**
  53600. * Registers the component in a given scene
  53601. */
  53602. register(): void;
  53603. /**
  53604. * Rebuilds the elements related to this component in case of
  53605. * context lost for instance.
  53606. */
  53607. rebuild(): void;
  53608. /**
  53609. * Serializes the component data to the specified json object
  53610. * @param serializationObject The object to serialize to
  53611. */
  53612. serialize(serializationObject: any): void;
  53613. /**
  53614. * Adds all the elements from the container to the scene
  53615. * @param container the container holding the elements
  53616. */
  53617. addFromContainer(container: AbstractScene): void;
  53618. /**
  53619. * Removes all the elements in the container from the scene
  53620. * @param container contains the elements to remove
  53621. * @param dispose if the removed element should be disposed (default: false)
  53622. */
  53623. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53624. /**
  53625. * Rebuilds the elements related to this component in case of
  53626. * context lost for instance.
  53627. */
  53628. dispose(): void;
  53629. private _gatherRenderTargets;
  53630. }
  53631. }
  53632. declare module "babylonjs/Lights/Shadows/index" {
  53633. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53634. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53635. }
  53636. declare module "babylonjs/Lights/pointLight" {
  53637. import { Scene } from "babylonjs/scene";
  53638. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53640. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53641. import { Effect } from "babylonjs/Materials/effect";
  53642. /**
  53643. * A point light is a light defined by an unique point in world space.
  53644. * The light is emitted in every direction from this point.
  53645. * A good example of a point light is a standard light bulb.
  53646. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53647. */
  53648. export class PointLight extends ShadowLight {
  53649. private _shadowAngle;
  53650. /**
  53651. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53652. * This specifies what angle the shadow will use to be created.
  53653. *
  53654. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53655. */
  53656. /**
  53657. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53658. * This specifies what angle the shadow will use to be created.
  53659. *
  53660. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53661. */
  53662. shadowAngle: number;
  53663. /**
  53664. * Gets the direction if it has been set.
  53665. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53666. */
  53667. /**
  53668. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53669. */
  53670. direction: Vector3;
  53671. /**
  53672. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53673. * A PointLight emits the light in every direction.
  53674. * It can cast shadows.
  53675. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53676. * ```javascript
  53677. * var pointLight = new PointLight("pl", camera.position, scene);
  53678. * ```
  53679. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53680. * @param name The light friendly name
  53681. * @param position The position of the point light in the scene
  53682. * @param scene The scene the lights belongs to
  53683. */
  53684. constructor(name: string, position: Vector3, scene: Scene);
  53685. /**
  53686. * Returns the string "PointLight"
  53687. * @returns the class name
  53688. */
  53689. getClassName(): string;
  53690. /**
  53691. * Returns the integer 0.
  53692. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53693. */
  53694. getTypeID(): number;
  53695. /**
  53696. * Specifies wether or not the shadowmap should be a cube texture.
  53697. * @returns true if the shadowmap needs to be a cube texture.
  53698. */
  53699. needCube(): boolean;
  53700. /**
  53701. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53702. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53703. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53704. */
  53705. getShadowDirection(faceIndex?: number): Vector3;
  53706. /**
  53707. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53708. * - fov = PI / 2
  53709. * - aspect ratio : 1.0
  53710. * - z-near and far equal to the active camera minZ and maxZ.
  53711. * Returns the PointLight.
  53712. */
  53713. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53714. protected _buildUniformLayout(): void;
  53715. /**
  53716. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53717. * @param effect The effect to update
  53718. * @param lightIndex The index of the light in the effect to update
  53719. * @returns The point light
  53720. */
  53721. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53722. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53723. /**
  53724. * Prepares the list of defines specific to the light type.
  53725. * @param defines the list of defines
  53726. * @param lightIndex defines the index of the light for the effect
  53727. */
  53728. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53729. }
  53730. }
  53731. declare module "babylonjs/Lights/index" {
  53732. export * from "babylonjs/Lights/light";
  53733. export * from "babylonjs/Lights/shadowLight";
  53734. export * from "babylonjs/Lights/Shadows/index";
  53735. export * from "babylonjs/Lights/directionalLight";
  53736. export * from "babylonjs/Lights/hemisphericLight";
  53737. export * from "babylonjs/Lights/pointLight";
  53738. export * from "babylonjs/Lights/spotLight";
  53739. }
  53740. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53741. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53742. /**
  53743. * Header information of HDR texture files.
  53744. */
  53745. export interface HDRInfo {
  53746. /**
  53747. * The height of the texture in pixels.
  53748. */
  53749. height: number;
  53750. /**
  53751. * The width of the texture in pixels.
  53752. */
  53753. width: number;
  53754. /**
  53755. * The index of the beginning of the data in the binary file.
  53756. */
  53757. dataPosition: number;
  53758. }
  53759. /**
  53760. * This groups tools to convert HDR texture to native colors array.
  53761. */
  53762. export class HDRTools {
  53763. private static Ldexp;
  53764. private static Rgbe2float;
  53765. private static readStringLine;
  53766. /**
  53767. * Reads header information from an RGBE texture stored in a native array.
  53768. * More information on this format are available here:
  53769. * https://en.wikipedia.org/wiki/RGBE_image_format
  53770. *
  53771. * @param uint8array The binary file stored in native array.
  53772. * @return The header information.
  53773. */
  53774. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53775. /**
  53776. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53777. * This RGBE texture needs to store the information as a panorama.
  53778. *
  53779. * More information on this format are available here:
  53780. * https://en.wikipedia.org/wiki/RGBE_image_format
  53781. *
  53782. * @param buffer The binary file stored in an array buffer.
  53783. * @param size The expected size of the extracted cubemap.
  53784. * @return The Cube Map information.
  53785. */
  53786. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53787. /**
  53788. * Returns the pixels data extracted from an RGBE texture.
  53789. * This pixels will be stored left to right up to down in the R G B order in one array.
  53790. *
  53791. * More information on this format are available here:
  53792. * https://en.wikipedia.org/wiki/RGBE_image_format
  53793. *
  53794. * @param uint8array The binary file stored in an array buffer.
  53795. * @param hdrInfo The header information of the file.
  53796. * @return The pixels data in RGB right to left up to down order.
  53797. */
  53798. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53799. private static RGBE_ReadPixels_RLE;
  53800. }
  53801. }
  53802. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53803. import { Nullable } from "babylonjs/types";
  53804. import { Scene } from "babylonjs/scene";
  53805. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53806. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53807. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53808. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53809. /**
  53810. * This represents a texture coming from an HDR input.
  53811. *
  53812. * The only supported format is currently panorama picture stored in RGBE format.
  53813. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53814. */
  53815. export class HDRCubeTexture extends BaseTexture {
  53816. private static _facesMapping;
  53817. private _generateHarmonics;
  53818. private _noMipmap;
  53819. private _textureMatrix;
  53820. private _size;
  53821. private _onLoad;
  53822. private _onError;
  53823. /**
  53824. * The texture URL.
  53825. */
  53826. url: string;
  53827. /**
  53828. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53829. */
  53830. coordinatesMode: number;
  53831. protected _isBlocking: boolean;
  53832. /**
  53833. * Sets wether or not the texture is blocking during loading.
  53834. */
  53835. /**
  53836. * Gets wether or not the texture is blocking during loading.
  53837. */
  53838. isBlocking: boolean;
  53839. protected _rotationY: number;
  53840. /**
  53841. * Sets texture matrix rotation angle around Y axis in radians.
  53842. */
  53843. /**
  53844. * Gets texture matrix rotation angle around Y axis radians.
  53845. */
  53846. rotationY: number;
  53847. /**
  53848. * Gets or sets the center of the bounding box associated with the cube texture
  53849. * It must define where the camera used to render the texture was set
  53850. */
  53851. boundingBoxPosition: Vector3;
  53852. private _boundingBoxSize;
  53853. /**
  53854. * Gets or sets the size of the bounding box associated with the cube texture
  53855. * When defined, the cubemap will switch to local mode
  53856. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53857. * @example https://www.babylonjs-playground.com/#RNASML
  53858. */
  53859. boundingBoxSize: Vector3;
  53860. /**
  53861. * Instantiates an HDRTexture from the following parameters.
  53862. *
  53863. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53864. * @param scene The scene the texture will be used in
  53865. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53866. * @param noMipmap Forces to not generate the mipmap if true
  53867. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53868. * @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)
  53869. * @param reserved Reserved flag for internal use.
  53870. */
  53871. 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>);
  53872. /**
  53873. * Get the current class name of the texture useful for serialization or dynamic coding.
  53874. * @returns "HDRCubeTexture"
  53875. */
  53876. getClassName(): string;
  53877. /**
  53878. * Occurs when the file is raw .hdr file.
  53879. */
  53880. private loadTexture;
  53881. clone(): HDRCubeTexture;
  53882. delayLoad(): void;
  53883. /**
  53884. * Get the texture reflection matrix used to rotate/transform the reflection.
  53885. * @returns the reflection matrix
  53886. */
  53887. getReflectionTextureMatrix(): Matrix;
  53888. /**
  53889. * Set the texture reflection matrix used to rotate/transform the reflection.
  53890. * @param value Define the reflection matrix to set
  53891. */
  53892. setReflectionTextureMatrix(value: Matrix): void;
  53893. /**
  53894. * Parses a JSON representation of an HDR Texture in order to create the texture
  53895. * @param parsedTexture Define the JSON representation
  53896. * @param scene Define the scene the texture should be created in
  53897. * @param rootUrl Define the root url in case we need to load relative dependencies
  53898. * @returns the newly created texture after parsing
  53899. */
  53900. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53901. serialize(): any;
  53902. }
  53903. }
  53904. declare module "babylonjs/Physics/physicsEngine" {
  53905. import { Nullable } from "babylonjs/types";
  53906. import { Vector3 } from "babylonjs/Maths/math.vector";
  53907. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53908. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53909. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53910. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53911. /**
  53912. * Class used to control physics engine
  53913. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53914. */
  53915. export class PhysicsEngine implements IPhysicsEngine {
  53916. private _physicsPlugin;
  53917. /**
  53918. * Global value used to control the smallest number supported by the simulation
  53919. */
  53920. static Epsilon: number;
  53921. private _impostors;
  53922. private _joints;
  53923. /**
  53924. * Gets the gravity vector used by the simulation
  53925. */
  53926. gravity: Vector3;
  53927. /**
  53928. * Factory used to create the default physics plugin.
  53929. * @returns The default physics plugin
  53930. */
  53931. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53932. /**
  53933. * Creates a new Physics Engine
  53934. * @param gravity defines the gravity vector used by the simulation
  53935. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53936. */
  53937. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53938. /**
  53939. * Sets the gravity vector used by the simulation
  53940. * @param gravity defines the gravity vector to use
  53941. */
  53942. setGravity(gravity: Vector3): void;
  53943. /**
  53944. * Set the time step of the physics engine.
  53945. * Default is 1/60.
  53946. * To slow it down, enter 1/600 for example.
  53947. * To speed it up, 1/30
  53948. * @param newTimeStep defines the new timestep to apply to this world.
  53949. */
  53950. setTimeStep(newTimeStep?: number): void;
  53951. /**
  53952. * Get the time step of the physics engine.
  53953. * @returns the current time step
  53954. */
  53955. getTimeStep(): number;
  53956. /**
  53957. * Release all resources
  53958. */
  53959. dispose(): void;
  53960. /**
  53961. * Gets the name of the current physics plugin
  53962. * @returns the name of the plugin
  53963. */
  53964. getPhysicsPluginName(): string;
  53965. /**
  53966. * Adding a new impostor for the impostor tracking.
  53967. * This will be done by the impostor itself.
  53968. * @param impostor the impostor to add
  53969. */
  53970. addImpostor(impostor: PhysicsImpostor): void;
  53971. /**
  53972. * Remove an impostor from the engine.
  53973. * This impostor and its mesh will not longer be updated by the physics engine.
  53974. * @param impostor the impostor to remove
  53975. */
  53976. removeImpostor(impostor: PhysicsImpostor): void;
  53977. /**
  53978. * Add a joint to the physics engine
  53979. * @param mainImpostor defines the main impostor to which the joint is added.
  53980. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53981. * @param joint defines the joint that will connect both impostors.
  53982. */
  53983. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53984. /**
  53985. * Removes a joint from the simulation
  53986. * @param mainImpostor defines the impostor used with the joint
  53987. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53988. * @param joint defines the joint to remove
  53989. */
  53990. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53991. /**
  53992. * Called by the scene. No need to call it.
  53993. * @param delta defines the timespam between frames
  53994. */
  53995. _step(delta: number): void;
  53996. /**
  53997. * Gets the current plugin used to run the simulation
  53998. * @returns current plugin
  53999. */
  54000. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54001. /**
  54002. * Gets the list of physic impostors
  54003. * @returns an array of PhysicsImpostor
  54004. */
  54005. getImpostors(): Array<PhysicsImpostor>;
  54006. /**
  54007. * Gets the impostor for a physics enabled object
  54008. * @param object defines the object impersonated by the impostor
  54009. * @returns the PhysicsImpostor or null if not found
  54010. */
  54011. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54012. /**
  54013. * Gets the impostor for a physics body object
  54014. * @param body defines physics body used by the impostor
  54015. * @returns the PhysicsImpostor or null if not found
  54016. */
  54017. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54018. /**
  54019. * Does a raycast in the physics world
  54020. * @param from when should the ray start?
  54021. * @param to when should the ray end?
  54022. * @returns PhysicsRaycastResult
  54023. */
  54024. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54025. }
  54026. }
  54027. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54028. import { Nullable } from "babylonjs/types";
  54029. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54031. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54032. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54033. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54034. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54035. /** @hidden */
  54036. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54037. private _useDeltaForWorldStep;
  54038. world: any;
  54039. name: string;
  54040. private _physicsMaterials;
  54041. private _fixedTimeStep;
  54042. private _cannonRaycastResult;
  54043. private _raycastResult;
  54044. private _physicsBodysToRemoveAfterStep;
  54045. BJSCANNON: any;
  54046. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54047. setGravity(gravity: Vector3): void;
  54048. setTimeStep(timeStep: number): void;
  54049. getTimeStep(): number;
  54050. executeStep(delta: number): void;
  54051. private _removeMarkedPhysicsBodiesFromWorld;
  54052. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54053. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54054. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54055. private _processChildMeshes;
  54056. removePhysicsBody(impostor: PhysicsImpostor): void;
  54057. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54058. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54059. private _addMaterial;
  54060. private _checkWithEpsilon;
  54061. private _createShape;
  54062. private _createHeightmap;
  54063. private _minus90X;
  54064. private _plus90X;
  54065. private _tmpPosition;
  54066. private _tmpDeltaPosition;
  54067. private _tmpUnityRotation;
  54068. private _updatePhysicsBodyTransformation;
  54069. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54070. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54071. isSupported(): boolean;
  54072. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54073. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54074. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54075. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54076. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54077. getBodyMass(impostor: PhysicsImpostor): number;
  54078. getBodyFriction(impostor: PhysicsImpostor): number;
  54079. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54080. getBodyRestitution(impostor: PhysicsImpostor): number;
  54081. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54082. sleepBody(impostor: PhysicsImpostor): void;
  54083. wakeUpBody(impostor: PhysicsImpostor): void;
  54084. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54085. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54086. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54087. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54088. getRadius(impostor: PhysicsImpostor): number;
  54089. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54090. dispose(): void;
  54091. private _extendNamespace;
  54092. /**
  54093. * Does a raycast in the physics world
  54094. * @param from when should the ray start?
  54095. * @param to when should the ray end?
  54096. * @returns PhysicsRaycastResult
  54097. */
  54098. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54099. }
  54100. }
  54101. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54102. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54103. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54104. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54106. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54107. import { Nullable } from "babylonjs/types";
  54108. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54109. /** @hidden */
  54110. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54111. world: any;
  54112. name: string;
  54113. BJSOIMO: any;
  54114. private _raycastResult;
  54115. constructor(iterations?: number, oimoInjection?: any);
  54116. setGravity(gravity: Vector3): void;
  54117. setTimeStep(timeStep: number): void;
  54118. getTimeStep(): number;
  54119. private _tmpImpostorsArray;
  54120. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54121. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54122. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54123. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54124. private _tmpPositionVector;
  54125. removePhysicsBody(impostor: PhysicsImpostor): void;
  54126. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54127. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54128. isSupported(): boolean;
  54129. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54130. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54131. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54132. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54133. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54134. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54135. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54136. getBodyMass(impostor: PhysicsImpostor): number;
  54137. getBodyFriction(impostor: PhysicsImpostor): number;
  54138. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54139. getBodyRestitution(impostor: PhysicsImpostor): number;
  54140. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54141. sleepBody(impostor: PhysicsImpostor): void;
  54142. wakeUpBody(impostor: PhysicsImpostor): void;
  54143. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54144. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54145. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54146. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54147. getRadius(impostor: PhysicsImpostor): number;
  54148. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54149. dispose(): void;
  54150. /**
  54151. * Does a raycast in the physics world
  54152. * @param from when should the ray start?
  54153. * @param to when should the ray end?
  54154. * @returns PhysicsRaycastResult
  54155. */
  54156. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54157. }
  54158. }
  54159. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54160. import { Nullable } from "babylonjs/types";
  54161. import { Scene } from "babylonjs/scene";
  54162. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54163. import { Color4 } from "babylonjs/Maths/math.color";
  54164. import { Mesh } from "babylonjs/Meshes/mesh";
  54165. /**
  54166. * Class containing static functions to help procedurally build meshes
  54167. */
  54168. export class RibbonBuilder {
  54169. /**
  54170. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54171. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54172. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54173. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54174. * * 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
  54175. * * 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
  54176. * * 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
  54177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54178. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54179. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54180. * * 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
  54181. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54182. * * 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
  54183. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54185. * @param name defines the name of the mesh
  54186. * @param options defines the options used to create the mesh
  54187. * @param scene defines the hosting scene
  54188. * @returns the ribbon mesh
  54189. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54190. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54191. */
  54192. static CreateRibbon(name: string, options: {
  54193. pathArray: Vector3[][];
  54194. closeArray?: boolean;
  54195. closePath?: boolean;
  54196. offset?: number;
  54197. updatable?: boolean;
  54198. sideOrientation?: number;
  54199. frontUVs?: Vector4;
  54200. backUVs?: Vector4;
  54201. instance?: Mesh;
  54202. invertUV?: boolean;
  54203. uvs?: Vector2[];
  54204. colors?: Color4[];
  54205. }, scene?: Nullable<Scene>): Mesh;
  54206. }
  54207. }
  54208. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54209. import { Nullable } from "babylonjs/types";
  54210. import { Scene } from "babylonjs/scene";
  54211. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54212. import { Mesh } from "babylonjs/Meshes/mesh";
  54213. /**
  54214. * Class containing static functions to help procedurally build meshes
  54215. */
  54216. export class ShapeBuilder {
  54217. /**
  54218. * 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.
  54219. * * 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.
  54220. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54221. * * 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.
  54222. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54223. * * 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
  54224. * * 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
  54225. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54228. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54230. * @param name defines the name of the mesh
  54231. * @param options defines the options used to create the mesh
  54232. * @param scene defines the hosting scene
  54233. * @returns the extruded shape mesh
  54234. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54235. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54236. */
  54237. static ExtrudeShape(name: string, options: {
  54238. shape: Vector3[];
  54239. path: Vector3[];
  54240. scale?: number;
  54241. rotation?: number;
  54242. cap?: number;
  54243. updatable?: boolean;
  54244. sideOrientation?: number;
  54245. frontUVs?: Vector4;
  54246. backUVs?: Vector4;
  54247. instance?: Mesh;
  54248. invertUV?: boolean;
  54249. }, scene?: Nullable<Scene>): Mesh;
  54250. /**
  54251. * Creates an custom extruded shape mesh.
  54252. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54253. * * 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.
  54254. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54255. * * 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
  54256. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54257. * * 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
  54258. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54259. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54260. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54261. * * 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
  54262. * * 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
  54263. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54265. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54266. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54268. * @param name defines the name of the mesh
  54269. * @param options defines the options used to create the mesh
  54270. * @param scene defines the hosting scene
  54271. * @returns the custom extruded shape mesh
  54272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54273. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54275. */
  54276. static ExtrudeShapeCustom(name: string, options: {
  54277. shape: Vector3[];
  54278. path: Vector3[];
  54279. scaleFunction?: any;
  54280. rotationFunction?: any;
  54281. ribbonCloseArray?: boolean;
  54282. ribbonClosePath?: boolean;
  54283. cap?: number;
  54284. updatable?: boolean;
  54285. sideOrientation?: number;
  54286. frontUVs?: Vector4;
  54287. backUVs?: Vector4;
  54288. instance?: Mesh;
  54289. invertUV?: boolean;
  54290. }, scene?: Nullable<Scene>): Mesh;
  54291. private static _ExtrudeShapeGeneric;
  54292. }
  54293. }
  54294. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54295. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54296. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54297. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54298. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54299. import { Nullable } from "babylonjs/types";
  54300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54301. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54302. /**
  54303. * AmmoJS Physics plugin
  54304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54305. * @see https://github.com/kripken/ammo.js/
  54306. */
  54307. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54308. private _useDeltaForWorldStep;
  54309. /**
  54310. * Reference to the Ammo library
  54311. */
  54312. bjsAMMO: any;
  54313. /**
  54314. * Created ammoJS world which physics bodies are added to
  54315. */
  54316. world: any;
  54317. /**
  54318. * Name of the plugin
  54319. */
  54320. name: string;
  54321. private _timeStep;
  54322. private _fixedTimeStep;
  54323. private _maxSteps;
  54324. private _tmpQuaternion;
  54325. private _tmpAmmoTransform;
  54326. private _tmpAmmoQuaternion;
  54327. private _tmpAmmoConcreteContactResultCallback;
  54328. private _collisionConfiguration;
  54329. private _dispatcher;
  54330. private _overlappingPairCache;
  54331. private _solver;
  54332. private _softBodySolver;
  54333. private _tmpAmmoVectorA;
  54334. private _tmpAmmoVectorB;
  54335. private _tmpAmmoVectorC;
  54336. private _tmpAmmoVectorD;
  54337. private _tmpContactCallbackResult;
  54338. private _tmpAmmoVectorRCA;
  54339. private _tmpAmmoVectorRCB;
  54340. private _raycastResult;
  54341. private static readonly DISABLE_COLLISION_FLAG;
  54342. private static readonly KINEMATIC_FLAG;
  54343. private static readonly DISABLE_DEACTIVATION_FLAG;
  54344. /**
  54345. * Initializes the ammoJS plugin
  54346. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54347. * @param ammoInjection can be used to inject your own ammo reference
  54348. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54349. */
  54350. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54351. /**
  54352. * Sets the gravity of the physics world (m/(s^2))
  54353. * @param gravity Gravity to set
  54354. */
  54355. setGravity(gravity: Vector3): void;
  54356. /**
  54357. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54358. * @param timeStep timestep to use in seconds
  54359. */
  54360. setTimeStep(timeStep: number): void;
  54361. /**
  54362. * 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)
  54363. * @param fixedTimeStep fixedTimeStep to use in seconds
  54364. */
  54365. setFixedTimeStep(fixedTimeStep: number): void;
  54366. /**
  54367. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54368. * @param maxSteps the maximum number of steps by the physics engine per frame
  54369. */
  54370. setMaxSteps(maxSteps: number): void;
  54371. /**
  54372. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54373. * @returns the current timestep in seconds
  54374. */
  54375. getTimeStep(): number;
  54376. private _isImpostorInContact;
  54377. private _isImpostorPairInContact;
  54378. private _stepSimulation;
  54379. /**
  54380. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54381. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54382. * After the step the babylon meshes are set to the position of the physics imposters
  54383. * @param delta amount of time to step forward
  54384. * @param impostors array of imposters to update before/after the step
  54385. */
  54386. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54387. /**
  54388. * Update babylon mesh to match physics world object
  54389. * @param impostor imposter to match
  54390. */
  54391. private _afterSoftStep;
  54392. /**
  54393. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54394. * @param impostor imposter to match
  54395. */
  54396. private _ropeStep;
  54397. /**
  54398. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54399. * @param impostor imposter to match
  54400. */
  54401. private _softbodyOrClothStep;
  54402. private _tmpVector;
  54403. private _tmpMatrix;
  54404. /**
  54405. * Applies an impulse on the imposter
  54406. * @param impostor imposter to apply impulse to
  54407. * @param force amount of force to be applied to the imposter
  54408. * @param contactPoint the location to apply the impulse on the imposter
  54409. */
  54410. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54411. /**
  54412. * Applies a force on the imposter
  54413. * @param impostor imposter to apply force
  54414. * @param force amount of force to be applied to the imposter
  54415. * @param contactPoint the location to apply the force on the imposter
  54416. */
  54417. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54418. /**
  54419. * Creates a physics body using the plugin
  54420. * @param impostor the imposter to create the physics body on
  54421. */
  54422. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54423. /**
  54424. * Removes the physics body from the imposter and disposes of the body's memory
  54425. * @param impostor imposter to remove the physics body from
  54426. */
  54427. removePhysicsBody(impostor: PhysicsImpostor): void;
  54428. /**
  54429. * Generates a joint
  54430. * @param impostorJoint the imposter joint to create the joint with
  54431. */
  54432. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54433. /**
  54434. * Removes a joint
  54435. * @param impostorJoint the imposter joint to remove the joint from
  54436. */
  54437. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54438. private _addMeshVerts;
  54439. /**
  54440. * Initialise the soft body vertices to match its object's (mesh) vertices
  54441. * Softbody vertices (nodes) are in world space and to match this
  54442. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54443. * @param impostor to create the softbody for
  54444. */
  54445. private _softVertexData;
  54446. /**
  54447. * Create an impostor's soft body
  54448. * @param impostor to create the softbody for
  54449. */
  54450. private _createSoftbody;
  54451. /**
  54452. * Create cloth for an impostor
  54453. * @param impostor to create the softbody for
  54454. */
  54455. private _createCloth;
  54456. /**
  54457. * Create rope for an impostor
  54458. * @param impostor to create the softbody for
  54459. */
  54460. private _createRope;
  54461. private _addHullVerts;
  54462. private _createShape;
  54463. /**
  54464. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54465. * @param impostor imposter containing the physics body and babylon object
  54466. */
  54467. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54468. /**
  54469. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54470. * @param impostor imposter containing the physics body and babylon object
  54471. * @param newPosition new position
  54472. * @param newRotation new rotation
  54473. */
  54474. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54475. /**
  54476. * If this plugin is supported
  54477. * @returns true if its supported
  54478. */
  54479. isSupported(): boolean;
  54480. /**
  54481. * Sets the linear velocity of the physics body
  54482. * @param impostor imposter to set the velocity on
  54483. * @param velocity velocity to set
  54484. */
  54485. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54486. /**
  54487. * Sets the angular velocity of the physics body
  54488. * @param impostor imposter to set the velocity on
  54489. * @param velocity velocity to set
  54490. */
  54491. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54492. /**
  54493. * gets the linear velocity
  54494. * @param impostor imposter to get linear velocity from
  54495. * @returns linear velocity
  54496. */
  54497. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54498. /**
  54499. * gets the angular velocity
  54500. * @param impostor imposter to get angular velocity from
  54501. * @returns angular velocity
  54502. */
  54503. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54504. /**
  54505. * Sets the mass of physics body
  54506. * @param impostor imposter to set the mass on
  54507. * @param mass mass to set
  54508. */
  54509. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54510. /**
  54511. * Gets the mass of the physics body
  54512. * @param impostor imposter to get the mass from
  54513. * @returns mass
  54514. */
  54515. getBodyMass(impostor: PhysicsImpostor): number;
  54516. /**
  54517. * Gets friction of the impostor
  54518. * @param impostor impostor to get friction from
  54519. * @returns friction value
  54520. */
  54521. getBodyFriction(impostor: PhysicsImpostor): number;
  54522. /**
  54523. * Sets friction of the impostor
  54524. * @param impostor impostor to set friction on
  54525. * @param friction friction value
  54526. */
  54527. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54528. /**
  54529. * Gets restitution of the impostor
  54530. * @param impostor impostor to get restitution from
  54531. * @returns restitution value
  54532. */
  54533. getBodyRestitution(impostor: PhysicsImpostor): number;
  54534. /**
  54535. * Sets resitution of the impostor
  54536. * @param impostor impostor to set resitution on
  54537. * @param restitution resitution value
  54538. */
  54539. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54540. /**
  54541. * Gets pressure inside the impostor
  54542. * @param impostor impostor to get pressure from
  54543. * @returns pressure value
  54544. */
  54545. getBodyPressure(impostor: PhysicsImpostor): number;
  54546. /**
  54547. * Sets pressure inside a soft body impostor
  54548. * Cloth and rope must remain 0 pressure
  54549. * @param impostor impostor to set pressure on
  54550. * @param pressure pressure value
  54551. */
  54552. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54553. /**
  54554. * Gets stiffness of the impostor
  54555. * @param impostor impostor to get stiffness from
  54556. * @returns pressure value
  54557. */
  54558. getBodyStiffness(impostor: PhysicsImpostor): number;
  54559. /**
  54560. * Sets stiffness of the impostor
  54561. * @param impostor impostor to set stiffness on
  54562. * @param stiffness stiffness value from 0 to 1
  54563. */
  54564. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54565. /**
  54566. * Gets velocityIterations of the impostor
  54567. * @param impostor impostor to get velocity iterations from
  54568. * @returns velocityIterations value
  54569. */
  54570. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54571. /**
  54572. * Sets velocityIterations of the impostor
  54573. * @param impostor impostor to set velocity iterations on
  54574. * @param velocityIterations velocityIterations value
  54575. */
  54576. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54577. /**
  54578. * Gets positionIterations of the impostor
  54579. * @param impostor impostor to get position iterations from
  54580. * @returns positionIterations value
  54581. */
  54582. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54583. /**
  54584. * Sets positionIterations of the impostor
  54585. * @param impostor impostor to set position on
  54586. * @param positionIterations positionIterations value
  54587. */
  54588. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54589. /**
  54590. * Append an anchor to a cloth object
  54591. * @param impostor is the cloth impostor to add anchor to
  54592. * @param otherImpostor is the rigid impostor to anchor to
  54593. * @param width ratio across width from 0 to 1
  54594. * @param height ratio up height from 0 to 1
  54595. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54596. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54597. */
  54598. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54599. /**
  54600. * Append an hook to a rope object
  54601. * @param impostor is the rope impostor to add hook to
  54602. * @param otherImpostor is the rigid impostor to hook to
  54603. * @param length ratio along the rope from 0 to 1
  54604. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54605. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54606. */
  54607. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54608. /**
  54609. * Sleeps the physics body and stops it from being active
  54610. * @param impostor impostor to sleep
  54611. */
  54612. sleepBody(impostor: PhysicsImpostor): void;
  54613. /**
  54614. * Activates the physics body
  54615. * @param impostor impostor to activate
  54616. */
  54617. wakeUpBody(impostor: PhysicsImpostor): void;
  54618. /**
  54619. * Updates the distance parameters of the joint
  54620. * @param joint joint to update
  54621. * @param maxDistance maximum distance of the joint
  54622. * @param minDistance minimum distance of the joint
  54623. */
  54624. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54625. /**
  54626. * Sets a motor on the joint
  54627. * @param joint joint to set motor on
  54628. * @param speed speed of the motor
  54629. * @param maxForce maximum force of the motor
  54630. * @param motorIndex index of the motor
  54631. */
  54632. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54633. /**
  54634. * Sets the motors limit
  54635. * @param joint joint to set limit on
  54636. * @param upperLimit upper limit
  54637. * @param lowerLimit lower limit
  54638. */
  54639. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54640. /**
  54641. * Syncs the position and rotation of a mesh with the impostor
  54642. * @param mesh mesh to sync
  54643. * @param impostor impostor to update the mesh with
  54644. */
  54645. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54646. /**
  54647. * Gets the radius of the impostor
  54648. * @param impostor impostor to get radius from
  54649. * @returns the radius
  54650. */
  54651. getRadius(impostor: PhysicsImpostor): number;
  54652. /**
  54653. * Gets the box size of the impostor
  54654. * @param impostor impostor to get box size from
  54655. * @param result the resulting box size
  54656. */
  54657. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54658. /**
  54659. * Disposes of the impostor
  54660. */
  54661. dispose(): void;
  54662. /**
  54663. * Does a raycast in the physics world
  54664. * @param from when should the ray start?
  54665. * @param to when should the ray end?
  54666. * @returns PhysicsRaycastResult
  54667. */
  54668. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54669. }
  54670. }
  54671. declare module "babylonjs/Probes/reflectionProbe" {
  54672. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54673. import { Vector3 } from "babylonjs/Maths/math.vector";
  54674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54675. import { Nullable } from "babylonjs/types";
  54676. import { Scene } from "babylonjs/scene";
  54677. module "babylonjs/abstractScene" {
  54678. interface AbstractScene {
  54679. /**
  54680. * The list of reflection probes added to the scene
  54681. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54682. */
  54683. reflectionProbes: Array<ReflectionProbe>;
  54684. /**
  54685. * Removes the given reflection probe from this scene.
  54686. * @param toRemove The reflection probe to remove
  54687. * @returns The index of the removed reflection probe
  54688. */
  54689. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54690. /**
  54691. * Adds the given reflection probe to this scene.
  54692. * @param newReflectionProbe The reflection probe to add
  54693. */
  54694. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54695. }
  54696. }
  54697. /**
  54698. * Class used to generate realtime reflection / refraction cube textures
  54699. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54700. */
  54701. export class ReflectionProbe {
  54702. /** defines the name of the probe */
  54703. name: string;
  54704. private _scene;
  54705. private _renderTargetTexture;
  54706. private _projectionMatrix;
  54707. private _viewMatrix;
  54708. private _target;
  54709. private _add;
  54710. private _attachedMesh;
  54711. private _invertYAxis;
  54712. /** Gets or sets probe position (center of the cube map) */
  54713. position: Vector3;
  54714. /**
  54715. * Creates a new reflection probe
  54716. * @param name defines the name of the probe
  54717. * @param size defines the texture resolution (for each face)
  54718. * @param scene defines the hosting scene
  54719. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54720. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54721. */
  54722. constructor(
  54723. /** defines the name of the probe */
  54724. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54725. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54726. samples: number;
  54727. /** Gets or sets the refresh rate to use (on every frame by default) */
  54728. refreshRate: number;
  54729. /**
  54730. * Gets the hosting scene
  54731. * @returns a Scene
  54732. */
  54733. getScene(): Scene;
  54734. /** Gets the internal CubeTexture used to render to */
  54735. readonly cubeTexture: RenderTargetTexture;
  54736. /** Gets the list of meshes to render */
  54737. readonly renderList: Nullable<AbstractMesh[]>;
  54738. /**
  54739. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54740. * @param mesh defines the mesh to attach to
  54741. */
  54742. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54743. /**
  54744. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54745. * @param renderingGroupId The rendering group id corresponding to its index
  54746. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54747. */
  54748. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54749. /**
  54750. * Clean all associated resources
  54751. */
  54752. dispose(): void;
  54753. /**
  54754. * Converts the reflection probe information to a readable string for debug purpose.
  54755. * @param fullDetails Supports for multiple levels of logging within scene loading
  54756. * @returns the human readable reflection probe info
  54757. */
  54758. toString(fullDetails?: boolean): string;
  54759. /**
  54760. * Get the class name of the relfection probe.
  54761. * @returns "ReflectionProbe"
  54762. */
  54763. getClassName(): string;
  54764. /**
  54765. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54766. * @returns The JSON representation of the texture
  54767. */
  54768. serialize(): any;
  54769. /**
  54770. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54771. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54772. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54773. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54774. * @returns The parsed reflection probe if successful
  54775. */
  54776. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54777. }
  54778. }
  54779. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54780. /** @hidden */
  54781. export var _BabylonLoaderRegistered: boolean;
  54782. /**
  54783. * Helps setting up some configuration for the babylon file loader.
  54784. */
  54785. export class BabylonFileLoaderConfiguration {
  54786. /**
  54787. * The loader does not allow injecting custom physix engine into the plugins.
  54788. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54789. * So you could set this variable to your engine import to make it work.
  54790. */
  54791. static LoaderInjectedPhysicsEngine: any;
  54792. }
  54793. }
  54794. declare module "babylonjs/Loading/Plugins/index" {
  54795. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54796. }
  54797. declare module "babylonjs/Loading/index" {
  54798. export * from "babylonjs/Loading/loadingScreen";
  54799. export * from "babylonjs/Loading/Plugins/index";
  54800. export * from "babylonjs/Loading/sceneLoader";
  54801. export * from "babylonjs/Loading/sceneLoaderFlags";
  54802. }
  54803. declare module "babylonjs/Materials/Background/index" {
  54804. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54805. }
  54806. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54807. import { Scene } from "babylonjs/scene";
  54808. import { Color3 } from "babylonjs/Maths/math.color";
  54809. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54811. /**
  54812. * The Physically based simple base material of BJS.
  54813. *
  54814. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54815. * It is used as the base class for both the specGloss and metalRough conventions.
  54816. */
  54817. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54818. /**
  54819. * Number of Simultaneous lights allowed on the material.
  54820. */
  54821. maxSimultaneousLights: number;
  54822. /**
  54823. * If sets to true, disables all the lights affecting the material.
  54824. */
  54825. disableLighting: boolean;
  54826. /**
  54827. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54828. */
  54829. environmentTexture: BaseTexture;
  54830. /**
  54831. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54832. */
  54833. invertNormalMapX: boolean;
  54834. /**
  54835. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54836. */
  54837. invertNormalMapY: boolean;
  54838. /**
  54839. * Normal map used in the model.
  54840. */
  54841. normalTexture: BaseTexture;
  54842. /**
  54843. * Emissivie color used to self-illuminate the model.
  54844. */
  54845. emissiveColor: Color3;
  54846. /**
  54847. * Emissivie texture used to self-illuminate the model.
  54848. */
  54849. emissiveTexture: BaseTexture;
  54850. /**
  54851. * Occlusion Channel Strenght.
  54852. */
  54853. occlusionStrength: number;
  54854. /**
  54855. * Occlusion Texture of the material (adding extra occlusion effects).
  54856. */
  54857. occlusionTexture: BaseTexture;
  54858. /**
  54859. * Defines the alpha limits in alpha test mode.
  54860. */
  54861. alphaCutOff: number;
  54862. /**
  54863. * Gets the current double sided mode.
  54864. */
  54865. /**
  54866. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54867. */
  54868. doubleSided: boolean;
  54869. /**
  54870. * Stores the pre-calculated light information of a mesh in a texture.
  54871. */
  54872. lightmapTexture: BaseTexture;
  54873. /**
  54874. * If true, the light map contains occlusion information instead of lighting info.
  54875. */
  54876. useLightmapAsShadowmap: boolean;
  54877. /**
  54878. * Instantiates a new PBRMaterial instance.
  54879. *
  54880. * @param name The material name
  54881. * @param scene The scene the material will be use in.
  54882. */
  54883. constructor(name: string, scene: Scene);
  54884. getClassName(): string;
  54885. }
  54886. }
  54887. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54888. import { Scene } from "babylonjs/scene";
  54889. import { Color3 } from "babylonjs/Maths/math.color";
  54890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54891. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54892. /**
  54893. * The PBR material of BJS following the metal roughness convention.
  54894. *
  54895. * This fits to the PBR convention in the GLTF definition:
  54896. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54897. */
  54898. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54899. /**
  54900. * The base color has two different interpretations depending on the value of metalness.
  54901. * When the material is a metal, the base color is the specific measured reflectance value
  54902. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54903. * of the material.
  54904. */
  54905. baseColor: Color3;
  54906. /**
  54907. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54908. * well as opacity information in the alpha channel.
  54909. */
  54910. baseTexture: BaseTexture;
  54911. /**
  54912. * Specifies the metallic scalar value of the material.
  54913. * Can also be used to scale the metalness values of the metallic texture.
  54914. */
  54915. metallic: number;
  54916. /**
  54917. * Specifies the roughness scalar value of the material.
  54918. * Can also be used to scale the roughness values of the metallic texture.
  54919. */
  54920. roughness: number;
  54921. /**
  54922. * Texture containing both the metallic value in the B channel and the
  54923. * roughness value in the G channel to keep better precision.
  54924. */
  54925. metallicRoughnessTexture: BaseTexture;
  54926. /**
  54927. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54928. *
  54929. * @param name The material name
  54930. * @param scene The scene the material will be use in.
  54931. */
  54932. constructor(name: string, scene: Scene);
  54933. /**
  54934. * Return the currrent class name of the material.
  54935. */
  54936. getClassName(): string;
  54937. /**
  54938. * Makes a duplicate of the current material.
  54939. * @param name - name to use for the new material.
  54940. */
  54941. clone(name: string): PBRMetallicRoughnessMaterial;
  54942. /**
  54943. * Serialize the material to a parsable JSON object.
  54944. */
  54945. serialize(): any;
  54946. /**
  54947. * Parses a JSON object correponding to the serialize function.
  54948. */
  54949. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54950. }
  54951. }
  54952. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54953. import { Scene } from "babylonjs/scene";
  54954. import { Color3 } from "babylonjs/Maths/math.color";
  54955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54956. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54957. /**
  54958. * The PBR material of BJS following the specular glossiness convention.
  54959. *
  54960. * This fits to the PBR convention in the GLTF definition:
  54961. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54962. */
  54963. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54964. /**
  54965. * Specifies the diffuse color of the material.
  54966. */
  54967. diffuseColor: Color3;
  54968. /**
  54969. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54970. * channel.
  54971. */
  54972. diffuseTexture: BaseTexture;
  54973. /**
  54974. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54975. */
  54976. specularColor: Color3;
  54977. /**
  54978. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54979. */
  54980. glossiness: number;
  54981. /**
  54982. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54983. */
  54984. specularGlossinessTexture: BaseTexture;
  54985. /**
  54986. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54987. *
  54988. * @param name The material name
  54989. * @param scene The scene the material will be use in.
  54990. */
  54991. constructor(name: string, scene: Scene);
  54992. /**
  54993. * Return the currrent class name of the material.
  54994. */
  54995. getClassName(): string;
  54996. /**
  54997. * Makes a duplicate of the current material.
  54998. * @param name - name to use for the new material.
  54999. */
  55000. clone(name: string): PBRSpecularGlossinessMaterial;
  55001. /**
  55002. * Serialize the material to a parsable JSON object.
  55003. */
  55004. serialize(): any;
  55005. /**
  55006. * Parses a JSON object correponding to the serialize function.
  55007. */
  55008. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55009. }
  55010. }
  55011. declare module "babylonjs/Materials/PBR/index" {
  55012. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55013. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55014. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55015. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55016. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55017. }
  55018. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55019. import { Nullable } from "babylonjs/types";
  55020. import { Scene } from "babylonjs/scene";
  55021. import { Matrix } from "babylonjs/Maths/math.vector";
  55022. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55023. /**
  55024. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55025. * It can help converting any input color in a desired output one. This can then be used to create effects
  55026. * from sepia, black and white to sixties or futuristic rendering...
  55027. *
  55028. * The only supported format is currently 3dl.
  55029. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55030. */
  55031. export class ColorGradingTexture extends BaseTexture {
  55032. /**
  55033. * The current texture matrix. (will always be identity in color grading texture)
  55034. */
  55035. private _textureMatrix;
  55036. /**
  55037. * The texture URL.
  55038. */
  55039. url: string;
  55040. /**
  55041. * Empty line regex stored for GC.
  55042. */
  55043. private static _noneEmptyLineRegex;
  55044. private _engine;
  55045. /**
  55046. * Instantiates a ColorGradingTexture from the following parameters.
  55047. *
  55048. * @param url The location of the color gradind data (currently only supporting 3dl)
  55049. * @param scene The scene the texture will be used in
  55050. */
  55051. constructor(url: string, scene: Scene);
  55052. /**
  55053. * Returns the texture matrix used in most of the material.
  55054. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55055. */
  55056. getTextureMatrix(): Matrix;
  55057. /**
  55058. * Occurs when the file being loaded is a .3dl LUT file.
  55059. */
  55060. private load3dlTexture;
  55061. /**
  55062. * Starts the loading process of the texture.
  55063. */
  55064. private loadTexture;
  55065. /**
  55066. * Clones the color gradind texture.
  55067. */
  55068. clone(): ColorGradingTexture;
  55069. /**
  55070. * Called during delayed load for textures.
  55071. */
  55072. delayLoad(): void;
  55073. /**
  55074. * Parses a color grading texture serialized by Babylon.
  55075. * @param parsedTexture The texture information being parsedTexture
  55076. * @param scene The scene to load the texture in
  55077. * @param rootUrl The root url of the data assets to load
  55078. * @return A color gradind texture
  55079. */
  55080. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55081. /**
  55082. * Serializes the LUT texture to json format.
  55083. */
  55084. serialize(): any;
  55085. }
  55086. }
  55087. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55088. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55089. import { Scene } from "babylonjs/scene";
  55090. import { Nullable } from "babylonjs/types";
  55091. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55092. /**
  55093. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55094. */
  55095. export class EquiRectangularCubeTexture extends BaseTexture {
  55096. /** The six faces of the cube. */
  55097. private static _FacesMapping;
  55098. private _noMipmap;
  55099. private _onLoad;
  55100. private _onError;
  55101. /** The size of the cubemap. */
  55102. private _size;
  55103. /** The buffer of the image. */
  55104. private _buffer;
  55105. /** The width of the input image. */
  55106. private _width;
  55107. /** The height of the input image. */
  55108. private _height;
  55109. /** The URL to the image. */
  55110. url: string;
  55111. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55112. coordinatesMode: number;
  55113. /**
  55114. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55115. * @param url The location of the image
  55116. * @param scene The scene the texture will be used in
  55117. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55118. * @param noMipmap Forces to not generate the mipmap if true
  55119. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55120. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55121. * @param onLoad — defines a callback called when texture is loaded
  55122. * @param onError — defines a callback called if there is an error
  55123. */
  55124. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55125. /**
  55126. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55127. */
  55128. private loadImage;
  55129. /**
  55130. * Convert the image buffer into a cubemap and create a CubeTexture.
  55131. */
  55132. private loadTexture;
  55133. /**
  55134. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55135. * @param buffer The ArrayBuffer that should be converted.
  55136. * @returns The buffer as Float32Array.
  55137. */
  55138. private getFloat32ArrayFromArrayBuffer;
  55139. /**
  55140. * Get the current class name of the texture useful for serialization or dynamic coding.
  55141. * @returns "EquiRectangularCubeTexture"
  55142. */
  55143. getClassName(): string;
  55144. /**
  55145. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55146. * @returns A clone of the current EquiRectangularCubeTexture.
  55147. */
  55148. clone(): EquiRectangularCubeTexture;
  55149. }
  55150. }
  55151. declare module "babylonjs/Misc/tga" {
  55152. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55153. /**
  55154. * Based on jsTGALoader - Javascript loader for TGA file
  55155. * By Vincent Thibault
  55156. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55157. */
  55158. export class TGATools {
  55159. private static _TYPE_INDEXED;
  55160. private static _TYPE_RGB;
  55161. private static _TYPE_GREY;
  55162. private static _TYPE_RLE_INDEXED;
  55163. private static _TYPE_RLE_RGB;
  55164. private static _TYPE_RLE_GREY;
  55165. private static _ORIGIN_MASK;
  55166. private static _ORIGIN_SHIFT;
  55167. private static _ORIGIN_BL;
  55168. private static _ORIGIN_BR;
  55169. private static _ORIGIN_UL;
  55170. private static _ORIGIN_UR;
  55171. /**
  55172. * Gets the header of a TGA file
  55173. * @param data defines the TGA data
  55174. * @returns the header
  55175. */
  55176. static GetTGAHeader(data: Uint8Array): any;
  55177. /**
  55178. * Uploads TGA content to a Babylon Texture
  55179. * @hidden
  55180. */
  55181. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55182. /** @hidden */
  55183. 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;
  55184. /** @hidden */
  55185. 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;
  55186. /** @hidden */
  55187. 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;
  55188. /** @hidden */
  55189. 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;
  55190. /** @hidden */
  55191. 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;
  55192. /** @hidden */
  55193. 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;
  55194. }
  55195. }
  55196. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55197. import { Nullable } from "babylonjs/types";
  55198. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55199. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55200. /**
  55201. * Implementation of the TGA Texture Loader.
  55202. * @hidden
  55203. */
  55204. export class _TGATextureLoader implements IInternalTextureLoader {
  55205. /**
  55206. * Defines wether the loader supports cascade loading the different faces.
  55207. */
  55208. readonly supportCascades: boolean;
  55209. /**
  55210. * This returns if the loader support the current file information.
  55211. * @param extension defines the file extension of the file being loaded
  55212. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55213. * @param fallback defines the fallback internal texture if any
  55214. * @param isBase64 defines whether the texture is encoded as a base64
  55215. * @param isBuffer defines whether the texture data are stored as a buffer
  55216. * @returns true if the loader can load the specified file
  55217. */
  55218. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55219. /**
  55220. * Transform the url before loading if required.
  55221. * @param rootUrl the url of the texture
  55222. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55223. * @returns the transformed texture
  55224. */
  55225. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55226. /**
  55227. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55228. * @param rootUrl the url of the texture
  55229. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55230. * @returns the fallback texture
  55231. */
  55232. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55233. /**
  55234. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55235. * @param data contains the texture data
  55236. * @param texture defines the BabylonJS internal texture
  55237. * @param createPolynomials will be true if polynomials have been requested
  55238. * @param onLoad defines the callback to trigger once the texture is ready
  55239. * @param onError defines the callback to trigger in case of error
  55240. */
  55241. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55242. /**
  55243. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55244. * @param data contains the texture data
  55245. * @param texture defines the BabylonJS internal texture
  55246. * @param callback defines the method to call once ready to upload
  55247. */
  55248. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55249. }
  55250. }
  55251. declare module "babylonjs/Misc/basis" {
  55252. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55253. /**
  55254. * Info about the .basis files
  55255. */
  55256. class BasisFileInfo {
  55257. /**
  55258. * If the file has alpha
  55259. */
  55260. hasAlpha: boolean;
  55261. /**
  55262. * Info about each image of the basis file
  55263. */
  55264. images: Array<{
  55265. levels: Array<{
  55266. width: number;
  55267. height: number;
  55268. transcodedPixels: ArrayBufferView;
  55269. }>;
  55270. }>;
  55271. }
  55272. /**
  55273. * Result of transcoding a basis file
  55274. */
  55275. class TranscodeResult {
  55276. /**
  55277. * Info about the .basis file
  55278. */
  55279. fileInfo: BasisFileInfo;
  55280. /**
  55281. * Format to use when loading the file
  55282. */
  55283. format: number;
  55284. }
  55285. /**
  55286. * Configuration options for the Basis transcoder
  55287. */
  55288. export class BasisTranscodeConfiguration {
  55289. /**
  55290. * Supported compression formats used to determine the supported output format of the transcoder
  55291. */
  55292. supportedCompressionFormats?: {
  55293. /**
  55294. * etc1 compression format
  55295. */
  55296. etc1?: boolean;
  55297. /**
  55298. * s3tc compression format
  55299. */
  55300. s3tc?: boolean;
  55301. /**
  55302. * pvrtc compression format
  55303. */
  55304. pvrtc?: boolean;
  55305. /**
  55306. * etc2 compression format
  55307. */
  55308. etc2?: boolean;
  55309. };
  55310. /**
  55311. * If mipmap levels should be loaded for transcoded images (Default: true)
  55312. */
  55313. loadMipmapLevels?: boolean;
  55314. /**
  55315. * Index of a single image to load (Default: all images)
  55316. */
  55317. loadSingleImage?: number;
  55318. }
  55319. /**
  55320. * Used to load .Basis files
  55321. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55322. */
  55323. export class BasisTools {
  55324. private static _IgnoreSupportedFormats;
  55325. /**
  55326. * URL to use when loading the basis transcoder
  55327. */
  55328. static JSModuleURL: string;
  55329. /**
  55330. * URL to use when loading the wasm module for the transcoder
  55331. */
  55332. static WasmModuleURL: string;
  55333. /**
  55334. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55335. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55336. * @returns internal format corresponding to the Basis format
  55337. */
  55338. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55339. private static _WorkerPromise;
  55340. private static _Worker;
  55341. private static _actionId;
  55342. private static _CreateWorkerAsync;
  55343. /**
  55344. * Transcodes a loaded image file to compressed pixel data
  55345. * @param imageData image data to transcode
  55346. * @param config configuration options for the transcoding
  55347. * @returns a promise resulting in the transcoded image
  55348. */
  55349. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55350. /**
  55351. * Loads a texture from the transcode result
  55352. * @param texture texture load to
  55353. * @param transcodeResult the result of transcoding the basis file to load from
  55354. */
  55355. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55356. }
  55357. }
  55358. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55359. import { Nullable } from "babylonjs/types";
  55360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55361. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55362. /**
  55363. * Loader for .basis file format
  55364. */
  55365. export class _BasisTextureLoader implements IInternalTextureLoader {
  55366. /**
  55367. * Defines whether the loader supports cascade loading the different faces.
  55368. */
  55369. readonly supportCascades: boolean;
  55370. /**
  55371. * This returns if the loader support the current file information.
  55372. * @param extension defines the file extension of the file being loaded
  55373. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55374. * @param fallback defines the fallback internal texture if any
  55375. * @param isBase64 defines whether the texture is encoded as a base64
  55376. * @param isBuffer defines whether the texture data are stored as a buffer
  55377. * @returns true if the loader can load the specified file
  55378. */
  55379. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55380. /**
  55381. * Transform the url before loading if required.
  55382. * @param rootUrl the url of the texture
  55383. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55384. * @returns the transformed texture
  55385. */
  55386. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55387. /**
  55388. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55389. * @param rootUrl the url of the texture
  55390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55391. * @returns the fallback texture
  55392. */
  55393. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55394. /**
  55395. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55396. * @param data contains the texture data
  55397. * @param texture defines the BabylonJS internal texture
  55398. * @param createPolynomials will be true if polynomials have been requested
  55399. * @param onLoad defines the callback to trigger once the texture is ready
  55400. * @param onError defines the callback to trigger in case of error
  55401. */
  55402. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55403. /**
  55404. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55405. * @param data contains the texture data
  55406. * @param texture defines the BabylonJS internal texture
  55407. * @param callback defines the method to call once ready to upload
  55408. */
  55409. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55410. }
  55411. }
  55412. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55413. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55414. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55415. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55416. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55417. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55418. }
  55419. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55420. import { Scene } from "babylonjs/scene";
  55421. import { Texture } from "babylonjs/Materials/Textures/texture";
  55422. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55423. /**
  55424. * 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.
  55425. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55426. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55427. */
  55428. export class CustomProceduralTexture extends ProceduralTexture {
  55429. private _animate;
  55430. private _time;
  55431. private _config;
  55432. private _texturePath;
  55433. /**
  55434. * Instantiates a new Custom Procedural Texture.
  55435. * 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.
  55436. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55437. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55438. * @param name Define the name of the texture
  55439. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55440. * @param size Define the size of the texture to create
  55441. * @param scene Define the scene the texture belongs to
  55442. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55443. * @param generateMipMaps Define if the texture should creates mip maps or not
  55444. */
  55445. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55446. private _loadJson;
  55447. /**
  55448. * Is the texture ready to be used ? (rendered at least once)
  55449. * @returns true if ready, otherwise, false.
  55450. */
  55451. isReady(): boolean;
  55452. /**
  55453. * Render the texture to its associated render target.
  55454. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55455. */
  55456. render(useCameraPostProcess?: boolean): void;
  55457. /**
  55458. * Update the list of dependant textures samplers in the shader.
  55459. */
  55460. updateTextures(): void;
  55461. /**
  55462. * Update the uniform values of the procedural texture in the shader.
  55463. */
  55464. updateShaderUniforms(): void;
  55465. /**
  55466. * Define if the texture animates or not.
  55467. */
  55468. animate: boolean;
  55469. }
  55470. }
  55471. declare module "babylonjs/Shaders/noise.fragment" {
  55472. /** @hidden */
  55473. export var noisePixelShader: {
  55474. name: string;
  55475. shader: string;
  55476. };
  55477. }
  55478. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55479. import { Nullable } from "babylonjs/types";
  55480. import { Scene } from "babylonjs/scene";
  55481. import { Texture } from "babylonjs/Materials/Textures/texture";
  55482. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55483. import "babylonjs/Shaders/noise.fragment";
  55484. /**
  55485. * Class used to generate noise procedural textures
  55486. */
  55487. export class NoiseProceduralTexture extends ProceduralTexture {
  55488. private _time;
  55489. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55490. brightness: number;
  55491. /** Defines the number of octaves to process */
  55492. octaves: number;
  55493. /** Defines the level of persistence (0.8 by default) */
  55494. persistence: number;
  55495. /** Gets or sets animation speed factor (default is 1) */
  55496. animationSpeedFactor: number;
  55497. /**
  55498. * Creates a new NoiseProceduralTexture
  55499. * @param name defines the name fo the texture
  55500. * @param size defines the size of the texture (default is 256)
  55501. * @param scene defines the hosting scene
  55502. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55503. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55504. */
  55505. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55506. private _updateShaderUniforms;
  55507. protected _getDefines(): string;
  55508. /** Generate the current state of the procedural texture */
  55509. render(useCameraPostProcess?: boolean): void;
  55510. /**
  55511. * Serializes this noise procedural texture
  55512. * @returns a serialized noise procedural texture object
  55513. */
  55514. serialize(): any;
  55515. /**
  55516. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55517. * @param parsedTexture defines parsed texture data
  55518. * @param scene defines the current scene
  55519. * @param rootUrl defines the root URL containing noise procedural texture information
  55520. * @returns a parsed NoiseProceduralTexture
  55521. */
  55522. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55523. }
  55524. }
  55525. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55526. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55527. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55528. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55529. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55530. }
  55531. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55532. import { Nullable } from "babylonjs/types";
  55533. import { Scene } from "babylonjs/scene";
  55534. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55535. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55536. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55537. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55538. /**
  55539. * Raw cube texture where the raw buffers are passed in
  55540. */
  55541. export class RawCubeTexture extends CubeTexture {
  55542. /**
  55543. * Creates a cube texture where the raw buffers are passed in.
  55544. * @param scene defines the scene the texture is attached to
  55545. * @param data defines the array of data to use to create each face
  55546. * @param size defines the size of the textures
  55547. * @param format defines the format of the data
  55548. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55549. * @param generateMipMaps defines if the engine should generate the mip levels
  55550. * @param invertY defines if data must be stored with Y axis inverted
  55551. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55552. * @param compression defines the compression used (null by default)
  55553. */
  55554. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55555. /**
  55556. * Updates the raw cube texture.
  55557. * @param data defines the data to store
  55558. * @param format defines the data format
  55559. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55560. * @param invertY defines if data must be stored with Y axis inverted
  55561. * @param compression defines the compression used (null by default)
  55562. * @param level defines which level of the texture to update
  55563. */
  55564. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55565. /**
  55566. * Updates a raw cube texture with RGBD encoded data.
  55567. * @param data defines the array of data [mipmap][face] to use to create each face
  55568. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55571. * @returns a promsie that resolves when the operation is complete
  55572. */
  55573. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55574. /**
  55575. * Clones the raw cube texture.
  55576. * @return a new cube texture
  55577. */
  55578. clone(): CubeTexture;
  55579. /** @hidden */
  55580. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55581. }
  55582. }
  55583. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55584. import { Scene } from "babylonjs/scene";
  55585. import { Texture } from "babylonjs/Materials/Textures/texture";
  55586. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55587. /**
  55588. * Class used to store 3D textures containing user data
  55589. */
  55590. export class RawTexture3D extends Texture {
  55591. /** Gets or sets the texture format to use */
  55592. format: number;
  55593. private _engine;
  55594. /**
  55595. * Create a new RawTexture3D
  55596. * @param data defines the data of the texture
  55597. * @param width defines the width of the texture
  55598. * @param height defines the height of the texture
  55599. * @param depth defines the depth of the texture
  55600. * @param format defines the texture format to use
  55601. * @param scene defines the hosting scene
  55602. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55603. * @param invertY defines if texture must be stored with Y axis inverted
  55604. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55605. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55606. */
  55607. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55608. /** Gets or sets the texture format to use */
  55609. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55610. /**
  55611. * Update the texture with new data
  55612. * @param data defines the data to store in the texture
  55613. */
  55614. update(data: ArrayBufferView): void;
  55615. }
  55616. }
  55617. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55618. import { Scene } from "babylonjs/scene";
  55619. import { Texture } from "babylonjs/Materials/Textures/texture";
  55620. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55621. /**
  55622. * Class used to store 2D array textures containing user data
  55623. */
  55624. export class RawTexture2DArray extends Texture {
  55625. /** Gets or sets the texture format to use */
  55626. format: number;
  55627. private _engine;
  55628. /**
  55629. * Create a new RawTexture2DArray
  55630. * @param data defines the data of the texture
  55631. * @param width defines the width of the texture
  55632. * @param height defines the height of the texture
  55633. * @param depth defines the number of layers of the texture
  55634. * @param format defines the texture format to use
  55635. * @param scene defines the hosting scene
  55636. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55637. * @param invertY defines if texture must be stored with Y axis inverted
  55638. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55639. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55640. */
  55641. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55642. /** Gets or sets the texture format to use */
  55643. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55644. /**
  55645. * Update the texture with new data
  55646. * @param data defines the data to store in the texture
  55647. */
  55648. update(data: ArrayBufferView): void;
  55649. }
  55650. }
  55651. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55652. import { Scene } from "babylonjs/scene";
  55653. import { Plane } from "babylonjs/Maths/math.plane";
  55654. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55655. /**
  55656. * Creates a refraction texture used by refraction channel of the standard material.
  55657. * It is like a mirror but to see through a material.
  55658. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55659. */
  55660. export class RefractionTexture extends RenderTargetTexture {
  55661. /**
  55662. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55663. * 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.
  55664. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55665. */
  55666. refractionPlane: Plane;
  55667. /**
  55668. * Define how deep under the surface we should see.
  55669. */
  55670. depth: number;
  55671. /**
  55672. * Creates a refraction texture used by refraction channel of the standard material.
  55673. * It is like a mirror but to see through a material.
  55674. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55675. * @param name Define the texture name
  55676. * @param size Define the size of the underlying texture
  55677. * @param scene Define the scene the refraction belongs to
  55678. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55679. */
  55680. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55681. /**
  55682. * Clone the refraction texture.
  55683. * @returns the cloned texture
  55684. */
  55685. clone(): RefractionTexture;
  55686. /**
  55687. * Serialize the texture to a JSON representation you could use in Parse later on
  55688. * @returns the serialized JSON representation
  55689. */
  55690. serialize(): any;
  55691. }
  55692. }
  55693. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55694. import { Nullable } from "babylonjs/types";
  55695. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55696. import { Matrix } from "babylonjs/Maths/math.vector";
  55697. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55698. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55699. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55700. import { Scene } from "babylonjs/scene";
  55701. /**
  55702. * Defines the options related to the creation of an HtmlElementTexture
  55703. */
  55704. export interface IHtmlElementTextureOptions {
  55705. /**
  55706. * Defines wether mip maps should be created or not.
  55707. */
  55708. generateMipMaps?: boolean;
  55709. /**
  55710. * Defines the sampling mode of the texture.
  55711. */
  55712. samplingMode?: number;
  55713. /**
  55714. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55715. */
  55716. engine: Nullable<ThinEngine>;
  55717. /**
  55718. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55719. */
  55720. scene: Nullable<Scene>;
  55721. }
  55722. /**
  55723. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55724. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55725. * is automatically managed.
  55726. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55727. * in your application.
  55728. *
  55729. * As the update is not automatic, you need to call them manually.
  55730. */
  55731. export class HtmlElementTexture extends BaseTexture {
  55732. /**
  55733. * The texture URL.
  55734. */
  55735. element: HTMLVideoElement | HTMLCanvasElement;
  55736. private static readonly DefaultOptions;
  55737. private _textureMatrix;
  55738. private _engine;
  55739. private _isVideo;
  55740. private _generateMipMaps;
  55741. private _samplingMode;
  55742. /**
  55743. * Instantiates a HtmlElementTexture from the following parameters.
  55744. *
  55745. * @param name Defines the name of the texture
  55746. * @param element Defines the video or canvas the texture is filled with
  55747. * @param options Defines the other none mandatory texture creation options
  55748. */
  55749. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55750. private _createInternalTexture;
  55751. /**
  55752. * Returns the texture matrix used in most of the material.
  55753. */
  55754. getTextureMatrix(): Matrix;
  55755. /**
  55756. * Updates the content of the texture.
  55757. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55758. */
  55759. update(invertY?: Nullable<boolean>): void;
  55760. }
  55761. }
  55762. declare module "babylonjs/Materials/Textures/index" {
  55763. export * from "babylonjs/Materials/Textures/baseTexture";
  55764. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55765. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55766. export * from "babylonjs/Materials/Textures/cubeTexture";
  55767. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55768. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55769. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55770. export * from "babylonjs/Materials/Textures/internalTexture";
  55771. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55772. export * from "babylonjs/Materials/Textures/Loaders/index";
  55773. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55774. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55775. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55776. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55777. export * from "babylonjs/Materials/Textures/rawTexture";
  55778. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55779. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55780. export * from "babylonjs/Materials/Textures/refractionTexture";
  55781. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55782. export * from "babylonjs/Materials/Textures/texture";
  55783. export * from "babylonjs/Materials/Textures/videoTexture";
  55784. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55785. }
  55786. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55787. /**
  55788. * Enum used to define the target of a block
  55789. */
  55790. export enum NodeMaterialBlockTargets {
  55791. /** Vertex shader */
  55792. Vertex = 1,
  55793. /** Fragment shader */
  55794. Fragment = 2,
  55795. /** Neutral */
  55796. Neutral = 4,
  55797. /** Vertex and Fragment */
  55798. VertexAndFragment = 3
  55799. }
  55800. }
  55801. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55802. /**
  55803. * Defines the kind of connection point for node based material
  55804. */
  55805. export enum NodeMaterialBlockConnectionPointTypes {
  55806. /** Float */
  55807. Float = 1,
  55808. /** Int */
  55809. Int = 2,
  55810. /** Vector2 */
  55811. Vector2 = 4,
  55812. /** Vector3 */
  55813. Vector3 = 8,
  55814. /** Vector4 */
  55815. Vector4 = 16,
  55816. /** Color3 */
  55817. Color3 = 32,
  55818. /** Color4 */
  55819. Color4 = 64,
  55820. /** Matrix */
  55821. Matrix = 128,
  55822. /** Detect type based on connection */
  55823. AutoDetect = 1024,
  55824. /** Output type that will be defined by input type */
  55825. BasedOnInput = 2048
  55826. }
  55827. }
  55828. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55829. /**
  55830. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55831. */
  55832. export enum NodeMaterialBlockConnectionPointMode {
  55833. /** Value is an uniform */
  55834. Uniform = 0,
  55835. /** Value is a mesh attribute */
  55836. Attribute = 1,
  55837. /** Value is a varying between vertex and fragment shaders */
  55838. Varying = 2,
  55839. /** Mode is undefined */
  55840. Undefined = 3
  55841. }
  55842. }
  55843. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55844. /**
  55845. * Enum used to define system values e.g. values automatically provided by the system
  55846. */
  55847. export enum NodeMaterialSystemValues {
  55848. /** World */
  55849. World = 1,
  55850. /** View */
  55851. View = 2,
  55852. /** Projection */
  55853. Projection = 3,
  55854. /** ViewProjection */
  55855. ViewProjection = 4,
  55856. /** WorldView */
  55857. WorldView = 5,
  55858. /** WorldViewProjection */
  55859. WorldViewProjection = 6,
  55860. /** CameraPosition */
  55861. CameraPosition = 7,
  55862. /** Fog Color */
  55863. FogColor = 8,
  55864. /** Delta time */
  55865. DeltaTime = 9
  55866. }
  55867. }
  55868. declare module "babylonjs/Materials/Node/Enums/index" {
  55869. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55870. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55871. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55872. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55873. }
  55874. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55876. /**
  55877. * Root class for all node material optimizers
  55878. */
  55879. export class NodeMaterialOptimizer {
  55880. /**
  55881. * Function used to optimize a NodeMaterial graph
  55882. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55883. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55884. */
  55885. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55886. }
  55887. }
  55888. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55889. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55890. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55891. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55892. import { Scene } from "babylonjs/scene";
  55893. /**
  55894. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55895. */
  55896. export class TransformBlock extends NodeMaterialBlock {
  55897. /**
  55898. * Defines the value to use to complement W value to transform it to a Vector4
  55899. */
  55900. complementW: number;
  55901. /**
  55902. * Defines the value to use to complement z value to transform it to a Vector4
  55903. */
  55904. complementZ: number;
  55905. /**
  55906. * Creates a new TransformBlock
  55907. * @param name defines the block name
  55908. */
  55909. constructor(name: string);
  55910. /**
  55911. * Gets the current class name
  55912. * @returns the class name
  55913. */
  55914. getClassName(): string;
  55915. /**
  55916. * Gets the vector input
  55917. */
  55918. readonly vector: NodeMaterialConnectionPoint;
  55919. /**
  55920. * Gets the output component
  55921. */
  55922. readonly output: NodeMaterialConnectionPoint;
  55923. /**
  55924. * Gets the matrix transform input
  55925. */
  55926. readonly transform: NodeMaterialConnectionPoint;
  55927. protected _buildBlock(state: NodeMaterialBuildState): this;
  55928. serialize(): any;
  55929. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55930. protected _dumpPropertiesCode(): string;
  55931. }
  55932. }
  55933. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55937. /**
  55938. * Block used to output the vertex position
  55939. */
  55940. export class VertexOutputBlock extends NodeMaterialBlock {
  55941. /**
  55942. * Creates a new VertexOutputBlock
  55943. * @param name defines the block name
  55944. */
  55945. constructor(name: string);
  55946. /**
  55947. * Gets the current class name
  55948. * @returns the class name
  55949. */
  55950. getClassName(): string;
  55951. /**
  55952. * Gets the vector input component
  55953. */
  55954. readonly vector: NodeMaterialConnectionPoint;
  55955. protected _buildBlock(state: NodeMaterialBuildState): this;
  55956. }
  55957. }
  55958. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55960. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55961. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55962. /**
  55963. * Block used to output the final color
  55964. */
  55965. export class FragmentOutputBlock extends NodeMaterialBlock {
  55966. /**
  55967. * Create a new FragmentOutputBlock
  55968. * @param name defines the block name
  55969. */
  55970. constructor(name: string);
  55971. /**
  55972. * Gets the current class name
  55973. * @returns the class name
  55974. */
  55975. getClassName(): string;
  55976. /**
  55977. * Gets the rgba input component
  55978. */
  55979. readonly rgba: NodeMaterialConnectionPoint;
  55980. /**
  55981. * Gets the rgb input component
  55982. */
  55983. readonly rgb: NodeMaterialConnectionPoint;
  55984. /**
  55985. * Gets the a input component
  55986. */
  55987. readonly a: NodeMaterialConnectionPoint;
  55988. protected _buildBlock(state: NodeMaterialBuildState): this;
  55989. }
  55990. }
  55991. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55995. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55997. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55998. import { Effect } from "babylonjs/Materials/effect";
  55999. import { Mesh } from "babylonjs/Meshes/mesh";
  56000. import { Nullable } from "babylonjs/types";
  56001. import { Scene } from "babylonjs/scene";
  56002. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56003. /**
  56004. * Block used to read a reflection texture from a sampler
  56005. */
  56006. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56007. private _define3DName;
  56008. private _defineCubicName;
  56009. private _defineExplicitName;
  56010. private _defineProjectionName;
  56011. private _defineLocalCubicName;
  56012. private _defineSphericalName;
  56013. private _definePlanarName;
  56014. private _defineEquirectangularName;
  56015. private _defineMirroredEquirectangularFixedName;
  56016. private _defineEquirectangularFixedName;
  56017. private _defineSkyboxName;
  56018. private _cubeSamplerName;
  56019. private _2DSamplerName;
  56020. private _positionUVWName;
  56021. private _directionWName;
  56022. private _reflectionCoordsName;
  56023. private _reflection2DCoordsName;
  56024. private _reflectionColorName;
  56025. private _reflectionMatrixName;
  56026. /**
  56027. * Gets or sets the texture associated with the node
  56028. */
  56029. texture: Nullable<BaseTexture>;
  56030. /**
  56031. * Create a new TextureBlock
  56032. * @param name defines the block name
  56033. */
  56034. constructor(name: string);
  56035. /**
  56036. * Gets the current class name
  56037. * @returns the class name
  56038. */
  56039. getClassName(): string;
  56040. /**
  56041. * Gets the world position input component
  56042. */
  56043. readonly position: NodeMaterialConnectionPoint;
  56044. /**
  56045. * Gets the world position input component
  56046. */
  56047. readonly worldPosition: NodeMaterialConnectionPoint;
  56048. /**
  56049. * Gets the world normal input component
  56050. */
  56051. readonly worldNormal: NodeMaterialConnectionPoint;
  56052. /**
  56053. * Gets the world input component
  56054. */
  56055. readonly world: NodeMaterialConnectionPoint;
  56056. /**
  56057. * Gets the camera (or eye) position component
  56058. */
  56059. readonly cameraPosition: NodeMaterialConnectionPoint;
  56060. /**
  56061. * Gets the view input component
  56062. */
  56063. readonly view: NodeMaterialConnectionPoint;
  56064. /**
  56065. * Gets the rgb output component
  56066. */
  56067. readonly rgb: NodeMaterialConnectionPoint;
  56068. /**
  56069. * Gets the r output component
  56070. */
  56071. readonly r: NodeMaterialConnectionPoint;
  56072. /**
  56073. * Gets the g output component
  56074. */
  56075. readonly g: NodeMaterialConnectionPoint;
  56076. /**
  56077. * Gets the b output component
  56078. */
  56079. readonly b: NodeMaterialConnectionPoint;
  56080. autoConfigure(material: NodeMaterial): void;
  56081. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56082. isReady(): boolean;
  56083. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56084. private _injectVertexCode;
  56085. private _writeOutput;
  56086. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56087. protected _dumpPropertiesCode(): string;
  56088. serialize(): any;
  56089. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56090. }
  56091. }
  56092. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56094. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56095. import { Scene } from "babylonjs/scene";
  56096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56097. import { Matrix } from "babylonjs/Maths/math.vector";
  56098. import { Mesh } from "babylonjs/Meshes/mesh";
  56099. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56100. import { Observable } from "babylonjs/Misc/observable";
  56101. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56103. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56104. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56105. import { Nullable } from "babylonjs/types";
  56106. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56107. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56108. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56109. /**
  56110. * Interface used to configure the node material editor
  56111. */
  56112. export interface INodeMaterialEditorOptions {
  56113. /** Define the URl to load node editor script */
  56114. editorURL?: string;
  56115. }
  56116. /** @hidden */
  56117. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56118. /** BONES */
  56119. NUM_BONE_INFLUENCERS: number;
  56120. BonesPerMesh: number;
  56121. BONETEXTURE: boolean;
  56122. /** MORPH TARGETS */
  56123. MORPHTARGETS: boolean;
  56124. MORPHTARGETS_NORMAL: boolean;
  56125. MORPHTARGETS_TANGENT: boolean;
  56126. MORPHTARGETS_UV: boolean;
  56127. NUM_MORPH_INFLUENCERS: number;
  56128. /** IMAGE PROCESSING */
  56129. IMAGEPROCESSING: boolean;
  56130. VIGNETTE: boolean;
  56131. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56132. VIGNETTEBLENDMODEOPAQUE: boolean;
  56133. TONEMAPPING: boolean;
  56134. TONEMAPPING_ACES: boolean;
  56135. CONTRAST: boolean;
  56136. EXPOSURE: boolean;
  56137. COLORCURVES: boolean;
  56138. COLORGRADING: boolean;
  56139. COLORGRADING3D: boolean;
  56140. SAMPLER3DGREENDEPTH: boolean;
  56141. SAMPLER3DBGRMAP: boolean;
  56142. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56143. /** MISC. */
  56144. BUMPDIRECTUV: number;
  56145. constructor();
  56146. setValue(name: string, value: boolean): void;
  56147. }
  56148. /**
  56149. * Class used to configure NodeMaterial
  56150. */
  56151. export interface INodeMaterialOptions {
  56152. /**
  56153. * Defines if blocks should emit comments
  56154. */
  56155. emitComments: boolean;
  56156. }
  56157. /**
  56158. * Class used to create a node based material built by assembling shader blocks
  56159. */
  56160. export class NodeMaterial extends PushMaterial {
  56161. private static _BuildIdGenerator;
  56162. private _options;
  56163. private _vertexCompilationState;
  56164. private _fragmentCompilationState;
  56165. private _sharedData;
  56166. private _buildId;
  56167. private _buildWasSuccessful;
  56168. private _cachedWorldViewMatrix;
  56169. private _cachedWorldViewProjectionMatrix;
  56170. private _optimizers;
  56171. private _animationFrame;
  56172. /** Define the URl to load node editor script */
  56173. static EditorURL: string;
  56174. private BJSNODEMATERIALEDITOR;
  56175. /** Get the inspector from bundle or global */
  56176. private _getGlobalNodeMaterialEditor;
  56177. /**
  56178. * 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)
  56179. */
  56180. ignoreAlpha: boolean;
  56181. /**
  56182. * Defines the maximum number of lights that can be used in the material
  56183. */
  56184. maxSimultaneousLights: number;
  56185. /**
  56186. * Observable raised when the material is built
  56187. */
  56188. onBuildObservable: Observable<NodeMaterial>;
  56189. /**
  56190. * Gets or sets the root nodes of the material vertex shader
  56191. */
  56192. _vertexOutputNodes: NodeMaterialBlock[];
  56193. /**
  56194. * Gets or sets the root nodes of the material fragment (pixel) shader
  56195. */
  56196. _fragmentOutputNodes: NodeMaterialBlock[];
  56197. /** Gets or sets options to control the node material overall behavior */
  56198. options: INodeMaterialOptions;
  56199. /**
  56200. * Default configuration related to image processing available in the standard Material.
  56201. */
  56202. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56203. /**
  56204. * Gets the image processing configuration used either in this material.
  56205. */
  56206. /**
  56207. * Sets the Default image processing configuration used either in the this material.
  56208. *
  56209. * If sets to null, the scene one is in use.
  56210. */
  56211. imageProcessingConfiguration: ImageProcessingConfiguration;
  56212. /**
  56213. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56214. */
  56215. attachedBlocks: NodeMaterialBlock[];
  56216. /**
  56217. * Create a new node based material
  56218. * @param name defines the material name
  56219. * @param scene defines the hosting scene
  56220. * @param options defines creation option
  56221. */
  56222. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56223. /**
  56224. * Gets the current class name of the material e.g. "NodeMaterial"
  56225. * @returns the class name
  56226. */
  56227. getClassName(): string;
  56228. /**
  56229. * Keep track of the image processing observer to allow dispose and replace.
  56230. */
  56231. private _imageProcessingObserver;
  56232. /**
  56233. * Attaches a new image processing configuration to the Standard Material.
  56234. * @param configuration
  56235. */
  56236. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56237. /**
  56238. * Get a block by its name
  56239. * @param name defines the name of the block to retrieve
  56240. * @returns the required block or null if not found
  56241. */
  56242. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56243. /**
  56244. * Get a block by its name
  56245. * @param predicate defines the predicate used to find the good candidate
  56246. * @returns the required block or null if not found
  56247. */
  56248. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56249. /**
  56250. * Get an input block by its name
  56251. * @param predicate defines the predicate used to find the good candidate
  56252. * @returns the required input block or null if not found
  56253. */
  56254. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56255. /**
  56256. * Gets the list of input blocks attached to this material
  56257. * @returns an array of InputBlocks
  56258. */
  56259. getInputBlocks(): InputBlock[];
  56260. /**
  56261. * Adds a new optimizer to the list of optimizers
  56262. * @param optimizer defines the optimizers to add
  56263. * @returns the current material
  56264. */
  56265. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56266. /**
  56267. * Remove an optimizer from the list of optimizers
  56268. * @param optimizer defines the optimizers to remove
  56269. * @returns the current material
  56270. */
  56271. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56272. /**
  56273. * Add a new block to the list of output nodes
  56274. * @param node defines the node to add
  56275. * @returns the current material
  56276. */
  56277. addOutputNode(node: NodeMaterialBlock): this;
  56278. /**
  56279. * Remove a block from the list of root nodes
  56280. * @param node defines the node to remove
  56281. * @returns the current material
  56282. */
  56283. removeOutputNode(node: NodeMaterialBlock): this;
  56284. private _addVertexOutputNode;
  56285. private _removeVertexOutputNode;
  56286. private _addFragmentOutputNode;
  56287. private _removeFragmentOutputNode;
  56288. /**
  56289. * Specifies if the material will require alpha blending
  56290. * @returns a boolean specifying if alpha blending is needed
  56291. */
  56292. needAlphaBlending(): boolean;
  56293. /**
  56294. * Specifies if this material should be rendered in alpha test mode
  56295. * @returns a boolean specifying if an alpha test is needed.
  56296. */
  56297. needAlphaTesting(): boolean;
  56298. private _initializeBlock;
  56299. private _resetDualBlocks;
  56300. /**
  56301. * Build the material and generates the inner effect
  56302. * @param verbose defines if the build should log activity
  56303. */
  56304. build(verbose?: boolean): void;
  56305. /**
  56306. * Runs an otpimization phase to try to improve the shader code
  56307. */
  56308. optimize(): void;
  56309. private _prepareDefinesForAttributes;
  56310. /**
  56311. * Get if the submesh is ready to be used and all its information available.
  56312. * Child classes can use it to update shaders
  56313. * @param mesh defines the mesh to check
  56314. * @param subMesh defines which submesh to check
  56315. * @param useInstances specifies that instances should be used
  56316. * @returns a boolean indicating that the submesh is ready or not
  56317. */
  56318. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56319. /**
  56320. * Get a string representing the shaders built by the current node graph
  56321. */
  56322. readonly compiledShaders: string;
  56323. /**
  56324. * Binds the world matrix to the material
  56325. * @param world defines the world transformation matrix
  56326. */
  56327. bindOnlyWorldMatrix(world: Matrix): void;
  56328. /**
  56329. * Binds the submesh to this material by preparing the effect and shader to draw
  56330. * @param world defines the world transformation matrix
  56331. * @param mesh defines the mesh containing the submesh
  56332. * @param subMesh defines the submesh to bind the material to
  56333. */
  56334. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56335. /**
  56336. * Gets the active textures from the material
  56337. * @returns an array of textures
  56338. */
  56339. getActiveTextures(): BaseTexture[];
  56340. /**
  56341. * Gets the list of texture blocks
  56342. * @returns an array of texture blocks
  56343. */
  56344. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56345. /**
  56346. * Specifies if the material uses a texture
  56347. * @param texture defines the texture to check against the material
  56348. * @returns a boolean specifying if the material uses the texture
  56349. */
  56350. hasTexture(texture: BaseTexture): boolean;
  56351. /**
  56352. * Disposes the material
  56353. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56354. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56355. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56356. */
  56357. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56358. /** Creates the node editor window. */
  56359. private _createNodeEditor;
  56360. /**
  56361. * Launch the node material editor
  56362. * @param config Define the configuration of the editor
  56363. * @return a promise fulfilled when the node editor is visible
  56364. */
  56365. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56366. /**
  56367. * Clear the current material
  56368. */
  56369. clear(): void;
  56370. /**
  56371. * Clear the current material and set it to a default state
  56372. */
  56373. setToDefault(): void;
  56374. /**
  56375. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56376. * @param url defines the url to load from
  56377. * @returns a promise that will fullfil when the material is fully loaded
  56378. */
  56379. loadAsync(url: string): Promise<void>;
  56380. private _gatherBlocks;
  56381. /**
  56382. * Generate a string containing the code declaration required to create an equivalent of this material
  56383. * @returns a string
  56384. */
  56385. generateCode(): string;
  56386. /**
  56387. * Serializes this material in a JSON representation
  56388. * @returns the serialized material object
  56389. */
  56390. serialize(): any;
  56391. private _restoreConnections;
  56392. /**
  56393. * Clear the current graph and load a new one from a serialization object
  56394. * @param source defines the JSON representation of the material
  56395. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56396. */
  56397. loadFromSerialization(source: any, rootUrl?: string): void;
  56398. /**
  56399. * Creates a node material from parsed material data
  56400. * @param source defines the JSON representation of the material
  56401. * @param scene defines the hosting scene
  56402. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56403. * @returns a new node material
  56404. */
  56405. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56406. /**
  56407. * Creates a new node material set to default basic configuration
  56408. * @param name defines the name of the material
  56409. * @param scene defines the hosting scene
  56410. * @returns a new NodeMaterial
  56411. */
  56412. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56413. }
  56414. }
  56415. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56418. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56419. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56421. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56422. import { Effect } from "babylonjs/Materials/effect";
  56423. import { Mesh } from "babylonjs/Meshes/mesh";
  56424. import { Nullable } from "babylonjs/types";
  56425. import { Texture } from "babylonjs/Materials/Textures/texture";
  56426. import { Scene } from "babylonjs/scene";
  56427. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56428. /**
  56429. * Block used to read a texture from a sampler
  56430. */
  56431. export class TextureBlock extends NodeMaterialBlock {
  56432. private _defineName;
  56433. private _linearDefineName;
  56434. private _samplerName;
  56435. private _transformedUVName;
  56436. private _textureTransformName;
  56437. private _textureInfoName;
  56438. private _mainUVName;
  56439. private _mainUVDefineName;
  56440. /**
  56441. * Gets or sets the texture associated with the node
  56442. */
  56443. texture: Nullable<Texture>;
  56444. /**
  56445. * Create a new TextureBlock
  56446. * @param name defines the block name
  56447. */
  56448. constructor(name: string);
  56449. /**
  56450. * Gets the current class name
  56451. * @returns the class name
  56452. */
  56453. getClassName(): string;
  56454. /**
  56455. * Gets the uv input component
  56456. */
  56457. readonly uv: NodeMaterialConnectionPoint;
  56458. /**
  56459. * Gets the rgba output component
  56460. */
  56461. readonly rgba: NodeMaterialConnectionPoint;
  56462. /**
  56463. * Gets the rgb output component
  56464. */
  56465. readonly rgb: NodeMaterialConnectionPoint;
  56466. /**
  56467. * Gets the r output component
  56468. */
  56469. readonly r: NodeMaterialConnectionPoint;
  56470. /**
  56471. * Gets the g output component
  56472. */
  56473. readonly g: NodeMaterialConnectionPoint;
  56474. /**
  56475. * Gets the b output component
  56476. */
  56477. readonly b: NodeMaterialConnectionPoint;
  56478. /**
  56479. * Gets the a output component
  56480. */
  56481. readonly a: NodeMaterialConnectionPoint;
  56482. readonly target: NodeMaterialBlockTargets;
  56483. autoConfigure(material: NodeMaterial): void;
  56484. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56485. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56486. isReady(): boolean;
  56487. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56488. private readonly _isMixed;
  56489. private _injectVertexCode;
  56490. private _writeOutput;
  56491. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56492. protected _dumpPropertiesCode(): string;
  56493. serialize(): any;
  56494. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56495. }
  56496. }
  56497. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56500. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56501. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56502. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56503. import { Scene } from "babylonjs/scene";
  56504. /**
  56505. * Class used to store shared data between 2 NodeMaterialBuildState
  56506. */
  56507. export class NodeMaterialBuildStateSharedData {
  56508. /**
  56509. * Gets the list of emitted varyings
  56510. */
  56511. temps: string[];
  56512. /**
  56513. * Gets the list of emitted varyings
  56514. */
  56515. varyings: string[];
  56516. /**
  56517. * Gets the varying declaration string
  56518. */
  56519. varyingDeclaration: string;
  56520. /**
  56521. * Input blocks
  56522. */
  56523. inputBlocks: InputBlock[];
  56524. /**
  56525. * Input blocks
  56526. */
  56527. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56528. /**
  56529. * Bindable blocks (Blocks that need to set data to the effect)
  56530. */
  56531. bindableBlocks: NodeMaterialBlock[];
  56532. /**
  56533. * List of blocks that can provide a compilation fallback
  56534. */
  56535. blocksWithFallbacks: NodeMaterialBlock[];
  56536. /**
  56537. * List of blocks that can provide a define update
  56538. */
  56539. blocksWithDefines: NodeMaterialBlock[];
  56540. /**
  56541. * List of blocks that can provide a repeatable content
  56542. */
  56543. repeatableContentBlocks: NodeMaterialBlock[];
  56544. /**
  56545. * List of blocks that can provide a dynamic list of uniforms
  56546. */
  56547. dynamicUniformBlocks: NodeMaterialBlock[];
  56548. /**
  56549. * List of blocks that can block the isReady function for the material
  56550. */
  56551. blockingBlocks: NodeMaterialBlock[];
  56552. /**
  56553. * Gets the list of animated inputs
  56554. */
  56555. animatedInputs: InputBlock[];
  56556. /**
  56557. * Build Id used to avoid multiple recompilations
  56558. */
  56559. buildId: number;
  56560. /** List of emitted variables */
  56561. variableNames: {
  56562. [key: string]: number;
  56563. };
  56564. /** List of emitted defines */
  56565. defineNames: {
  56566. [key: string]: number;
  56567. };
  56568. /** Should emit comments? */
  56569. emitComments: boolean;
  56570. /** Emit build activity */
  56571. verbose: boolean;
  56572. /** Gets or sets the hosting scene */
  56573. scene: Scene;
  56574. /**
  56575. * Gets the compilation hints emitted at compilation time
  56576. */
  56577. hints: {
  56578. needWorldViewMatrix: boolean;
  56579. needWorldViewProjectionMatrix: boolean;
  56580. needAlphaBlending: boolean;
  56581. needAlphaTesting: boolean;
  56582. };
  56583. /**
  56584. * List of compilation checks
  56585. */
  56586. checks: {
  56587. emitVertex: boolean;
  56588. emitFragment: boolean;
  56589. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56590. };
  56591. /** Creates a new shared data */
  56592. constructor();
  56593. /**
  56594. * Emits console errors and exceptions if there is a failing check
  56595. */
  56596. emitErrors(): void;
  56597. }
  56598. }
  56599. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56600. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56601. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56602. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56603. /**
  56604. * Class used to store node based material build state
  56605. */
  56606. export class NodeMaterialBuildState {
  56607. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56608. supportUniformBuffers: boolean;
  56609. /**
  56610. * Gets the list of emitted attributes
  56611. */
  56612. attributes: string[];
  56613. /**
  56614. * Gets the list of emitted uniforms
  56615. */
  56616. uniforms: string[];
  56617. /**
  56618. * Gets the list of emitted constants
  56619. */
  56620. constants: string[];
  56621. /**
  56622. * Gets the list of emitted samplers
  56623. */
  56624. samplers: string[];
  56625. /**
  56626. * Gets the list of emitted functions
  56627. */
  56628. functions: {
  56629. [key: string]: string;
  56630. };
  56631. /**
  56632. * Gets the list of emitted extensions
  56633. */
  56634. extensions: {
  56635. [key: string]: string;
  56636. };
  56637. /**
  56638. * Gets the target of the compilation state
  56639. */
  56640. target: NodeMaterialBlockTargets;
  56641. /**
  56642. * Gets the list of emitted counters
  56643. */
  56644. counters: {
  56645. [key: string]: number;
  56646. };
  56647. /**
  56648. * Shared data between multiple NodeMaterialBuildState instances
  56649. */
  56650. sharedData: NodeMaterialBuildStateSharedData;
  56651. /** @hidden */
  56652. _vertexState: NodeMaterialBuildState;
  56653. /** @hidden */
  56654. _attributeDeclaration: string;
  56655. /** @hidden */
  56656. _uniformDeclaration: string;
  56657. /** @hidden */
  56658. _constantDeclaration: string;
  56659. /** @hidden */
  56660. _samplerDeclaration: string;
  56661. /** @hidden */
  56662. _varyingTransfer: string;
  56663. private _repeatableContentAnchorIndex;
  56664. /** @hidden */
  56665. _builtCompilationString: string;
  56666. /**
  56667. * Gets the emitted compilation strings
  56668. */
  56669. compilationString: string;
  56670. /**
  56671. * Finalize the compilation strings
  56672. * @param state defines the current compilation state
  56673. */
  56674. finalize(state: NodeMaterialBuildState): void;
  56675. /** @hidden */
  56676. readonly _repeatableContentAnchor: string;
  56677. /** @hidden */
  56678. _getFreeVariableName(prefix: string): string;
  56679. /** @hidden */
  56680. _getFreeDefineName(prefix: string): string;
  56681. /** @hidden */
  56682. _excludeVariableName(name: string): void;
  56683. /** @hidden */
  56684. _emit2DSampler(name: string): void;
  56685. /** @hidden */
  56686. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56687. /** @hidden */
  56688. _emitExtension(name: string, extension: string): void;
  56689. /** @hidden */
  56690. _emitFunction(name: string, code: string, comments: string): void;
  56691. /** @hidden */
  56692. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56693. replaceStrings?: {
  56694. search: RegExp;
  56695. replace: string;
  56696. }[];
  56697. repeatKey?: string;
  56698. }): string;
  56699. /** @hidden */
  56700. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56701. repeatKey?: string;
  56702. removeAttributes?: boolean;
  56703. removeUniforms?: boolean;
  56704. removeVaryings?: boolean;
  56705. removeIfDef?: boolean;
  56706. replaceStrings?: {
  56707. search: RegExp;
  56708. replace: string;
  56709. }[];
  56710. }, storeKey?: string): void;
  56711. /** @hidden */
  56712. _registerTempVariable(name: string): boolean;
  56713. /** @hidden */
  56714. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56715. /** @hidden */
  56716. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56717. /** @hidden */
  56718. _emitFloat(value: number): string;
  56719. }
  56720. }
  56721. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56722. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56724. import { Nullable } from "babylonjs/types";
  56725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56726. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56727. import { Effect } from "babylonjs/Materials/effect";
  56728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56729. import { Mesh } from "babylonjs/Meshes/mesh";
  56730. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56731. import { Scene } from "babylonjs/scene";
  56732. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56733. /**
  56734. * Defines a block that can be used inside a node based material
  56735. */
  56736. export class NodeMaterialBlock {
  56737. private _buildId;
  56738. private _buildTarget;
  56739. private _target;
  56740. private _isFinalMerger;
  56741. private _isInput;
  56742. protected _isUnique: boolean;
  56743. /** @hidden */
  56744. _codeVariableName: string;
  56745. /** @hidden */
  56746. _inputs: NodeMaterialConnectionPoint[];
  56747. /** @hidden */
  56748. _outputs: NodeMaterialConnectionPoint[];
  56749. /** @hidden */
  56750. _preparationId: number;
  56751. /**
  56752. * Gets or sets the name of the block
  56753. */
  56754. name: string;
  56755. /**
  56756. * Gets or sets the unique id of the node
  56757. */
  56758. uniqueId: number;
  56759. /**
  56760. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  56761. */
  56762. readonly isUnique: boolean;
  56763. /**
  56764. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56765. */
  56766. readonly isFinalMerger: boolean;
  56767. /**
  56768. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56769. */
  56770. readonly isInput: boolean;
  56771. /**
  56772. * Gets or sets the build Id
  56773. */
  56774. buildId: number;
  56775. /**
  56776. * Gets or sets the target of the block
  56777. */
  56778. target: NodeMaterialBlockTargets;
  56779. /**
  56780. * Gets the list of input points
  56781. */
  56782. readonly inputs: NodeMaterialConnectionPoint[];
  56783. /** Gets the list of output points */
  56784. readonly outputs: NodeMaterialConnectionPoint[];
  56785. /**
  56786. * Find an input by its name
  56787. * @param name defines the name of the input to look for
  56788. * @returns the input or null if not found
  56789. */
  56790. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56791. /**
  56792. * Find an output by its name
  56793. * @param name defines the name of the outputto look for
  56794. * @returns the output or null if not found
  56795. */
  56796. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56797. /**
  56798. * Creates a new NodeMaterialBlock
  56799. * @param name defines the block name
  56800. * @param target defines the target of that block (Vertex by default)
  56801. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56802. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56803. */
  56804. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56805. /**
  56806. * Initialize the block and prepare the context for build
  56807. * @param state defines the state that will be used for the build
  56808. */
  56809. initialize(state: NodeMaterialBuildState): void;
  56810. /**
  56811. * Bind data to effect. Will only be called for blocks with isBindable === true
  56812. * @param effect defines the effect to bind data to
  56813. * @param nodeMaterial defines the hosting NodeMaterial
  56814. * @param mesh defines the mesh that will be rendered
  56815. */
  56816. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56817. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56818. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56819. protected _writeFloat(value: number): string;
  56820. /**
  56821. * Gets the current class name e.g. "NodeMaterialBlock"
  56822. * @returns the class name
  56823. */
  56824. getClassName(): string;
  56825. /**
  56826. * Register a new input. Must be called inside a block constructor
  56827. * @param name defines the connection point name
  56828. * @param type defines the connection point type
  56829. * @param isOptional defines a boolean indicating that this input can be omitted
  56830. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56831. * @returns the current block
  56832. */
  56833. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56834. /**
  56835. * Register a new output. Must be called inside a block constructor
  56836. * @param name defines the connection point name
  56837. * @param type defines the connection point type
  56838. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56839. * @returns the current block
  56840. */
  56841. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56842. /**
  56843. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56844. * @param forOutput defines an optional connection point to check compatibility with
  56845. * @returns the first available input or null
  56846. */
  56847. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56848. /**
  56849. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56850. * @param forBlock defines an optional block to check compatibility with
  56851. * @returns the first available input or null
  56852. */
  56853. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56854. /**
  56855. * Gets the sibling of the given output
  56856. * @param current defines the current output
  56857. * @returns the next output in the list or null
  56858. */
  56859. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56860. /**
  56861. * Connect current block with another block
  56862. * @param other defines the block to connect with
  56863. * @param options define the various options to help pick the right connections
  56864. * @returns the current block
  56865. */
  56866. connectTo(other: NodeMaterialBlock, options?: {
  56867. input?: string;
  56868. output?: string;
  56869. outputSwizzle?: string;
  56870. }): this | undefined;
  56871. protected _buildBlock(state: NodeMaterialBuildState): void;
  56872. /**
  56873. * Add uniforms, samplers and uniform buffers at compilation time
  56874. * @param state defines the state to update
  56875. * @param nodeMaterial defines the node material requesting the update
  56876. * @param defines defines the material defines to update
  56877. * @param uniformBuffers defines the list of uniform buffer names
  56878. */
  56879. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56880. /**
  56881. * Add potential fallbacks if shader compilation fails
  56882. * @param mesh defines the mesh to be rendered
  56883. * @param fallbacks defines the current prioritized list of fallbacks
  56884. */
  56885. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56886. /**
  56887. * Initialize defines for shader compilation
  56888. * @param mesh defines the mesh to be rendered
  56889. * @param nodeMaterial defines the node material requesting the update
  56890. * @param defines defines the material defines to update
  56891. * @param useInstances specifies that instances should be used
  56892. */
  56893. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56894. /**
  56895. * Update defines for shader compilation
  56896. * @param mesh defines the mesh to be rendered
  56897. * @param nodeMaterial defines the node material requesting the update
  56898. * @param defines defines the material defines to update
  56899. * @param useInstances specifies that instances should be used
  56900. */
  56901. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56902. /**
  56903. * Lets the block try to connect some inputs automatically
  56904. * @param material defines the hosting NodeMaterial
  56905. */
  56906. autoConfigure(material: NodeMaterial): void;
  56907. /**
  56908. * Function called when a block is declared as repeatable content generator
  56909. * @param vertexShaderState defines the current compilation state for the vertex shader
  56910. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56911. * @param mesh defines the mesh to be rendered
  56912. * @param defines defines the material defines to update
  56913. */
  56914. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56915. /**
  56916. * Checks if the block is ready
  56917. * @param mesh defines the mesh to be rendered
  56918. * @param nodeMaterial defines the node material requesting the update
  56919. * @param defines defines the material defines to update
  56920. * @param useInstances specifies that instances should be used
  56921. * @returns true if the block is ready
  56922. */
  56923. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56924. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56925. private _processBuild;
  56926. /**
  56927. * Compile the current node and generate the shader code
  56928. * @param state defines the current compilation state (uniforms, samplers, current string)
  56929. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56930. * @returns true if already built
  56931. */
  56932. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56933. protected _inputRename(name: string): string;
  56934. protected _outputRename(name: string): string;
  56935. protected _dumpPropertiesCode(): string;
  56936. /** @hidden */
  56937. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56938. /** @hidden */
  56939. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56940. /**
  56941. * Clone the current block to a new identical block
  56942. * @param scene defines the hosting scene
  56943. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56944. * @returns a copy of the current block
  56945. */
  56946. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56947. /**
  56948. * Serializes this block in a JSON representation
  56949. * @returns the serialized block object
  56950. */
  56951. serialize(): any;
  56952. /** @hidden */
  56953. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56954. /**
  56955. * Release resources
  56956. */
  56957. dispose(): void;
  56958. }
  56959. }
  56960. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56961. /**
  56962. * Enum defining the type of animations supported by InputBlock
  56963. */
  56964. export enum AnimatedInputBlockTypes {
  56965. /** No animation */
  56966. None = 0,
  56967. /** Time based animation. Will only work for floats */
  56968. Time = 1
  56969. }
  56970. }
  56971. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56972. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56973. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56974. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56975. import { Nullable } from "babylonjs/types";
  56976. import { Effect } from "babylonjs/Materials/effect";
  56977. import { Matrix } from "babylonjs/Maths/math.vector";
  56978. import { Scene } from "babylonjs/scene";
  56979. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56981. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56982. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56983. /**
  56984. * Block used to expose an input value
  56985. */
  56986. export class InputBlock extends NodeMaterialBlock {
  56987. private _mode;
  56988. private _associatedVariableName;
  56989. private _storedValue;
  56990. private _valueCallback;
  56991. private _type;
  56992. private _animationType;
  56993. /** Gets or set a value used to limit the range of float values */
  56994. min: number;
  56995. /** Gets or set a value used to limit the range of float values */
  56996. max: number;
  56997. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56998. matrixMode: number;
  56999. /** @hidden */
  57000. _systemValue: Nullable<NodeMaterialSystemValues>;
  57001. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57002. visibleInInspector: boolean;
  57003. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57004. isConstant: boolean;
  57005. /**
  57006. * Gets or sets the connection point type (default is float)
  57007. */
  57008. readonly type: NodeMaterialBlockConnectionPointTypes;
  57009. /**
  57010. * Creates a new InputBlock
  57011. * @param name defines the block name
  57012. * @param target defines the target of that block (Vertex by default)
  57013. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57014. */
  57015. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57016. /**
  57017. * Gets the output component
  57018. */
  57019. readonly output: NodeMaterialConnectionPoint;
  57020. /**
  57021. * Set the source of this connection point to a vertex attribute
  57022. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57023. * @returns the current connection point
  57024. */
  57025. setAsAttribute(attributeName?: string): InputBlock;
  57026. /**
  57027. * Set the source of this connection point to a system value
  57028. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57029. * @returns the current connection point
  57030. */
  57031. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57032. /**
  57033. * Gets or sets the value of that point.
  57034. * Please note that this value will be ignored if valueCallback is defined
  57035. */
  57036. value: any;
  57037. /**
  57038. * Gets or sets a callback used to get the value of that point.
  57039. * Please note that setting this value will force the connection point to ignore the value property
  57040. */
  57041. valueCallback: () => any;
  57042. /**
  57043. * Gets or sets the associated variable name in the shader
  57044. */
  57045. associatedVariableName: string;
  57046. /** Gets or sets the type of animation applied to the input */
  57047. animationType: AnimatedInputBlockTypes;
  57048. /**
  57049. * Gets a boolean indicating that this connection point not defined yet
  57050. */
  57051. readonly isUndefined: boolean;
  57052. /**
  57053. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57054. * In this case the connection point name must be the name of the uniform to use.
  57055. * Can only be set on inputs
  57056. */
  57057. isUniform: boolean;
  57058. /**
  57059. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57060. * In this case the connection point name must be the name of the attribute to use
  57061. * Can only be set on inputs
  57062. */
  57063. isAttribute: boolean;
  57064. /**
  57065. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57066. * Can only be set on exit points
  57067. */
  57068. isVarying: boolean;
  57069. /**
  57070. * Gets a boolean indicating that the current connection point is a system value
  57071. */
  57072. readonly isSystemValue: boolean;
  57073. /**
  57074. * Gets or sets the current well known value or null if not defined as a system value
  57075. */
  57076. systemValue: Nullable<NodeMaterialSystemValues>;
  57077. /**
  57078. * Gets the current class name
  57079. * @returns the class name
  57080. */
  57081. getClassName(): string;
  57082. /**
  57083. * Animate the input if animationType !== None
  57084. * @param scene defines the rendering scene
  57085. */
  57086. animate(scene: Scene): void;
  57087. private _emitDefine;
  57088. initialize(state: NodeMaterialBuildState): void;
  57089. /**
  57090. * Set the input block to its default value (based on its type)
  57091. */
  57092. setDefaultValue(): void;
  57093. private _emitConstant;
  57094. private _emit;
  57095. /** @hidden */
  57096. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57097. /** @hidden */
  57098. _transmit(effect: Effect, scene: Scene): void;
  57099. protected _buildBlock(state: NodeMaterialBuildState): void;
  57100. protected _dumpPropertiesCode(): string;
  57101. serialize(): any;
  57102. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57103. }
  57104. }
  57105. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57106. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57107. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57108. import { Nullable } from "babylonjs/types";
  57109. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57110. import { Observable } from "babylonjs/Misc/observable";
  57111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57112. /**
  57113. * Enum used to define the compatibility state between two connection points
  57114. */
  57115. export enum NodeMaterialConnectionPointCompatibilityStates {
  57116. /** Points are compatibles */
  57117. Compatible = 0,
  57118. /** Points are incompatible because of their types */
  57119. TypeIncompatible = 1,
  57120. /** Points are incompatible because of their targets (vertex vs fragment) */
  57121. TargetIncompatible = 2
  57122. }
  57123. /**
  57124. * Defines a connection point for a block
  57125. */
  57126. export class NodeMaterialConnectionPoint {
  57127. /** @hidden */
  57128. _ownerBlock: NodeMaterialBlock;
  57129. /** @hidden */
  57130. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57131. private _endpoints;
  57132. private _associatedVariableName;
  57133. /** @hidden */
  57134. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57135. /** @hidden */
  57136. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57137. private _type;
  57138. /** @hidden */
  57139. _enforceAssociatedVariableName: boolean;
  57140. /**
  57141. * Gets or sets the additional types supported by this connection point
  57142. */
  57143. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57144. /**
  57145. * Gets or sets the additional types excluded by this connection point
  57146. */
  57147. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57148. /**
  57149. * Observable triggered when this point is connected
  57150. */
  57151. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57152. /**
  57153. * Gets or sets the associated variable name in the shader
  57154. */
  57155. associatedVariableName: string;
  57156. /**
  57157. * Gets or sets the connection point type (default is float)
  57158. */
  57159. type: NodeMaterialBlockConnectionPointTypes;
  57160. /**
  57161. * Gets or sets the connection point name
  57162. */
  57163. name: string;
  57164. /**
  57165. * Gets or sets a boolean indicating that this connection point can be omitted
  57166. */
  57167. isOptional: boolean;
  57168. /**
  57169. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57170. */
  57171. define: string;
  57172. /** @hidden */
  57173. _prioritizeVertex: boolean;
  57174. private _target;
  57175. /** Gets or sets the target of that connection point */
  57176. target: NodeMaterialBlockTargets;
  57177. /**
  57178. * Gets a boolean indicating that the current point is connected
  57179. */
  57180. readonly isConnected: boolean;
  57181. /**
  57182. * Gets a boolean indicating that the current point is connected to an input block
  57183. */
  57184. readonly isConnectedToInputBlock: boolean;
  57185. /**
  57186. * Gets a the connected input block (if any)
  57187. */
  57188. readonly connectInputBlock: Nullable<InputBlock>;
  57189. /** Get the other side of the connection (if any) */
  57190. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57191. /** Get the block that owns this connection point */
  57192. readonly ownerBlock: NodeMaterialBlock;
  57193. /** Get the block connected on the other side of this connection (if any) */
  57194. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57195. /** Get the block connected on the endpoints of this connection (if any) */
  57196. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57197. /** Gets the list of connected endpoints */
  57198. readonly endpoints: NodeMaterialConnectionPoint[];
  57199. /** Gets a boolean indicating if that output point is connected to at least one input */
  57200. readonly hasEndpoints: boolean;
  57201. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57202. readonly isConnectedInVertexShader: boolean;
  57203. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57204. readonly isConnectedInFragmentShader: boolean;
  57205. /**
  57206. * Creates a new connection point
  57207. * @param name defines the connection point name
  57208. * @param ownerBlock defines the block hosting this connection point
  57209. */
  57210. constructor(name: string, ownerBlock: NodeMaterialBlock);
  57211. /**
  57212. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57213. * @returns the class name
  57214. */
  57215. getClassName(): string;
  57216. /**
  57217. * Gets a boolean indicating if the current point can be connected to another point
  57218. * @param connectionPoint defines the other connection point
  57219. * @returns a boolean
  57220. */
  57221. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57222. /**
  57223. * Gets a number indicating if the current point can be connected to another point
  57224. * @param connectionPoint defines the other connection point
  57225. * @returns a number defining the compatibility state
  57226. */
  57227. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57228. /**
  57229. * Connect this point to another connection point
  57230. * @param connectionPoint defines the other connection point
  57231. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57232. * @returns the current connection point
  57233. */
  57234. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57235. /**
  57236. * Disconnect this point from one of his endpoint
  57237. * @param endpoint defines the other connection point
  57238. * @returns the current connection point
  57239. */
  57240. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57241. /**
  57242. * Serializes this point in a JSON representation
  57243. * @returns the serialized point object
  57244. */
  57245. serialize(): any;
  57246. /**
  57247. * Release resources
  57248. */
  57249. dispose(): void;
  57250. }
  57251. }
  57252. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57253. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57254. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57256. import { Mesh } from "babylonjs/Meshes/mesh";
  57257. import { Effect } from "babylonjs/Materials/effect";
  57258. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57259. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57260. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57261. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57262. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57263. /**
  57264. * Block used to add support for vertex skinning (bones)
  57265. */
  57266. export class BonesBlock extends NodeMaterialBlock {
  57267. /**
  57268. * Creates a new BonesBlock
  57269. * @param name defines the block name
  57270. */
  57271. constructor(name: string);
  57272. /**
  57273. * Initialize the block and prepare the context for build
  57274. * @param state defines the state that will be used for the build
  57275. */
  57276. initialize(state: NodeMaterialBuildState): void;
  57277. /**
  57278. * Gets the current class name
  57279. * @returns the class name
  57280. */
  57281. getClassName(): string;
  57282. /**
  57283. * Gets the matrix indices input component
  57284. */
  57285. readonly matricesIndices: NodeMaterialConnectionPoint;
  57286. /**
  57287. * Gets the matrix weights input component
  57288. */
  57289. readonly matricesWeights: NodeMaterialConnectionPoint;
  57290. /**
  57291. * Gets the extra matrix indices input component
  57292. */
  57293. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57294. /**
  57295. * Gets the extra matrix weights input component
  57296. */
  57297. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57298. /**
  57299. * Gets the world input component
  57300. */
  57301. readonly world: NodeMaterialConnectionPoint;
  57302. /**
  57303. * Gets the output component
  57304. */
  57305. readonly output: NodeMaterialConnectionPoint;
  57306. autoConfigure(material: NodeMaterial): void;
  57307. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57308. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57309. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57310. protected _buildBlock(state: NodeMaterialBuildState): this;
  57311. }
  57312. }
  57313. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57318. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57319. /**
  57320. * Block used to add support for instances
  57321. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57322. */
  57323. export class InstancesBlock extends NodeMaterialBlock {
  57324. /**
  57325. * Creates a new InstancesBlock
  57326. * @param name defines the block name
  57327. */
  57328. constructor(name: string);
  57329. /**
  57330. * Gets the current class name
  57331. * @returns the class name
  57332. */
  57333. getClassName(): string;
  57334. /**
  57335. * Gets the first world row input component
  57336. */
  57337. readonly world0: NodeMaterialConnectionPoint;
  57338. /**
  57339. * Gets the second world row input component
  57340. */
  57341. readonly world1: NodeMaterialConnectionPoint;
  57342. /**
  57343. * Gets the third world row input component
  57344. */
  57345. readonly world2: NodeMaterialConnectionPoint;
  57346. /**
  57347. * Gets the forth world row input component
  57348. */
  57349. readonly world3: NodeMaterialConnectionPoint;
  57350. /**
  57351. * Gets the world input component
  57352. */
  57353. readonly world: NodeMaterialConnectionPoint;
  57354. /**
  57355. * Gets the output component
  57356. */
  57357. readonly output: NodeMaterialConnectionPoint;
  57358. autoConfigure(material: NodeMaterial): void;
  57359. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57360. protected _buildBlock(state: NodeMaterialBuildState): this;
  57361. }
  57362. }
  57363. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57368. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57369. import { Effect } from "babylonjs/Materials/effect";
  57370. import { Mesh } from "babylonjs/Meshes/mesh";
  57371. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57372. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57373. /**
  57374. * Block used to add morph targets support to vertex shader
  57375. */
  57376. export class MorphTargetsBlock extends NodeMaterialBlock {
  57377. private _repeatableContentAnchor;
  57378. private _repeatebleContentGenerated;
  57379. /**
  57380. * Create a new MorphTargetsBlock
  57381. * @param name defines the block name
  57382. */
  57383. constructor(name: string);
  57384. /**
  57385. * Gets the current class name
  57386. * @returns the class name
  57387. */
  57388. getClassName(): string;
  57389. /**
  57390. * Gets the position input component
  57391. */
  57392. readonly position: NodeMaterialConnectionPoint;
  57393. /**
  57394. * Gets the normal input component
  57395. */
  57396. readonly normal: NodeMaterialConnectionPoint;
  57397. /**
  57398. * Gets the tangent input component
  57399. */
  57400. readonly tangent: NodeMaterialConnectionPoint;
  57401. /**
  57402. * Gets the tangent input component
  57403. */
  57404. readonly uv: NodeMaterialConnectionPoint;
  57405. /**
  57406. * Gets the position output component
  57407. */
  57408. readonly positionOutput: NodeMaterialConnectionPoint;
  57409. /**
  57410. * Gets the normal output component
  57411. */
  57412. readonly normalOutput: NodeMaterialConnectionPoint;
  57413. /**
  57414. * Gets the tangent output component
  57415. */
  57416. readonly tangentOutput: NodeMaterialConnectionPoint;
  57417. /**
  57418. * Gets the tangent output component
  57419. */
  57420. readonly uvOutput: NodeMaterialConnectionPoint;
  57421. initialize(state: NodeMaterialBuildState): void;
  57422. autoConfigure(material: NodeMaterial): void;
  57423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57424. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57425. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57426. protected _buildBlock(state: NodeMaterialBuildState): this;
  57427. }
  57428. }
  57429. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57430. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57431. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57432. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57433. import { Nullable } from "babylonjs/types";
  57434. import { Scene } from "babylonjs/scene";
  57435. import { Effect } from "babylonjs/Materials/effect";
  57436. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57437. import { Mesh } from "babylonjs/Meshes/mesh";
  57438. import { Light } from "babylonjs/Lights/light";
  57439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57440. /**
  57441. * Block used to get data information from a light
  57442. */
  57443. export class LightInformationBlock extends NodeMaterialBlock {
  57444. private _lightDataUniformName;
  57445. private _lightColorUniformName;
  57446. private _lightTypeDefineName;
  57447. /**
  57448. * Gets or sets the light associated with this block
  57449. */
  57450. light: Nullable<Light>;
  57451. /**
  57452. * Creates a new LightInformationBlock
  57453. * @param name defines the block name
  57454. */
  57455. constructor(name: string);
  57456. /**
  57457. * Gets the current class name
  57458. * @returns the class name
  57459. */
  57460. getClassName(): string;
  57461. /**
  57462. * Gets the world position input component
  57463. */
  57464. readonly worldPosition: NodeMaterialConnectionPoint;
  57465. /**
  57466. * Gets the direction output component
  57467. */
  57468. readonly direction: NodeMaterialConnectionPoint;
  57469. /**
  57470. * Gets the direction output component
  57471. */
  57472. readonly color: NodeMaterialConnectionPoint;
  57473. /**
  57474. * Gets the direction output component
  57475. */
  57476. readonly intensity: NodeMaterialConnectionPoint;
  57477. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57478. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57479. protected _buildBlock(state: NodeMaterialBuildState): this;
  57480. serialize(): any;
  57481. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57482. }
  57483. }
  57484. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57485. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57486. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57487. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57488. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57489. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57490. }
  57491. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57492. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57493. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57494. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57496. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57497. import { Effect } from "babylonjs/Materials/effect";
  57498. import { Mesh } from "babylonjs/Meshes/mesh";
  57499. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57500. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57501. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57502. /**
  57503. * Block used to add image processing support to fragment shader
  57504. */
  57505. export class ImageProcessingBlock extends NodeMaterialBlock {
  57506. /**
  57507. * Create a new ImageProcessingBlock
  57508. * @param name defines the block name
  57509. */
  57510. constructor(name: string);
  57511. /**
  57512. * Gets the current class name
  57513. * @returns the class name
  57514. */
  57515. getClassName(): string;
  57516. /**
  57517. * Gets the color input component
  57518. */
  57519. readonly color: NodeMaterialConnectionPoint;
  57520. /**
  57521. * Gets the output component
  57522. */
  57523. readonly output: NodeMaterialConnectionPoint;
  57524. /**
  57525. * Initialize the block and prepare the context for build
  57526. * @param state defines the state that will be used for the build
  57527. */
  57528. initialize(state: NodeMaterialBuildState): void;
  57529. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57530. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57531. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57532. protected _buildBlock(state: NodeMaterialBuildState): this;
  57533. }
  57534. }
  57535. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57536. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57538. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57539. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57541. import { Effect } from "babylonjs/Materials/effect";
  57542. import { Mesh } from "babylonjs/Meshes/mesh";
  57543. import { Scene } from "babylonjs/scene";
  57544. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57545. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57546. /**
  57547. * Block used to pertub normals based on a normal map
  57548. */
  57549. export class PerturbNormalBlock extends NodeMaterialBlock {
  57550. private _tangentSpaceParameterName;
  57551. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57552. invertX: boolean;
  57553. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57554. invertY: boolean;
  57555. /**
  57556. * Create a new PerturbNormalBlock
  57557. * @param name defines the block name
  57558. */
  57559. constructor(name: string);
  57560. /**
  57561. * Gets the current class name
  57562. * @returns the class name
  57563. */
  57564. getClassName(): string;
  57565. /**
  57566. * Gets the world position input component
  57567. */
  57568. readonly worldPosition: NodeMaterialConnectionPoint;
  57569. /**
  57570. * Gets the world normal input component
  57571. */
  57572. readonly worldNormal: NodeMaterialConnectionPoint;
  57573. /**
  57574. * Gets the uv input component
  57575. */
  57576. readonly uv: NodeMaterialConnectionPoint;
  57577. /**
  57578. * Gets the normal map color input component
  57579. */
  57580. readonly normalMapColor: NodeMaterialConnectionPoint;
  57581. /**
  57582. * Gets the strength input component
  57583. */
  57584. readonly strength: NodeMaterialConnectionPoint;
  57585. /**
  57586. * Gets the output component
  57587. */
  57588. readonly output: NodeMaterialConnectionPoint;
  57589. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57590. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57591. autoConfigure(material: NodeMaterial): void;
  57592. protected _buildBlock(state: NodeMaterialBuildState): this;
  57593. protected _dumpPropertiesCode(): string;
  57594. serialize(): any;
  57595. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57596. }
  57597. }
  57598. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57602. /**
  57603. * Block used to discard a pixel if a value is smaller than a cutoff
  57604. */
  57605. export class DiscardBlock extends NodeMaterialBlock {
  57606. /**
  57607. * Create a new DiscardBlock
  57608. * @param name defines the block name
  57609. */
  57610. constructor(name: string);
  57611. /**
  57612. * Gets the current class name
  57613. * @returns the class name
  57614. */
  57615. getClassName(): string;
  57616. /**
  57617. * Gets the color input component
  57618. */
  57619. readonly value: NodeMaterialConnectionPoint;
  57620. /**
  57621. * Gets the cutoff input component
  57622. */
  57623. readonly cutoff: NodeMaterialConnectionPoint;
  57624. protected _buildBlock(state: NodeMaterialBuildState): this;
  57625. }
  57626. }
  57627. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  57628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57631. /**
  57632. * Block used to test if the fragment shader is front facing
  57633. */
  57634. export class FrontFacingBlock extends NodeMaterialBlock {
  57635. /**
  57636. * Creates a new FrontFacingBlock
  57637. * @param name defines the block name
  57638. */
  57639. constructor(name: string);
  57640. /**
  57641. * Gets the current class name
  57642. * @returns the class name
  57643. */
  57644. getClassName(): string;
  57645. /**
  57646. * Gets the output component
  57647. */
  57648. readonly output: NodeMaterialConnectionPoint;
  57649. protected _buildBlock(state: NodeMaterialBuildState): this;
  57650. }
  57651. }
  57652. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57653. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57654. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57655. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57656. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57657. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  57658. }
  57659. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57662. import { Mesh } from "babylonjs/Meshes/mesh";
  57663. import { Effect } from "babylonjs/Materials/effect";
  57664. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57666. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57667. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57668. /**
  57669. * Block used to add support for scene fog
  57670. */
  57671. export class FogBlock extends NodeMaterialBlock {
  57672. private _fogDistanceName;
  57673. private _fogParameters;
  57674. /**
  57675. * Create a new FogBlock
  57676. * @param name defines the block name
  57677. */
  57678. constructor(name: string);
  57679. /**
  57680. * Gets the current class name
  57681. * @returns the class name
  57682. */
  57683. getClassName(): string;
  57684. /**
  57685. * Gets the world position input component
  57686. */
  57687. readonly worldPosition: NodeMaterialConnectionPoint;
  57688. /**
  57689. * Gets the view input component
  57690. */
  57691. readonly view: NodeMaterialConnectionPoint;
  57692. /**
  57693. * Gets the color input component
  57694. */
  57695. readonly input: NodeMaterialConnectionPoint;
  57696. /**
  57697. * Gets the fog color input component
  57698. */
  57699. readonly fogColor: NodeMaterialConnectionPoint;
  57700. /**
  57701. * Gets the output component
  57702. */
  57703. readonly output: NodeMaterialConnectionPoint;
  57704. autoConfigure(material: NodeMaterial): void;
  57705. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57706. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57707. protected _buildBlock(state: NodeMaterialBuildState): this;
  57708. }
  57709. }
  57710. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  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 { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57715. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57716. import { Effect } from "babylonjs/Materials/effect";
  57717. import { Mesh } from "babylonjs/Meshes/mesh";
  57718. import { Light } from "babylonjs/Lights/light";
  57719. import { Nullable } from "babylonjs/types";
  57720. import { Scene } from "babylonjs/scene";
  57721. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57722. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57723. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57724. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57725. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57726. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57727. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57728. /**
  57729. * Block used to add light in the fragment shader
  57730. */
  57731. export class LightBlock extends NodeMaterialBlock {
  57732. private _lightId;
  57733. /**
  57734. * Gets or sets the light associated with this block
  57735. */
  57736. light: Nullable<Light>;
  57737. /**
  57738. * Create a new LightBlock
  57739. * @param name defines the block name
  57740. */
  57741. constructor(name: string);
  57742. /**
  57743. * Gets the current class name
  57744. * @returns the class name
  57745. */
  57746. getClassName(): string;
  57747. /**
  57748. * Gets the world position input component
  57749. */
  57750. readonly worldPosition: NodeMaterialConnectionPoint;
  57751. /**
  57752. * Gets the world normal input component
  57753. */
  57754. readonly worldNormal: NodeMaterialConnectionPoint;
  57755. /**
  57756. * Gets the camera (or eye) position component
  57757. */
  57758. readonly cameraPosition: NodeMaterialConnectionPoint;
  57759. /**
  57760. * Gets the glossiness component
  57761. */
  57762. readonly glossiness: NodeMaterialConnectionPoint;
  57763. /**
  57764. * Gets the glossinness power component
  57765. */
  57766. readonly glossPower: NodeMaterialConnectionPoint;
  57767. /**
  57768. * Gets the diffuse color component
  57769. */
  57770. readonly diffuseColor: NodeMaterialConnectionPoint;
  57771. /**
  57772. * Gets the specular color component
  57773. */
  57774. readonly specularColor: NodeMaterialConnectionPoint;
  57775. /**
  57776. * Gets the diffuse output component
  57777. */
  57778. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57779. /**
  57780. * Gets the specular output component
  57781. */
  57782. readonly specularOutput: NodeMaterialConnectionPoint;
  57783. autoConfigure(material: NodeMaterial): void;
  57784. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57785. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57786. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57787. private _injectVertexCode;
  57788. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57789. serialize(): any;
  57790. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57791. }
  57792. }
  57793. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57794. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57795. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57796. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57797. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57798. }
  57799. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57800. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57801. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57802. }
  57803. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57806. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57807. /**
  57808. * Block used to multiply 2 values
  57809. */
  57810. export class MultiplyBlock extends NodeMaterialBlock {
  57811. /**
  57812. * Creates a new MultiplyBlock
  57813. * @param name defines the block name
  57814. */
  57815. constructor(name: string);
  57816. /**
  57817. * Gets the current class name
  57818. * @returns the class name
  57819. */
  57820. getClassName(): string;
  57821. /**
  57822. * Gets the left operand input component
  57823. */
  57824. readonly left: NodeMaterialConnectionPoint;
  57825. /**
  57826. * Gets the right operand input component
  57827. */
  57828. readonly right: NodeMaterialConnectionPoint;
  57829. /**
  57830. * Gets the output component
  57831. */
  57832. readonly output: NodeMaterialConnectionPoint;
  57833. protected _buildBlock(state: NodeMaterialBuildState): this;
  57834. }
  57835. }
  57836. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57840. /**
  57841. * Block used to add 2 vectors
  57842. */
  57843. export class AddBlock extends NodeMaterialBlock {
  57844. /**
  57845. * Creates a new AddBlock
  57846. * @param name defines the block name
  57847. */
  57848. constructor(name: string);
  57849. /**
  57850. * Gets the current class name
  57851. * @returns the class name
  57852. */
  57853. getClassName(): string;
  57854. /**
  57855. * Gets the left operand input component
  57856. */
  57857. readonly left: NodeMaterialConnectionPoint;
  57858. /**
  57859. * Gets the right operand input component
  57860. */
  57861. readonly right: NodeMaterialConnectionPoint;
  57862. /**
  57863. * Gets the output component
  57864. */
  57865. readonly output: NodeMaterialConnectionPoint;
  57866. protected _buildBlock(state: NodeMaterialBuildState): this;
  57867. }
  57868. }
  57869. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57872. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57873. /**
  57874. * Block used to scale a vector by a float
  57875. */
  57876. export class ScaleBlock extends NodeMaterialBlock {
  57877. /**
  57878. * Creates a new ScaleBlock
  57879. * @param name defines the block name
  57880. */
  57881. constructor(name: string);
  57882. /**
  57883. * Gets the current class name
  57884. * @returns the class name
  57885. */
  57886. getClassName(): string;
  57887. /**
  57888. * Gets the input component
  57889. */
  57890. readonly input: NodeMaterialConnectionPoint;
  57891. /**
  57892. * Gets the factor input component
  57893. */
  57894. readonly factor: NodeMaterialConnectionPoint;
  57895. /**
  57896. * Gets the output component
  57897. */
  57898. readonly output: NodeMaterialConnectionPoint;
  57899. protected _buildBlock(state: NodeMaterialBuildState): this;
  57900. }
  57901. }
  57902. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57903. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57906. import { Scene } from "babylonjs/scene";
  57907. /**
  57908. * Block used to clamp a float
  57909. */
  57910. export class ClampBlock extends NodeMaterialBlock {
  57911. /** Gets or sets the minimum range */
  57912. minimum: number;
  57913. /** Gets or sets the maximum range */
  57914. maximum: number;
  57915. /**
  57916. * Creates a new ClampBlock
  57917. * @param name defines the block name
  57918. */
  57919. constructor(name: string);
  57920. /**
  57921. * Gets the current class name
  57922. * @returns the class name
  57923. */
  57924. getClassName(): string;
  57925. /**
  57926. * Gets the value input component
  57927. */
  57928. readonly value: NodeMaterialConnectionPoint;
  57929. /**
  57930. * Gets the output component
  57931. */
  57932. readonly output: NodeMaterialConnectionPoint;
  57933. protected _buildBlock(state: NodeMaterialBuildState): this;
  57934. protected _dumpPropertiesCode(): string;
  57935. serialize(): any;
  57936. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57937. }
  57938. }
  57939. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57943. /**
  57944. * Block used to apply a cross product between 2 vectors
  57945. */
  57946. export class CrossBlock extends NodeMaterialBlock {
  57947. /**
  57948. * Creates a new CrossBlock
  57949. * @param name defines the block name
  57950. */
  57951. constructor(name: string);
  57952. /**
  57953. * Gets the current class name
  57954. * @returns the class name
  57955. */
  57956. getClassName(): string;
  57957. /**
  57958. * Gets the left operand input component
  57959. */
  57960. readonly left: NodeMaterialConnectionPoint;
  57961. /**
  57962. * Gets the right operand input component
  57963. */
  57964. readonly right: NodeMaterialConnectionPoint;
  57965. /**
  57966. * Gets the output component
  57967. */
  57968. readonly output: NodeMaterialConnectionPoint;
  57969. protected _buildBlock(state: NodeMaterialBuildState): this;
  57970. }
  57971. }
  57972. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57973. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57974. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57976. /**
  57977. * Block used to apply a dot product between 2 vectors
  57978. */
  57979. export class DotBlock extends NodeMaterialBlock {
  57980. /**
  57981. * Creates a new DotBlock
  57982. * @param name defines the block name
  57983. */
  57984. constructor(name: string);
  57985. /**
  57986. * Gets the current class name
  57987. * @returns the class name
  57988. */
  57989. getClassName(): string;
  57990. /**
  57991. * Gets the left operand input component
  57992. */
  57993. readonly left: NodeMaterialConnectionPoint;
  57994. /**
  57995. * Gets the right operand input component
  57996. */
  57997. readonly right: NodeMaterialConnectionPoint;
  57998. /**
  57999. * Gets the output component
  58000. */
  58001. readonly output: NodeMaterialConnectionPoint;
  58002. protected _buildBlock(state: NodeMaterialBuildState): this;
  58003. }
  58004. }
  58005. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58006. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58007. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58009. import { Vector2 } from "babylonjs/Maths/math.vector";
  58010. import { Scene } from "babylonjs/scene";
  58011. /**
  58012. * Block used to remap a float from a range to a new one
  58013. */
  58014. export class RemapBlock extends NodeMaterialBlock {
  58015. /**
  58016. * Gets or sets the source range
  58017. */
  58018. sourceRange: Vector2;
  58019. /**
  58020. * Gets or sets the target range
  58021. */
  58022. targetRange: Vector2;
  58023. /**
  58024. * Creates a new RemapBlock
  58025. * @param name defines the block name
  58026. */
  58027. constructor(name: string);
  58028. /**
  58029. * Gets the current class name
  58030. * @returns the class name
  58031. */
  58032. getClassName(): string;
  58033. /**
  58034. * Gets the input component
  58035. */
  58036. readonly input: NodeMaterialConnectionPoint;
  58037. /**
  58038. * Gets the source min input component
  58039. */
  58040. readonly sourceMin: NodeMaterialConnectionPoint;
  58041. /**
  58042. * Gets the source max input component
  58043. */
  58044. readonly sourceMax: NodeMaterialConnectionPoint;
  58045. /**
  58046. * Gets the target min input component
  58047. */
  58048. readonly targetMin: NodeMaterialConnectionPoint;
  58049. /**
  58050. * Gets the target max input component
  58051. */
  58052. readonly targetMax: NodeMaterialConnectionPoint;
  58053. /**
  58054. * Gets the output component
  58055. */
  58056. readonly output: NodeMaterialConnectionPoint;
  58057. protected _buildBlock(state: NodeMaterialBuildState): this;
  58058. protected _dumpPropertiesCode(): string;
  58059. serialize(): any;
  58060. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58061. }
  58062. }
  58063. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58064. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58065. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58066. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58067. /**
  58068. * Block used to normalize a vector
  58069. */
  58070. export class NormalizeBlock extends NodeMaterialBlock {
  58071. /**
  58072. * Creates a new NormalizeBlock
  58073. * @param name defines the block name
  58074. */
  58075. constructor(name: string);
  58076. /**
  58077. * Gets the current class name
  58078. * @returns the class name
  58079. */
  58080. getClassName(): string;
  58081. /**
  58082. * Gets the input component
  58083. */
  58084. readonly input: NodeMaterialConnectionPoint;
  58085. /**
  58086. * Gets the output component
  58087. */
  58088. readonly output: NodeMaterialConnectionPoint;
  58089. protected _buildBlock(state: NodeMaterialBuildState): this;
  58090. }
  58091. }
  58092. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58096. import { Scene } from "babylonjs/scene";
  58097. /**
  58098. * Operations supported by the Trigonometry block
  58099. */
  58100. export enum TrigonometryBlockOperations {
  58101. /** Cos */
  58102. Cos = 0,
  58103. /** Sin */
  58104. Sin = 1,
  58105. /** Abs */
  58106. Abs = 2,
  58107. /** Exp */
  58108. Exp = 3,
  58109. /** Exp2 */
  58110. Exp2 = 4,
  58111. /** Round */
  58112. Round = 5,
  58113. /** Floor */
  58114. Floor = 6,
  58115. /** Ceiling */
  58116. Ceiling = 7,
  58117. /** Square root */
  58118. Sqrt = 8,
  58119. /** Log */
  58120. Log = 9,
  58121. /** Tangent */
  58122. Tan = 10,
  58123. /** Arc tangent */
  58124. ArcTan = 11,
  58125. /** Arc cosinus */
  58126. ArcCos = 12,
  58127. /** Arc sinus */
  58128. ArcSin = 13,
  58129. /** Fraction */
  58130. Fract = 14,
  58131. /** Sign */
  58132. Sign = 15,
  58133. /** To radians (from degrees) */
  58134. Radians = 16,
  58135. /** To degrees (from radians) */
  58136. Degrees = 17
  58137. }
  58138. /**
  58139. * Block used to apply trigonometry operation to floats
  58140. */
  58141. export class TrigonometryBlock extends NodeMaterialBlock {
  58142. /**
  58143. * Gets or sets the operation applied by the block
  58144. */
  58145. operation: TrigonometryBlockOperations;
  58146. /**
  58147. * Creates a new TrigonometryBlock
  58148. * @param name defines the block name
  58149. */
  58150. constructor(name: string);
  58151. /**
  58152. * Gets the current class name
  58153. * @returns the class name
  58154. */
  58155. getClassName(): string;
  58156. /**
  58157. * Gets the input component
  58158. */
  58159. readonly input: NodeMaterialConnectionPoint;
  58160. /**
  58161. * Gets the output component
  58162. */
  58163. readonly output: NodeMaterialConnectionPoint;
  58164. protected _buildBlock(state: NodeMaterialBuildState): this;
  58165. serialize(): any;
  58166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58167. }
  58168. }
  58169. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58172. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58173. /**
  58174. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58175. */
  58176. export class ColorMergerBlock extends NodeMaterialBlock {
  58177. /**
  58178. * Create a new ColorMergerBlock
  58179. * @param name defines the block name
  58180. */
  58181. constructor(name: string);
  58182. /**
  58183. * Gets the current class name
  58184. * @returns the class name
  58185. */
  58186. getClassName(): string;
  58187. /**
  58188. * Gets the r component (input)
  58189. */
  58190. readonly r: NodeMaterialConnectionPoint;
  58191. /**
  58192. * Gets the g component (input)
  58193. */
  58194. readonly g: NodeMaterialConnectionPoint;
  58195. /**
  58196. * Gets the b component (input)
  58197. */
  58198. readonly b: NodeMaterialConnectionPoint;
  58199. /**
  58200. * Gets the a component (input)
  58201. */
  58202. readonly a: NodeMaterialConnectionPoint;
  58203. /**
  58204. * Gets the rgba component (output)
  58205. */
  58206. readonly rgba: NodeMaterialConnectionPoint;
  58207. /**
  58208. * Gets the rgb component (output)
  58209. */
  58210. readonly rgb: NodeMaterialConnectionPoint;
  58211. protected _buildBlock(state: NodeMaterialBuildState): this;
  58212. }
  58213. }
  58214. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58215. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58216. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58217. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58218. /**
  58219. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58220. */
  58221. export class VectorMergerBlock extends NodeMaterialBlock {
  58222. /**
  58223. * Create a new VectorMergerBlock
  58224. * @param name defines the block name
  58225. */
  58226. constructor(name: string);
  58227. /**
  58228. * Gets the current class name
  58229. * @returns the class name
  58230. */
  58231. getClassName(): string;
  58232. /**
  58233. * Gets the x component (input)
  58234. */
  58235. readonly x: NodeMaterialConnectionPoint;
  58236. /**
  58237. * Gets the y component (input)
  58238. */
  58239. readonly y: NodeMaterialConnectionPoint;
  58240. /**
  58241. * Gets the z component (input)
  58242. */
  58243. readonly z: NodeMaterialConnectionPoint;
  58244. /**
  58245. * Gets the w component (input)
  58246. */
  58247. readonly w: NodeMaterialConnectionPoint;
  58248. /**
  58249. * Gets the xyzw component (output)
  58250. */
  58251. readonly xyzw: NodeMaterialConnectionPoint;
  58252. /**
  58253. * Gets the xyz component (output)
  58254. */
  58255. readonly xyz: NodeMaterialConnectionPoint;
  58256. /**
  58257. * Gets the xy component (output)
  58258. */
  58259. readonly xy: NodeMaterialConnectionPoint;
  58260. protected _buildBlock(state: NodeMaterialBuildState): this;
  58261. }
  58262. }
  58263. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58267. /**
  58268. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58269. */
  58270. export class ColorSplitterBlock extends NodeMaterialBlock {
  58271. /**
  58272. * Create a new ColorSplitterBlock
  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 rgba component (input)
  58283. */
  58284. readonly rgba: NodeMaterialConnectionPoint;
  58285. /**
  58286. * Gets the rgb component (input)
  58287. */
  58288. readonly rgbIn: NodeMaterialConnectionPoint;
  58289. /**
  58290. * Gets the rgb component (output)
  58291. */
  58292. readonly rgbOut: NodeMaterialConnectionPoint;
  58293. /**
  58294. * Gets the r component (output)
  58295. */
  58296. readonly r: NodeMaterialConnectionPoint;
  58297. /**
  58298. * Gets the g component (output)
  58299. */
  58300. readonly g: NodeMaterialConnectionPoint;
  58301. /**
  58302. * Gets the b component (output)
  58303. */
  58304. readonly b: NodeMaterialConnectionPoint;
  58305. /**
  58306. * Gets the a component (output)
  58307. */
  58308. readonly a: NodeMaterialConnectionPoint;
  58309. protected _inputRename(name: string): string;
  58310. protected _outputRename(name: string): string;
  58311. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58312. }
  58313. }
  58314. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58318. /**
  58319. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58320. */
  58321. export class VectorSplitterBlock extends NodeMaterialBlock {
  58322. /**
  58323. * Create a new VectorSplitterBlock
  58324. * @param name defines the block name
  58325. */
  58326. constructor(name: string);
  58327. /**
  58328. * Gets the current class name
  58329. * @returns the class name
  58330. */
  58331. getClassName(): string;
  58332. /**
  58333. * Gets the xyzw component (input)
  58334. */
  58335. readonly xyzw: NodeMaterialConnectionPoint;
  58336. /**
  58337. * Gets the xyz component (input)
  58338. */
  58339. readonly xyzIn: NodeMaterialConnectionPoint;
  58340. /**
  58341. * Gets the xy component (input)
  58342. */
  58343. readonly xyIn: NodeMaterialConnectionPoint;
  58344. /**
  58345. * Gets the xyz component (output)
  58346. */
  58347. readonly xyzOut: NodeMaterialConnectionPoint;
  58348. /**
  58349. * Gets the xy component (output)
  58350. */
  58351. readonly xyOut: NodeMaterialConnectionPoint;
  58352. /**
  58353. * Gets the x component (output)
  58354. */
  58355. readonly x: NodeMaterialConnectionPoint;
  58356. /**
  58357. * Gets the y component (output)
  58358. */
  58359. readonly y: NodeMaterialConnectionPoint;
  58360. /**
  58361. * Gets the z component (output)
  58362. */
  58363. readonly z: NodeMaterialConnectionPoint;
  58364. /**
  58365. * Gets the w component (output)
  58366. */
  58367. readonly w: NodeMaterialConnectionPoint;
  58368. protected _inputRename(name: string): string;
  58369. protected _outputRename(name: string): string;
  58370. protected _buildBlock(state: NodeMaterialBuildState): this;
  58371. }
  58372. }
  58373. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58376. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58377. /**
  58378. * Block used to lerp between 2 values
  58379. */
  58380. export class LerpBlock extends NodeMaterialBlock {
  58381. /**
  58382. * Creates a new LerpBlock
  58383. * @param name defines the block name
  58384. */
  58385. constructor(name: string);
  58386. /**
  58387. * Gets the current class name
  58388. * @returns the class name
  58389. */
  58390. getClassName(): string;
  58391. /**
  58392. * Gets the left operand input component
  58393. */
  58394. readonly left: NodeMaterialConnectionPoint;
  58395. /**
  58396. * Gets the right operand input component
  58397. */
  58398. readonly right: NodeMaterialConnectionPoint;
  58399. /**
  58400. * Gets the gradient operand input component
  58401. */
  58402. readonly gradient: NodeMaterialConnectionPoint;
  58403. /**
  58404. * Gets the output component
  58405. */
  58406. readonly output: NodeMaterialConnectionPoint;
  58407. protected _buildBlock(state: NodeMaterialBuildState): this;
  58408. }
  58409. }
  58410. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58414. /**
  58415. * Block used to divide 2 vectors
  58416. */
  58417. export class DivideBlock extends NodeMaterialBlock {
  58418. /**
  58419. * Creates a new DivideBlock
  58420. * @param name defines the block name
  58421. */
  58422. constructor(name: string);
  58423. /**
  58424. * Gets the current class name
  58425. * @returns the class name
  58426. */
  58427. getClassName(): string;
  58428. /**
  58429. * Gets the left operand input component
  58430. */
  58431. readonly left: NodeMaterialConnectionPoint;
  58432. /**
  58433. * Gets the right operand input component
  58434. */
  58435. readonly right: NodeMaterialConnectionPoint;
  58436. /**
  58437. * Gets the output component
  58438. */
  58439. readonly output: NodeMaterialConnectionPoint;
  58440. protected _buildBlock(state: NodeMaterialBuildState): this;
  58441. }
  58442. }
  58443. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58447. /**
  58448. * Block used to subtract 2 vectors
  58449. */
  58450. export class SubtractBlock extends NodeMaterialBlock {
  58451. /**
  58452. * Creates a new SubtractBlock
  58453. * @param name defines the block name
  58454. */
  58455. constructor(name: string);
  58456. /**
  58457. * Gets the current class name
  58458. * @returns the class name
  58459. */
  58460. getClassName(): string;
  58461. /**
  58462. * Gets the left operand input component
  58463. */
  58464. readonly left: NodeMaterialConnectionPoint;
  58465. /**
  58466. * Gets the right operand input component
  58467. */
  58468. readonly right: NodeMaterialConnectionPoint;
  58469. /**
  58470. * Gets the output component
  58471. */
  58472. readonly output: NodeMaterialConnectionPoint;
  58473. protected _buildBlock(state: NodeMaterialBuildState): this;
  58474. }
  58475. }
  58476. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58480. /**
  58481. * Block used to step a value
  58482. */
  58483. export class StepBlock extends NodeMaterialBlock {
  58484. /**
  58485. * Creates a new StepBlock
  58486. * @param name defines the block name
  58487. */
  58488. constructor(name: string);
  58489. /**
  58490. * Gets the current class name
  58491. * @returns the class name
  58492. */
  58493. getClassName(): string;
  58494. /**
  58495. * Gets the value operand input component
  58496. */
  58497. readonly value: NodeMaterialConnectionPoint;
  58498. /**
  58499. * Gets the edge operand input component
  58500. */
  58501. readonly edge: NodeMaterialConnectionPoint;
  58502. /**
  58503. * Gets the output component
  58504. */
  58505. readonly output: NodeMaterialConnectionPoint;
  58506. protected _buildBlock(state: NodeMaterialBuildState): this;
  58507. }
  58508. }
  58509. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58511. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58513. /**
  58514. * Block used to get the opposite (1 - x) of a value
  58515. */
  58516. export class OneMinusBlock extends NodeMaterialBlock {
  58517. /**
  58518. * Creates a new OneMinusBlock
  58519. * @param name defines the block name
  58520. */
  58521. constructor(name: string);
  58522. /**
  58523. * Gets the current class name
  58524. * @returns the class name
  58525. */
  58526. getClassName(): string;
  58527. /**
  58528. * Gets the input component
  58529. */
  58530. readonly input: NodeMaterialConnectionPoint;
  58531. /**
  58532. * Gets the output component
  58533. */
  58534. readonly output: NodeMaterialConnectionPoint;
  58535. protected _buildBlock(state: NodeMaterialBuildState): this;
  58536. }
  58537. }
  58538. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58542. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58543. /**
  58544. * Block used to get the view direction
  58545. */
  58546. export class ViewDirectionBlock extends NodeMaterialBlock {
  58547. /**
  58548. * Creates a new ViewDirectionBlock
  58549. * @param name defines the block name
  58550. */
  58551. constructor(name: string);
  58552. /**
  58553. * Gets the current class name
  58554. * @returns the class name
  58555. */
  58556. getClassName(): string;
  58557. /**
  58558. * Gets the world position component
  58559. */
  58560. readonly worldPosition: NodeMaterialConnectionPoint;
  58561. /**
  58562. * Gets the camera position component
  58563. */
  58564. readonly cameraPosition: NodeMaterialConnectionPoint;
  58565. /**
  58566. * Gets the output component
  58567. */
  58568. readonly output: NodeMaterialConnectionPoint;
  58569. autoConfigure(material: NodeMaterial): void;
  58570. protected _buildBlock(state: NodeMaterialBuildState): this;
  58571. }
  58572. }
  58573. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58574. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58575. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58576. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58577. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58578. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58579. /**
  58580. * Block used to compute fresnel value
  58581. */
  58582. export class FresnelBlock extends NodeMaterialBlock {
  58583. /**
  58584. * Create a new FresnelBlock
  58585. * @param name defines the block name
  58586. */
  58587. constructor(name: string);
  58588. /**
  58589. * Gets the current class name
  58590. * @returns the class name
  58591. */
  58592. getClassName(): string;
  58593. /**
  58594. * Gets the world normal input component
  58595. */
  58596. readonly worldNormal: NodeMaterialConnectionPoint;
  58597. /**
  58598. * Gets the view direction input component
  58599. */
  58600. readonly viewDirection: NodeMaterialConnectionPoint;
  58601. /**
  58602. * Gets the bias input component
  58603. */
  58604. readonly bias: NodeMaterialConnectionPoint;
  58605. /**
  58606. * Gets the camera (or eye) position component
  58607. */
  58608. readonly power: NodeMaterialConnectionPoint;
  58609. /**
  58610. * Gets the fresnel output component
  58611. */
  58612. readonly fresnel: NodeMaterialConnectionPoint;
  58613. autoConfigure(material: NodeMaterial): void;
  58614. protected _buildBlock(state: NodeMaterialBuildState): this;
  58615. }
  58616. }
  58617. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58621. /**
  58622. * Block used to get the max of 2 values
  58623. */
  58624. export class MaxBlock extends NodeMaterialBlock {
  58625. /**
  58626. * Creates a new MaxBlock
  58627. * @param name defines the block name
  58628. */
  58629. constructor(name: string);
  58630. /**
  58631. * Gets the current class name
  58632. * @returns the class name
  58633. */
  58634. getClassName(): string;
  58635. /**
  58636. * Gets the left operand input component
  58637. */
  58638. readonly left: NodeMaterialConnectionPoint;
  58639. /**
  58640. * Gets the right operand input component
  58641. */
  58642. readonly right: NodeMaterialConnectionPoint;
  58643. /**
  58644. * Gets the output component
  58645. */
  58646. readonly output: NodeMaterialConnectionPoint;
  58647. protected _buildBlock(state: NodeMaterialBuildState): this;
  58648. }
  58649. }
  58650. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58651. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58652. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58653. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58654. /**
  58655. * Block used to get the min of 2 values
  58656. */
  58657. export class MinBlock extends NodeMaterialBlock {
  58658. /**
  58659. * Creates a new MinBlock
  58660. * @param name defines the block name
  58661. */
  58662. constructor(name: string);
  58663. /**
  58664. * Gets the current class name
  58665. * @returns the class name
  58666. */
  58667. getClassName(): string;
  58668. /**
  58669. * Gets the left operand input component
  58670. */
  58671. readonly left: NodeMaterialConnectionPoint;
  58672. /**
  58673. * Gets the right operand input component
  58674. */
  58675. readonly right: NodeMaterialConnectionPoint;
  58676. /**
  58677. * Gets the output component
  58678. */
  58679. readonly output: NodeMaterialConnectionPoint;
  58680. protected _buildBlock(state: NodeMaterialBuildState): this;
  58681. }
  58682. }
  58683. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58685. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58686. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58687. /**
  58688. * Block used to get the distance between 2 values
  58689. */
  58690. export class DistanceBlock extends NodeMaterialBlock {
  58691. /**
  58692. * Creates a new DistanceBlock
  58693. * @param name defines the block name
  58694. */
  58695. constructor(name: string);
  58696. /**
  58697. * Gets the current class name
  58698. * @returns the class name
  58699. */
  58700. getClassName(): string;
  58701. /**
  58702. * Gets the left operand input component
  58703. */
  58704. readonly left: NodeMaterialConnectionPoint;
  58705. /**
  58706. * Gets the right operand input component
  58707. */
  58708. readonly right: NodeMaterialConnectionPoint;
  58709. /**
  58710. * Gets the output component
  58711. */
  58712. readonly output: NodeMaterialConnectionPoint;
  58713. protected _buildBlock(state: NodeMaterialBuildState): this;
  58714. }
  58715. }
  58716. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58717. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58718. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58719. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58720. /**
  58721. * Block used to get the length of a vector
  58722. */
  58723. export class LengthBlock extends NodeMaterialBlock {
  58724. /**
  58725. * Creates a new LengthBlock
  58726. * @param name defines the block name
  58727. */
  58728. constructor(name: string);
  58729. /**
  58730. * Gets the current class name
  58731. * @returns the class name
  58732. */
  58733. getClassName(): string;
  58734. /**
  58735. * Gets the value input component
  58736. */
  58737. readonly value: NodeMaterialConnectionPoint;
  58738. /**
  58739. * Gets the output component
  58740. */
  58741. readonly output: NodeMaterialConnectionPoint;
  58742. protected _buildBlock(state: NodeMaterialBuildState): this;
  58743. }
  58744. }
  58745. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58749. /**
  58750. * Block used to get negative version of a value (i.e. x * -1)
  58751. */
  58752. export class NegateBlock extends NodeMaterialBlock {
  58753. /**
  58754. * Creates a new NegateBlock
  58755. * @param name defines the block name
  58756. */
  58757. constructor(name: string);
  58758. /**
  58759. * Gets the current class name
  58760. * @returns the class name
  58761. */
  58762. getClassName(): string;
  58763. /**
  58764. * Gets the value input component
  58765. */
  58766. readonly value: NodeMaterialConnectionPoint;
  58767. /**
  58768. * Gets the output component
  58769. */
  58770. readonly output: NodeMaterialConnectionPoint;
  58771. protected _buildBlock(state: NodeMaterialBuildState): this;
  58772. }
  58773. }
  58774. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58775. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58776. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58777. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58778. /**
  58779. * Block used to get the value of the first parameter raised to the power of the second
  58780. */
  58781. export class PowBlock extends NodeMaterialBlock {
  58782. /**
  58783. * Creates a new PowBlock
  58784. * @param name defines the block name
  58785. */
  58786. constructor(name: string);
  58787. /**
  58788. * Gets the current class name
  58789. * @returns the class name
  58790. */
  58791. getClassName(): string;
  58792. /**
  58793. * Gets the value operand input component
  58794. */
  58795. readonly value: NodeMaterialConnectionPoint;
  58796. /**
  58797. * Gets the power operand input component
  58798. */
  58799. readonly power: NodeMaterialConnectionPoint;
  58800. /**
  58801. * Gets the output component
  58802. */
  58803. readonly output: NodeMaterialConnectionPoint;
  58804. protected _buildBlock(state: NodeMaterialBuildState): this;
  58805. }
  58806. }
  58807. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58811. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58812. /**
  58813. * Block used to get a random number
  58814. */
  58815. export class RandomNumberBlock extends NodeMaterialBlock {
  58816. /**
  58817. * Creates a new RandomNumberBlock
  58818. * @param name defines the block name
  58819. */
  58820. constructor(name: string);
  58821. /**
  58822. * Gets the current class name
  58823. * @returns the class name
  58824. */
  58825. getClassName(): string;
  58826. /**
  58827. * Gets the seed input component
  58828. */
  58829. readonly seed: NodeMaterialConnectionPoint;
  58830. /**
  58831. * Gets the output component
  58832. */
  58833. readonly output: NodeMaterialConnectionPoint;
  58834. protected _buildBlock(state: NodeMaterialBuildState): this;
  58835. }
  58836. }
  58837. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58841. /**
  58842. * Block used to compute arc tangent of 2 values
  58843. */
  58844. export class ArcTan2Block extends NodeMaterialBlock {
  58845. /**
  58846. * Creates a new ArcTan2Block
  58847. * @param name defines the block name
  58848. */
  58849. constructor(name: string);
  58850. /**
  58851. * Gets the current class name
  58852. * @returns the class name
  58853. */
  58854. getClassName(): string;
  58855. /**
  58856. * Gets the x operand input component
  58857. */
  58858. readonly x: NodeMaterialConnectionPoint;
  58859. /**
  58860. * Gets the y operand input component
  58861. */
  58862. readonly y: NodeMaterialConnectionPoint;
  58863. /**
  58864. * Gets the output component
  58865. */
  58866. readonly output: NodeMaterialConnectionPoint;
  58867. protected _buildBlock(state: NodeMaterialBuildState): this;
  58868. }
  58869. }
  58870. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58871. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58872. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58873. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58874. /**
  58875. * Block used to smooth step a value
  58876. */
  58877. export class SmoothStepBlock extends NodeMaterialBlock {
  58878. /**
  58879. * Creates a new SmoothStepBlock
  58880. * @param name defines the block name
  58881. */
  58882. constructor(name: string);
  58883. /**
  58884. * Gets the current class name
  58885. * @returns the class name
  58886. */
  58887. getClassName(): string;
  58888. /**
  58889. * Gets the value operand input component
  58890. */
  58891. readonly value: NodeMaterialConnectionPoint;
  58892. /**
  58893. * Gets the first edge operand input component
  58894. */
  58895. readonly edge0: NodeMaterialConnectionPoint;
  58896. /**
  58897. * Gets the second edge operand input component
  58898. */
  58899. readonly edge1: NodeMaterialConnectionPoint;
  58900. /**
  58901. * Gets the output component
  58902. */
  58903. readonly output: NodeMaterialConnectionPoint;
  58904. protected _buildBlock(state: NodeMaterialBuildState): this;
  58905. }
  58906. }
  58907. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58910. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58911. /**
  58912. * Block used to get the reciprocal (1 / x) of a value
  58913. */
  58914. export class ReciprocalBlock extends NodeMaterialBlock {
  58915. /**
  58916. * Creates a new ReciprocalBlock
  58917. * @param name defines the block name
  58918. */
  58919. constructor(name: string);
  58920. /**
  58921. * Gets the current class name
  58922. * @returns the class name
  58923. */
  58924. getClassName(): string;
  58925. /**
  58926. * Gets the input component
  58927. */
  58928. readonly input: NodeMaterialConnectionPoint;
  58929. /**
  58930. * Gets the output component
  58931. */
  58932. readonly output: NodeMaterialConnectionPoint;
  58933. protected _buildBlock(state: NodeMaterialBuildState): this;
  58934. }
  58935. }
  58936. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58937. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58938. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58939. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58940. /**
  58941. * Block used to replace a color by another one
  58942. */
  58943. export class ReplaceColorBlock extends NodeMaterialBlock {
  58944. /**
  58945. * Creates a new ReplaceColorBlock
  58946. * @param name defines the block name
  58947. */
  58948. constructor(name: string);
  58949. /**
  58950. * Gets the current class name
  58951. * @returns the class name
  58952. */
  58953. getClassName(): string;
  58954. /**
  58955. * Gets the value input component
  58956. */
  58957. readonly value: NodeMaterialConnectionPoint;
  58958. /**
  58959. * Gets the reference input component
  58960. */
  58961. readonly reference: NodeMaterialConnectionPoint;
  58962. /**
  58963. * Gets the distance input component
  58964. */
  58965. readonly distance: NodeMaterialConnectionPoint;
  58966. /**
  58967. * Gets the replacement input component
  58968. */
  58969. readonly replacement: NodeMaterialConnectionPoint;
  58970. /**
  58971. * Gets the output component
  58972. */
  58973. readonly output: NodeMaterialConnectionPoint;
  58974. protected _buildBlock(state: NodeMaterialBuildState): this;
  58975. }
  58976. }
  58977. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58981. /**
  58982. * Block used to posterize a value
  58983. * @see https://en.wikipedia.org/wiki/Posterization
  58984. */
  58985. export class PosterizeBlock extends NodeMaterialBlock {
  58986. /**
  58987. * Creates a new PosterizeBlock
  58988. * @param name defines the block name
  58989. */
  58990. constructor(name: string);
  58991. /**
  58992. * Gets the current class name
  58993. * @returns the class name
  58994. */
  58995. getClassName(): string;
  58996. /**
  58997. * Gets the value input component
  58998. */
  58999. readonly value: NodeMaterialConnectionPoint;
  59000. /**
  59001. * Gets the steps input component
  59002. */
  59003. readonly steps: NodeMaterialConnectionPoint;
  59004. /**
  59005. * Gets the output component
  59006. */
  59007. readonly output: NodeMaterialConnectionPoint;
  59008. protected _buildBlock(state: NodeMaterialBuildState): this;
  59009. }
  59010. }
  59011. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59015. import { Scene } from "babylonjs/scene";
  59016. /**
  59017. * Operations supported by the Wave block
  59018. */
  59019. export enum WaveBlockKind {
  59020. /** SawTooth */
  59021. SawTooth = 0,
  59022. /** Square */
  59023. Square = 1,
  59024. /** Triangle */
  59025. Triangle = 2
  59026. }
  59027. /**
  59028. * Block used to apply wave operation to floats
  59029. */
  59030. export class WaveBlock extends NodeMaterialBlock {
  59031. /**
  59032. * Gets or sets the kibnd of wave to be applied by the block
  59033. */
  59034. kind: WaveBlockKind;
  59035. /**
  59036. * Creates a new WaveBlock
  59037. * @param name defines the block name
  59038. */
  59039. constructor(name: string);
  59040. /**
  59041. * Gets the current class name
  59042. * @returns the class name
  59043. */
  59044. getClassName(): string;
  59045. /**
  59046. * Gets the input component
  59047. */
  59048. readonly input: NodeMaterialConnectionPoint;
  59049. /**
  59050. * Gets the output component
  59051. */
  59052. readonly output: NodeMaterialConnectionPoint;
  59053. protected _buildBlock(state: NodeMaterialBuildState): this;
  59054. serialize(): any;
  59055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59056. }
  59057. }
  59058. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59061. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59062. import { Color3 } from "babylonjs/Maths/math.color";
  59063. import { Scene } from "babylonjs/scene";
  59064. /**
  59065. * Class used to store a color step for the GradientBlock
  59066. */
  59067. export class GradientBlockColorStep {
  59068. /**
  59069. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59070. */
  59071. step: number;
  59072. /**
  59073. * Gets or sets the color associated with this step
  59074. */
  59075. color: Color3;
  59076. /**
  59077. * Creates a new GradientBlockColorStep
  59078. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59079. * @param color defines the color associated with this step
  59080. */
  59081. constructor(
  59082. /**
  59083. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59084. */
  59085. step: number,
  59086. /**
  59087. * Gets or sets the color associated with this step
  59088. */
  59089. color: Color3);
  59090. }
  59091. /**
  59092. * Block used to return a color from a gradient based on an input value between 0 and 1
  59093. */
  59094. export class GradientBlock extends NodeMaterialBlock {
  59095. /**
  59096. * Gets or sets the list of color steps
  59097. */
  59098. colorSteps: GradientBlockColorStep[];
  59099. /**
  59100. * Creates a new GradientBlock
  59101. * @param name defines the block name
  59102. */
  59103. constructor(name: string);
  59104. /**
  59105. * Gets the current class name
  59106. * @returns the class name
  59107. */
  59108. getClassName(): string;
  59109. /**
  59110. * Gets the gradient input component
  59111. */
  59112. readonly gradient: NodeMaterialConnectionPoint;
  59113. /**
  59114. * Gets the output component
  59115. */
  59116. readonly output: NodeMaterialConnectionPoint;
  59117. private _writeColorConstant;
  59118. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59119. serialize(): any;
  59120. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59121. protected _dumpPropertiesCode(): string;
  59122. }
  59123. }
  59124. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59125. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59126. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59127. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59128. /**
  59129. * Block used to normalize lerp between 2 values
  59130. */
  59131. export class NLerpBlock extends NodeMaterialBlock {
  59132. /**
  59133. * Creates a new NLerpBlock
  59134. * @param name defines the block name
  59135. */
  59136. constructor(name: string);
  59137. /**
  59138. * Gets the current class name
  59139. * @returns the class name
  59140. */
  59141. getClassName(): string;
  59142. /**
  59143. * Gets the left operand input component
  59144. */
  59145. readonly left: NodeMaterialConnectionPoint;
  59146. /**
  59147. * Gets the right operand input component
  59148. */
  59149. readonly right: NodeMaterialConnectionPoint;
  59150. /**
  59151. * Gets the gradient operand input component
  59152. */
  59153. readonly gradient: NodeMaterialConnectionPoint;
  59154. /**
  59155. * Gets the output component
  59156. */
  59157. readonly output: NodeMaterialConnectionPoint;
  59158. protected _buildBlock(state: NodeMaterialBuildState): this;
  59159. }
  59160. }
  59161. declare module "babylonjs/Materials/Node/Blocks/index" {
  59162. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59163. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59164. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59165. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59166. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59167. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59168. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59169. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59170. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59171. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59172. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59173. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59174. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59175. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59176. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59177. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59178. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59179. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59180. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59181. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59182. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59183. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59184. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59185. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59186. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59187. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59188. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59189. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59190. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59191. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59192. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59193. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59194. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59195. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59196. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59197. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59198. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59199. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59200. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59201. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59202. }
  59203. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59204. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59205. }
  59206. declare module "babylonjs/Materials/Node/index" {
  59207. export * from "babylonjs/Materials/Node/Enums/index";
  59208. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59209. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59210. export * from "babylonjs/Materials/Node/nodeMaterial";
  59211. export * from "babylonjs/Materials/Node/Blocks/index";
  59212. export * from "babylonjs/Materials/Node/Optimizers/index";
  59213. }
  59214. declare module "babylonjs/Materials/effectRenderer" {
  59215. import { Nullable } from "babylonjs/types";
  59216. import { Texture } from "babylonjs/Materials/Textures/texture";
  59217. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59218. import { Viewport } from "babylonjs/Maths/math.viewport";
  59219. import { Observable } from "babylonjs/Misc/observable";
  59220. import { Effect } from "babylonjs/Materials/effect";
  59221. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59222. import "babylonjs/Shaders/postprocess.vertex";
  59223. /**
  59224. * Effect Render Options
  59225. */
  59226. export interface IEffectRendererOptions {
  59227. /**
  59228. * Defines the vertices positions.
  59229. */
  59230. positions?: number[];
  59231. /**
  59232. * Defines the indices.
  59233. */
  59234. indices?: number[];
  59235. }
  59236. /**
  59237. * Helper class to render one or more effects
  59238. */
  59239. export class EffectRenderer {
  59240. private engine;
  59241. private static _DefaultOptions;
  59242. private _vertexBuffers;
  59243. private _indexBuffer;
  59244. private _ringBufferIndex;
  59245. private _ringScreenBuffer;
  59246. private _fullscreenViewport;
  59247. private _getNextFrameBuffer;
  59248. /**
  59249. * Creates an effect renderer
  59250. * @param engine the engine to use for rendering
  59251. * @param options defines the options of the effect renderer
  59252. */
  59253. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59254. /**
  59255. * Sets the current viewport in normalized coordinates 0-1
  59256. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59257. */
  59258. setViewport(viewport?: Viewport): void;
  59259. /**
  59260. * Binds the embedded attributes buffer to the effect.
  59261. * @param effect Defines the effect to bind the attributes for
  59262. */
  59263. bindBuffers(effect: Effect): void;
  59264. /**
  59265. * Sets the current effect wrapper to use during draw.
  59266. * The effect needs to be ready before calling this api.
  59267. * This also sets the default full screen position attribute.
  59268. * @param effectWrapper Defines the effect to draw with
  59269. */
  59270. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59271. /**
  59272. * Draws a full screen quad.
  59273. */
  59274. draw(): void;
  59275. /**
  59276. * renders one or more effects to a specified texture
  59277. * @param effectWrappers list of effects to renderer
  59278. * @param outputTexture texture to draw to, if null it will render to the screen
  59279. */
  59280. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59281. /**
  59282. * Disposes of the effect renderer
  59283. */
  59284. dispose(): void;
  59285. }
  59286. /**
  59287. * Options to create an EffectWrapper
  59288. */
  59289. interface EffectWrapperCreationOptions {
  59290. /**
  59291. * Engine to use to create the effect
  59292. */
  59293. engine: ThinEngine;
  59294. /**
  59295. * Fragment shader for the effect
  59296. */
  59297. fragmentShader: string;
  59298. /**
  59299. * Vertex shader for the effect
  59300. */
  59301. vertexShader?: string;
  59302. /**
  59303. * Attributes to use in the shader
  59304. */
  59305. attributeNames?: Array<string>;
  59306. /**
  59307. * Uniforms to use in the shader
  59308. */
  59309. uniformNames?: Array<string>;
  59310. /**
  59311. * Texture sampler names to use in the shader
  59312. */
  59313. samplerNames?: Array<string>;
  59314. /**
  59315. * The friendly name of the effect displayed in Spector.
  59316. */
  59317. name?: string;
  59318. }
  59319. /**
  59320. * Wraps an effect to be used for rendering
  59321. */
  59322. export class EffectWrapper {
  59323. /**
  59324. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59325. */
  59326. onApplyObservable: Observable<{}>;
  59327. /**
  59328. * The underlying effect
  59329. */
  59330. effect: Effect;
  59331. /**
  59332. * Creates an effect to be renderer
  59333. * @param creationOptions options to create the effect
  59334. */
  59335. constructor(creationOptions: EffectWrapperCreationOptions);
  59336. /**
  59337. * Disposes of the effect wrapper
  59338. */
  59339. dispose(): void;
  59340. }
  59341. }
  59342. declare module "babylonjs/Materials/index" {
  59343. export * from "babylonjs/Materials/Background/index";
  59344. export * from "babylonjs/Materials/colorCurves";
  59345. export * from "babylonjs/Materials/iEffectFallbacks";
  59346. export * from "babylonjs/Materials/effectFallbacks";
  59347. export * from "babylonjs/Materials/effect";
  59348. export * from "babylonjs/Materials/fresnelParameters";
  59349. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59350. export * from "babylonjs/Materials/material";
  59351. export * from "babylonjs/Materials/materialDefines";
  59352. export * from "babylonjs/Materials/materialHelper";
  59353. export * from "babylonjs/Materials/multiMaterial";
  59354. export * from "babylonjs/Materials/PBR/index";
  59355. export * from "babylonjs/Materials/pushMaterial";
  59356. export * from "babylonjs/Materials/shaderMaterial";
  59357. export * from "babylonjs/Materials/standardMaterial";
  59358. export * from "babylonjs/Materials/Textures/index";
  59359. export * from "babylonjs/Materials/uniformBuffer";
  59360. export * from "babylonjs/Materials/materialFlags";
  59361. export * from "babylonjs/Materials/Node/index";
  59362. export * from "babylonjs/Materials/effectRenderer";
  59363. }
  59364. declare module "babylonjs/Maths/index" {
  59365. export * from "babylonjs/Maths/math.scalar";
  59366. export * from "babylonjs/Maths/math";
  59367. export * from "babylonjs/Maths/sphericalPolynomial";
  59368. }
  59369. declare module "babylonjs/Misc/workerPool" {
  59370. import { IDisposable } from "babylonjs/scene";
  59371. /**
  59372. * Helper class to push actions to a pool of workers.
  59373. */
  59374. export class WorkerPool implements IDisposable {
  59375. private _workerInfos;
  59376. private _pendingActions;
  59377. /**
  59378. * Constructor
  59379. * @param workers Array of workers to use for actions
  59380. */
  59381. constructor(workers: Array<Worker>);
  59382. /**
  59383. * Terminates all workers and clears any pending actions.
  59384. */
  59385. dispose(): void;
  59386. /**
  59387. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59388. * pended until a worker has completed its action.
  59389. * @param action The action to perform. Call onComplete when the action is complete.
  59390. */
  59391. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59392. private _execute;
  59393. }
  59394. }
  59395. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59396. import { IDisposable } from "babylonjs/scene";
  59397. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59398. /**
  59399. * Configuration for Draco compression
  59400. */
  59401. export interface IDracoCompressionConfiguration {
  59402. /**
  59403. * Configuration for the decoder.
  59404. */
  59405. decoder: {
  59406. /**
  59407. * The url to the WebAssembly module.
  59408. */
  59409. wasmUrl?: string;
  59410. /**
  59411. * The url to the WebAssembly binary.
  59412. */
  59413. wasmBinaryUrl?: string;
  59414. /**
  59415. * The url to the fallback JavaScript module.
  59416. */
  59417. fallbackUrl?: string;
  59418. };
  59419. }
  59420. /**
  59421. * Draco compression (https://google.github.io/draco/)
  59422. *
  59423. * This class wraps the Draco module.
  59424. *
  59425. * **Encoder**
  59426. *
  59427. * The encoder is not currently implemented.
  59428. *
  59429. * **Decoder**
  59430. *
  59431. * 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.
  59432. *
  59433. * To update the configuration, use the following code:
  59434. * ```javascript
  59435. * DracoCompression.Configuration = {
  59436. * decoder: {
  59437. * wasmUrl: "<url to the WebAssembly library>",
  59438. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59439. * fallbackUrl: "<url to the fallback JavaScript library>",
  59440. * }
  59441. * };
  59442. * ```
  59443. *
  59444. * 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.
  59445. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59446. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59447. *
  59448. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59449. * ```javascript
  59450. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59451. * ```
  59452. *
  59453. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59454. */
  59455. export class DracoCompression implements IDisposable {
  59456. private _workerPoolPromise?;
  59457. private _decoderModulePromise?;
  59458. /**
  59459. * The configuration. Defaults to the following urls:
  59460. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59461. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59462. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59463. */
  59464. static Configuration: IDracoCompressionConfiguration;
  59465. /**
  59466. * Returns true if the decoder configuration is available.
  59467. */
  59468. static readonly DecoderAvailable: boolean;
  59469. /**
  59470. * Default number of workers to create when creating the draco compression object.
  59471. */
  59472. static DefaultNumWorkers: number;
  59473. private static GetDefaultNumWorkers;
  59474. private static _Default;
  59475. /**
  59476. * Default instance for the draco compression object.
  59477. */
  59478. static readonly Default: DracoCompression;
  59479. /**
  59480. * Constructor
  59481. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59482. */
  59483. constructor(numWorkers?: number);
  59484. /**
  59485. * Stop all async operations and release resources.
  59486. */
  59487. dispose(): void;
  59488. /**
  59489. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59490. * @returns a promise that resolves when ready
  59491. */
  59492. whenReadyAsync(): Promise<void>;
  59493. /**
  59494. * Decode Draco compressed mesh data to vertex data.
  59495. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59496. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59497. * @returns A promise that resolves with the decoded vertex data
  59498. */
  59499. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59500. [kind: string]: number;
  59501. }): Promise<VertexData>;
  59502. }
  59503. }
  59504. declare module "babylonjs/Meshes/Compression/index" {
  59505. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59506. }
  59507. declare module "babylonjs/Meshes/csg" {
  59508. import { Nullable } from "babylonjs/types";
  59509. import { Scene } from "babylonjs/scene";
  59510. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59511. import { Mesh } from "babylonjs/Meshes/mesh";
  59512. import { Material } from "babylonjs/Materials/material";
  59513. /**
  59514. * Class for building Constructive Solid Geometry
  59515. */
  59516. export class CSG {
  59517. private polygons;
  59518. /**
  59519. * The world matrix
  59520. */
  59521. matrix: Matrix;
  59522. /**
  59523. * Stores the position
  59524. */
  59525. position: Vector3;
  59526. /**
  59527. * Stores the rotation
  59528. */
  59529. rotation: Vector3;
  59530. /**
  59531. * Stores the rotation quaternion
  59532. */
  59533. rotationQuaternion: Nullable<Quaternion>;
  59534. /**
  59535. * Stores the scaling vector
  59536. */
  59537. scaling: Vector3;
  59538. /**
  59539. * Convert the Mesh to CSG
  59540. * @param mesh The Mesh to convert to CSG
  59541. * @returns A new CSG from the Mesh
  59542. */
  59543. static FromMesh(mesh: Mesh): CSG;
  59544. /**
  59545. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59546. * @param polygons Polygons used to construct a CSG solid
  59547. */
  59548. private static FromPolygons;
  59549. /**
  59550. * Clones, or makes a deep copy, of the CSG
  59551. * @returns A new CSG
  59552. */
  59553. clone(): CSG;
  59554. /**
  59555. * Unions this CSG with another CSG
  59556. * @param csg The CSG to union against this CSG
  59557. * @returns The unioned CSG
  59558. */
  59559. union(csg: CSG): CSG;
  59560. /**
  59561. * Unions this CSG with another CSG in place
  59562. * @param csg The CSG to union against this CSG
  59563. */
  59564. unionInPlace(csg: CSG): void;
  59565. /**
  59566. * Subtracts this CSG with another CSG
  59567. * @param csg The CSG to subtract against this CSG
  59568. * @returns A new CSG
  59569. */
  59570. subtract(csg: CSG): CSG;
  59571. /**
  59572. * Subtracts this CSG with another CSG in place
  59573. * @param csg The CSG to subtact against this CSG
  59574. */
  59575. subtractInPlace(csg: CSG): void;
  59576. /**
  59577. * Intersect this CSG with another CSG
  59578. * @param csg The CSG to intersect against this CSG
  59579. * @returns A new CSG
  59580. */
  59581. intersect(csg: CSG): CSG;
  59582. /**
  59583. * Intersects this CSG with another CSG in place
  59584. * @param csg The CSG to intersect against this CSG
  59585. */
  59586. intersectInPlace(csg: CSG): void;
  59587. /**
  59588. * Return a new CSG solid with solid and empty space switched. This solid is
  59589. * not modified.
  59590. * @returns A new CSG solid with solid and empty space switched
  59591. */
  59592. inverse(): CSG;
  59593. /**
  59594. * Inverses the CSG in place
  59595. */
  59596. inverseInPlace(): void;
  59597. /**
  59598. * This is used to keep meshes transformations so they can be restored
  59599. * when we build back a Babylon Mesh
  59600. * NB : All CSG operations are performed in world coordinates
  59601. * @param csg The CSG to copy the transform attributes from
  59602. * @returns This CSG
  59603. */
  59604. copyTransformAttributes(csg: CSG): CSG;
  59605. /**
  59606. * Build Raw mesh from CSG
  59607. * Coordinates here are in world space
  59608. * @param name The name of the mesh geometry
  59609. * @param scene The Scene
  59610. * @param keepSubMeshes Specifies if the submeshes should be kept
  59611. * @returns A new Mesh
  59612. */
  59613. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59614. /**
  59615. * Build Mesh from CSG taking material and transforms into account
  59616. * @param name The name of the Mesh
  59617. * @param material The material of the Mesh
  59618. * @param scene The Scene
  59619. * @param keepSubMeshes Specifies if submeshes should be kept
  59620. * @returns The new Mesh
  59621. */
  59622. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59623. }
  59624. }
  59625. declare module "babylonjs/Meshes/trailMesh" {
  59626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59627. import { Mesh } from "babylonjs/Meshes/mesh";
  59628. import { Scene } from "babylonjs/scene";
  59629. /**
  59630. * Class used to create a trail following a mesh
  59631. */
  59632. export class TrailMesh extends Mesh {
  59633. private _generator;
  59634. private _autoStart;
  59635. private _running;
  59636. private _diameter;
  59637. private _length;
  59638. private _sectionPolygonPointsCount;
  59639. private _sectionVectors;
  59640. private _sectionNormalVectors;
  59641. private _beforeRenderObserver;
  59642. /**
  59643. * @constructor
  59644. * @param name The value used by scene.getMeshByName() to do a lookup.
  59645. * @param generator The mesh to generate a trail.
  59646. * @param scene The scene to add this mesh to.
  59647. * @param diameter Diameter of trailing mesh. Default is 1.
  59648. * @param length Length of trailing mesh. Default is 60.
  59649. * @param autoStart Automatically start trailing mesh. Default true.
  59650. */
  59651. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59652. /**
  59653. * "TrailMesh"
  59654. * @returns "TrailMesh"
  59655. */
  59656. getClassName(): string;
  59657. private _createMesh;
  59658. /**
  59659. * Start trailing mesh.
  59660. */
  59661. start(): void;
  59662. /**
  59663. * Stop trailing mesh.
  59664. */
  59665. stop(): void;
  59666. /**
  59667. * Update trailing mesh geometry.
  59668. */
  59669. update(): void;
  59670. /**
  59671. * Returns a new TrailMesh object.
  59672. * @param name is a string, the name given to the new mesh
  59673. * @param newGenerator use new generator object for cloned trail mesh
  59674. * @returns a new mesh
  59675. */
  59676. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59677. /**
  59678. * Serializes this trail mesh
  59679. * @param serializationObject object to write serialization to
  59680. */
  59681. serialize(serializationObject: any): void;
  59682. /**
  59683. * Parses a serialized trail mesh
  59684. * @param parsedMesh the serialized mesh
  59685. * @param scene the scene to create the trail mesh in
  59686. * @returns the created trail mesh
  59687. */
  59688. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59689. }
  59690. }
  59691. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59692. import { Nullable } from "babylonjs/types";
  59693. import { Scene } from "babylonjs/scene";
  59694. import { Vector4 } from "babylonjs/Maths/math.vector";
  59695. import { Color4 } from "babylonjs/Maths/math.color";
  59696. import { Mesh } from "babylonjs/Meshes/mesh";
  59697. /**
  59698. * Class containing static functions to help procedurally build meshes
  59699. */
  59700. export class TiledBoxBuilder {
  59701. /**
  59702. * Creates a box mesh
  59703. * 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)
  59704. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59708. * @param name defines the name of the mesh
  59709. * @param options defines the options used to create the mesh
  59710. * @param scene defines the hosting scene
  59711. * @returns the box mesh
  59712. */
  59713. static CreateTiledBox(name: string, options: {
  59714. pattern?: number;
  59715. width?: number;
  59716. height?: number;
  59717. depth?: number;
  59718. tileSize?: number;
  59719. tileWidth?: number;
  59720. tileHeight?: number;
  59721. alignHorizontal?: number;
  59722. alignVertical?: number;
  59723. faceUV?: Vector4[];
  59724. faceColors?: Color4[];
  59725. sideOrientation?: number;
  59726. updatable?: boolean;
  59727. }, scene?: Nullable<Scene>): Mesh;
  59728. }
  59729. }
  59730. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59731. import { Vector4 } from "babylonjs/Maths/math.vector";
  59732. import { Mesh } from "babylonjs/Meshes/mesh";
  59733. /**
  59734. * Class containing static functions to help procedurally build meshes
  59735. */
  59736. export class TorusKnotBuilder {
  59737. /**
  59738. * Creates a torus knot mesh
  59739. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59740. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59741. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59742. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59746. * @param name defines the name of the mesh
  59747. * @param options defines the options used to create the mesh
  59748. * @param scene defines the hosting scene
  59749. * @returns the torus knot mesh
  59750. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59751. */
  59752. static CreateTorusKnot(name: string, options: {
  59753. radius?: number;
  59754. tube?: number;
  59755. radialSegments?: number;
  59756. tubularSegments?: number;
  59757. p?: number;
  59758. q?: number;
  59759. updatable?: boolean;
  59760. sideOrientation?: number;
  59761. frontUVs?: Vector4;
  59762. backUVs?: Vector4;
  59763. }, scene: any): Mesh;
  59764. }
  59765. }
  59766. declare module "babylonjs/Meshes/polygonMesh" {
  59767. import { Scene } from "babylonjs/scene";
  59768. import { Vector2 } from "babylonjs/Maths/math.vector";
  59769. import { Mesh } from "babylonjs/Meshes/mesh";
  59770. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59771. import { Path2 } from "babylonjs/Maths/math.path";
  59772. /**
  59773. * Polygon
  59774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59775. */
  59776. export class Polygon {
  59777. /**
  59778. * Creates a rectangle
  59779. * @param xmin bottom X coord
  59780. * @param ymin bottom Y coord
  59781. * @param xmax top X coord
  59782. * @param ymax top Y coord
  59783. * @returns points that make the resulting rectation
  59784. */
  59785. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59786. /**
  59787. * Creates a circle
  59788. * @param radius radius of circle
  59789. * @param cx scale in x
  59790. * @param cy scale in y
  59791. * @param numberOfSides number of sides that make up the circle
  59792. * @returns points that make the resulting circle
  59793. */
  59794. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59795. /**
  59796. * Creates a polygon from input string
  59797. * @param input Input polygon data
  59798. * @returns the parsed points
  59799. */
  59800. static Parse(input: string): Vector2[];
  59801. /**
  59802. * Starts building a polygon from x and y coordinates
  59803. * @param x x coordinate
  59804. * @param y y coordinate
  59805. * @returns the started path2
  59806. */
  59807. static StartingAt(x: number, y: number): Path2;
  59808. }
  59809. /**
  59810. * Builds a polygon
  59811. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59812. */
  59813. export class PolygonMeshBuilder {
  59814. private _points;
  59815. private _outlinepoints;
  59816. private _holes;
  59817. private _name;
  59818. private _scene;
  59819. private _epoints;
  59820. private _eholes;
  59821. private _addToepoint;
  59822. /**
  59823. * Babylon reference to the earcut plugin.
  59824. */
  59825. bjsEarcut: any;
  59826. /**
  59827. * Creates a PolygonMeshBuilder
  59828. * @param name name of the builder
  59829. * @param contours Path of the polygon
  59830. * @param scene scene to add to when creating the mesh
  59831. * @param earcutInjection can be used to inject your own earcut reference
  59832. */
  59833. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59834. /**
  59835. * Adds a whole within the polygon
  59836. * @param hole Array of points defining the hole
  59837. * @returns this
  59838. */
  59839. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59840. /**
  59841. * Creates the polygon
  59842. * @param updatable If the mesh should be updatable
  59843. * @param depth The depth of the mesh created
  59844. * @returns the created mesh
  59845. */
  59846. build(updatable?: boolean, depth?: number): Mesh;
  59847. /**
  59848. * Creates the polygon
  59849. * @param depth The depth of the mesh created
  59850. * @returns the created VertexData
  59851. */
  59852. buildVertexData(depth?: number): VertexData;
  59853. /**
  59854. * Adds a side to the polygon
  59855. * @param positions points that make the polygon
  59856. * @param normals normals of the polygon
  59857. * @param uvs uvs of the polygon
  59858. * @param indices indices of the polygon
  59859. * @param bounds bounds of the polygon
  59860. * @param points points of the polygon
  59861. * @param depth depth of the polygon
  59862. * @param flip flip of the polygon
  59863. */
  59864. private addSide;
  59865. }
  59866. }
  59867. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59868. import { Scene } from "babylonjs/scene";
  59869. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59870. import { Color4 } from "babylonjs/Maths/math.color";
  59871. import { Mesh } from "babylonjs/Meshes/mesh";
  59872. import { Nullable } from "babylonjs/types";
  59873. /**
  59874. * Class containing static functions to help procedurally build meshes
  59875. */
  59876. export class PolygonBuilder {
  59877. /**
  59878. * Creates a polygon mesh
  59879. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59880. * * 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
  59881. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59884. * * Remember you can only change the shape positions, not their number when updating a polygon
  59885. * @param name defines the name of the mesh
  59886. * @param options defines the options used to create the mesh
  59887. * @param scene defines the hosting scene
  59888. * @param earcutInjection can be used to inject your own earcut reference
  59889. * @returns the polygon mesh
  59890. */
  59891. static CreatePolygon(name: string, options: {
  59892. shape: Vector3[];
  59893. holes?: Vector3[][];
  59894. depth?: number;
  59895. faceUV?: Vector4[];
  59896. faceColors?: Color4[];
  59897. updatable?: boolean;
  59898. sideOrientation?: number;
  59899. frontUVs?: Vector4;
  59900. backUVs?: Vector4;
  59901. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59902. /**
  59903. * Creates an extruded polygon mesh, with depth in the Y direction.
  59904. * * 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)
  59905. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59906. * @param name defines the name of the mesh
  59907. * @param options defines the options used to create the mesh
  59908. * @param scene defines the hosting scene
  59909. * @param earcutInjection can be used to inject your own earcut reference
  59910. * @returns the polygon mesh
  59911. */
  59912. static ExtrudePolygon(name: string, options: {
  59913. shape: Vector3[];
  59914. holes?: Vector3[][];
  59915. depth?: number;
  59916. faceUV?: Vector4[];
  59917. faceColors?: Color4[];
  59918. updatable?: boolean;
  59919. sideOrientation?: number;
  59920. frontUVs?: Vector4;
  59921. backUVs?: Vector4;
  59922. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59923. }
  59924. }
  59925. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59926. import { Scene } from "babylonjs/scene";
  59927. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59928. import { Mesh } from "babylonjs/Meshes/mesh";
  59929. import { Nullable } from "babylonjs/types";
  59930. /**
  59931. * Class containing static functions to help procedurally build meshes
  59932. */
  59933. export class LatheBuilder {
  59934. /**
  59935. * Creates lathe mesh.
  59936. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59937. * * 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
  59938. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59939. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59940. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59941. * * 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
  59942. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59943. * * 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
  59944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59946. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59948. * @param name defines the name of the mesh
  59949. * @param options defines the options used to create the mesh
  59950. * @param scene defines the hosting scene
  59951. * @returns the lathe mesh
  59952. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59953. */
  59954. static CreateLathe(name: string, options: {
  59955. shape: Vector3[];
  59956. radius?: number;
  59957. tessellation?: number;
  59958. clip?: number;
  59959. arc?: number;
  59960. closed?: boolean;
  59961. updatable?: boolean;
  59962. sideOrientation?: number;
  59963. frontUVs?: Vector4;
  59964. backUVs?: Vector4;
  59965. cap?: number;
  59966. invertUV?: boolean;
  59967. }, scene?: Nullable<Scene>): Mesh;
  59968. }
  59969. }
  59970. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59971. import { Nullable } from "babylonjs/types";
  59972. import { Scene } from "babylonjs/scene";
  59973. import { Vector4 } from "babylonjs/Maths/math.vector";
  59974. import { Mesh } from "babylonjs/Meshes/mesh";
  59975. /**
  59976. * Class containing static functions to help procedurally build meshes
  59977. */
  59978. export class TiledPlaneBuilder {
  59979. /**
  59980. * Creates a tiled plane mesh
  59981. * * The parameter `pattern` will, depending on value, do nothing or
  59982. * * * flip (reflect about central vertical) alternate tiles across and up
  59983. * * * flip every tile on alternate rows
  59984. * * * rotate (180 degs) alternate tiles across and up
  59985. * * * rotate every tile on alternate rows
  59986. * * * flip and rotate alternate tiles across and up
  59987. * * * flip and rotate every tile on alternate rows
  59988. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59989. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59992. * * 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)
  59993. * * 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)
  59994. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59995. * @param name defines the name of the mesh
  59996. * @param options defines the options used to create the mesh
  59997. * @param scene defines the hosting scene
  59998. * @returns the box mesh
  59999. */
  60000. static CreateTiledPlane(name: string, options: {
  60001. pattern?: number;
  60002. tileSize?: number;
  60003. tileWidth?: number;
  60004. tileHeight?: number;
  60005. size?: number;
  60006. width?: number;
  60007. height?: number;
  60008. alignHorizontal?: number;
  60009. alignVertical?: number;
  60010. sideOrientation?: number;
  60011. frontUVs?: Vector4;
  60012. backUVs?: Vector4;
  60013. updatable?: boolean;
  60014. }, scene?: Nullable<Scene>): Mesh;
  60015. }
  60016. }
  60017. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60018. import { Nullable } from "babylonjs/types";
  60019. import { Scene } from "babylonjs/scene";
  60020. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60021. import { Mesh } from "babylonjs/Meshes/mesh";
  60022. /**
  60023. * Class containing static functions to help procedurally build meshes
  60024. */
  60025. export class TubeBuilder {
  60026. /**
  60027. * Creates a tube mesh.
  60028. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60029. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60030. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60031. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60032. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60033. * * 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)
  60034. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60035. * * 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
  60036. * * 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
  60037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60039. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60041. * @param name defines the name of the mesh
  60042. * @param options defines the options used to create the mesh
  60043. * @param scene defines the hosting scene
  60044. * @returns the tube mesh
  60045. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60046. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60047. */
  60048. static CreateTube(name: string, options: {
  60049. path: Vector3[];
  60050. radius?: number;
  60051. tessellation?: number;
  60052. radiusFunction?: {
  60053. (i: number, distance: number): number;
  60054. };
  60055. cap?: number;
  60056. arc?: number;
  60057. updatable?: boolean;
  60058. sideOrientation?: number;
  60059. frontUVs?: Vector4;
  60060. backUVs?: Vector4;
  60061. instance?: Mesh;
  60062. invertUV?: boolean;
  60063. }, scene?: Nullable<Scene>): Mesh;
  60064. }
  60065. }
  60066. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60067. import { Scene } from "babylonjs/scene";
  60068. import { Vector4 } from "babylonjs/Maths/math.vector";
  60069. import { Mesh } from "babylonjs/Meshes/mesh";
  60070. import { Nullable } from "babylonjs/types";
  60071. /**
  60072. * Class containing static functions to help procedurally build meshes
  60073. */
  60074. export class IcoSphereBuilder {
  60075. /**
  60076. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60077. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60078. * * 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`)
  60079. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60080. * * 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
  60081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60084. * @param name defines the name of the mesh
  60085. * @param options defines the options used to create the mesh
  60086. * @param scene defines the hosting scene
  60087. * @returns the icosahedron mesh
  60088. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60089. */
  60090. static CreateIcoSphere(name: string, options: {
  60091. radius?: number;
  60092. radiusX?: number;
  60093. radiusY?: number;
  60094. radiusZ?: number;
  60095. flat?: boolean;
  60096. subdivisions?: number;
  60097. sideOrientation?: number;
  60098. frontUVs?: Vector4;
  60099. backUVs?: Vector4;
  60100. updatable?: boolean;
  60101. }, scene?: Nullable<Scene>): Mesh;
  60102. }
  60103. }
  60104. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60105. import { Vector3 } from "babylonjs/Maths/math.vector";
  60106. import { Mesh } from "babylonjs/Meshes/mesh";
  60107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60108. /**
  60109. * Class containing static functions to help procedurally build meshes
  60110. */
  60111. export class DecalBuilder {
  60112. /**
  60113. * Creates a decal mesh.
  60114. * 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
  60115. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60116. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60117. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60118. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60119. * @param name defines the name of the mesh
  60120. * @param sourceMesh defines the mesh where the decal must be applied
  60121. * @param options defines the options used to create the mesh
  60122. * @param scene defines the hosting scene
  60123. * @returns the decal mesh
  60124. * @see https://doc.babylonjs.com/how_to/decals
  60125. */
  60126. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60127. position?: Vector3;
  60128. normal?: Vector3;
  60129. size?: Vector3;
  60130. angle?: number;
  60131. }): Mesh;
  60132. }
  60133. }
  60134. declare module "babylonjs/Meshes/meshBuilder" {
  60135. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60136. import { Nullable } from "babylonjs/types";
  60137. import { Scene } from "babylonjs/scene";
  60138. import { Mesh } from "babylonjs/Meshes/mesh";
  60139. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60140. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60142. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60143. import { Plane } from "babylonjs/Maths/math.plane";
  60144. /**
  60145. * Class containing static functions to help procedurally build meshes
  60146. */
  60147. export class MeshBuilder {
  60148. /**
  60149. * Creates a box mesh
  60150. * * The parameter `size` sets the size (float) of each box side (default 1)
  60151. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60152. * * 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)
  60153. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60157. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60158. * @param name defines the name of the mesh
  60159. * @param options defines the options used to create the mesh
  60160. * @param scene defines the hosting scene
  60161. * @returns the box mesh
  60162. */
  60163. static CreateBox(name: string, options: {
  60164. size?: number;
  60165. width?: number;
  60166. height?: number;
  60167. depth?: number;
  60168. faceUV?: Vector4[];
  60169. faceColors?: Color4[];
  60170. sideOrientation?: number;
  60171. frontUVs?: Vector4;
  60172. backUVs?: Vector4;
  60173. updatable?: boolean;
  60174. }, scene?: Nullable<Scene>): Mesh;
  60175. /**
  60176. * Creates a tiled box mesh
  60177. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60179. * @param name defines the name of the mesh
  60180. * @param options defines the options used to create the mesh
  60181. * @param scene defines the hosting scene
  60182. * @returns the tiled box mesh
  60183. */
  60184. static CreateTiledBox(name: string, options: {
  60185. pattern?: number;
  60186. size?: number;
  60187. width?: number;
  60188. height?: number;
  60189. depth: number;
  60190. tileSize?: number;
  60191. tileWidth?: number;
  60192. tileHeight?: number;
  60193. faceUV?: Vector4[];
  60194. faceColors?: Color4[];
  60195. alignHorizontal?: number;
  60196. alignVertical?: number;
  60197. sideOrientation?: number;
  60198. updatable?: boolean;
  60199. }, scene?: Nullable<Scene>): Mesh;
  60200. /**
  60201. * Creates a sphere mesh
  60202. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60203. * * 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`)
  60204. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60205. * * 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
  60206. * * 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)
  60207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60210. * @param name defines the name of the mesh
  60211. * @param options defines the options used to create the mesh
  60212. * @param scene defines the hosting scene
  60213. * @returns the sphere mesh
  60214. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60215. */
  60216. static CreateSphere(name: string, options: {
  60217. segments?: number;
  60218. diameter?: number;
  60219. diameterX?: number;
  60220. diameterY?: number;
  60221. diameterZ?: number;
  60222. arc?: number;
  60223. slice?: number;
  60224. sideOrientation?: number;
  60225. frontUVs?: Vector4;
  60226. backUVs?: Vector4;
  60227. updatable?: boolean;
  60228. }, scene?: Nullable<Scene>): Mesh;
  60229. /**
  60230. * Creates a plane polygonal mesh. By default, this is a disc
  60231. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60232. * * 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
  60233. * * 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
  60234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60237. * @param name defines the name of the mesh
  60238. * @param options defines the options used to create the mesh
  60239. * @param scene defines the hosting scene
  60240. * @returns the plane polygonal mesh
  60241. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60242. */
  60243. static CreateDisc(name: string, options: {
  60244. radius?: number;
  60245. tessellation?: number;
  60246. arc?: number;
  60247. updatable?: boolean;
  60248. sideOrientation?: number;
  60249. frontUVs?: Vector4;
  60250. backUVs?: Vector4;
  60251. }, scene?: Nullable<Scene>): Mesh;
  60252. /**
  60253. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60254. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60255. * * 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`)
  60256. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60257. * * 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
  60258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60261. * @param name defines the name of the mesh
  60262. * @param options defines the options used to create the mesh
  60263. * @param scene defines the hosting scene
  60264. * @returns the icosahedron mesh
  60265. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60266. */
  60267. static CreateIcoSphere(name: string, options: {
  60268. radius?: number;
  60269. radiusX?: number;
  60270. radiusY?: number;
  60271. radiusZ?: number;
  60272. flat?: boolean;
  60273. subdivisions?: number;
  60274. sideOrientation?: number;
  60275. frontUVs?: Vector4;
  60276. backUVs?: Vector4;
  60277. updatable?: boolean;
  60278. }, scene?: Nullable<Scene>): Mesh;
  60279. /**
  60280. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60281. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60282. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60283. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60284. * * 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
  60285. * * 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
  60286. * * 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
  60287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60289. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60290. * * 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
  60291. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60292. * * 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
  60293. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60295. * @param name defines the name of the mesh
  60296. * @param options defines the options used to create the mesh
  60297. * @param scene defines the hosting scene
  60298. * @returns the ribbon mesh
  60299. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60301. */
  60302. static CreateRibbon(name: string, options: {
  60303. pathArray: Vector3[][];
  60304. closeArray?: boolean;
  60305. closePath?: boolean;
  60306. offset?: number;
  60307. updatable?: boolean;
  60308. sideOrientation?: number;
  60309. frontUVs?: Vector4;
  60310. backUVs?: Vector4;
  60311. instance?: Mesh;
  60312. invertUV?: boolean;
  60313. uvs?: Vector2[];
  60314. colors?: Color4[];
  60315. }, scene?: Nullable<Scene>): Mesh;
  60316. /**
  60317. * Creates a cylinder or a cone mesh
  60318. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60319. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60320. * * 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.
  60321. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60322. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60323. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60324. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60325. * * 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).
  60326. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60327. * * 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).
  60328. * * 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
  60329. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60330. * * 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
  60331. * * 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.
  60332. * * If `enclose` is false, a ring surface is one element.
  60333. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60334. * * 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
  60335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60338. * @param name defines the name of the mesh
  60339. * @param options defines the options used to create the mesh
  60340. * @param scene defines the hosting scene
  60341. * @returns the cylinder mesh
  60342. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60343. */
  60344. static CreateCylinder(name: string, options: {
  60345. height?: number;
  60346. diameterTop?: number;
  60347. diameterBottom?: number;
  60348. diameter?: number;
  60349. tessellation?: number;
  60350. subdivisions?: number;
  60351. arc?: number;
  60352. faceColors?: Color4[];
  60353. faceUV?: Vector4[];
  60354. updatable?: boolean;
  60355. hasRings?: boolean;
  60356. enclose?: boolean;
  60357. cap?: number;
  60358. sideOrientation?: number;
  60359. frontUVs?: Vector4;
  60360. backUVs?: Vector4;
  60361. }, scene?: Nullable<Scene>): Mesh;
  60362. /**
  60363. * Creates a torus mesh
  60364. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60365. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60366. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60370. * @param name defines the name of the mesh
  60371. * @param options defines the options used to create the mesh
  60372. * @param scene defines the hosting scene
  60373. * @returns the torus mesh
  60374. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60375. */
  60376. static CreateTorus(name: string, options: {
  60377. diameter?: number;
  60378. thickness?: number;
  60379. tessellation?: number;
  60380. updatable?: boolean;
  60381. sideOrientation?: number;
  60382. frontUVs?: Vector4;
  60383. backUVs?: Vector4;
  60384. }, scene?: Nullable<Scene>): Mesh;
  60385. /**
  60386. * Creates a torus knot mesh
  60387. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60388. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60389. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60390. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60394. * @param name defines the name of the mesh
  60395. * @param options defines the options used to create the mesh
  60396. * @param scene defines the hosting scene
  60397. * @returns the torus knot mesh
  60398. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60399. */
  60400. static CreateTorusKnot(name: string, options: {
  60401. radius?: number;
  60402. tube?: number;
  60403. radialSegments?: number;
  60404. tubularSegments?: number;
  60405. p?: number;
  60406. q?: number;
  60407. updatable?: boolean;
  60408. sideOrientation?: number;
  60409. frontUVs?: Vector4;
  60410. backUVs?: Vector4;
  60411. }, scene?: Nullable<Scene>): Mesh;
  60412. /**
  60413. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60414. * * 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
  60415. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60416. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60417. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60418. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60419. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60420. * * 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
  60421. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60424. * @param name defines the name of the new line system
  60425. * @param options defines the options used to create the line system
  60426. * @param scene defines the hosting scene
  60427. * @returns a new line system mesh
  60428. */
  60429. static CreateLineSystem(name: string, options: {
  60430. lines: Vector3[][];
  60431. updatable?: boolean;
  60432. instance?: Nullable<LinesMesh>;
  60433. colors?: Nullable<Color4[][]>;
  60434. useVertexAlpha?: boolean;
  60435. }, scene: Nullable<Scene>): LinesMesh;
  60436. /**
  60437. * Creates a line mesh
  60438. * 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
  60439. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60440. * * The parameter `points` is an array successive Vector3
  60441. * * 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
  60442. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60443. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60444. * * When updating an instance, remember that only point positions can change, not the number of points
  60445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60447. * @param name defines the name of the new line system
  60448. * @param options defines the options used to create the line system
  60449. * @param scene defines the hosting scene
  60450. * @returns a new line mesh
  60451. */
  60452. static CreateLines(name: string, options: {
  60453. points: Vector3[];
  60454. updatable?: boolean;
  60455. instance?: Nullable<LinesMesh>;
  60456. colors?: Color4[];
  60457. useVertexAlpha?: boolean;
  60458. }, scene?: Nullable<Scene>): LinesMesh;
  60459. /**
  60460. * Creates a dashed line mesh
  60461. * * 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
  60462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60463. * * The parameter `points` is an array successive Vector3
  60464. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60465. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60466. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60467. * * 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
  60468. * * When updating an instance, remember that only point positions can change, not the number of points
  60469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60470. * @param name defines the name of the mesh
  60471. * @param options defines the options used to create the mesh
  60472. * @param scene defines the hosting scene
  60473. * @returns the dashed line mesh
  60474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60475. */
  60476. static CreateDashedLines(name: string, options: {
  60477. points: Vector3[];
  60478. dashSize?: number;
  60479. gapSize?: number;
  60480. dashNb?: number;
  60481. updatable?: boolean;
  60482. instance?: LinesMesh;
  60483. }, scene?: Nullable<Scene>): LinesMesh;
  60484. /**
  60485. * 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.
  60486. * * 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.
  60487. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60488. * * 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.
  60489. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60490. * * 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
  60491. * * 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
  60492. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60495. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60497. * @param name defines the name of the mesh
  60498. * @param options defines the options used to create the mesh
  60499. * @param scene defines the hosting scene
  60500. * @returns the extruded shape mesh
  60501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60503. */
  60504. static ExtrudeShape(name: string, options: {
  60505. shape: Vector3[];
  60506. path: Vector3[];
  60507. scale?: number;
  60508. rotation?: number;
  60509. cap?: number;
  60510. updatable?: boolean;
  60511. sideOrientation?: number;
  60512. frontUVs?: Vector4;
  60513. backUVs?: Vector4;
  60514. instance?: Mesh;
  60515. invertUV?: boolean;
  60516. }, scene?: Nullable<Scene>): Mesh;
  60517. /**
  60518. * Creates an custom extruded shape mesh.
  60519. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60520. * * 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.
  60521. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60522. * * 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
  60523. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60524. * * 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
  60525. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60526. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60527. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60528. * * 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
  60529. * * 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
  60530. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60535. * @param name defines the name of the mesh
  60536. * @param options defines the options used to create the mesh
  60537. * @param scene defines the hosting scene
  60538. * @returns the custom extruded shape mesh
  60539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60540. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60542. */
  60543. static ExtrudeShapeCustom(name: string, options: {
  60544. shape: Vector3[];
  60545. path: Vector3[];
  60546. scaleFunction?: any;
  60547. rotationFunction?: any;
  60548. ribbonCloseArray?: boolean;
  60549. ribbonClosePath?: boolean;
  60550. cap?: number;
  60551. updatable?: boolean;
  60552. sideOrientation?: number;
  60553. frontUVs?: Vector4;
  60554. backUVs?: Vector4;
  60555. instance?: Mesh;
  60556. invertUV?: boolean;
  60557. }, scene?: Nullable<Scene>): Mesh;
  60558. /**
  60559. * Creates lathe mesh.
  60560. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60561. * * 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
  60562. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60563. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60564. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60565. * * 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
  60566. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60567. * * 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
  60568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60570. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60572. * @param name defines the name of the mesh
  60573. * @param options defines the options used to create the mesh
  60574. * @param scene defines the hosting scene
  60575. * @returns the lathe mesh
  60576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60577. */
  60578. static CreateLathe(name: string, options: {
  60579. shape: Vector3[];
  60580. radius?: number;
  60581. tessellation?: number;
  60582. clip?: number;
  60583. arc?: number;
  60584. closed?: boolean;
  60585. updatable?: boolean;
  60586. sideOrientation?: number;
  60587. frontUVs?: Vector4;
  60588. backUVs?: Vector4;
  60589. cap?: number;
  60590. invertUV?: boolean;
  60591. }, scene?: Nullable<Scene>): Mesh;
  60592. /**
  60593. * Creates a tiled plane mesh
  60594. * * You can set a limited pattern arrangement with the tiles
  60595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60598. * @param name defines the name of the mesh
  60599. * @param options defines the options used to create the mesh
  60600. * @param scene defines the hosting scene
  60601. * @returns the plane mesh
  60602. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60603. */
  60604. static CreateTiledPlane(name: string, options: {
  60605. pattern?: number;
  60606. tileSize?: number;
  60607. tileWidth?: number;
  60608. tileHeight?: number;
  60609. size?: number;
  60610. width?: number;
  60611. height?: number;
  60612. alignHorizontal?: number;
  60613. alignVertical?: number;
  60614. sideOrientation?: number;
  60615. frontUVs?: Vector4;
  60616. backUVs?: Vector4;
  60617. updatable?: boolean;
  60618. }, scene?: Nullable<Scene>): Mesh;
  60619. /**
  60620. * Creates a plane mesh
  60621. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60622. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60623. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60627. * @param name defines the name of the mesh
  60628. * @param options defines the options used to create the mesh
  60629. * @param scene defines the hosting scene
  60630. * @returns the plane mesh
  60631. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60632. */
  60633. static CreatePlane(name: string, options: {
  60634. size?: number;
  60635. width?: number;
  60636. height?: number;
  60637. sideOrientation?: number;
  60638. frontUVs?: Vector4;
  60639. backUVs?: Vector4;
  60640. updatable?: boolean;
  60641. sourcePlane?: Plane;
  60642. }, scene?: Nullable<Scene>): Mesh;
  60643. /**
  60644. * Creates a ground mesh
  60645. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60646. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60648. * @param name defines the name of the mesh
  60649. * @param options defines the options used to create the mesh
  60650. * @param scene defines the hosting scene
  60651. * @returns the ground mesh
  60652. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60653. */
  60654. static CreateGround(name: string, options: {
  60655. width?: number;
  60656. height?: number;
  60657. subdivisions?: number;
  60658. subdivisionsX?: number;
  60659. subdivisionsY?: number;
  60660. updatable?: boolean;
  60661. }, scene?: Nullable<Scene>): Mesh;
  60662. /**
  60663. * Creates a tiled ground mesh
  60664. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60665. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60666. * * 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
  60667. * * 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
  60668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60669. * @param name defines the name of the mesh
  60670. * @param options defines the options used to create the mesh
  60671. * @param scene defines the hosting scene
  60672. * @returns the tiled ground mesh
  60673. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60674. */
  60675. static CreateTiledGround(name: string, options: {
  60676. xmin: number;
  60677. zmin: number;
  60678. xmax: number;
  60679. zmax: number;
  60680. subdivisions?: {
  60681. w: number;
  60682. h: number;
  60683. };
  60684. precision?: {
  60685. w: number;
  60686. h: number;
  60687. };
  60688. updatable?: boolean;
  60689. }, scene?: Nullable<Scene>): Mesh;
  60690. /**
  60691. * Creates a ground mesh from a height map
  60692. * * The parameter `url` sets the URL of the height map image resource.
  60693. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60694. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60695. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60696. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60697. * * 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.
  60698. * * 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).
  60699. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60701. * @param name defines the name of the mesh
  60702. * @param url defines the url to the height map
  60703. * @param options defines the options used to create the mesh
  60704. * @param scene defines the hosting scene
  60705. * @returns the ground mesh
  60706. * @see https://doc.babylonjs.com/babylon101/height_map
  60707. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60708. */
  60709. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60710. width?: number;
  60711. height?: number;
  60712. subdivisions?: number;
  60713. minHeight?: number;
  60714. maxHeight?: number;
  60715. colorFilter?: Color3;
  60716. alphaFilter?: number;
  60717. updatable?: boolean;
  60718. onReady?: (mesh: GroundMesh) => void;
  60719. }, scene?: Nullable<Scene>): GroundMesh;
  60720. /**
  60721. * Creates a polygon mesh
  60722. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60723. * * 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
  60724. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60727. * * Remember you can only change the shape positions, not their number when updating a polygon
  60728. * @param name defines the name of the mesh
  60729. * @param options defines the options used to create the mesh
  60730. * @param scene defines the hosting scene
  60731. * @param earcutInjection can be used to inject your own earcut reference
  60732. * @returns the polygon mesh
  60733. */
  60734. static CreatePolygon(name: string, options: {
  60735. shape: Vector3[];
  60736. holes?: Vector3[][];
  60737. depth?: number;
  60738. faceUV?: Vector4[];
  60739. faceColors?: Color4[];
  60740. updatable?: boolean;
  60741. sideOrientation?: number;
  60742. frontUVs?: Vector4;
  60743. backUVs?: Vector4;
  60744. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60745. /**
  60746. * Creates an extruded polygon mesh, with depth in the Y direction.
  60747. * * 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)
  60748. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60749. * @param name defines the name of the mesh
  60750. * @param options defines the options used to create the mesh
  60751. * @param scene defines the hosting scene
  60752. * @param earcutInjection can be used to inject your own earcut reference
  60753. * @returns the polygon mesh
  60754. */
  60755. static ExtrudePolygon(name: string, options: {
  60756. shape: Vector3[];
  60757. holes?: Vector3[][];
  60758. depth?: number;
  60759. faceUV?: Vector4[];
  60760. faceColors?: Color4[];
  60761. updatable?: boolean;
  60762. sideOrientation?: number;
  60763. frontUVs?: Vector4;
  60764. backUVs?: Vector4;
  60765. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60766. /**
  60767. * Creates a tube mesh.
  60768. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60769. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60770. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60771. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60772. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60773. * * 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)
  60774. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60775. * * 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
  60776. * * 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
  60777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60779. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60781. * @param name defines the name of the mesh
  60782. * @param options defines the options used to create the mesh
  60783. * @param scene defines the hosting scene
  60784. * @returns the tube mesh
  60785. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60786. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60787. */
  60788. static CreateTube(name: string, options: {
  60789. path: Vector3[];
  60790. radius?: number;
  60791. tessellation?: number;
  60792. radiusFunction?: {
  60793. (i: number, distance: number): number;
  60794. };
  60795. cap?: number;
  60796. arc?: number;
  60797. updatable?: boolean;
  60798. sideOrientation?: number;
  60799. frontUVs?: Vector4;
  60800. backUVs?: Vector4;
  60801. instance?: Mesh;
  60802. invertUV?: boolean;
  60803. }, scene?: Nullable<Scene>): Mesh;
  60804. /**
  60805. * Creates a polyhedron mesh
  60806. * * 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
  60807. * * The parameter `size` (positive float, default 1) sets the polygon size
  60808. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60809. * * 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`
  60810. * * 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
  60811. * * 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)`)
  60812. * * 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
  60813. * * 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
  60814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60815. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60817. * @param name defines the name of the mesh
  60818. * @param options defines the options used to create the mesh
  60819. * @param scene defines the hosting scene
  60820. * @returns the polyhedron mesh
  60821. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60822. */
  60823. static CreatePolyhedron(name: string, options: {
  60824. type?: number;
  60825. size?: number;
  60826. sizeX?: number;
  60827. sizeY?: number;
  60828. sizeZ?: number;
  60829. custom?: any;
  60830. faceUV?: Vector4[];
  60831. faceColors?: Color4[];
  60832. flat?: boolean;
  60833. updatable?: boolean;
  60834. sideOrientation?: number;
  60835. frontUVs?: Vector4;
  60836. backUVs?: Vector4;
  60837. }, scene?: Nullable<Scene>): Mesh;
  60838. /**
  60839. * Creates a decal mesh.
  60840. * 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
  60841. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60842. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60843. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60844. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60845. * @param name defines the name of the mesh
  60846. * @param sourceMesh defines the mesh where the decal must be applied
  60847. * @param options defines the options used to create the mesh
  60848. * @param scene defines the hosting scene
  60849. * @returns the decal mesh
  60850. * @see https://doc.babylonjs.com/how_to/decals
  60851. */
  60852. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60853. position?: Vector3;
  60854. normal?: Vector3;
  60855. size?: Vector3;
  60856. angle?: number;
  60857. }): Mesh;
  60858. }
  60859. }
  60860. declare module "babylonjs/Meshes/meshSimplification" {
  60861. import { Mesh } from "babylonjs/Meshes/mesh";
  60862. /**
  60863. * A simplifier interface for future simplification implementations
  60864. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60865. */
  60866. export interface ISimplifier {
  60867. /**
  60868. * Simplification of a given mesh according to the given settings.
  60869. * Since this requires computation, it is assumed that the function runs async.
  60870. * @param settings The settings of the simplification, including quality and distance
  60871. * @param successCallback A callback that will be called after the mesh was simplified.
  60872. * @param errorCallback in case of an error, this callback will be called. optional.
  60873. */
  60874. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60875. }
  60876. /**
  60877. * Expected simplification settings.
  60878. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60879. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60880. */
  60881. export interface ISimplificationSettings {
  60882. /**
  60883. * Gets or sets the expected quality
  60884. */
  60885. quality: number;
  60886. /**
  60887. * Gets or sets the distance when this optimized version should be used
  60888. */
  60889. distance: number;
  60890. /**
  60891. * Gets an already optimized mesh
  60892. */
  60893. optimizeMesh?: boolean;
  60894. }
  60895. /**
  60896. * Class used to specify simplification options
  60897. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60898. */
  60899. export class SimplificationSettings implements ISimplificationSettings {
  60900. /** expected quality */
  60901. quality: number;
  60902. /** distance when this optimized version should be used */
  60903. distance: number;
  60904. /** already optimized mesh */
  60905. optimizeMesh?: boolean | undefined;
  60906. /**
  60907. * Creates a SimplificationSettings
  60908. * @param quality expected quality
  60909. * @param distance distance when this optimized version should be used
  60910. * @param optimizeMesh already optimized mesh
  60911. */
  60912. constructor(
  60913. /** expected quality */
  60914. quality: number,
  60915. /** distance when this optimized version should be used */
  60916. distance: number,
  60917. /** already optimized mesh */
  60918. optimizeMesh?: boolean | undefined);
  60919. }
  60920. /**
  60921. * Interface used to define a simplification task
  60922. */
  60923. export interface ISimplificationTask {
  60924. /**
  60925. * Array of settings
  60926. */
  60927. settings: Array<ISimplificationSettings>;
  60928. /**
  60929. * Simplification type
  60930. */
  60931. simplificationType: SimplificationType;
  60932. /**
  60933. * Mesh to simplify
  60934. */
  60935. mesh: Mesh;
  60936. /**
  60937. * Callback called on success
  60938. */
  60939. successCallback?: () => void;
  60940. /**
  60941. * Defines if parallel processing can be used
  60942. */
  60943. parallelProcessing: boolean;
  60944. }
  60945. /**
  60946. * Queue used to order the simplification tasks
  60947. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60948. */
  60949. export class SimplificationQueue {
  60950. private _simplificationArray;
  60951. /**
  60952. * Gets a boolean indicating that the process is still running
  60953. */
  60954. running: boolean;
  60955. /**
  60956. * Creates a new queue
  60957. */
  60958. constructor();
  60959. /**
  60960. * Adds a new simplification task
  60961. * @param task defines a task to add
  60962. */
  60963. addTask(task: ISimplificationTask): void;
  60964. /**
  60965. * Execute next task
  60966. */
  60967. executeNext(): void;
  60968. /**
  60969. * Execute a simplification task
  60970. * @param task defines the task to run
  60971. */
  60972. runSimplification(task: ISimplificationTask): void;
  60973. private getSimplifier;
  60974. }
  60975. /**
  60976. * The implemented types of simplification
  60977. * At the moment only Quadratic Error Decimation is implemented
  60978. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60979. */
  60980. export enum SimplificationType {
  60981. /** Quadratic error decimation */
  60982. QUADRATIC = 0
  60983. }
  60984. }
  60985. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60986. import { Scene } from "babylonjs/scene";
  60987. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60988. import { ISceneComponent } from "babylonjs/sceneComponent";
  60989. module "babylonjs/scene" {
  60990. interface Scene {
  60991. /** @hidden (Backing field) */
  60992. _simplificationQueue: SimplificationQueue;
  60993. /**
  60994. * Gets or sets the simplification queue attached to the scene
  60995. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60996. */
  60997. simplificationQueue: SimplificationQueue;
  60998. }
  60999. }
  61000. module "babylonjs/Meshes/mesh" {
  61001. interface Mesh {
  61002. /**
  61003. * Simplify the mesh according to the given array of settings.
  61004. * Function will return immediately and will simplify async
  61005. * @param settings a collection of simplification settings
  61006. * @param parallelProcessing should all levels calculate parallel or one after the other
  61007. * @param simplificationType the type of simplification to run
  61008. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61009. * @returns the current mesh
  61010. */
  61011. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61012. }
  61013. }
  61014. /**
  61015. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61016. * created in a scene
  61017. */
  61018. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61019. /**
  61020. * The component name helpfull to identify the component in the list of scene components.
  61021. */
  61022. readonly name: string;
  61023. /**
  61024. * The scene the component belongs to.
  61025. */
  61026. scene: Scene;
  61027. /**
  61028. * Creates a new instance of the component for the given scene
  61029. * @param scene Defines the scene to register the component in
  61030. */
  61031. constructor(scene: Scene);
  61032. /**
  61033. * Registers the component in a given scene
  61034. */
  61035. register(): void;
  61036. /**
  61037. * Rebuilds the elements related to this component in case of
  61038. * context lost for instance.
  61039. */
  61040. rebuild(): void;
  61041. /**
  61042. * Disposes the component and the associated ressources
  61043. */
  61044. dispose(): void;
  61045. private _beforeCameraUpdate;
  61046. }
  61047. }
  61048. declare module "babylonjs/Meshes/Builders/index" {
  61049. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61050. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61051. export * from "babylonjs/Meshes/Builders/discBuilder";
  61052. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61053. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61054. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61055. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61056. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61057. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61058. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61059. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61060. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61061. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61062. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61063. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61064. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61065. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61066. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61067. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61068. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61069. }
  61070. declare module "babylonjs/Meshes/index" {
  61071. export * from "babylonjs/Meshes/abstractMesh";
  61072. export * from "babylonjs/Meshes/buffer";
  61073. export * from "babylonjs/Meshes/Compression/index";
  61074. export * from "babylonjs/Meshes/csg";
  61075. export * from "babylonjs/Meshes/geometry";
  61076. export * from "babylonjs/Meshes/groundMesh";
  61077. export * from "babylonjs/Meshes/trailMesh";
  61078. export * from "babylonjs/Meshes/instancedMesh";
  61079. export * from "babylonjs/Meshes/linesMesh";
  61080. export * from "babylonjs/Meshes/mesh";
  61081. export * from "babylonjs/Meshes/mesh.vertexData";
  61082. export * from "babylonjs/Meshes/meshBuilder";
  61083. export * from "babylonjs/Meshes/meshSimplification";
  61084. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61085. export * from "babylonjs/Meshes/polygonMesh";
  61086. export * from "babylonjs/Meshes/subMesh";
  61087. export * from "babylonjs/Meshes/meshLODLevel";
  61088. export * from "babylonjs/Meshes/transformNode";
  61089. export * from "babylonjs/Meshes/Builders/index";
  61090. export * from "babylonjs/Meshes/dataBuffer";
  61091. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61092. }
  61093. declare module "babylonjs/Morph/index" {
  61094. export * from "babylonjs/Morph/morphTarget";
  61095. export * from "babylonjs/Morph/morphTargetManager";
  61096. }
  61097. declare module "babylonjs/Navigation/INavigationEngine" {
  61098. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61099. import { Vector3 } from "babylonjs/Maths/math";
  61100. import { Mesh } from "babylonjs/Meshes/mesh";
  61101. import { Scene } from "babylonjs/scene";
  61102. /**
  61103. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61104. */
  61105. export interface INavigationEnginePlugin {
  61106. /**
  61107. * plugin name
  61108. */
  61109. name: string;
  61110. /**
  61111. * Creates a navigation mesh
  61112. * @param meshes array of all the geometry used to compute the navigatio mesh
  61113. * @param parameters bunch of parameters used to filter geometry
  61114. */
  61115. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61116. /**
  61117. * Create a navigation mesh debug mesh
  61118. * @param scene is where the mesh will be added
  61119. * @returns debug display mesh
  61120. */
  61121. createDebugNavMesh(scene: Scene): Mesh;
  61122. /**
  61123. * Get a navigation mesh constrained position, closest to the parameter position
  61124. * @param position world position
  61125. * @returns the closest point to position constrained by the navigation mesh
  61126. */
  61127. getClosestPoint(position: Vector3): Vector3;
  61128. /**
  61129. * Get a navigation mesh constrained position, within a particular radius
  61130. * @param position world position
  61131. * @param maxRadius the maximum distance to the constrained world position
  61132. * @returns the closest point to position constrained by the navigation mesh
  61133. */
  61134. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61135. /**
  61136. * Compute the final position from a segment made of destination-position
  61137. * @param position world position
  61138. * @param destination world position
  61139. * @returns the resulting point along the navmesh
  61140. */
  61141. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61142. /**
  61143. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61144. * @param start world position
  61145. * @param end world position
  61146. * @returns array containing world position composing the path
  61147. */
  61148. computePath(start: Vector3, end: Vector3): Vector3[];
  61149. /**
  61150. * If this plugin is supported
  61151. * @returns true if plugin is supported
  61152. */
  61153. isSupported(): boolean;
  61154. /**
  61155. * Create a new Crowd so you can add agents
  61156. * @param maxAgents the maximum agent count in the crowd
  61157. * @param maxAgentRadius the maximum radius an agent can have
  61158. * @param scene to attach the crowd to
  61159. * @returns the crowd you can add agents to
  61160. */
  61161. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61162. /**
  61163. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61164. * The queries will try to find a solution within those bounds
  61165. * default is (1,1,1)
  61166. * @param extent x,y,z value that define the extent around the queries point of reference
  61167. */
  61168. setDefaultQueryExtent(extent: Vector3): void;
  61169. /**
  61170. * Get the Bounding box extent specified by setDefaultQueryExtent
  61171. * @returns the box extent values
  61172. */
  61173. getDefaultQueryExtent(): Vector3;
  61174. /**
  61175. * Release all resources
  61176. */
  61177. dispose(): void;
  61178. }
  61179. /**
  61180. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61181. */
  61182. export interface ICrowd {
  61183. /**
  61184. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61185. * You can attach anything to that node. The node position is updated in the scene update tick.
  61186. * @param pos world position that will be constrained by the navigation mesh
  61187. * @param parameters agent parameters
  61188. * @param transform hooked to the agent that will be update by the scene
  61189. * @returns agent index
  61190. */
  61191. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61192. /**
  61193. * Returns the agent position in world space
  61194. * @param index agent index returned by addAgent
  61195. * @returns world space position
  61196. */
  61197. getAgentPosition(index: number): Vector3;
  61198. /**
  61199. * Gets the agent velocity in world space
  61200. * @param index agent index returned by addAgent
  61201. * @returns world space velocity
  61202. */
  61203. getAgentVelocity(index: number): Vector3;
  61204. /**
  61205. * remove a particular agent previously created
  61206. * @param index agent index returned by addAgent
  61207. */
  61208. removeAgent(index: number): void;
  61209. /**
  61210. * get the list of all agents attached to this crowd
  61211. * @returns list of agent indices
  61212. */
  61213. getAgents(): number[];
  61214. /**
  61215. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61216. * @param deltaTime in seconds
  61217. */
  61218. update(deltaTime: number): void;
  61219. /**
  61220. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61221. * @param index agent index returned by addAgent
  61222. * @param destination targeted world position
  61223. */
  61224. agentGoto(index: number, destination: Vector3): void;
  61225. /**
  61226. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61227. * The queries will try to find a solution within those bounds
  61228. * default is (1,1,1)
  61229. * @param extent x,y,z value that define the extent around the queries point of reference
  61230. */
  61231. setDefaultQueryExtent(extent: Vector3): void;
  61232. /**
  61233. * Get the Bounding box extent specified by setDefaultQueryExtent
  61234. * @returns the box extent values
  61235. */
  61236. getDefaultQueryExtent(): Vector3;
  61237. /**
  61238. * Release all resources
  61239. */
  61240. dispose(): void;
  61241. }
  61242. /**
  61243. * Configures an agent
  61244. */
  61245. export interface IAgentParameters {
  61246. /**
  61247. * Agent radius. [Limit: >= 0]
  61248. */
  61249. radius: number;
  61250. /**
  61251. * Agent height. [Limit: > 0]
  61252. */
  61253. height: number;
  61254. /**
  61255. * Maximum allowed acceleration. [Limit: >= 0]
  61256. */
  61257. maxAcceleration: number;
  61258. /**
  61259. * Maximum allowed speed. [Limit: >= 0]
  61260. */
  61261. maxSpeed: number;
  61262. /**
  61263. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61264. */
  61265. collisionQueryRange: number;
  61266. /**
  61267. * The path visibility optimization range. [Limit: > 0]
  61268. */
  61269. pathOptimizationRange: number;
  61270. /**
  61271. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61272. */
  61273. separationWeight: number;
  61274. }
  61275. /**
  61276. * Configures the navigation mesh creation
  61277. */
  61278. export interface INavMeshParameters {
  61279. /**
  61280. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61281. */
  61282. cs: number;
  61283. /**
  61284. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61285. */
  61286. ch: number;
  61287. /**
  61288. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61289. */
  61290. walkableSlopeAngle: number;
  61291. /**
  61292. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61293. * be considered walkable. [Limit: >= 3] [Units: vx]
  61294. */
  61295. walkableHeight: number;
  61296. /**
  61297. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61298. */
  61299. walkableClimb: number;
  61300. /**
  61301. * The distance to erode/shrink the walkable area of the heightfield away from
  61302. * obstructions. [Limit: >=0] [Units: vx]
  61303. */
  61304. walkableRadius: number;
  61305. /**
  61306. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61307. */
  61308. maxEdgeLen: number;
  61309. /**
  61310. * The maximum distance a simplfied contour's border edges should deviate
  61311. * the original raw contour. [Limit: >=0] [Units: vx]
  61312. */
  61313. maxSimplificationError: number;
  61314. /**
  61315. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61316. */
  61317. minRegionArea: number;
  61318. /**
  61319. * Any regions with a span count smaller than this value will, if possible,
  61320. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61321. */
  61322. mergeRegionArea: number;
  61323. /**
  61324. * The maximum number of vertices allowed for polygons generated during the
  61325. * contour to polygon conversion process. [Limit: >= 3]
  61326. */
  61327. maxVertsPerPoly: number;
  61328. /**
  61329. * Sets the sampling distance to use when generating the detail mesh.
  61330. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61331. */
  61332. detailSampleDist: number;
  61333. /**
  61334. * The maximum distance the detail mesh surface should deviate from heightfield
  61335. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61336. */
  61337. detailSampleMaxError: number;
  61338. }
  61339. }
  61340. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61341. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61342. import { Mesh } from "babylonjs/Meshes/mesh";
  61343. import { Scene } from "babylonjs/scene";
  61344. import { Vector3 } from "babylonjs/Maths/math";
  61345. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61346. /**
  61347. * RecastJS navigation plugin
  61348. */
  61349. export class RecastJSPlugin implements INavigationEnginePlugin {
  61350. /**
  61351. * Reference to the Recast library
  61352. */
  61353. bjsRECAST: any;
  61354. /**
  61355. * plugin name
  61356. */
  61357. name: string;
  61358. /**
  61359. * the first navmesh created. We might extend this to support multiple navmeshes
  61360. */
  61361. navMesh: any;
  61362. /**
  61363. * Initializes the recastJS plugin
  61364. * @param recastInjection can be used to inject your own recast reference
  61365. */
  61366. constructor(recastInjection?: any);
  61367. /**
  61368. * Creates a navigation mesh
  61369. * @param meshes array of all the geometry used to compute the navigatio mesh
  61370. * @param parameters bunch of parameters used to filter geometry
  61371. */
  61372. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61373. /**
  61374. * Create a navigation mesh debug mesh
  61375. * @param scene is where the mesh will be added
  61376. * @returns debug display mesh
  61377. */
  61378. createDebugNavMesh(scene: Scene): Mesh;
  61379. /**
  61380. * Get a navigation mesh constrained position, closest to the parameter position
  61381. * @param position world position
  61382. * @returns the closest point to position constrained by the navigation mesh
  61383. */
  61384. getClosestPoint(position: Vector3): Vector3;
  61385. /**
  61386. * Get a navigation mesh constrained position, within a particular radius
  61387. * @param position world position
  61388. * @param maxRadius the maximum distance to the constrained world position
  61389. * @returns the closest point to position constrained by the navigation mesh
  61390. */
  61391. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61392. /**
  61393. * Compute the final position from a segment made of destination-position
  61394. * @param position world position
  61395. * @param destination world position
  61396. * @returns the resulting point along the navmesh
  61397. */
  61398. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61399. /**
  61400. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61401. * @param start world position
  61402. * @param end world position
  61403. * @returns array containing world position composing the path
  61404. */
  61405. computePath(start: Vector3, end: Vector3): Vector3[];
  61406. /**
  61407. * Create a new Crowd so you can add agents
  61408. * @param maxAgents the maximum agent count in the crowd
  61409. * @param maxAgentRadius the maximum radius an agent can have
  61410. * @param scene to attach the crowd to
  61411. * @returns the crowd you can add agents to
  61412. */
  61413. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61414. /**
  61415. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61416. * The queries will try to find a solution within those bounds
  61417. * default is (1,1,1)
  61418. * @param extent x,y,z value that define the extent around the queries point of reference
  61419. */
  61420. setDefaultQueryExtent(extent: Vector3): void;
  61421. /**
  61422. * Get the Bounding box extent specified by setDefaultQueryExtent
  61423. * @returns the box extent values
  61424. */
  61425. getDefaultQueryExtent(): Vector3;
  61426. /**
  61427. * Disposes
  61428. */
  61429. dispose(): void;
  61430. /**
  61431. * If this plugin is supported
  61432. * @returns true if plugin is supported
  61433. */
  61434. isSupported(): boolean;
  61435. }
  61436. /**
  61437. * Recast detour crowd implementation
  61438. */
  61439. export class RecastJSCrowd implements ICrowd {
  61440. /**
  61441. * Recast/detour plugin
  61442. */
  61443. bjsRECASTPlugin: RecastJSPlugin;
  61444. /**
  61445. * Link to the detour crowd
  61446. */
  61447. recastCrowd: any;
  61448. /**
  61449. * One transform per agent
  61450. */
  61451. transforms: TransformNode[];
  61452. /**
  61453. * All agents created
  61454. */
  61455. agents: number[];
  61456. /**
  61457. * Link to the scene is kept to unregister the crowd from the scene
  61458. */
  61459. private _scene;
  61460. /**
  61461. * Observer for crowd updates
  61462. */
  61463. private _onBeforeAnimationsObserver;
  61464. /**
  61465. * Constructor
  61466. * @param plugin recastJS plugin
  61467. * @param maxAgents the maximum agent count in the crowd
  61468. * @param maxAgentRadius the maximum radius an agent can have
  61469. * @param scene to attach the crowd to
  61470. * @returns the crowd you can add agents to
  61471. */
  61472. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61473. /**
  61474. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61475. * You can attach anything to that node. The node position is updated in the scene update tick.
  61476. * @param pos world position that will be constrained by the navigation mesh
  61477. * @param parameters agent parameters
  61478. * @param transform hooked to the agent that will be update by the scene
  61479. * @returns agent index
  61480. */
  61481. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61482. /**
  61483. * Returns the agent position in world space
  61484. * @param index agent index returned by addAgent
  61485. * @returns world space position
  61486. */
  61487. getAgentPosition(index: number): Vector3;
  61488. /**
  61489. * Returns the agent velocity in world space
  61490. * @param index agent index returned by addAgent
  61491. * @returns world space velocity
  61492. */
  61493. getAgentVelocity(index: number): Vector3;
  61494. /**
  61495. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61496. * @param index agent index returned by addAgent
  61497. * @param destination targeted world position
  61498. */
  61499. agentGoto(index: number, destination: Vector3): void;
  61500. /**
  61501. * remove a particular agent previously created
  61502. * @param index agent index returned by addAgent
  61503. */
  61504. removeAgent(index: number): void;
  61505. /**
  61506. * get the list of all agents attached to this crowd
  61507. * @returns list of agent indices
  61508. */
  61509. getAgents(): number[];
  61510. /**
  61511. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61512. * @param deltaTime in seconds
  61513. */
  61514. update(deltaTime: number): void;
  61515. /**
  61516. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61517. * The queries will try to find a solution within those bounds
  61518. * default is (1,1,1)
  61519. * @param extent x,y,z value that define the extent around the queries point of reference
  61520. */
  61521. setDefaultQueryExtent(extent: Vector3): void;
  61522. /**
  61523. * Get the Bounding box extent specified by setDefaultQueryExtent
  61524. * @returns the box extent values
  61525. */
  61526. getDefaultQueryExtent(): Vector3;
  61527. /**
  61528. * Release all resources
  61529. */
  61530. dispose(): void;
  61531. }
  61532. }
  61533. declare module "babylonjs/Navigation/Plugins/index" {
  61534. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61535. }
  61536. declare module "babylonjs/Navigation/index" {
  61537. export * from "babylonjs/Navigation/INavigationEngine";
  61538. export * from "babylonjs/Navigation/Plugins/index";
  61539. }
  61540. declare module "babylonjs/Offline/database" {
  61541. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61542. /**
  61543. * Class used to enable access to IndexedDB
  61544. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61545. */
  61546. export class Database implements IOfflineProvider {
  61547. private _callbackManifestChecked;
  61548. private _currentSceneUrl;
  61549. private _db;
  61550. private _enableSceneOffline;
  61551. private _enableTexturesOffline;
  61552. private _manifestVersionFound;
  61553. private _mustUpdateRessources;
  61554. private _hasReachedQuota;
  61555. private _isSupported;
  61556. private _idbFactory;
  61557. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61558. private static IsUASupportingBlobStorage;
  61559. /**
  61560. * Gets a boolean indicating if Database storate is enabled (off by default)
  61561. */
  61562. static IDBStorageEnabled: boolean;
  61563. /**
  61564. * Gets a boolean indicating if scene must be saved in the database
  61565. */
  61566. readonly enableSceneOffline: boolean;
  61567. /**
  61568. * Gets a boolean indicating if textures must be saved in the database
  61569. */
  61570. readonly enableTexturesOffline: boolean;
  61571. /**
  61572. * Creates a new Database
  61573. * @param urlToScene defines the url to load the scene
  61574. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61575. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61576. */
  61577. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61578. private static _ParseURL;
  61579. private static _ReturnFullUrlLocation;
  61580. private _checkManifestFile;
  61581. /**
  61582. * Open the database and make it available
  61583. * @param successCallback defines the callback to call on success
  61584. * @param errorCallback defines the callback to call on error
  61585. */
  61586. open(successCallback: () => void, errorCallback: () => void): void;
  61587. /**
  61588. * Loads an image from the database
  61589. * @param url defines the url to load from
  61590. * @param image defines the target DOM image
  61591. */
  61592. loadImage(url: string, image: HTMLImageElement): void;
  61593. private _loadImageFromDBAsync;
  61594. private _saveImageIntoDBAsync;
  61595. private _checkVersionFromDB;
  61596. private _loadVersionFromDBAsync;
  61597. private _saveVersionIntoDBAsync;
  61598. /**
  61599. * Loads a file from database
  61600. * @param url defines the URL to load from
  61601. * @param sceneLoaded defines a callback to call on success
  61602. * @param progressCallBack defines a callback to call when progress changed
  61603. * @param errorCallback defines a callback to call on error
  61604. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61605. */
  61606. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61607. private _loadFileAsync;
  61608. private _saveFileAsync;
  61609. /**
  61610. * Validates if xhr data is correct
  61611. * @param xhr defines the request to validate
  61612. * @param dataType defines the expected data type
  61613. * @returns true if data is correct
  61614. */
  61615. private static _ValidateXHRData;
  61616. }
  61617. }
  61618. declare module "babylonjs/Offline/index" {
  61619. export * from "babylonjs/Offline/database";
  61620. export * from "babylonjs/Offline/IOfflineProvider";
  61621. }
  61622. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61623. /** @hidden */
  61624. export var gpuUpdateParticlesPixelShader: {
  61625. name: string;
  61626. shader: string;
  61627. };
  61628. }
  61629. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61630. /** @hidden */
  61631. export var gpuUpdateParticlesVertexShader: {
  61632. name: string;
  61633. shader: string;
  61634. };
  61635. }
  61636. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61637. /** @hidden */
  61638. export var clipPlaneFragmentDeclaration2: {
  61639. name: string;
  61640. shader: string;
  61641. };
  61642. }
  61643. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61644. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61645. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61646. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61647. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61648. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61649. /** @hidden */
  61650. export var gpuRenderParticlesPixelShader: {
  61651. name: string;
  61652. shader: string;
  61653. };
  61654. }
  61655. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61656. /** @hidden */
  61657. export var clipPlaneVertexDeclaration2: {
  61658. name: string;
  61659. shader: string;
  61660. };
  61661. }
  61662. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61663. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61664. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61665. /** @hidden */
  61666. export var gpuRenderParticlesVertexShader: {
  61667. name: string;
  61668. shader: string;
  61669. };
  61670. }
  61671. declare module "babylonjs/Particles/gpuParticleSystem" {
  61672. import { Nullable } from "babylonjs/types";
  61673. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61674. import { Observable } from "babylonjs/Misc/observable";
  61675. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61676. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61677. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61678. import { Scene, IDisposable } from "babylonjs/scene";
  61679. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61680. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61681. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61682. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61683. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61684. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61685. /**
  61686. * This represents a GPU particle system in Babylon
  61687. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61688. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61689. */
  61690. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61691. /**
  61692. * The layer mask we are rendering the particles through.
  61693. */
  61694. layerMask: number;
  61695. private _capacity;
  61696. private _activeCount;
  61697. private _currentActiveCount;
  61698. private _accumulatedCount;
  61699. private _renderEffect;
  61700. private _updateEffect;
  61701. private _buffer0;
  61702. private _buffer1;
  61703. private _spriteBuffer;
  61704. private _updateVAO;
  61705. private _renderVAO;
  61706. private _targetIndex;
  61707. private _sourceBuffer;
  61708. private _targetBuffer;
  61709. private _engine;
  61710. private _currentRenderId;
  61711. private _started;
  61712. private _stopped;
  61713. private _timeDelta;
  61714. private _randomTexture;
  61715. private _randomTexture2;
  61716. private _attributesStrideSize;
  61717. private _updateEffectOptions;
  61718. private _randomTextureSize;
  61719. private _actualFrame;
  61720. private readonly _rawTextureWidth;
  61721. /**
  61722. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61723. */
  61724. static readonly IsSupported: boolean;
  61725. /**
  61726. * An event triggered when the system is disposed.
  61727. */
  61728. onDisposeObservable: Observable<GPUParticleSystem>;
  61729. /**
  61730. * Gets the maximum number of particles active at the same time.
  61731. * @returns The max number of active particles.
  61732. */
  61733. getCapacity(): number;
  61734. /**
  61735. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61736. * to override the particles.
  61737. */
  61738. forceDepthWrite: boolean;
  61739. /**
  61740. * Gets or set the number of active particles
  61741. */
  61742. activeParticleCount: number;
  61743. private _preWarmDone;
  61744. /**
  61745. * Is this system ready to be used/rendered
  61746. * @return true if the system is ready
  61747. */
  61748. isReady(): boolean;
  61749. /**
  61750. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61751. * @returns True if it has been started, otherwise false.
  61752. */
  61753. isStarted(): boolean;
  61754. /**
  61755. * Starts the particle system and begins to emit
  61756. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61757. */
  61758. start(delay?: number): void;
  61759. /**
  61760. * Stops the particle system.
  61761. */
  61762. stop(): void;
  61763. /**
  61764. * Remove all active particles
  61765. */
  61766. reset(): void;
  61767. /**
  61768. * Returns the string "GPUParticleSystem"
  61769. * @returns a string containing the class name
  61770. */
  61771. getClassName(): string;
  61772. private _colorGradientsTexture;
  61773. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61774. /**
  61775. * Adds a new color gradient
  61776. * @param gradient defines the gradient to use (between 0 and 1)
  61777. * @param color1 defines the color to affect to the specified gradient
  61778. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61779. * @returns the current particle system
  61780. */
  61781. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61782. /**
  61783. * Remove a specific color gradient
  61784. * @param gradient defines the gradient to remove
  61785. * @returns the current particle system
  61786. */
  61787. removeColorGradient(gradient: number): GPUParticleSystem;
  61788. private _angularSpeedGradientsTexture;
  61789. private _sizeGradientsTexture;
  61790. private _velocityGradientsTexture;
  61791. private _limitVelocityGradientsTexture;
  61792. private _dragGradientsTexture;
  61793. private _addFactorGradient;
  61794. /**
  61795. * Adds a new size gradient
  61796. * @param gradient defines the gradient to use (between 0 and 1)
  61797. * @param factor defines the size factor to affect to the specified gradient
  61798. * @returns the current particle system
  61799. */
  61800. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61801. /**
  61802. * Remove a specific size gradient
  61803. * @param gradient defines the gradient to remove
  61804. * @returns the current particle system
  61805. */
  61806. removeSizeGradient(gradient: number): GPUParticleSystem;
  61807. /**
  61808. * Adds a new angular speed gradient
  61809. * @param gradient defines the gradient to use (between 0 and 1)
  61810. * @param factor defines the angular speed to affect to the specified gradient
  61811. * @returns the current particle system
  61812. */
  61813. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61814. /**
  61815. * Remove a specific angular speed gradient
  61816. * @param gradient defines the gradient to remove
  61817. * @returns the current particle system
  61818. */
  61819. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61820. /**
  61821. * Adds a new velocity gradient
  61822. * @param gradient defines the gradient to use (between 0 and 1)
  61823. * @param factor defines the velocity to affect to the specified gradient
  61824. * @returns the current particle system
  61825. */
  61826. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61827. /**
  61828. * Remove a specific velocity gradient
  61829. * @param gradient defines the gradient to remove
  61830. * @returns the current particle system
  61831. */
  61832. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61833. /**
  61834. * Adds a new limit velocity gradient
  61835. * @param gradient defines the gradient to use (between 0 and 1)
  61836. * @param factor defines the limit velocity value to affect to the specified gradient
  61837. * @returns the current particle system
  61838. */
  61839. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61840. /**
  61841. * Remove a specific limit velocity gradient
  61842. * @param gradient defines the gradient to remove
  61843. * @returns the current particle system
  61844. */
  61845. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61846. /**
  61847. * Adds a new drag gradient
  61848. * @param gradient defines the gradient to use (between 0 and 1)
  61849. * @param factor defines the drag value to affect to the specified gradient
  61850. * @returns the current particle system
  61851. */
  61852. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61853. /**
  61854. * Remove a specific drag gradient
  61855. * @param gradient defines the gradient to remove
  61856. * @returns the current particle system
  61857. */
  61858. removeDragGradient(gradient: number): GPUParticleSystem;
  61859. /**
  61860. * Not supported by GPUParticleSystem
  61861. * @param gradient defines the gradient to use (between 0 and 1)
  61862. * @param factor defines the emit rate value to affect to the specified gradient
  61863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61864. * @returns the current particle system
  61865. */
  61866. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61867. /**
  61868. * Not supported by GPUParticleSystem
  61869. * @param gradient defines the gradient to remove
  61870. * @returns the current particle system
  61871. */
  61872. removeEmitRateGradient(gradient: number): IParticleSystem;
  61873. /**
  61874. * Not supported by GPUParticleSystem
  61875. * @param gradient defines the gradient to use (between 0 and 1)
  61876. * @param factor defines the start size value to affect to the specified gradient
  61877. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61878. * @returns the current particle system
  61879. */
  61880. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61881. /**
  61882. * Not supported by GPUParticleSystem
  61883. * @param gradient defines the gradient to remove
  61884. * @returns the current particle system
  61885. */
  61886. removeStartSizeGradient(gradient: number): IParticleSystem;
  61887. /**
  61888. * Not supported by GPUParticleSystem
  61889. * @param gradient defines the gradient to use (between 0 and 1)
  61890. * @param min defines the color remap minimal range
  61891. * @param max defines the color remap maximal range
  61892. * @returns the current particle system
  61893. */
  61894. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61895. /**
  61896. * Not supported by GPUParticleSystem
  61897. * @param gradient defines the gradient to remove
  61898. * @returns the current particle system
  61899. */
  61900. removeColorRemapGradient(): IParticleSystem;
  61901. /**
  61902. * Not supported by GPUParticleSystem
  61903. * @param gradient defines the gradient to use (between 0 and 1)
  61904. * @param min defines the alpha remap minimal range
  61905. * @param max defines the alpha remap maximal range
  61906. * @returns the current particle system
  61907. */
  61908. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61909. /**
  61910. * Not supported by GPUParticleSystem
  61911. * @param gradient defines the gradient to remove
  61912. * @returns the current particle system
  61913. */
  61914. removeAlphaRemapGradient(): IParticleSystem;
  61915. /**
  61916. * Not supported by GPUParticleSystem
  61917. * @param gradient defines the gradient to use (between 0 and 1)
  61918. * @param color defines the color to affect to the specified gradient
  61919. * @returns the current particle system
  61920. */
  61921. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61922. /**
  61923. * Not supported by GPUParticleSystem
  61924. * @param gradient defines the gradient to remove
  61925. * @returns the current particle system
  61926. */
  61927. removeRampGradient(): IParticleSystem;
  61928. /**
  61929. * Not supported by GPUParticleSystem
  61930. * @returns the list of ramp gradients
  61931. */
  61932. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61933. /**
  61934. * Not supported by GPUParticleSystem
  61935. * Gets or sets a boolean indicating that ramp gradients must be used
  61936. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61937. */
  61938. useRampGradients: boolean;
  61939. /**
  61940. * Not supported by GPUParticleSystem
  61941. * @param gradient defines the gradient to use (between 0 and 1)
  61942. * @param factor defines the life time factor to affect to the specified gradient
  61943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61944. * @returns the current particle system
  61945. */
  61946. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61947. /**
  61948. * Not supported by GPUParticleSystem
  61949. * @param gradient defines the gradient to remove
  61950. * @returns the current particle system
  61951. */
  61952. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61953. /**
  61954. * Instantiates a GPU particle system.
  61955. * 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.
  61956. * @param name The name of the particle system
  61957. * @param options The options used to create the system
  61958. * @param scene The scene the particle system belongs to
  61959. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61960. */
  61961. constructor(name: string, options: Partial<{
  61962. capacity: number;
  61963. randomTextureSize: number;
  61964. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61965. protected _reset(): void;
  61966. private _createUpdateVAO;
  61967. private _createRenderVAO;
  61968. private _initialize;
  61969. /** @hidden */
  61970. _recreateUpdateEffect(): void;
  61971. /** @hidden */
  61972. _recreateRenderEffect(): void;
  61973. /**
  61974. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61975. * @param preWarm defines if we are in the pre-warmimg phase
  61976. */
  61977. animate(preWarm?: boolean): void;
  61978. private _createFactorGradientTexture;
  61979. private _createSizeGradientTexture;
  61980. private _createAngularSpeedGradientTexture;
  61981. private _createVelocityGradientTexture;
  61982. private _createLimitVelocityGradientTexture;
  61983. private _createDragGradientTexture;
  61984. private _createColorGradientTexture;
  61985. /**
  61986. * Renders the particle system in its current state
  61987. * @param preWarm defines if the system should only update the particles but not render them
  61988. * @returns the current number of particles
  61989. */
  61990. render(preWarm?: boolean): number;
  61991. /**
  61992. * Rebuilds the particle system
  61993. */
  61994. rebuild(): void;
  61995. private _releaseBuffers;
  61996. private _releaseVAOs;
  61997. /**
  61998. * Disposes the particle system and free the associated resources
  61999. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62000. */
  62001. dispose(disposeTexture?: boolean): void;
  62002. /**
  62003. * Clones the particle system.
  62004. * @param name The name of the cloned object
  62005. * @param newEmitter The new emitter to use
  62006. * @returns the cloned particle system
  62007. */
  62008. clone(name: string, newEmitter: any): GPUParticleSystem;
  62009. /**
  62010. * Serializes the particle system to a JSON object.
  62011. * @returns the JSON object
  62012. */
  62013. serialize(): any;
  62014. /**
  62015. * Parses a JSON object to create a GPU particle system.
  62016. * @param parsedParticleSystem The JSON object to parse
  62017. * @param scene The scene to create the particle system in
  62018. * @param rootUrl The root url to use to load external dependencies like texture
  62019. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62020. * @returns the parsed GPU particle system
  62021. */
  62022. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62023. }
  62024. }
  62025. declare module "babylonjs/Particles/particleSystemSet" {
  62026. import { Nullable } from "babylonjs/types";
  62027. import { Color3 } from "babylonjs/Maths/math.color";
  62028. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62030. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62031. import { Scene, IDisposable } from "babylonjs/scene";
  62032. /**
  62033. * Represents a set of particle systems working together to create a specific effect
  62034. */
  62035. export class ParticleSystemSet implements IDisposable {
  62036. /**
  62037. * Gets or sets base Assets URL
  62038. */
  62039. static BaseAssetsUrl: string;
  62040. private _emitterCreationOptions;
  62041. private _emitterNode;
  62042. /**
  62043. * Gets the particle system list
  62044. */
  62045. systems: IParticleSystem[];
  62046. /**
  62047. * Gets the emitter node used with this set
  62048. */
  62049. readonly emitterNode: Nullable<TransformNode>;
  62050. /**
  62051. * Creates a new emitter mesh as a sphere
  62052. * @param options defines the options used to create the sphere
  62053. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62054. * @param scene defines the hosting scene
  62055. */
  62056. setEmitterAsSphere(options: {
  62057. diameter: number;
  62058. segments: number;
  62059. color: Color3;
  62060. }, renderingGroupId: number, scene: Scene): void;
  62061. /**
  62062. * Starts all particle systems of the set
  62063. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62064. */
  62065. start(emitter?: AbstractMesh): void;
  62066. /**
  62067. * Release all associated resources
  62068. */
  62069. dispose(): void;
  62070. /**
  62071. * Serialize the set into a JSON compatible object
  62072. * @returns a JSON compatible representation of the set
  62073. */
  62074. serialize(): any;
  62075. /**
  62076. * Parse a new ParticleSystemSet from a serialized source
  62077. * @param data defines a JSON compatible representation of the set
  62078. * @param scene defines the hosting scene
  62079. * @param gpu defines if we want GPU particles or CPU particles
  62080. * @returns a new ParticleSystemSet
  62081. */
  62082. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62083. }
  62084. }
  62085. declare module "babylonjs/Particles/particleHelper" {
  62086. import { Nullable } from "babylonjs/types";
  62087. import { Scene } from "babylonjs/scene";
  62088. import { Vector3 } from "babylonjs/Maths/math.vector";
  62089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62090. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62091. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62092. /**
  62093. * This class is made for on one-liner static method to help creating particle system set.
  62094. */
  62095. export class ParticleHelper {
  62096. /**
  62097. * Gets or sets base Assets URL
  62098. */
  62099. static BaseAssetsUrl: string;
  62100. /**
  62101. * Create a default particle system that you can tweak
  62102. * @param emitter defines the emitter to use
  62103. * @param capacity defines the system capacity (default is 500 particles)
  62104. * @param scene defines the hosting scene
  62105. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62106. * @returns the new Particle system
  62107. */
  62108. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62109. /**
  62110. * This is the main static method (one-liner) of this helper to create different particle systems
  62111. * @param type This string represents the type to the particle system to create
  62112. * @param scene The scene where the particle system should live
  62113. * @param gpu If the system will use gpu
  62114. * @returns the ParticleSystemSet created
  62115. */
  62116. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62117. /**
  62118. * Static function used to export a particle system to a ParticleSystemSet variable.
  62119. * Please note that the emitter shape is not exported
  62120. * @param systems defines the particle systems to export
  62121. * @returns the created particle system set
  62122. */
  62123. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62124. }
  62125. }
  62126. declare module "babylonjs/Particles/particleSystemComponent" {
  62127. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62128. import { Effect } from "babylonjs/Materials/effect";
  62129. import "babylonjs/Shaders/particles.vertex";
  62130. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62131. module "babylonjs/Engines/engine" {
  62132. interface Engine {
  62133. /**
  62134. * Create an effect to use with particle systems.
  62135. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62136. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62137. * @param uniformsNames defines a list of attribute names
  62138. * @param samplers defines an array of string used to represent textures
  62139. * @param defines defines the string containing the defines to use to compile the shaders
  62140. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62141. * @param onCompiled defines a function to call when the effect creation is successful
  62142. * @param onError defines a function to call when the effect creation has failed
  62143. * @returns the new Effect
  62144. */
  62145. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62146. }
  62147. }
  62148. module "babylonjs/Meshes/mesh" {
  62149. interface Mesh {
  62150. /**
  62151. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62152. * @returns an array of IParticleSystem
  62153. */
  62154. getEmittedParticleSystems(): IParticleSystem[];
  62155. /**
  62156. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62157. * @returns an array of IParticleSystem
  62158. */
  62159. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62160. }
  62161. }
  62162. /**
  62163. * @hidden
  62164. */
  62165. export var _IDoNeedToBeInTheBuild: number;
  62166. }
  62167. declare module "babylonjs/Particles/pointsCloudSystem" {
  62168. import { Color4 } from "babylonjs/Maths/math";
  62169. import { Mesh } from "babylonjs/Meshes/mesh";
  62170. import { Scene, IDisposable } from "babylonjs/scene";
  62171. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62172. /** Defines the 4 color options */
  62173. export enum PointColor {
  62174. /** color value */
  62175. Color = 2,
  62176. /** uv value */
  62177. UV = 1,
  62178. /** random value */
  62179. Random = 0,
  62180. /** stated value */
  62181. Stated = 3
  62182. }
  62183. /**
  62184. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62185. * 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.
  62186. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62187. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62188. *
  62189. * Full documentation here : TO BE ENTERED
  62190. */
  62191. export class PointsCloudSystem implements IDisposable {
  62192. /**
  62193. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62194. * Example : var p = SPS.particles[i];
  62195. */
  62196. particles: CloudPoint[];
  62197. /**
  62198. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62199. */
  62200. nbParticles: number;
  62201. /**
  62202. * This a counter for your own usage. It's not set by any SPS functions.
  62203. */
  62204. counter: number;
  62205. /**
  62206. * The PCS name. This name is also given to the underlying mesh.
  62207. */
  62208. name: string;
  62209. /**
  62210. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62211. */
  62212. mesh: Mesh;
  62213. /**
  62214. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62215. * Please read :
  62216. */
  62217. vars: any;
  62218. /**
  62219. * @hidden
  62220. */
  62221. _size: number;
  62222. private _scene;
  62223. private _promises;
  62224. private _positions;
  62225. private _indices;
  62226. private _normals;
  62227. private _colors;
  62228. private _uvs;
  62229. private _indices32;
  62230. private _positions32;
  62231. private _colors32;
  62232. private _uvs32;
  62233. private _updatable;
  62234. private _isVisibilityBoxLocked;
  62235. private _alwaysVisible;
  62236. private _groups;
  62237. private _groupCounter;
  62238. private _computeParticleColor;
  62239. private _computeParticleTexture;
  62240. private _computeParticleRotation;
  62241. private _computeBoundingBox;
  62242. private _isReady;
  62243. /**
  62244. * Creates a PCS (Points Cloud System) object
  62245. * @param name (String) is the PCS name, this will be the underlying mesh name
  62246. * @param pointSize (number) is the size for each point
  62247. * @param scene (Scene) is the scene in which the PCS is added
  62248. * @param options defines the options of the PCS e.g.
  62249. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62250. */
  62251. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62252. updatable?: boolean;
  62253. });
  62254. /**
  62255. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62256. * If no points were added to the PCS, the returned mesh is just a single point.
  62257. * @returns a promise for the created mesh
  62258. */
  62259. buildMeshAsync(): Promise<Mesh>;
  62260. /**
  62261. * @hidden
  62262. */
  62263. private _buildMesh;
  62264. private _addParticle;
  62265. private _randomUnitVector;
  62266. private _getColorIndicesForCoord;
  62267. private _setPointsColorOrUV;
  62268. private _colorFromTexture;
  62269. private _calculateDensity;
  62270. /**
  62271. * Adds points to the PCS in random positions within a unit sphere
  62272. * @param nb (positive integer) the number of particles to be created from this model
  62273. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62274. * @returns the number of groups in the system
  62275. */
  62276. addPoints(nb: number, pointFunction?: any): number;
  62277. /**
  62278. * Adds points to the PCS from the surface of the model shape
  62279. * @param mesh is any Mesh object that will be used as a surface model for the points
  62280. * @param nb (positive integer) the number of particles to be created from this model
  62281. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62282. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62283. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62284. * @returns the number of groups in the system
  62285. */
  62286. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62287. /**
  62288. * Adds points to the PCS inside the model shape
  62289. * @param mesh is any Mesh object that will be used as a surface model for the points
  62290. * @param nb (positive integer) the number of particles to be created from this model
  62291. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62292. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62293. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62294. * @returns the number of groups in the system
  62295. */
  62296. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62297. /**
  62298. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62299. * This method calls `updateParticle()` for each particle of the SPS.
  62300. * For an animated SPS, it is usually called within the render loop.
  62301. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62302. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62303. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62304. * @returns the PCS.
  62305. */
  62306. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62307. /**
  62308. * Disposes the PCS.
  62309. */
  62310. dispose(): void;
  62311. /**
  62312. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62313. * doc :
  62314. * @returns the PCS.
  62315. */
  62316. refreshVisibleSize(): PointsCloudSystem;
  62317. /**
  62318. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62319. * @param size the size (float) of the visibility box
  62320. * note : this doesn't lock the PCS mesh bounding box.
  62321. * doc :
  62322. */
  62323. setVisibilityBox(size: number): void;
  62324. /**
  62325. * Gets whether the PCS is always visible or not
  62326. * doc :
  62327. */
  62328. /**
  62329. * Sets the PCS as always visible or not
  62330. * doc :
  62331. */
  62332. isAlwaysVisible: boolean;
  62333. /**
  62334. * Tells to `setParticles()` to compute the particle rotations or not
  62335. * Default value : false. The PCS is faster when it's set to false
  62336. * Note : particle rotations are only applied to parent particles
  62337. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62338. */
  62339. computeParticleRotation: boolean;
  62340. /**
  62341. * Tells to `setParticles()` to compute the particle colors or not.
  62342. * Default value : true. The PCS is faster when it's set to false.
  62343. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62344. */
  62345. /**
  62346. * Gets if `setParticles()` computes the particle colors or not.
  62347. * Default value : false. The PCS is faster when it's set to false.
  62348. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62349. */
  62350. computeParticleColor: boolean;
  62351. /**
  62352. * Gets if `setParticles()` computes the particle textures or not.
  62353. * Default value : false. The PCS is faster when it's set to false.
  62354. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62355. */
  62356. computeParticleTexture: boolean;
  62357. /**
  62358. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62359. */
  62360. /**
  62361. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62362. */
  62363. computeBoundingBox: boolean;
  62364. /**
  62365. * This function does nothing. It may be overwritten to set all the particle first values.
  62366. * The PCS doesn't call this function, you may have to call it by your own.
  62367. * doc :
  62368. */
  62369. initParticles(): void;
  62370. /**
  62371. * This function does nothing. It may be overwritten to recycle a particle
  62372. * The PCS doesn't call this function, you can to call it
  62373. * doc :
  62374. * @param particle The particle to recycle
  62375. * @returns the recycled particle
  62376. */
  62377. recycleParticle(particle: CloudPoint): CloudPoint;
  62378. /**
  62379. * Updates a particle : this function should be overwritten by the user.
  62380. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62381. * doc :
  62382. * @example : just set a particle position or velocity and recycle conditions
  62383. * @param particle The particle to update
  62384. * @returns the updated particle
  62385. */
  62386. updateParticle(particle: CloudPoint): CloudPoint;
  62387. /**
  62388. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62389. * This does nothing and may be overwritten by the user.
  62390. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62391. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62392. * @param update the boolean update value actually passed to setParticles()
  62393. */
  62394. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62395. /**
  62396. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62397. * This will be passed three parameters.
  62398. * This does nothing and may be overwritten by the user.
  62399. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62400. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62401. * @param update the boolean update value actually passed to setParticles()
  62402. */
  62403. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62404. }
  62405. }
  62406. declare module "babylonjs/Particles/cloudPoint" {
  62407. import { Nullable } from "babylonjs/types";
  62408. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62409. import { Mesh } from "babylonjs/Meshes/mesh";
  62410. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62411. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62412. /**
  62413. * Represents one particle of a points cloud system.
  62414. */
  62415. export class CloudPoint {
  62416. /**
  62417. * particle global index
  62418. */
  62419. idx: number;
  62420. /**
  62421. * The color of the particle
  62422. */
  62423. color: Nullable<Color4>;
  62424. /**
  62425. * The world space position of the particle.
  62426. */
  62427. position: Vector3;
  62428. /**
  62429. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62430. */
  62431. rotation: Vector3;
  62432. /**
  62433. * The world space rotation quaternion of the particle.
  62434. */
  62435. rotationQuaternion: Nullable<Quaternion>;
  62436. /**
  62437. * The uv of the particle.
  62438. */
  62439. uv: Nullable<Vector2>;
  62440. /**
  62441. * The current speed of the particle.
  62442. */
  62443. velocity: Vector3;
  62444. /**
  62445. * The pivot point in the particle local space.
  62446. */
  62447. pivot: Vector3;
  62448. /**
  62449. * Must the particle be translated from its pivot point in its local space ?
  62450. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62451. * Default : false
  62452. */
  62453. translateFromPivot: boolean;
  62454. /**
  62455. * Index of this particle in the global "positions" array (Internal use)
  62456. * @hidden
  62457. */
  62458. _pos: number;
  62459. /**
  62460. * @hidden Index of this particle in the global "indices" array (Internal use)
  62461. */
  62462. _ind: number;
  62463. /**
  62464. * Group this particle belongs to
  62465. */
  62466. _group: PointsGroup;
  62467. /**
  62468. * Group id of this particle
  62469. */
  62470. groupId: number;
  62471. /**
  62472. * Index of the particle in its group id (Internal use)
  62473. */
  62474. idxInGroup: number;
  62475. /**
  62476. * @hidden Particle BoundingInfo object (Internal use)
  62477. */
  62478. _boundingInfo: BoundingInfo;
  62479. /**
  62480. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62481. */
  62482. _pcs: PointsCloudSystem;
  62483. /**
  62484. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62485. */
  62486. _stillInvisible: boolean;
  62487. /**
  62488. * @hidden Last computed particle rotation matrix
  62489. */
  62490. _rotationMatrix: number[];
  62491. /**
  62492. * Parent particle Id, if any.
  62493. * Default null.
  62494. */
  62495. parentId: Nullable<number>;
  62496. /**
  62497. * @hidden Internal global position in the PCS.
  62498. */
  62499. _globalPosition: Vector3;
  62500. /**
  62501. * Creates a Point Cloud object.
  62502. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62503. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62504. * @param group (PointsGroup) is the group the particle belongs to
  62505. * @param groupId (integer) is the group identifier in the PCS.
  62506. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62507. * @param pcs defines the PCS it is associated to
  62508. */
  62509. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62510. /**
  62511. * get point size
  62512. */
  62513. /**
  62514. * Set point size
  62515. */
  62516. size: Vector3;
  62517. /**
  62518. * Legacy support, changed quaternion to rotationQuaternion
  62519. */
  62520. /**
  62521. * Legacy support, changed quaternion to rotationQuaternion
  62522. */
  62523. quaternion: Nullable<Quaternion>;
  62524. /**
  62525. * Returns a boolean. True if the particle intersects a mesh, else false
  62526. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62527. * @param target is the object (point or mesh) what the intersection is computed against
  62528. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62529. * @returns true if it intersects
  62530. */
  62531. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62532. /**
  62533. * get the rotation matrix of the particle
  62534. * @hidden
  62535. */
  62536. getRotationMatrix(m: Matrix): void;
  62537. }
  62538. /**
  62539. * Represents a group of points in a points cloud system
  62540. * * PCS internal tool, don't use it manually.
  62541. */
  62542. export class PointsGroup {
  62543. /**
  62544. * The group id
  62545. * @hidden
  62546. */
  62547. groupID: number;
  62548. /**
  62549. * image data for group (internal use)
  62550. * @hidden
  62551. */
  62552. _groupImageData: Nullable<ArrayBufferView>;
  62553. /**
  62554. * Image Width (internal use)
  62555. * @hidden
  62556. */
  62557. _groupImgWidth: number;
  62558. /**
  62559. * Image Height (internal use)
  62560. * @hidden
  62561. */
  62562. _groupImgHeight: number;
  62563. /**
  62564. * Custom position function (internal use)
  62565. * @hidden
  62566. */
  62567. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62568. /**
  62569. * density per facet for surface points
  62570. * @hidden
  62571. */
  62572. _groupDensity: number[];
  62573. /**
  62574. * Only when points are colored by texture carries pointer to texture list array
  62575. * @hidden
  62576. */
  62577. _textureNb: number;
  62578. /**
  62579. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62580. * PCS internal tool, don't use it manually.
  62581. * @hidden
  62582. */
  62583. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62584. }
  62585. }
  62586. declare module "babylonjs/Particles/index" {
  62587. export * from "babylonjs/Particles/baseParticleSystem";
  62588. export * from "babylonjs/Particles/EmitterTypes/index";
  62589. export * from "babylonjs/Particles/gpuParticleSystem";
  62590. export * from "babylonjs/Particles/IParticleSystem";
  62591. export * from "babylonjs/Particles/particle";
  62592. export * from "babylonjs/Particles/particleHelper";
  62593. export * from "babylonjs/Particles/particleSystem";
  62594. export * from "babylonjs/Particles/particleSystemComponent";
  62595. export * from "babylonjs/Particles/particleSystemSet";
  62596. export * from "babylonjs/Particles/solidParticle";
  62597. export * from "babylonjs/Particles/solidParticleSystem";
  62598. export * from "babylonjs/Particles/cloudPoint";
  62599. export * from "babylonjs/Particles/pointsCloudSystem";
  62600. export * from "babylonjs/Particles/subEmitter";
  62601. }
  62602. declare module "babylonjs/Physics/physicsEngineComponent" {
  62603. import { Nullable } from "babylonjs/types";
  62604. import { Observable, Observer } from "babylonjs/Misc/observable";
  62605. import { Vector3 } from "babylonjs/Maths/math.vector";
  62606. import { Mesh } from "babylonjs/Meshes/mesh";
  62607. import { ISceneComponent } from "babylonjs/sceneComponent";
  62608. import { Scene } from "babylonjs/scene";
  62609. import { Node } from "babylonjs/node";
  62610. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62611. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62612. module "babylonjs/scene" {
  62613. interface Scene {
  62614. /** @hidden (Backing field) */
  62615. _physicsEngine: Nullable<IPhysicsEngine>;
  62616. /**
  62617. * Gets the current physics engine
  62618. * @returns a IPhysicsEngine or null if none attached
  62619. */
  62620. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62621. /**
  62622. * Enables physics to the current scene
  62623. * @param gravity defines the scene's gravity for the physics engine
  62624. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62625. * @return a boolean indicating if the physics engine was initialized
  62626. */
  62627. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62628. /**
  62629. * Disables and disposes the physics engine associated with the scene
  62630. */
  62631. disablePhysicsEngine(): void;
  62632. /**
  62633. * Gets a boolean indicating if there is an active physics engine
  62634. * @returns a boolean indicating if there is an active physics engine
  62635. */
  62636. isPhysicsEnabled(): boolean;
  62637. /**
  62638. * Deletes a physics compound impostor
  62639. * @param compound defines the compound to delete
  62640. */
  62641. deleteCompoundImpostor(compound: any): void;
  62642. /**
  62643. * An event triggered when physic simulation is about to be run
  62644. */
  62645. onBeforePhysicsObservable: Observable<Scene>;
  62646. /**
  62647. * An event triggered when physic simulation has been done
  62648. */
  62649. onAfterPhysicsObservable: Observable<Scene>;
  62650. }
  62651. }
  62652. module "babylonjs/Meshes/abstractMesh" {
  62653. interface AbstractMesh {
  62654. /** @hidden */
  62655. _physicsImpostor: Nullable<PhysicsImpostor>;
  62656. /**
  62657. * Gets or sets impostor used for physic simulation
  62658. * @see http://doc.babylonjs.com/features/physics_engine
  62659. */
  62660. physicsImpostor: Nullable<PhysicsImpostor>;
  62661. /**
  62662. * Gets the current physics impostor
  62663. * @see http://doc.babylonjs.com/features/physics_engine
  62664. * @returns a physics impostor or null
  62665. */
  62666. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62667. /** Apply a physic impulse to the mesh
  62668. * @param force defines the force to apply
  62669. * @param contactPoint defines where to apply the force
  62670. * @returns the current mesh
  62671. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62672. */
  62673. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62674. /**
  62675. * Creates a physic joint between two meshes
  62676. * @param otherMesh defines the other mesh to use
  62677. * @param pivot1 defines the pivot to use on this mesh
  62678. * @param pivot2 defines the pivot to use on the other mesh
  62679. * @param options defines additional options (can be plugin dependent)
  62680. * @returns the current mesh
  62681. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62682. */
  62683. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62684. /** @hidden */
  62685. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62686. }
  62687. }
  62688. /**
  62689. * Defines the physics engine scene component responsible to manage a physics engine
  62690. */
  62691. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62692. /**
  62693. * The component name helpful to identify the component in the list of scene components.
  62694. */
  62695. readonly name: string;
  62696. /**
  62697. * The scene the component belongs to.
  62698. */
  62699. scene: Scene;
  62700. /**
  62701. * Creates a new instance of the component for the given scene
  62702. * @param scene Defines the scene to register the component in
  62703. */
  62704. constructor(scene: Scene);
  62705. /**
  62706. * Registers the component in a given scene
  62707. */
  62708. register(): void;
  62709. /**
  62710. * Rebuilds the elements related to this component in case of
  62711. * context lost for instance.
  62712. */
  62713. rebuild(): void;
  62714. /**
  62715. * Disposes the component and the associated ressources
  62716. */
  62717. dispose(): void;
  62718. }
  62719. }
  62720. declare module "babylonjs/Physics/physicsHelper" {
  62721. import { Nullable } from "babylonjs/types";
  62722. import { Vector3 } from "babylonjs/Maths/math.vector";
  62723. import { Mesh } from "babylonjs/Meshes/mesh";
  62724. import { Scene } from "babylonjs/scene";
  62725. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62726. /**
  62727. * A helper for physics simulations
  62728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62729. */
  62730. export class PhysicsHelper {
  62731. private _scene;
  62732. private _physicsEngine;
  62733. /**
  62734. * Initializes the Physics helper
  62735. * @param scene Babylon.js scene
  62736. */
  62737. constructor(scene: Scene);
  62738. /**
  62739. * Applies a radial explosion impulse
  62740. * @param origin the origin of the explosion
  62741. * @param radiusOrEventOptions the radius or the options of radial explosion
  62742. * @param strength the explosion strength
  62743. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62744. * @returns A physics radial explosion event, or null
  62745. */
  62746. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62747. /**
  62748. * Applies a radial explosion force
  62749. * @param origin the origin of the explosion
  62750. * @param radiusOrEventOptions the radius or the options of radial explosion
  62751. * @param strength the explosion strength
  62752. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62753. * @returns A physics radial explosion event, or null
  62754. */
  62755. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62756. /**
  62757. * Creates a gravitational field
  62758. * @param origin the origin of the explosion
  62759. * @param radiusOrEventOptions the radius or the options of radial explosion
  62760. * @param strength the explosion strength
  62761. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62762. * @returns A physics gravitational field event, or null
  62763. */
  62764. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62765. /**
  62766. * Creates a physics updraft event
  62767. * @param origin the origin of the updraft
  62768. * @param radiusOrEventOptions the radius or the options of the updraft
  62769. * @param strength the strength of the updraft
  62770. * @param height the height of the updraft
  62771. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62772. * @returns A physics updraft event, or null
  62773. */
  62774. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62775. /**
  62776. * Creates a physics vortex event
  62777. * @param origin the of the vortex
  62778. * @param radiusOrEventOptions the radius or the options of the vortex
  62779. * @param strength the strength of the vortex
  62780. * @param height the height of the vortex
  62781. * @returns a Physics vortex event, or null
  62782. * A physics vortex event or null
  62783. */
  62784. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62785. }
  62786. /**
  62787. * Represents a physics radial explosion event
  62788. */
  62789. class PhysicsRadialExplosionEvent {
  62790. private _scene;
  62791. private _options;
  62792. private _sphere;
  62793. private _dataFetched;
  62794. /**
  62795. * Initializes a radial explosioin event
  62796. * @param _scene BabylonJS scene
  62797. * @param _options The options for the vortex event
  62798. */
  62799. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62800. /**
  62801. * Returns the data related to the radial explosion event (sphere).
  62802. * @returns The radial explosion event data
  62803. */
  62804. getData(): PhysicsRadialExplosionEventData;
  62805. /**
  62806. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62807. * @param impostor A physics imposter
  62808. * @param origin the origin of the explosion
  62809. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62810. */
  62811. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62812. /**
  62813. * Triggers affecterd impostors callbacks
  62814. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62815. */
  62816. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62817. /**
  62818. * Disposes the sphere.
  62819. * @param force Specifies if the sphere should be disposed by force
  62820. */
  62821. dispose(force?: boolean): void;
  62822. /*** Helpers ***/
  62823. private _prepareSphere;
  62824. private _intersectsWithSphere;
  62825. }
  62826. /**
  62827. * Represents a gravitational field event
  62828. */
  62829. class PhysicsGravitationalFieldEvent {
  62830. private _physicsHelper;
  62831. private _scene;
  62832. private _origin;
  62833. private _options;
  62834. private _tickCallback;
  62835. private _sphere;
  62836. private _dataFetched;
  62837. /**
  62838. * Initializes the physics gravitational field event
  62839. * @param _physicsHelper A physics helper
  62840. * @param _scene BabylonJS scene
  62841. * @param _origin The origin position of the gravitational field event
  62842. * @param _options The options for the vortex event
  62843. */
  62844. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62845. /**
  62846. * Returns the data related to the gravitational field event (sphere).
  62847. * @returns A gravitational field event
  62848. */
  62849. getData(): PhysicsGravitationalFieldEventData;
  62850. /**
  62851. * Enables the gravitational field.
  62852. */
  62853. enable(): void;
  62854. /**
  62855. * Disables the gravitational field.
  62856. */
  62857. disable(): void;
  62858. /**
  62859. * Disposes the sphere.
  62860. * @param force The force to dispose from the gravitational field event
  62861. */
  62862. dispose(force?: boolean): void;
  62863. private _tick;
  62864. }
  62865. /**
  62866. * Represents a physics updraft event
  62867. */
  62868. class PhysicsUpdraftEvent {
  62869. private _scene;
  62870. private _origin;
  62871. private _options;
  62872. private _physicsEngine;
  62873. private _originTop;
  62874. private _originDirection;
  62875. private _tickCallback;
  62876. private _cylinder;
  62877. private _cylinderPosition;
  62878. private _dataFetched;
  62879. /**
  62880. * Initializes the physics updraft event
  62881. * @param _scene BabylonJS scene
  62882. * @param _origin The origin position of the updraft
  62883. * @param _options The options for the updraft event
  62884. */
  62885. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62886. /**
  62887. * Returns the data related to the updraft event (cylinder).
  62888. * @returns A physics updraft event
  62889. */
  62890. getData(): PhysicsUpdraftEventData;
  62891. /**
  62892. * Enables the updraft.
  62893. */
  62894. enable(): void;
  62895. /**
  62896. * Disables the updraft.
  62897. */
  62898. disable(): void;
  62899. /**
  62900. * Disposes the cylinder.
  62901. * @param force Specifies if the updraft should be disposed by force
  62902. */
  62903. dispose(force?: boolean): void;
  62904. private getImpostorHitData;
  62905. private _tick;
  62906. /*** Helpers ***/
  62907. private _prepareCylinder;
  62908. private _intersectsWithCylinder;
  62909. }
  62910. /**
  62911. * Represents a physics vortex event
  62912. */
  62913. class PhysicsVortexEvent {
  62914. private _scene;
  62915. private _origin;
  62916. private _options;
  62917. private _physicsEngine;
  62918. private _originTop;
  62919. private _tickCallback;
  62920. private _cylinder;
  62921. private _cylinderPosition;
  62922. private _dataFetched;
  62923. /**
  62924. * Initializes the physics vortex event
  62925. * @param _scene The BabylonJS scene
  62926. * @param _origin The origin position of the vortex
  62927. * @param _options The options for the vortex event
  62928. */
  62929. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62930. /**
  62931. * Returns the data related to the vortex event (cylinder).
  62932. * @returns The physics vortex event data
  62933. */
  62934. getData(): PhysicsVortexEventData;
  62935. /**
  62936. * Enables the vortex.
  62937. */
  62938. enable(): void;
  62939. /**
  62940. * Disables the cortex.
  62941. */
  62942. disable(): void;
  62943. /**
  62944. * Disposes the sphere.
  62945. * @param force
  62946. */
  62947. dispose(force?: boolean): void;
  62948. private getImpostorHitData;
  62949. private _tick;
  62950. /*** Helpers ***/
  62951. private _prepareCylinder;
  62952. private _intersectsWithCylinder;
  62953. }
  62954. /**
  62955. * Options fot the radial explosion event
  62956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62957. */
  62958. export class PhysicsRadialExplosionEventOptions {
  62959. /**
  62960. * The radius of the sphere for the radial explosion.
  62961. */
  62962. radius: number;
  62963. /**
  62964. * The strenth of the explosion.
  62965. */
  62966. strength: number;
  62967. /**
  62968. * The strenght of the force in correspondence to the distance of the affected object
  62969. */
  62970. falloff: PhysicsRadialImpulseFalloff;
  62971. /**
  62972. * Sphere options for the radial explosion.
  62973. */
  62974. sphere: {
  62975. segments: number;
  62976. diameter: number;
  62977. };
  62978. /**
  62979. * Sphere options for the radial explosion.
  62980. */
  62981. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62982. }
  62983. /**
  62984. * Options fot the updraft event
  62985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62986. */
  62987. export class PhysicsUpdraftEventOptions {
  62988. /**
  62989. * The radius of the cylinder for the vortex
  62990. */
  62991. radius: number;
  62992. /**
  62993. * The strenth of the updraft.
  62994. */
  62995. strength: number;
  62996. /**
  62997. * The height of the cylinder for the updraft.
  62998. */
  62999. height: number;
  63000. /**
  63001. * The mode for the the updraft.
  63002. */
  63003. updraftMode: PhysicsUpdraftMode;
  63004. }
  63005. /**
  63006. * Options fot the vortex event
  63007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63008. */
  63009. export class PhysicsVortexEventOptions {
  63010. /**
  63011. * The radius of the cylinder for the vortex
  63012. */
  63013. radius: number;
  63014. /**
  63015. * The strenth of the vortex.
  63016. */
  63017. strength: number;
  63018. /**
  63019. * The height of the cylinder for the vortex.
  63020. */
  63021. height: number;
  63022. /**
  63023. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63024. */
  63025. centripetalForceThreshold: number;
  63026. /**
  63027. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63028. */
  63029. centripetalForceMultiplier: number;
  63030. /**
  63031. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63032. */
  63033. centrifugalForceMultiplier: number;
  63034. /**
  63035. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63036. */
  63037. updraftForceMultiplier: number;
  63038. }
  63039. /**
  63040. * The strenght of the force in correspondence to the distance of the affected object
  63041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63042. */
  63043. export enum PhysicsRadialImpulseFalloff {
  63044. /** Defines that impulse is constant in strength across it's whole radius */
  63045. Constant = 0,
  63046. /** Defines that impulse gets weaker if it's further from the origin */
  63047. Linear = 1
  63048. }
  63049. /**
  63050. * The strength of the force in correspondence to the distance of the affected object
  63051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63052. */
  63053. export enum PhysicsUpdraftMode {
  63054. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63055. Center = 0,
  63056. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63057. Perpendicular = 1
  63058. }
  63059. /**
  63060. * Interface for a physics hit data
  63061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63062. */
  63063. export interface PhysicsHitData {
  63064. /**
  63065. * The force applied at the contact point
  63066. */
  63067. force: Vector3;
  63068. /**
  63069. * The contact point
  63070. */
  63071. contactPoint: Vector3;
  63072. /**
  63073. * The distance from the origin to the contact point
  63074. */
  63075. distanceFromOrigin: number;
  63076. }
  63077. /**
  63078. * Interface for radial explosion event data
  63079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63080. */
  63081. export interface PhysicsRadialExplosionEventData {
  63082. /**
  63083. * A sphere used for the radial explosion event
  63084. */
  63085. sphere: Mesh;
  63086. }
  63087. /**
  63088. * Interface for gravitational field event data
  63089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63090. */
  63091. export interface PhysicsGravitationalFieldEventData {
  63092. /**
  63093. * A sphere mesh used for the gravitational field event
  63094. */
  63095. sphere: Mesh;
  63096. }
  63097. /**
  63098. * Interface for updraft event data
  63099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63100. */
  63101. export interface PhysicsUpdraftEventData {
  63102. /**
  63103. * A cylinder used for the updraft event
  63104. */
  63105. cylinder: Mesh;
  63106. }
  63107. /**
  63108. * Interface for vortex event data
  63109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63110. */
  63111. export interface PhysicsVortexEventData {
  63112. /**
  63113. * A cylinder used for the vortex event
  63114. */
  63115. cylinder: Mesh;
  63116. }
  63117. /**
  63118. * Interface for an affected physics impostor
  63119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63120. */
  63121. export interface PhysicsAffectedImpostorWithData {
  63122. /**
  63123. * The impostor affected by the effect
  63124. */
  63125. impostor: PhysicsImpostor;
  63126. /**
  63127. * The data about the hit/horce from the explosion
  63128. */
  63129. hitData: PhysicsHitData;
  63130. }
  63131. }
  63132. declare module "babylonjs/Physics/Plugins/index" {
  63133. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63134. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63135. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63136. }
  63137. declare module "babylonjs/Physics/index" {
  63138. export * from "babylonjs/Physics/IPhysicsEngine";
  63139. export * from "babylonjs/Physics/physicsEngine";
  63140. export * from "babylonjs/Physics/physicsEngineComponent";
  63141. export * from "babylonjs/Physics/physicsHelper";
  63142. export * from "babylonjs/Physics/physicsImpostor";
  63143. export * from "babylonjs/Physics/physicsJoint";
  63144. export * from "babylonjs/Physics/Plugins/index";
  63145. }
  63146. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63147. /** @hidden */
  63148. export var blackAndWhitePixelShader: {
  63149. name: string;
  63150. shader: string;
  63151. };
  63152. }
  63153. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63154. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63155. import { Camera } from "babylonjs/Cameras/camera";
  63156. import { Engine } from "babylonjs/Engines/engine";
  63157. import "babylonjs/Shaders/blackAndWhite.fragment";
  63158. /**
  63159. * Post process used to render in black and white
  63160. */
  63161. export class BlackAndWhitePostProcess extends PostProcess {
  63162. /**
  63163. * Linear about to convert he result to black and white (default: 1)
  63164. */
  63165. degree: number;
  63166. /**
  63167. * Creates a black and white post process
  63168. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63169. * @param name The name of the effect.
  63170. * @param options The required width/height ratio to downsize to before computing the render pass.
  63171. * @param camera The camera to apply the render pass to.
  63172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63173. * @param engine The engine which the post process will be applied. (default: current engine)
  63174. * @param reusable If the post process can be reused on the same frame. (default: false)
  63175. */
  63176. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63177. }
  63178. }
  63179. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63180. import { Nullable } from "babylonjs/types";
  63181. import { Camera } from "babylonjs/Cameras/camera";
  63182. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63183. import { Engine } from "babylonjs/Engines/engine";
  63184. /**
  63185. * This represents a set of one or more post processes in Babylon.
  63186. * A post process can be used to apply a shader to a texture after it is rendered.
  63187. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63188. */
  63189. export class PostProcessRenderEffect {
  63190. private _postProcesses;
  63191. private _getPostProcesses;
  63192. private _singleInstance;
  63193. private _cameras;
  63194. private _indicesForCamera;
  63195. /**
  63196. * Name of the effect
  63197. * @hidden
  63198. */
  63199. _name: string;
  63200. /**
  63201. * Instantiates a post process render effect.
  63202. * A post process can be used to apply a shader to a texture after it is rendered.
  63203. * @param engine The engine the effect is tied to
  63204. * @param name The name of the effect
  63205. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63206. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63207. */
  63208. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63209. /**
  63210. * Checks if all the post processes in the effect are supported.
  63211. */
  63212. readonly isSupported: boolean;
  63213. /**
  63214. * Updates the current state of the effect
  63215. * @hidden
  63216. */
  63217. _update(): void;
  63218. /**
  63219. * Attaches the effect on cameras
  63220. * @param cameras The camera to attach to.
  63221. * @hidden
  63222. */
  63223. _attachCameras(cameras: Camera): void;
  63224. /**
  63225. * Attaches the effect on cameras
  63226. * @param cameras The camera to attach to.
  63227. * @hidden
  63228. */
  63229. _attachCameras(cameras: Camera[]): void;
  63230. /**
  63231. * Detaches the effect on cameras
  63232. * @param cameras The camera to detatch from.
  63233. * @hidden
  63234. */
  63235. _detachCameras(cameras: Camera): void;
  63236. /**
  63237. * Detatches the effect on cameras
  63238. * @param cameras The camera to detatch from.
  63239. * @hidden
  63240. */
  63241. _detachCameras(cameras: Camera[]): void;
  63242. /**
  63243. * Enables the effect on given cameras
  63244. * @param cameras The camera to enable.
  63245. * @hidden
  63246. */
  63247. _enable(cameras: Camera): void;
  63248. /**
  63249. * Enables the effect on given cameras
  63250. * @param cameras The camera to enable.
  63251. * @hidden
  63252. */
  63253. _enable(cameras: Nullable<Camera[]>): void;
  63254. /**
  63255. * Disables the effect on the given cameras
  63256. * @param cameras The camera to disable.
  63257. * @hidden
  63258. */
  63259. _disable(cameras: Camera): void;
  63260. /**
  63261. * Disables the effect on the given cameras
  63262. * @param cameras The camera to disable.
  63263. * @hidden
  63264. */
  63265. _disable(cameras: Nullable<Camera[]>): void;
  63266. /**
  63267. * Gets a list of the post processes contained in the effect.
  63268. * @param camera The camera to get the post processes on.
  63269. * @returns The list of the post processes in the effect.
  63270. */
  63271. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63272. }
  63273. }
  63274. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63275. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63276. /** @hidden */
  63277. export var extractHighlightsPixelShader: {
  63278. name: string;
  63279. shader: string;
  63280. };
  63281. }
  63282. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63283. import { Nullable } from "babylonjs/types";
  63284. import { Camera } from "babylonjs/Cameras/camera";
  63285. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63286. import { Engine } from "babylonjs/Engines/engine";
  63287. import "babylonjs/Shaders/extractHighlights.fragment";
  63288. /**
  63289. * 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.
  63290. */
  63291. export class ExtractHighlightsPostProcess extends PostProcess {
  63292. /**
  63293. * The luminance threshold, pixels below this value will be set to black.
  63294. */
  63295. threshold: number;
  63296. /** @hidden */
  63297. _exposure: number;
  63298. /**
  63299. * Post process which has the input texture to be used when performing highlight extraction
  63300. * @hidden
  63301. */
  63302. _inputPostProcess: Nullable<PostProcess>;
  63303. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63304. }
  63305. }
  63306. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63307. /** @hidden */
  63308. export var bloomMergePixelShader: {
  63309. name: string;
  63310. shader: string;
  63311. };
  63312. }
  63313. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63314. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63315. import { Nullable } from "babylonjs/types";
  63316. import { Engine } from "babylonjs/Engines/engine";
  63317. import { Camera } from "babylonjs/Cameras/camera";
  63318. import "babylonjs/Shaders/bloomMerge.fragment";
  63319. /**
  63320. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63321. */
  63322. export class BloomMergePostProcess extends PostProcess {
  63323. /** Weight of the bloom to be added to the original input. */
  63324. weight: number;
  63325. /**
  63326. * Creates a new instance of @see BloomMergePostProcess
  63327. * @param name The name of the effect.
  63328. * @param originalFromInput Post process which's input will be used for the merge.
  63329. * @param blurred Blurred highlights post process which's output will be used.
  63330. * @param weight Weight of the bloom to be added to the original input.
  63331. * @param options The required width/height ratio to downsize to before computing the render pass.
  63332. * @param camera The camera to apply the render pass to.
  63333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63334. * @param engine The engine which the post process will be applied. (default: current engine)
  63335. * @param reusable If the post process can be reused on the same frame. (default: false)
  63336. * @param textureType Type of textures used when performing the post process. (default: 0)
  63337. * @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)
  63338. */
  63339. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63340. /** Weight of the bloom to be added to the original input. */
  63341. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63342. }
  63343. }
  63344. declare module "babylonjs/PostProcesses/bloomEffect" {
  63345. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63346. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63347. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63348. import { Camera } from "babylonjs/Cameras/camera";
  63349. import { Scene } from "babylonjs/scene";
  63350. /**
  63351. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63352. */
  63353. export class BloomEffect extends PostProcessRenderEffect {
  63354. private bloomScale;
  63355. /**
  63356. * @hidden Internal
  63357. */
  63358. _effects: Array<PostProcess>;
  63359. /**
  63360. * @hidden Internal
  63361. */
  63362. _downscale: ExtractHighlightsPostProcess;
  63363. private _blurX;
  63364. private _blurY;
  63365. private _merge;
  63366. /**
  63367. * The luminance threshold to find bright areas of the image to bloom.
  63368. */
  63369. threshold: number;
  63370. /**
  63371. * The strength of the bloom.
  63372. */
  63373. weight: number;
  63374. /**
  63375. * Specifies the size of the bloom blur kernel, relative to the final output size
  63376. */
  63377. kernel: number;
  63378. /**
  63379. * Creates a new instance of @see BloomEffect
  63380. * @param scene The scene the effect belongs to.
  63381. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63382. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63383. * @param bloomWeight The the strength of bloom.
  63384. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63385. * @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)
  63386. */
  63387. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63388. /**
  63389. * Disposes each of the internal effects for a given camera.
  63390. * @param camera The camera to dispose the effect on.
  63391. */
  63392. disposeEffects(camera: Camera): void;
  63393. /**
  63394. * @hidden Internal
  63395. */
  63396. _updateEffects(): void;
  63397. /**
  63398. * Internal
  63399. * @returns if all the contained post processes are ready.
  63400. * @hidden
  63401. */
  63402. _isReady(): boolean;
  63403. }
  63404. }
  63405. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63406. /** @hidden */
  63407. export var chromaticAberrationPixelShader: {
  63408. name: string;
  63409. shader: string;
  63410. };
  63411. }
  63412. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63413. import { Vector2 } from "babylonjs/Maths/math.vector";
  63414. import { Nullable } from "babylonjs/types";
  63415. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63416. import { Camera } from "babylonjs/Cameras/camera";
  63417. import { Engine } from "babylonjs/Engines/engine";
  63418. import "babylonjs/Shaders/chromaticAberration.fragment";
  63419. /**
  63420. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63421. */
  63422. export class ChromaticAberrationPostProcess extends PostProcess {
  63423. /**
  63424. * The amount of seperation of rgb channels (default: 30)
  63425. */
  63426. aberrationAmount: number;
  63427. /**
  63428. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63429. */
  63430. radialIntensity: number;
  63431. /**
  63432. * 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))
  63433. */
  63434. direction: Vector2;
  63435. /**
  63436. * 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))
  63437. */
  63438. centerPosition: Vector2;
  63439. /**
  63440. * Creates a new instance ChromaticAberrationPostProcess
  63441. * @param name The name of the effect.
  63442. * @param screenWidth The width of the screen to apply the effect on.
  63443. * @param screenHeight The height of the screen to apply the effect on.
  63444. * @param options The required width/height ratio to downsize to before computing the render pass.
  63445. * @param camera The camera to apply the render pass to.
  63446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63447. * @param engine The engine which the post process will be applied. (default: current engine)
  63448. * @param reusable If the post process can be reused on the same frame. (default: false)
  63449. * @param textureType Type of textures used when performing the post process. (default: 0)
  63450. * @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)
  63451. */
  63452. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63453. }
  63454. }
  63455. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63456. /** @hidden */
  63457. export var circleOfConfusionPixelShader: {
  63458. name: string;
  63459. shader: string;
  63460. };
  63461. }
  63462. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63463. import { Nullable } from "babylonjs/types";
  63464. import { Engine } from "babylonjs/Engines/engine";
  63465. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63466. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63467. import { Camera } from "babylonjs/Cameras/camera";
  63468. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63469. /**
  63470. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63471. */
  63472. export class CircleOfConfusionPostProcess extends PostProcess {
  63473. /**
  63474. * 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.
  63475. */
  63476. lensSize: number;
  63477. /**
  63478. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63479. */
  63480. fStop: number;
  63481. /**
  63482. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63483. */
  63484. focusDistance: number;
  63485. /**
  63486. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63487. */
  63488. focalLength: number;
  63489. private _depthTexture;
  63490. /**
  63491. * Creates a new instance CircleOfConfusionPostProcess
  63492. * @param name The name of the effect.
  63493. * @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.
  63494. * @param options The required width/height ratio to downsize to before computing the render pass.
  63495. * @param camera The camera to apply the render pass to.
  63496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63497. * @param engine The engine which the post process will be applied. (default: current engine)
  63498. * @param reusable If the post process can be reused on the same frame. (default: false)
  63499. * @param textureType Type of textures used when performing the post process. (default: 0)
  63500. * @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)
  63501. */
  63502. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63503. /**
  63504. * 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.
  63505. */
  63506. depthTexture: RenderTargetTexture;
  63507. }
  63508. }
  63509. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63510. /** @hidden */
  63511. export var colorCorrectionPixelShader: {
  63512. name: string;
  63513. shader: string;
  63514. };
  63515. }
  63516. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63517. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63518. import { Engine } from "babylonjs/Engines/engine";
  63519. import { Camera } from "babylonjs/Cameras/camera";
  63520. import "babylonjs/Shaders/colorCorrection.fragment";
  63521. /**
  63522. *
  63523. * This post-process allows the modification of rendered colors by using
  63524. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63525. *
  63526. * The object needs to be provided an url to a texture containing the color
  63527. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63528. * Use an image editing software to tweak the LUT to match your needs.
  63529. *
  63530. * For an example of a color LUT, see here:
  63531. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63532. * For explanations on color grading, see here:
  63533. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63534. *
  63535. */
  63536. export class ColorCorrectionPostProcess extends PostProcess {
  63537. private _colorTableTexture;
  63538. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63539. }
  63540. }
  63541. declare module "babylonjs/Shaders/convolution.fragment" {
  63542. /** @hidden */
  63543. export var convolutionPixelShader: {
  63544. name: string;
  63545. shader: string;
  63546. };
  63547. }
  63548. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63549. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63550. import { Nullable } from "babylonjs/types";
  63551. import { Camera } from "babylonjs/Cameras/camera";
  63552. import { Engine } from "babylonjs/Engines/engine";
  63553. import "babylonjs/Shaders/convolution.fragment";
  63554. /**
  63555. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63556. * input texture to perform effects such as edge detection or sharpening
  63557. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63558. */
  63559. export class ConvolutionPostProcess extends PostProcess {
  63560. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63561. kernel: number[];
  63562. /**
  63563. * Creates a new instance ConvolutionPostProcess
  63564. * @param name The name of the effect.
  63565. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63566. * @param options The required width/height ratio to downsize to before computing the render pass.
  63567. * @param camera The camera to apply the render pass to.
  63568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63569. * @param engine The engine which the post process will be applied. (default: current engine)
  63570. * @param reusable If the post process can be reused on the same frame. (default: false)
  63571. * @param textureType Type of textures used when performing the post process. (default: 0)
  63572. */
  63573. constructor(name: string,
  63574. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63575. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63576. /**
  63577. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63578. */
  63579. static EdgeDetect0Kernel: number[];
  63580. /**
  63581. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63582. */
  63583. static EdgeDetect1Kernel: number[];
  63584. /**
  63585. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63586. */
  63587. static EdgeDetect2Kernel: number[];
  63588. /**
  63589. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63590. */
  63591. static SharpenKernel: number[];
  63592. /**
  63593. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63594. */
  63595. static EmbossKernel: number[];
  63596. /**
  63597. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63598. */
  63599. static GaussianKernel: number[];
  63600. }
  63601. }
  63602. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63603. import { Nullable } from "babylonjs/types";
  63604. import { Vector2 } from "babylonjs/Maths/math.vector";
  63605. import { Camera } from "babylonjs/Cameras/camera";
  63606. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63607. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63608. import { Engine } from "babylonjs/Engines/engine";
  63609. import { Scene } from "babylonjs/scene";
  63610. /**
  63611. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63612. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63613. * based on samples that have a large difference in distance than the center pixel.
  63614. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63615. */
  63616. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63617. direction: Vector2;
  63618. /**
  63619. * Creates a new instance CircleOfConfusionPostProcess
  63620. * @param name The name of the effect.
  63621. * @param scene The scene the effect belongs to.
  63622. * @param direction The direction the blur should be applied.
  63623. * @param kernel The size of the kernel used to blur.
  63624. * @param options The required width/height ratio to downsize to before computing the render pass.
  63625. * @param camera The camera to apply the render pass to.
  63626. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63627. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63629. * @param engine The engine which the post process will be applied. (default: current engine)
  63630. * @param reusable If the post process can be reused on the same frame. (default: false)
  63631. * @param textureType Type of textures used when performing the post process. (default: 0)
  63632. * @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)
  63633. */
  63634. 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);
  63635. }
  63636. }
  63637. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63638. /** @hidden */
  63639. export var depthOfFieldMergePixelShader: {
  63640. name: string;
  63641. shader: string;
  63642. };
  63643. }
  63644. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63645. import { Nullable } from "babylonjs/types";
  63646. import { Camera } from "babylonjs/Cameras/camera";
  63647. import { Effect } from "babylonjs/Materials/effect";
  63648. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63649. import { Engine } from "babylonjs/Engines/engine";
  63650. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63651. /**
  63652. * Options to be set when merging outputs from the default pipeline.
  63653. */
  63654. export class DepthOfFieldMergePostProcessOptions {
  63655. /**
  63656. * The original image to merge on top of
  63657. */
  63658. originalFromInput: PostProcess;
  63659. /**
  63660. * Parameters to perform the merge of the depth of field effect
  63661. */
  63662. depthOfField?: {
  63663. circleOfConfusion: PostProcess;
  63664. blurSteps: Array<PostProcess>;
  63665. };
  63666. /**
  63667. * Parameters to perform the merge of bloom effect
  63668. */
  63669. bloom?: {
  63670. blurred: PostProcess;
  63671. weight: number;
  63672. };
  63673. }
  63674. /**
  63675. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63676. */
  63677. export class DepthOfFieldMergePostProcess extends PostProcess {
  63678. private blurSteps;
  63679. /**
  63680. * Creates a new instance of DepthOfFieldMergePostProcess
  63681. * @param name The name of the effect.
  63682. * @param originalFromInput Post process which's input will be used for the merge.
  63683. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63684. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63685. * @param options The required width/height ratio to downsize to before computing the render pass.
  63686. * @param camera The camera to apply the render pass to.
  63687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63688. * @param engine The engine which the post process will be applied. (default: current engine)
  63689. * @param reusable If the post process can be reused on the same frame. (default: false)
  63690. * @param textureType Type of textures used when performing the post process. (default: 0)
  63691. * @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)
  63692. */
  63693. 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);
  63694. /**
  63695. * Updates the effect with the current post process compile time values and recompiles the shader.
  63696. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63697. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63698. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63699. * @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
  63700. * @param onCompiled Called when the shader has been compiled.
  63701. * @param onError Called if there is an error when compiling a shader.
  63702. */
  63703. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63704. }
  63705. }
  63706. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63707. import { Nullable } from "babylonjs/types";
  63708. import { Camera } from "babylonjs/Cameras/camera";
  63709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63710. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63711. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63712. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63713. import { Scene } from "babylonjs/scene";
  63714. /**
  63715. * Specifies the level of max blur that should be applied when using the depth of field effect
  63716. */
  63717. export enum DepthOfFieldEffectBlurLevel {
  63718. /**
  63719. * Subtle blur
  63720. */
  63721. Low = 0,
  63722. /**
  63723. * Medium blur
  63724. */
  63725. Medium = 1,
  63726. /**
  63727. * Large blur
  63728. */
  63729. High = 2
  63730. }
  63731. /**
  63732. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63733. */
  63734. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63735. private _circleOfConfusion;
  63736. /**
  63737. * @hidden Internal, blurs from high to low
  63738. */
  63739. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63740. private _depthOfFieldBlurY;
  63741. private _dofMerge;
  63742. /**
  63743. * @hidden Internal post processes in depth of field effect
  63744. */
  63745. _effects: Array<PostProcess>;
  63746. /**
  63747. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63748. */
  63749. focalLength: number;
  63750. /**
  63751. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63752. */
  63753. fStop: number;
  63754. /**
  63755. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63756. */
  63757. focusDistance: number;
  63758. /**
  63759. * 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.
  63760. */
  63761. lensSize: number;
  63762. /**
  63763. * Creates a new instance DepthOfFieldEffect
  63764. * @param scene The scene the effect belongs to.
  63765. * @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.
  63766. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63767. * @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)
  63768. */
  63769. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63770. /**
  63771. * Get the current class name of the current effet
  63772. * @returns "DepthOfFieldEffect"
  63773. */
  63774. getClassName(): string;
  63775. /**
  63776. * 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.
  63777. */
  63778. depthTexture: RenderTargetTexture;
  63779. /**
  63780. * Disposes each of the internal effects for a given camera.
  63781. * @param camera The camera to dispose the effect on.
  63782. */
  63783. disposeEffects(camera: Camera): void;
  63784. /**
  63785. * @hidden Internal
  63786. */
  63787. _updateEffects(): void;
  63788. /**
  63789. * Internal
  63790. * @returns if all the contained post processes are ready.
  63791. * @hidden
  63792. */
  63793. _isReady(): boolean;
  63794. }
  63795. }
  63796. declare module "babylonjs/Shaders/displayPass.fragment" {
  63797. /** @hidden */
  63798. export var displayPassPixelShader: {
  63799. name: string;
  63800. shader: string;
  63801. };
  63802. }
  63803. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63804. import { Nullable } from "babylonjs/types";
  63805. import { Camera } from "babylonjs/Cameras/camera";
  63806. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63807. import { Engine } from "babylonjs/Engines/engine";
  63808. import "babylonjs/Shaders/displayPass.fragment";
  63809. /**
  63810. * DisplayPassPostProcess which produces an output the same as it's input
  63811. */
  63812. export class DisplayPassPostProcess extends PostProcess {
  63813. /**
  63814. * Creates the DisplayPassPostProcess
  63815. * @param name The name of the effect.
  63816. * @param options The required width/height ratio to downsize to before computing the render pass.
  63817. * @param camera The camera to apply the render pass to.
  63818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63819. * @param engine The engine which the post process will be applied. (default: current engine)
  63820. * @param reusable If the post process can be reused on the same frame. (default: false)
  63821. */
  63822. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63823. }
  63824. }
  63825. declare module "babylonjs/Shaders/filter.fragment" {
  63826. /** @hidden */
  63827. export var filterPixelShader: {
  63828. name: string;
  63829. shader: string;
  63830. };
  63831. }
  63832. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63833. import { Nullable } from "babylonjs/types";
  63834. import { Matrix } from "babylonjs/Maths/math.vector";
  63835. import { Camera } from "babylonjs/Cameras/camera";
  63836. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63837. import { Engine } from "babylonjs/Engines/engine";
  63838. import "babylonjs/Shaders/filter.fragment";
  63839. /**
  63840. * Applies a kernel filter to the image
  63841. */
  63842. export class FilterPostProcess extends PostProcess {
  63843. /** The matrix to be applied to the image */
  63844. kernelMatrix: Matrix;
  63845. /**
  63846. *
  63847. * @param name The name of the effect.
  63848. * @param kernelMatrix The matrix to be applied to the image
  63849. * @param options The required width/height ratio to downsize to before computing the render pass.
  63850. * @param camera The camera to apply the render pass to.
  63851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63852. * @param engine The engine which the post process will be applied. (default: current engine)
  63853. * @param reusable If the post process can be reused on the same frame. (default: false)
  63854. */
  63855. constructor(name: string,
  63856. /** The matrix to be applied to the image */
  63857. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63858. }
  63859. }
  63860. declare module "babylonjs/Shaders/fxaa.fragment" {
  63861. /** @hidden */
  63862. export var fxaaPixelShader: {
  63863. name: string;
  63864. shader: string;
  63865. };
  63866. }
  63867. declare module "babylonjs/Shaders/fxaa.vertex" {
  63868. /** @hidden */
  63869. export var fxaaVertexShader: {
  63870. name: string;
  63871. shader: string;
  63872. };
  63873. }
  63874. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63875. import { Nullable } from "babylonjs/types";
  63876. import { Camera } from "babylonjs/Cameras/camera";
  63877. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63878. import { Engine } from "babylonjs/Engines/engine";
  63879. import "babylonjs/Shaders/fxaa.fragment";
  63880. import "babylonjs/Shaders/fxaa.vertex";
  63881. /**
  63882. * Fxaa post process
  63883. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63884. */
  63885. export class FxaaPostProcess extends PostProcess {
  63886. /** @hidden */
  63887. texelWidth: number;
  63888. /** @hidden */
  63889. texelHeight: number;
  63890. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63891. private _getDefines;
  63892. }
  63893. }
  63894. declare module "babylonjs/Shaders/grain.fragment" {
  63895. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63896. /** @hidden */
  63897. export var grainPixelShader: {
  63898. name: string;
  63899. shader: string;
  63900. };
  63901. }
  63902. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63903. import { Nullable } from "babylonjs/types";
  63904. import { Camera } from "babylonjs/Cameras/camera";
  63905. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63906. import { Engine } from "babylonjs/Engines/engine";
  63907. import "babylonjs/Shaders/grain.fragment";
  63908. /**
  63909. * The GrainPostProcess adds noise to the image at mid luminance levels
  63910. */
  63911. export class GrainPostProcess extends PostProcess {
  63912. /**
  63913. * The intensity of the grain added (default: 30)
  63914. */
  63915. intensity: number;
  63916. /**
  63917. * If the grain should be randomized on every frame
  63918. */
  63919. animated: boolean;
  63920. /**
  63921. * Creates a new instance of @see GrainPostProcess
  63922. * @param name The name of the effect.
  63923. * @param options The required width/height ratio to downsize to before computing the render pass.
  63924. * @param camera The camera to apply the render pass to.
  63925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63926. * @param engine The engine which the post process will be applied. (default: current engine)
  63927. * @param reusable If the post process can be reused on the same frame. (default: false)
  63928. * @param textureType Type of textures used when performing the post process. (default: 0)
  63929. * @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)
  63930. */
  63931. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63932. }
  63933. }
  63934. declare module "babylonjs/Shaders/highlights.fragment" {
  63935. /** @hidden */
  63936. export var highlightsPixelShader: {
  63937. name: string;
  63938. shader: string;
  63939. };
  63940. }
  63941. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63942. import { Nullable } from "babylonjs/types";
  63943. import { Camera } from "babylonjs/Cameras/camera";
  63944. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63945. import { Engine } from "babylonjs/Engines/engine";
  63946. import "babylonjs/Shaders/highlights.fragment";
  63947. /**
  63948. * Extracts highlights from the image
  63949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63950. */
  63951. export class HighlightsPostProcess extends PostProcess {
  63952. /**
  63953. * Extracts highlights from the image
  63954. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63955. * @param name The name of the effect.
  63956. * @param options The required width/height ratio to downsize to before computing the render pass.
  63957. * @param camera The camera to apply the render pass to.
  63958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63959. * @param engine The engine which the post process will be applied. (default: current engine)
  63960. * @param reusable If the post process can be reused on the same frame. (default: false)
  63961. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63962. */
  63963. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63964. }
  63965. }
  63966. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63967. /** @hidden */
  63968. export var mrtFragmentDeclaration: {
  63969. name: string;
  63970. shader: string;
  63971. };
  63972. }
  63973. declare module "babylonjs/Shaders/geometry.fragment" {
  63974. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63975. /** @hidden */
  63976. export var geometryPixelShader: {
  63977. name: string;
  63978. shader: string;
  63979. };
  63980. }
  63981. declare module "babylonjs/Shaders/geometry.vertex" {
  63982. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63983. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63984. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63985. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63986. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63987. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63988. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63989. /** @hidden */
  63990. export var geometryVertexShader: {
  63991. name: string;
  63992. shader: string;
  63993. };
  63994. }
  63995. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63996. import { Matrix } from "babylonjs/Maths/math.vector";
  63997. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63998. import { Mesh } from "babylonjs/Meshes/mesh";
  63999. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64000. import { Effect } from "babylonjs/Materials/effect";
  64001. import { Scene } from "babylonjs/scene";
  64002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64003. import "babylonjs/Shaders/geometry.fragment";
  64004. import "babylonjs/Shaders/geometry.vertex";
  64005. /** @hidden */
  64006. interface ISavedTransformationMatrix {
  64007. world: Matrix;
  64008. viewProjection: Matrix;
  64009. }
  64010. /**
  64011. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64012. */
  64013. export class GeometryBufferRenderer {
  64014. /**
  64015. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64016. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64017. */
  64018. static readonly POSITION_TEXTURE_TYPE: number;
  64019. /**
  64020. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64021. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64022. */
  64023. static readonly VELOCITY_TEXTURE_TYPE: number;
  64024. /**
  64025. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64026. * in order to compute objects velocities when enableVelocity is set to "true"
  64027. * @hidden
  64028. */
  64029. _previousTransformationMatrices: {
  64030. [index: number]: ISavedTransformationMatrix;
  64031. };
  64032. /**
  64033. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64034. * in order to compute objects velocities when enableVelocity is set to "true"
  64035. * @hidden
  64036. */
  64037. _previousBonesTransformationMatrices: {
  64038. [index: number]: Float32Array;
  64039. };
  64040. /**
  64041. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64042. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64043. */
  64044. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64045. private _scene;
  64046. private _multiRenderTarget;
  64047. private _ratio;
  64048. private _enablePosition;
  64049. private _enableVelocity;
  64050. private _positionIndex;
  64051. private _velocityIndex;
  64052. protected _effect: Effect;
  64053. protected _cachedDefines: string;
  64054. /**
  64055. * Set the render list (meshes to be rendered) used in the G buffer.
  64056. */
  64057. renderList: Mesh[];
  64058. /**
  64059. * Gets wether or not G buffer are supported by the running hardware.
  64060. * This requires draw buffer supports
  64061. */
  64062. readonly isSupported: boolean;
  64063. /**
  64064. * Returns the index of the given texture type in the G-Buffer textures array
  64065. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64066. * @returns the index of the given texture type in the G-Buffer textures array
  64067. */
  64068. getTextureIndex(textureType: number): number;
  64069. /**
  64070. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64071. */
  64072. /**
  64073. * Sets whether or not objects positions are enabled for the G buffer.
  64074. */
  64075. enablePosition: boolean;
  64076. /**
  64077. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64078. */
  64079. /**
  64080. * Sets wether or not objects velocities are enabled for the G buffer.
  64081. */
  64082. enableVelocity: boolean;
  64083. /**
  64084. * Gets the scene associated with the buffer.
  64085. */
  64086. readonly scene: Scene;
  64087. /**
  64088. * Gets the ratio used by the buffer during its creation.
  64089. * How big is the buffer related to the main canvas.
  64090. */
  64091. readonly ratio: number;
  64092. /** @hidden */
  64093. static _SceneComponentInitialization: (scene: Scene) => void;
  64094. /**
  64095. * Creates a new G Buffer for the scene
  64096. * @param scene The scene the buffer belongs to
  64097. * @param ratio How big is the buffer related to the main canvas.
  64098. */
  64099. constructor(scene: Scene, ratio?: number);
  64100. /**
  64101. * Checks wether everything is ready to render a submesh to the G buffer.
  64102. * @param subMesh the submesh to check readiness for
  64103. * @param useInstances is the mesh drawn using instance or not
  64104. * @returns true if ready otherwise false
  64105. */
  64106. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64107. /**
  64108. * Gets the current underlying G Buffer.
  64109. * @returns the buffer
  64110. */
  64111. getGBuffer(): MultiRenderTarget;
  64112. /**
  64113. * Gets the number of samples used to render the buffer (anti aliasing).
  64114. */
  64115. /**
  64116. * Sets the number of samples used to render the buffer (anti aliasing).
  64117. */
  64118. samples: number;
  64119. /**
  64120. * Disposes the renderer and frees up associated resources.
  64121. */
  64122. dispose(): void;
  64123. protected _createRenderTargets(): void;
  64124. private _copyBonesTransformationMatrices;
  64125. }
  64126. }
  64127. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64128. import { Nullable } from "babylonjs/types";
  64129. import { Scene } from "babylonjs/scene";
  64130. import { ISceneComponent } from "babylonjs/sceneComponent";
  64131. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64132. module "babylonjs/scene" {
  64133. interface Scene {
  64134. /** @hidden (Backing field) */
  64135. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64136. /**
  64137. * Gets or Sets the current geometry buffer associated to the scene.
  64138. */
  64139. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64140. /**
  64141. * Enables a GeometryBufferRender and associates it with the scene
  64142. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64143. * @returns the GeometryBufferRenderer
  64144. */
  64145. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64146. /**
  64147. * Disables the GeometryBufferRender associated with the scene
  64148. */
  64149. disableGeometryBufferRenderer(): void;
  64150. }
  64151. }
  64152. /**
  64153. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64154. * in several rendering techniques.
  64155. */
  64156. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64157. /**
  64158. * The component name helpful to identify the component in the list of scene components.
  64159. */
  64160. readonly name: string;
  64161. /**
  64162. * The scene the component belongs to.
  64163. */
  64164. scene: Scene;
  64165. /**
  64166. * Creates a new instance of the component for the given scene
  64167. * @param scene Defines the scene to register the component in
  64168. */
  64169. constructor(scene: Scene);
  64170. /**
  64171. * Registers the component in a given scene
  64172. */
  64173. register(): void;
  64174. /**
  64175. * Rebuilds the elements related to this component in case of
  64176. * context lost for instance.
  64177. */
  64178. rebuild(): void;
  64179. /**
  64180. * Disposes the component and the associated ressources
  64181. */
  64182. dispose(): void;
  64183. private _gatherRenderTargets;
  64184. }
  64185. }
  64186. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64187. /** @hidden */
  64188. export var motionBlurPixelShader: {
  64189. name: string;
  64190. shader: string;
  64191. };
  64192. }
  64193. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64194. import { Nullable } from "babylonjs/types";
  64195. import { Camera } from "babylonjs/Cameras/camera";
  64196. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64197. import { Scene } from "babylonjs/scene";
  64198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64199. import "babylonjs/Animations/animatable";
  64200. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64201. import "babylonjs/Shaders/motionBlur.fragment";
  64202. import { Engine } from "babylonjs/Engines/engine";
  64203. /**
  64204. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64205. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64206. * As an example, all you have to do is to create the post-process:
  64207. * var mb = new BABYLON.MotionBlurPostProcess(
  64208. * 'mb', // The name of the effect.
  64209. * scene, // The scene containing the objects to blur according to their velocity.
  64210. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64211. * camera // The camera to apply the render pass to.
  64212. * );
  64213. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64214. */
  64215. export class MotionBlurPostProcess extends PostProcess {
  64216. /**
  64217. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64218. */
  64219. motionStrength: number;
  64220. /**
  64221. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64222. */
  64223. /**
  64224. * Sets the number of iterations to be used for motion blur quality
  64225. */
  64226. motionBlurSamples: number;
  64227. private _motionBlurSamples;
  64228. private _geometryBufferRenderer;
  64229. /**
  64230. * Creates a new instance MotionBlurPostProcess
  64231. * @param name The name of the effect.
  64232. * @param scene The scene containing the objects to blur according to their velocity.
  64233. * @param options The required width/height ratio to downsize to before computing the render pass.
  64234. * @param camera The camera to apply the render pass to.
  64235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64236. * @param engine The engine which the post process will be applied. (default: current engine)
  64237. * @param reusable If the post process can be reused on the same frame. (default: false)
  64238. * @param textureType Type of textures used when performing the post process. (default: 0)
  64239. * @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)
  64240. */
  64241. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64242. /**
  64243. * Excludes the given skinned mesh from computing bones velocities.
  64244. * 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.
  64245. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64246. */
  64247. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64248. /**
  64249. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64250. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64251. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64252. */
  64253. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64254. /**
  64255. * Disposes the post process.
  64256. * @param camera The camera to dispose the post process on.
  64257. */
  64258. dispose(camera?: Camera): void;
  64259. }
  64260. }
  64261. declare module "babylonjs/Shaders/refraction.fragment" {
  64262. /** @hidden */
  64263. export var refractionPixelShader: {
  64264. name: string;
  64265. shader: string;
  64266. };
  64267. }
  64268. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64269. import { Color3 } from "babylonjs/Maths/math.color";
  64270. import { Camera } from "babylonjs/Cameras/camera";
  64271. import { Texture } from "babylonjs/Materials/Textures/texture";
  64272. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64273. import { Engine } from "babylonjs/Engines/engine";
  64274. import "babylonjs/Shaders/refraction.fragment";
  64275. /**
  64276. * Post process which applies a refractin texture
  64277. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64278. */
  64279. export class RefractionPostProcess extends PostProcess {
  64280. /** the base color of the refraction (used to taint the rendering) */
  64281. color: Color3;
  64282. /** simulated refraction depth */
  64283. depth: number;
  64284. /** the coefficient of the base color (0 to remove base color tainting) */
  64285. colorLevel: number;
  64286. private _refTexture;
  64287. private _ownRefractionTexture;
  64288. /**
  64289. * Gets or sets the refraction texture
  64290. * Please note that you are responsible for disposing the texture if you set it manually
  64291. */
  64292. refractionTexture: Texture;
  64293. /**
  64294. * Initializes the RefractionPostProcess
  64295. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64296. * @param name The name of the effect.
  64297. * @param refractionTextureUrl Url of the refraction texture to use
  64298. * @param color the base color of the refraction (used to taint the rendering)
  64299. * @param depth simulated refraction depth
  64300. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64301. * @param camera The camera to apply the render pass to.
  64302. * @param options The required width/height ratio to downsize to before computing the render pass.
  64303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64304. * @param engine The engine which the post process will be applied. (default: current engine)
  64305. * @param reusable If the post process can be reused on the same frame. (default: false)
  64306. */
  64307. constructor(name: string, refractionTextureUrl: string,
  64308. /** the base color of the refraction (used to taint the rendering) */
  64309. color: Color3,
  64310. /** simulated refraction depth */
  64311. depth: number,
  64312. /** the coefficient of the base color (0 to remove base color tainting) */
  64313. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64314. /**
  64315. * Disposes of the post process
  64316. * @param camera Camera to dispose post process on
  64317. */
  64318. dispose(camera: Camera): void;
  64319. }
  64320. }
  64321. declare module "babylonjs/Shaders/sharpen.fragment" {
  64322. /** @hidden */
  64323. export var sharpenPixelShader: {
  64324. name: string;
  64325. shader: string;
  64326. };
  64327. }
  64328. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64329. import { Nullable } from "babylonjs/types";
  64330. import { Camera } from "babylonjs/Cameras/camera";
  64331. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64332. import "babylonjs/Shaders/sharpen.fragment";
  64333. import { Engine } from "babylonjs/Engines/engine";
  64334. /**
  64335. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64336. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64337. */
  64338. export class SharpenPostProcess extends PostProcess {
  64339. /**
  64340. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64341. */
  64342. colorAmount: number;
  64343. /**
  64344. * How much sharpness should be applied (default: 0.3)
  64345. */
  64346. edgeAmount: number;
  64347. /**
  64348. * Creates a new instance ConvolutionPostProcess
  64349. * @param name The name of the effect.
  64350. * @param options The required width/height ratio to downsize to before computing the render pass.
  64351. * @param camera The camera to apply the render pass to.
  64352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64353. * @param engine The engine which the post process will be applied. (default: current engine)
  64354. * @param reusable If the post process can be reused on the same frame. (default: false)
  64355. * @param textureType Type of textures used when performing the post process. (default: 0)
  64356. * @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)
  64357. */
  64358. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64359. }
  64360. }
  64361. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64362. import { Nullable } from "babylonjs/types";
  64363. import { Camera } from "babylonjs/Cameras/camera";
  64364. import { Engine } from "babylonjs/Engines/engine";
  64365. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64366. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64367. /**
  64368. * PostProcessRenderPipeline
  64369. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64370. */
  64371. export class PostProcessRenderPipeline {
  64372. private engine;
  64373. private _renderEffects;
  64374. private _renderEffectsForIsolatedPass;
  64375. /**
  64376. * List of inspectable custom properties (used by the Inspector)
  64377. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64378. */
  64379. inspectableCustomProperties: IInspectable[];
  64380. /**
  64381. * @hidden
  64382. */
  64383. protected _cameras: Camera[];
  64384. /** @hidden */
  64385. _name: string;
  64386. /**
  64387. * Gets pipeline name
  64388. */
  64389. readonly name: string;
  64390. /** Gets the list of attached cameras */
  64391. readonly cameras: Camera[];
  64392. /**
  64393. * Initializes a PostProcessRenderPipeline
  64394. * @param engine engine to add the pipeline to
  64395. * @param name name of the pipeline
  64396. */
  64397. constructor(engine: Engine, name: string);
  64398. /**
  64399. * Gets the class name
  64400. * @returns "PostProcessRenderPipeline"
  64401. */
  64402. getClassName(): string;
  64403. /**
  64404. * If all the render effects in the pipeline are supported
  64405. */
  64406. readonly isSupported: boolean;
  64407. /**
  64408. * Adds an effect to the pipeline
  64409. * @param renderEffect the effect to add
  64410. */
  64411. addEffect(renderEffect: PostProcessRenderEffect): void;
  64412. /** @hidden */
  64413. _rebuild(): void;
  64414. /** @hidden */
  64415. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64416. /** @hidden */
  64417. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64418. /** @hidden */
  64419. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64420. /** @hidden */
  64421. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64422. /** @hidden */
  64423. _attachCameras(cameras: Camera, unique: boolean): void;
  64424. /** @hidden */
  64425. _attachCameras(cameras: Camera[], unique: boolean): void;
  64426. /** @hidden */
  64427. _detachCameras(cameras: Camera): void;
  64428. /** @hidden */
  64429. _detachCameras(cameras: Nullable<Camera[]>): void;
  64430. /** @hidden */
  64431. _update(): void;
  64432. /** @hidden */
  64433. _reset(): void;
  64434. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64435. /**
  64436. * Disposes of the pipeline
  64437. */
  64438. dispose(): void;
  64439. }
  64440. }
  64441. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64442. import { Camera } from "babylonjs/Cameras/camera";
  64443. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64444. /**
  64445. * PostProcessRenderPipelineManager class
  64446. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64447. */
  64448. export class PostProcessRenderPipelineManager {
  64449. private _renderPipelines;
  64450. /**
  64451. * Initializes a PostProcessRenderPipelineManager
  64452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64453. */
  64454. constructor();
  64455. /**
  64456. * Gets the list of supported render pipelines
  64457. */
  64458. readonly supportedPipelines: PostProcessRenderPipeline[];
  64459. /**
  64460. * Adds a pipeline to the manager
  64461. * @param renderPipeline The pipeline to add
  64462. */
  64463. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64464. /**
  64465. * Attaches a camera to the pipeline
  64466. * @param renderPipelineName The name of the pipeline to attach to
  64467. * @param cameras the camera to attach
  64468. * @param unique if the camera can be attached multiple times to the pipeline
  64469. */
  64470. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64471. /**
  64472. * Detaches a camera from the pipeline
  64473. * @param renderPipelineName The name of the pipeline to detach from
  64474. * @param cameras the camera to detach
  64475. */
  64476. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64477. /**
  64478. * Enables an effect by name on a pipeline
  64479. * @param renderPipelineName the name of the pipeline to enable the effect in
  64480. * @param renderEffectName the name of the effect to enable
  64481. * @param cameras the cameras that the effect should be enabled on
  64482. */
  64483. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64484. /**
  64485. * Disables an effect by name on a pipeline
  64486. * @param renderPipelineName the name of the pipeline to disable the effect in
  64487. * @param renderEffectName the name of the effect to disable
  64488. * @param cameras the cameras that the effect should be disabled on
  64489. */
  64490. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64491. /**
  64492. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64493. */
  64494. update(): void;
  64495. /** @hidden */
  64496. _rebuild(): void;
  64497. /**
  64498. * Disposes of the manager and pipelines
  64499. */
  64500. dispose(): void;
  64501. }
  64502. }
  64503. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64504. import { ISceneComponent } from "babylonjs/sceneComponent";
  64505. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64506. import { Scene } from "babylonjs/scene";
  64507. module "babylonjs/scene" {
  64508. interface Scene {
  64509. /** @hidden (Backing field) */
  64510. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64511. /**
  64512. * Gets the postprocess render pipeline manager
  64513. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64514. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64515. */
  64516. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64517. }
  64518. }
  64519. /**
  64520. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64521. */
  64522. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64523. /**
  64524. * The component name helpfull to identify the component in the list of scene components.
  64525. */
  64526. readonly name: string;
  64527. /**
  64528. * The scene the component belongs to.
  64529. */
  64530. scene: Scene;
  64531. /**
  64532. * Creates a new instance of the component for the given scene
  64533. * @param scene Defines the scene to register the component in
  64534. */
  64535. constructor(scene: Scene);
  64536. /**
  64537. * Registers the component in a given scene
  64538. */
  64539. register(): void;
  64540. /**
  64541. * Rebuilds the elements related to this component in case of
  64542. * context lost for instance.
  64543. */
  64544. rebuild(): void;
  64545. /**
  64546. * Disposes the component and the associated ressources
  64547. */
  64548. dispose(): void;
  64549. private _gatherRenderTargets;
  64550. }
  64551. }
  64552. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64553. import { Nullable } from "babylonjs/types";
  64554. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64555. import { Camera } from "babylonjs/Cameras/camera";
  64556. import { IDisposable } from "babylonjs/scene";
  64557. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64558. import { Scene } from "babylonjs/scene";
  64559. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64560. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64561. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64562. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64563. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64564. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64565. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64566. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64567. import { Animation } from "babylonjs/Animations/animation";
  64568. /**
  64569. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64570. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64571. */
  64572. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64573. private _scene;
  64574. private _camerasToBeAttached;
  64575. /**
  64576. * ID of the sharpen post process,
  64577. */
  64578. private readonly SharpenPostProcessId;
  64579. /**
  64580. * @ignore
  64581. * ID of the image processing post process;
  64582. */
  64583. readonly ImageProcessingPostProcessId: string;
  64584. /**
  64585. * @ignore
  64586. * ID of the Fast Approximate Anti-Aliasing post process;
  64587. */
  64588. readonly FxaaPostProcessId: string;
  64589. /**
  64590. * ID of the chromatic aberration post process,
  64591. */
  64592. private readonly ChromaticAberrationPostProcessId;
  64593. /**
  64594. * ID of the grain post process
  64595. */
  64596. private readonly GrainPostProcessId;
  64597. /**
  64598. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64599. */
  64600. sharpen: SharpenPostProcess;
  64601. private _sharpenEffect;
  64602. private bloom;
  64603. /**
  64604. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64605. */
  64606. depthOfField: DepthOfFieldEffect;
  64607. /**
  64608. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64609. */
  64610. fxaa: FxaaPostProcess;
  64611. /**
  64612. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64613. */
  64614. imageProcessing: ImageProcessingPostProcess;
  64615. /**
  64616. * Chromatic aberration post process which will shift rgb colors in the image
  64617. */
  64618. chromaticAberration: ChromaticAberrationPostProcess;
  64619. private _chromaticAberrationEffect;
  64620. /**
  64621. * Grain post process which add noise to the image
  64622. */
  64623. grain: GrainPostProcess;
  64624. private _grainEffect;
  64625. /**
  64626. * Glow post process which adds a glow to emissive areas of the image
  64627. */
  64628. private _glowLayer;
  64629. /**
  64630. * Animations which can be used to tweak settings over a period of time
  64631. */
  64632. animations: Animation[];
  64633. private _imageProcessingConfigurationObserver;
  64634. private _sharpenEnabled;
  64635. private _bloomEnabled;
  64636. private _depthOfFieldEnabled;
  64637. private _depthOfFieldBlurLevel;
  64638. private _fxaaEnabled;
  64639. private _imageProcessingEnabled;
  64640. private _defaultPipelineTextureType;
  64641. private _bloomScale;
  64642. private _chromaticAberrationEnabled;
  64643. private _grainEnabled;
  64644. private _buildAllowed;
  64645. /**
  64646. * Gets active scene
  64647. */
  64648. readonly scene: Scene;
  64649. /**
  64650. * Enable or disable the sharpen process from the pipeline
  64651. */
  64652. sharpenEnabled: boolean;
  64653. private _resizeObserver;
  64654. private _hardwareScaleLevel;
  64655. private _bloomKernel;
  64656. /**
  64657. * Specifies the size of the bloom blur kernel, relative to the final output size
  64658. */
  64659. bloomKernel: number;
  64660. /**
  64661. * Specifies the weight of the bloom in the final rendering
  64662. */
  64663. private _bloomWeight;
  64664. /**
  64665. * Specifies the luma threshold for the area that will be blurred by the bloom
  64666. */
  64667. private _bloomThreshold;
  64668. private _hdr;
  64669. /**
  64670. * The strength of the bloom.
  64671. */
  64672. bloomWeight: number;
  64673. /**
  64674. * The strength of the bloom.
  64675. */
  64676. bloomThreshold: number;
  64677. /**
  64678. * The scale of the bloom, lower value will provide better performance.
  64679. */
  64680. bloomScale: number;
  64681. /**
  64682. * Enable or disable the bloom from the pipeline
  64683. */
  64684. bloomEnabled: boolean;
  64685. private _rebuildBloom;
  64686. /**
  64687. * If the depth of field is enabled.
  64688. */
  64689. depthOfFieldEnabled: boolean;
  64690. /**
  64691. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64692. */
  64693. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64694. /**
  64695. * If the anti aliasing is enabled.
  64696. */
  64697. fxaaEnabled: boolean;
  64698. private _samples;
  64699. /**
  64700. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64701. */
  64702. samples: number;
  64703. /**
  64704. * If image processing is enabled.
  64705. */
  64706. imageProcessingEnabled: boolean;
  64707. /**
  64708. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64709. */
  64710. glowLayerEnabled: boolean;
  64711. /**
  64712. * Gets the glow layer (or null if not defined)
  64713. */
  64714. readonly glowLayer: Nullable<GlowLayer>;
  64715. /**
  64716. * Enable or disable the chromaticAberration process from the pipeline
  64717. */
  64718. chromaticAberrationEnabled: boolean;
  64719. /**
  64720. * Enable or disable the grain process from the pipeline
  64721. */
  64722. grainEnabled: boolean;
  64723. /**
  64724. * @constructor
  64725. * @param name - The rendering pipeline name (default: "")
  64726. * @param hdr - If high dynamic range textures should be used (default: true)
  64727. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64728. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64729. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64730. */
  64731. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64732. /**
  64733. * Get the class name
  64734. * @returns "DefaultRenderingPipeline"
  64735. */
  64736. getClassName(): string;
  64737. /**
  64738. * Force the compilation of the entire pipeline.
  64739. */
  64740. prepare(): void;
  64741. private _hasCleared;
  64742. private _prevPostProcess;
  64743. private _prevPrevPostProcess;
  64744. private _setAutoClearAndTextureSharing;
  64745. private _depthOfFieldSceneObserver;
  64746. private _buildPipeline;
  64747. private _disposePostProcesses;
  64748. /**
  64749. * Adds a camera to the pipeline
  64750. * @param camera the camera to be added
  64751. */
  64752. addCamera(camera: Camera): void;
  64753. /**
  64754. * Removes a camera from the pipeline
  64755. * @param camera the camera to remove
  64756. */
  64757. removeCamera(camera: Camera): void;
  64758. /**
  64759. * Dispose of the pipeline and stop all post processes
  64760. */
  64761. dispose(): void;
  64762. /**
  64763. * Serialize the rendering pipeline (Used when exporting)
  64764. * @returns the serialized object
  64765. */
  64766. serialize(): any;
  64767. /**
  64768. * Parse the serialized pipeline
  64769. * @param source Source pipeline.
  64770. * @param scene The scene to load the pipeline to.
  64771. * @param rootUrl The URL of the serialized pipeline.
  64772. * @returns An instantiated pipeline from the serialized object.
  64773. */
  64774. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64775. }
  64776. }
  64777. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64778. /** @hidden */
  64779. export var lensHighlightsPixelShader: {
  64780. name: string;
  64781. shader: string;
  64782. };
  64783. }
  64784. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64785. /** @hidden */
  64786. export var depthOfFieldPixelShader: {
  64787. name: string;
  64788. shader: string;
  64789. };
  64790. }
  64791. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64792. import { Camera } from "babylonjs/Cameras/camera";
  64793. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64794. import { Scene } from "babylonjs/scene";
  64795. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64796. import "babylonjs/Shaders/chromaticAberration.fragment";
  64797. import "babylonjs/Shaders/lensHighlights.fragment";
  64798. import "babylonjs/Shaders/depthOfField.fragment";
  64799. /**
  64800. * BABYLON.JS Chromatic Aberration GLSL Shader
  64801. * Author: Olivier Guyot
  64802. * Separates very slightly R, G and B colors on the edges of the screen
  64803. * Inspired by Francois Tarlier & Martins Upitis
  64804. */
  64805. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64806. /**
  64807. * @ignore
  64808. * The chromatic aberration PostProcess id in the pipeline
  64809. */
  64810. LensChromaticAberrationEffect: string;
  64811. /**
  64812. * @ignore
  64813. * The highlights enhancing PostProcess id in the pipeline
  64814. */
  64815. HighlightsEnhancingEffect: string;
  64816. /**
  64817. * @ignore
  64818. * The depth-of-field PostProcess id in the pipeline
  64819. */
  64820. LensDepthOfFieldEffect: string;
  64821. private _scene;
  64822. private _depthTexture;
  64823. private _grainTexture;
  64824. private _chromaticAberrationPostProcess;
  64825. private _highlightsPostProcess;
  64826. private _depthOfFieldPostProcess;
  64827. private _edgeBlur;
  64828. private _grainAmount;
  64829. private _chromaticAberration;
  64830. private _distortion;
  64831. private _highlightsGain;
  64832. private _highlightsThreshold;
  64833. private _dofDistance;
  64834. private _dofAperture;
  64835. private _dofDarken;
  64836. private _dofPentagon;
  64837. private _blurNoise;
  64838. /**
  64839. * @constructor
  64840. *
  64841. * Effect parameters are as follow:
  64842. * {
  64843. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64844. * edge_blur: number; // from 0 to x (1 for realism)
  64845. * distortion: number; // from 0 to x (1 for realism)
  64846. * grain_amount: number; // from 0 to 1
  64847. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64848. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64849. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64850. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64851. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64852. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64853. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64854. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64855. * }
  64856. * Note: if an effect parameter is unset, effect is disabled
  64857. *
  64858. * @param name The rendering pipeline name
  64859. * @param parameters - An object containing all parameters (see above)
  64860. * @param scene The scene linked to this pipeline
  64861. * @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)
  64862. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64863. */
  64864. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64865. /**
  64866. * Get the class name
  64867. * @returns "LensRenderingPipeline"
  64868. */
  64869. getClassName(): string;
  64870. /**
  64871. * Gets associated scene
  64872. */
  64873. readonly scene: Scene;
  64874. /**
  64875. * Gets or sets the edge blur
  64876. */
  64877. edgeBlur: number;
  64878. /**
  64879. * Gets or sets the grain amount
  64880. */
  64881. grainAmount: number;
  64882. /**
  64883. * Gets or sets the chromatic aberration amount
  64884. */
  64885. chromaticAberration: number;
  64886. /**
  64887. * Gets or sets the depth of field aperture
  64888. */
  64889. dofAperture: number;
  64890. /**
  64891. * Gets or sets the edge distortion
  64892. */
  64893. edgeDistortion: number;
  64894. /**
  64895. * Gets or sets the depth of field distortion
  64896. */
  64897. dofDistortion: number;
  64898. /**
  64899. * Gets or sets the darken out of focus amount
  64900. */
  64901. darkenOutOfFocus: number;
  64902. /**
  64903. * Gets or sets a boolean indicating if blur noise is enabled
  64904. */
  64905. blurNoise: boolean;
  64906. /**
  64907. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64908. */
  64909. pentagonBokeh: boolean;
  64910. /**
  64911. * Gets or sets the highlight grain amount
  64912. */
  64913. highlightsGain: number;
  64914. /**
  64915. * Gets or sets the highlight threshold
  64916. */
  64917. highlightsThreshold: number;
  64918. /**
  64919. * Sets the amount of blur at the edges
  64920. * @param amount blur amount
  64921. */
  64922. setEdgeBlur(amount: number): void;
  64923. /**
  64924. * Sets edge blur to 0
  64925. */
  64926. disableEdgeBlur(): void;
  64927. /**
  64928. * Sets the amout of grain
  64929. * @param amount Amount of grain
  64930. */
  64931. setGrainAmount(amount: number): void;
  64932. /**
  64933. * Set grain amount to 0
  64934. */
  64935. disableGrain(): void;
  64936. /**
  64937. * Sets the chromatic aberration amount
  64938. * @param amount amount of chromatic aberration
  64939. */
  64940. setChromaticAberration(amount: number): void;
  64941. /**
  64942. * Sets chromatic aberration amount to 0
  64943. */
  64944. disableChromaticAberration(): void;
  64945. /**
  64946. * Sets the EdgeDistortion amount
  64947. * @param amount amount of EdgeDistortion
  64948. */
  64949. setEdgeDistortion(amount: number): void;
  64950. /**
  64951. * Sets edge distortion to 0
  64952. */
  64953. disableEdgeDistortion(): void;
  64954. /**
  64955. * Sets the FocusDistance amount
  64956. * @param amount amount of FocusDistance
  64957. */
  64958. setFocusDistance(amount: number): void;
  64959. /**
  64960. * Disables depth of field
  64961. */
  64962. disableDepthOfField(): void;
  64963. /**
  64964. * Sets the Aperture amount
  64965. * @param amount amount of Aperture
  64966. */
  64967. setAperture(amount: number): void;
  64968. /**
  64969. * Sets the DarkenOutOfFocus amount
  64970. * @param amount amount of DarkenOutOfFocus
  64971. */
  64972. setDarkenOutOfFocus(amount: number): void;
  64973. private _pentagonBokehIsEnabled;
  64974. /**
  64975. * Creates a pentagon bokeh effect
  64976. */
  64977. enablePentagonBokeh(): void;
  64978. /**
  64979. * Disables the pentagon bokeh effect
  64980. */
  64981. disablePentagonBokeh(): void;
  64982. /**
  64983. * Enables noise blur
  64984. */
  64985. enableNoiseBlur(): void;
  64986. /**
  64987. * Disables noise blur
  64988. */
  64989. disableNoiseBlur(): void;
  64990. /**
  64991. * Sets the HighlightsGain amount
  64992. * @param amount amount of HighlightsGain
  64993. */
  64994. setHighlightsGain(amount: number): void;
  64995. /**
  64996. * Sets the HighlightsThreshold amount
  64997. * @param amount amount of HighlightsThreshold
  64998. */
  64999. setHighlightsThreshold(amount: number): void;
  65000. /**
  65001. * Disables highlights
  65002. */
  65003. disableHighlights(): void;
  65004. /**
  65005. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65006. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65007. */
  65008. dispose(disableDepthRender?: boolean): void;
  65009. private _createChromaticAberrationPostProcess;
  65010. private _createHighlightsPostProcess;
  65011. private _createDepthOfFieldPostProcess;
  65012. private _createGrainTexture;
  65013. }
  65014. }
  65015. declare module "babylonjs/Shaders/ssao2.fragment" {
  65016. /** @hidden */
  65017. export var ssao2PixelShader: {
  65018. name: string;
  65019. shader: string;
  65020. };
  65021. }
  65022. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65023. /** @hidden */
  65024. export var ssaoCombinePixelShader: {
  65025. name: string;
  65026. shader: string;
  65027. };
  65028. }
  65029. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65030. import { Camera } from "babylonjs/Cameras/camera";
  65031. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65032. import { Scene } from "babylonjs/scene";
  65033. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65034. import "babylonjs/Shaders/ssao2.fragment";
  65035. import "babylonjs/Shaders/ssaoCombine.fragment";
  65036. /**
  65037. * Render pipeline to produce ssao effect
  65038. */
  65039. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65040. /**
  65041. * @ignore
  65042. * The PassPostProcess id in the pipeline that contains the original scene color
  65043. */
  65044. SSAOOriginalSceneColorEffect: string;
  65045. /**
  65046. * @ignore
  65047. * The SSAO PostProcess id in the pipeline
  65048. */
  65049. SSAORenderEffect: string;
  65050. /**
  65051. * @ignore
  65052. * The horizontal blur PostProcess id in the pipeline
  65053. */
  65054. SSAOBlurHRenderEffect: string;
  65055. /**
  65056. * @ignore
  65057. * The vertical blur PostProcess id in the pipeline
  65058. */
  65059. SSAOBlurVRenderEffect: string;
  65060. /**
  65061. * @ignore
  65062. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65063. */
  65064. SSAOCombineRenderEffect: string;
  65065. /**
  65066. * The output strength of the SSAO post-process. Default value is 1.0.
  65067. */
  65068. totalStrength: number;
  65069. /**
  65070. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65071. */
  65072. maxZ: number;
  65073. /**
  65074. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65075. */
  65076. minZAspect: number;
  65077. private _samples;
  65078. /**
  65079. * Number of samples used for the SSAO calculations. Default value is 8
  65080. */
  65081. samples: number;
  65082. private _textureSamples;
  65083. /**
  65084. * Number of samples to use for antialiasing
  65085. */
  65086. textureSamples: number;
  65087. /**
  65088. * Ratio object used for SSAO ratio and blur ratio
  65089. */
  65090. private _ratio;
  65091. /**
  65092. * Dynamically generated sphere sampler.
  65093. */
  65094. private _sampleSphere;
  65095. /**
  65096. * Blur filter offsets
  65097. */
  65098. private _samplerOffsets;
  65099. private _expensiveBlur;
  65100. /**
  65101. * If bilateral blur should be used
  65102. */
  65103. expensiveBlur: boolean;
  65104. /**
  65105. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65106. */
  65107. radius: number;
  65108. /**
  65109. * The base color of the SSAO post-process
  65110. * The final result is "base + ssao" between [0, 1]
  65111. */
  65112. base: number;
  65113. /**
  65114. * Support test.
  65115. */
  65116. static readonly IsSupported: boolean;
  65117. private _scene;
  65118. private _depthTexture;
  65119. private _normalTexture;
  65120. private _randomTexture;
  65121. private _originalColorPostProcess;
  65122. private _ssaoPostProcess;
  65123. private _blurHPostProcess;
  65124. private _blurVPostProcess;
  65125. private _ssaoCombinePostProcess;
  65126. /**
  65127. * Gets active scene
  65128. */
  65129. readonly scene: Scene;
  65130. /**
  65131. * @constructor
  65132. * @param name The rendering pipeline name
  65133. * @param scene The scene linked to this pipeline
  65134. * @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 }
  65135. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65136. */
  65137. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65138. /**
  65139. * Get the class name
  65140. * @returns "SSAO2RenderingPipeline"
  65141. */
  65142. getClassName(): string;
  65143. /**
  65144. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65145. */
  65146. dispose(disableGeometryBufferRenderer?: boolean): void;
  65147. private _createBlurPostProcess;
  65148. /** @hidden */
  65149. _rebuild(): void;
  65150. private _bits;
  65151. private _radicalInverse_VdC;
  65152. private _hammersley;
  65153. private _hemisphereSample_uniform;
  65154. private _generateHemisphere;
  65155. private _createSSAOPostProcess;
  65156. private _createSSAOCombinePostProcess;
  65157. private _createRandomTexture;
  65158. /**
  65159. * Serialize the rendering pipeline (Used when exporting)
  65160. * @returns the serialized object
  65161. */
  65162. serialize(): any;
  65163. /**
  65164. * Parse the serialized pipeline
  65165. * @param source Source pipeline.
  65166. * @param scene The scene to load the pipeline to.
  65167. * @param rootUrl The URL of the serialized pipeline.
  65168. * @returns An instantiated pipeline from the serialized object.
  65169. */
  65170. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65171. }
  65172. }
  65173. declare module "babylonjs/Shaders/ssao.fragment" {
  65174. /** @hidden */
  65175. export var ssaoPixelShader: {
  65176. name: string;
  65177. shader: string;
  65178. };
  65179. }
  65180. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65181. import { Camera } from "babylonjs/Cameras/camera";
  65182. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65183. import { Scene } from "babylonjs/scene";
  65184. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65185. import "babylonjs/Shaders/ssao.fragment";
  65186. import "babylonjs/Shaders/ssaoCombine.fragment";
  65187. /**
  65188. * Render pipeline to produce ssao effect
  65189. */
  65190. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65191. /**
  65192. * @ignore
  65193. * The PassPostProcess id in the pipeline that contains the original scene color
  65194. */
  65195. SSAOOriginalSceneColorEffect: string;
  65196. /**
  65197. * @ignore
  65198. * The SSAO PostProcess id in the pipeline
  65199. */
  65200. SSAORenderEffect: string;
  65201. /**
  65202. * @ignore
  65203. * The horizontal blur PostProcess id in the pipeline
  65204. */
  65205. SSAOBlurHRenderEffect: string;
  65206. /**
  65207. * @ignore
  65208. * The vertical blur PostProcess id in the pipeline
  65209. */
  65210. SSAOBlurVRenderEffect: string;
  65211. /**
  65212. * @ignore
  65213. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65214. */
  65215. SSAOCombineRenderEffect: string;
  65216. /**
  65217. * The output strength of the SSAO post-process. Default value is 1.0.
  65218. */
  65219. totalStrength: number;
  65220. /**
  65221. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65222. */
  65223. radius: number;
  65224. /**
  65225. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65226. * Must not be equal to fallOff and superior to fallOff.
  65227. * Default value is 0.0075
  65228. */
  65229. area: number;
  65230. /**
  65231. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65232. * Must not be equal to area and inferior to area.
  65233. * Default value is 0.000001
  65234. */
  65235. fallOff: number;
  65236. /**
  65237. * The base color of the SSAO post-process
  65238. * The final result is "base + ssao" between [0, 1]
  65239. */
  65240. base: number;
  65241. private _scene;
  65242. private _depthTexture;
  65243. private _randomTexture;
  65244. private _originalColorPostProcess;
  65245. private _ssaoPostProcess;
  65246. private _blurHPostProcess;
  65247. private _blurVPostProcess;
  65248. private _ssaoCombinePostProcess;
  65249. private _firstUpdate;
  65250. /**
  65251. * Gets active scene
  65252. */
  65253. readonly scene: Scene;
  65254. /**
  65255. * @constructor
  65256. * @param name - The rendering pipeline name
  65257. * @param scene - The scene linked to this pipeline
  65258. * @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 }
  65259. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65260. */
  65261. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65262. /**
  65263. * Get the class name
  65264. * @returns "SSAORenderingPipeline"
  65265. */
  65266. getClassName(): string;
  65267. /**
  65268. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65269. */
  65270. dispose(disableDepthRender?: boolean): void;
  65271. private _createBlurPostProcess;
  65272. /** @hidden */
  65273. _rebuild(): void;
  65274. private _createSSAOPostProcess;
  65275. private _createSSAOCombinePostProcess;
  65276. private _createRandomTexture;
  65277. }
  65278. }
  65279. declare module "babylonjs/Shaders/standard.fragment" {
  65280. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65281. /** @hidden */
  65282. export var standardPixelShader: {
  65283. name: string;
  65284. shader: string;
  65285. };
  65286. }
  65287. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65288. import { Nullable } from "babylonjs/types";
  65289. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65290. import { Camera } from "babylonjs/Cameras/camera";
  65291. import { Texture } from "babylonjs/Materials/Textures/texture";
  65292. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65293. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65294. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65295. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65296. import { IDisposable } from "babylonjs/scene";
  65297. import { SpotLight } from "babylonjs/Lights/spotLight";
  65298. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65299. import { Scene } from "babylonjs/scene";
  65300. import { Animation } from "babylonjs/Animations/animation";
  65301. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65302. import "babylonjs/Shaders/standard.fragment";
  65303. /**
  65304. * Standard rendering pipeline
  65305. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65306. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65307. */
  65308. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65309. /**
  65310. * Public members
  65311. */
  65312. /**
  65313. * Post-process which contains the original scene color before the pipeline applies all the effects
  65314. */
  65315. originalPostProcess: Nullable<PostProcess>;
  65316. /**
  65317. * Post-process used to down scale an image x4
  65318. */
  65319. downSampleX4PostProcess: Nullable<PostProcess>;
  65320. /**
  65321. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65322. */
  65323. brightPassPostProcess: Nullable<PostProcess>;
  65324. /**
  65325. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65326. */
  65327. blurHPostProcesses: PostProcess[];
  65328. /**
  65329. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65330. */
  65331. blurVPostProcesses: PostProcess[];
  65332. /**
  65333. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65334. */
  65335. textureAdderPostProcess: Nullable<PostProcess>;
  65336. /**
  65337. * Post-process used to create volumetric lighting effect
  65338. */
  65339. volumetricLightPostProcess: Nullable<PostProcess>;
  65340. /**
  65341. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65342. */
  65343. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65344. /**
  65345. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65346. */
  65347. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65348. /**
  65349. * Post-process used to merge the volumetric light effect and the real scene color
  65350. */
  65351. volumetricLightMergePostProces: Nullable<PostProcess>;
  65352. /**
  65353. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65354. */
  65355. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65356. /**
  65357. * Base post-process used to calculate the average luminance of the final image for HDR
  65358. */
  65359. luminancePostProcess: Nullable<PostProcess>;
  65360. /**
  65361. * Post-processes used to create down sample post-processes in order to get
  65362. * the average luminance of the final image for HDR
  65363. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65364. */
  65365. luminanceDownSamplePostProcesses: PostProcess[];
  65366. /**
  65367. * Post-process used to create a HDR effect (light adaptation)
  65368. */
  65369. hdrPostProcess: Nullable<PostProcess>;
  65370. /**
  65371. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65372. */
  65373. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65374. /**
  65375. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65376. */
  65377. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65378. /**
  65379. * Post-process used to merge the final HDR post-process and the real scene color
  65380. */
  65381. hdrFinalPostProcess: Nullable<PostProcess>;
  65382. /**
  65383. * Post-process used to create a lens flare effect
  65384. */
  65385. lensFlarePostProcess: Nullable<PostProcess>;
  65386. /**
  65387. * Post-process that merges the result of the lens flare post-process and the real scene color
  65388. */
  65389. lensFlareComposePostProcess: Nullable<PostProcess>;
  65390. /**
  65391. * Post-process used to create a motion blur effect
  65392. */
  65393. motionBlurPostProcess: Nullable<PostProcess>;
  65394. /**
  65395. * Post-process used to create a depth of field effect
  65396. */
  65397. depthOfFieldPostProcess: Nullable<PostProcess>;
  65398. /**
  65399. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65400. */
  65401. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65402. /**
  65403. * Represents the brightness threshold in order to configure the illuminated surfaces
  65404. */
  65405. brightThreshold: number;
  65406. /**
  65407. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65408. */
  65409. blurWidth: number;
  65410. /**
  65411. * Sets if the blur for highlighted surfaces must be only horizontal
  65412. */
  65413. horizontalBlur: boolean;
  65414. /**
  65415. * Gets the overall exposure used by the pipeline
  65416. */
  65417. /**
  65418. * Sets the overall exposure used by the pipeline
  65419. */
  65420. exposure: number;
  65421. /**
  65422. * Texture used typically to simulate "dirty" on camera lens
  65423. */
  65424. lensTexture: Nullable<Texture>;
  65425. /**
  65426. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65427. */
  65428. volumetricLightCoefficient: number;
  65429. /**
  65430. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65431. */
  65432. volumetricLightPower: number;
  65433. /**
  65434. * Used the set the blur intensity to smooth the volumetric lights
  65435. */
  65436. volumetricLightBlurScale: number;
  65437. /**
  65438. * Light (spot or directional) used to generate the volumetric lights rays
  65439. * The source light must have a shadow generate so the pipeline can get its
  65440. * depth map
  65441. */
  65442. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65443. /**
  65444. * For eye adaptation, represents the minimum luminance the eye can see
  65445. */
  65446. hdrMinimumLuminance: number;
  65447. /**
  65448. * For eye adaptation, represents the decrease luminance speed
  65449. */
  65450. hdrDecreaseRate: number;
  65451. /**
  65452. * For eye adaptation, represents the increase luminance speed
  65453. */
  65454. hdrIncreaseRate: number;
  65455. /**
  65456. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65457. */
  65458. /**
  65459. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65460. */
  65461. hdrAutoExposure: boolean;
  65462. /**
  65463. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65464. */
  65465. lensColorTexture: Nullable<Texture>;
  65466. /**
  65467. * The overall strengh for the lens flare effect
  65468. */
  65469. lensFlareStrength: number;
  65470. /**
  65471. * Dispersion coefficient for lens flare ghosts
  65472. */
  65473. lensFlareGhostDispersal: number;
  65474. /**
  65475. * Main lens flare halo width
  65476. */
  65477. lensFlareHaloWidth: number;
  65478. /**
  65479. * Based on the lens distortion effect, defines how much the lens flare result
  65480. * is distorted
  65481. */
  65482. lensFlareDistortionStrength: number;
  65483. /**
  65484. * Configures the blur intensity used for for lens flare (halo)
  65485. */
  65486. lensFlareBlurWidth: number;
  65487. /**
  65488. * Lens star texture must be used to simulate rays on the flares and is available
  65489. * in the documentation
  65490. */
  65491. lensStarTexture: Nullable<Texture>;
  65492. /**
  65493. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65494. * flare effect by taking account of the dirt texture
  65495. */
  65496. lensFlareDirtTexture: Nullable<Texture>;
  65497. /**
  65498. * Represents the focal length for the depth of field effect
  65499. */
  65500. depthOfFieldDistance: number;
  65501. /**
  65502. * Represents the blur intensity for the blurred part of the depth of field effect
  65503. */
  65504. depthOfFieldBlurWidth: number;
  65505. /**
  65506. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65507. */
  65508. /**
  65509. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65510. */
  65511. motionStrength: number;
  65512. /**
  65513. * Gets wether or not the motion blur post-process is object based or screen based.
  65514. */
  65515. /**
  65516. * Sets wether or not the motion blur post-process should be object based or screen based
  65517. */
  65518. objectBasedMotionBlur: boolean;
  65519. /**
  65520. * List of animations for the pipeline (IAnimatable implementation)
  65521. */
  65522. animations: Animation[];
  65523. /**
  65524. * Private members
  65525. */
  65526. private _scene;
  65527. private _currentDepthOfFieldSource;
  65528. private _basePostProcess;
  65529. private _fixedExposure;
  65530. private _currentExposure;
  65531. private _hdrAutoExposure;
  65532. private _hdrCurrentLuminance;
  65533. private _motionStrength;
  65534. private _isObjectBasedMotionBlur;
  65535. private _floatTextureType;
  65536. private _camerasToBeAttached;
  65537. private _ratio;
  65538. private _bloomEnabled;
  65539. private _depthOfFieldEnabled;
  65540. private _vlsEnabled;
  65541. private _lensFlareEnabled;
  65542. private _hdrEnabled;
  65543. private _motionBlurEnabled;
  65544. private _fxaaEnabled;
  65545. private _motionBlurSamples;
  65546. private _volumetricLightStepsCount;
  65547. private _samples;
  65548. /**
  65549. * @ignore
  65550. * Specifies if the bloom pipeline is enabled
  65551. */
  65552. BloomEnabled: boolean;
  65553. /**
  65554. * @ignore
  65555. * Specifies if the depth of field pipeline is enabed
  65556. */
  65557. DepthOfFieldEnabled: boolean;
  65558. /**
  65559. * @ignore
  65560. * Specifies if the lens flare pipeline is enabed
  65561. */
  65562. LensFlareEnabled: boolean;
  65563. /**
  65564. * @ignore
  65565. * Specifies if the HDR pipeline is enabled
  65566. */
  65567. HDREnabled: boolean;
  65568. /**
  65569. * @ignore
  65570. * Specifies if the volumetric lights scattering effect is enabled
  65571. */
  65572. VLSEnabled: boolean;
  65573. /**
  65574. * @ignore
  65575. * Specifies if the motion blur effect is enabled
  65576. */
  65577. MotionBlurEnabled: boolean;
  65578. /**
  65579. * Specifies if anti-aliasing is enabled
  65580. */
  65581. fxaaEnabled: boolean;
  65582. /**
  65583. * Specifies the number of steps used to calculate the volumetric lights
  65584. * Typically in interval [50, 200]
  65585. */
  65586. volumetricLightStepsCount: number;
  65587. /**
  65588. * Specifies the number of samples used for the motion blur effect
  65589. * Typically in interval [16, 64]
  65590. */
  65591. motionBlurSamples: number;
  65592. /**
  65593. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65594. */
  65595. samples: number;
  65596. /**
  65597. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65598. * @constructor
  65599. * @param name The rendering pipeline name
  65600. * @param scene The scene linked to this pipeline
  65601. * @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)
  65602. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65603. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65604. */
  65605. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65606. private _buildPipeline;
  65607. private _createDownSampleX4PostProcess;
  65608. private _createBrightPassPostProcess;
  65609. private _createBlurPostProcesses;
  65610. private _createTextureAdderPostProcess;
  65611. private _createVolumetricLightPostProcess;
  65612. private _createLuminancePostProcesses;
  65613. private _createHdrPostProcess;
  65614. private _createLensFlarePostProcess;
  65615. private _createDepthOfFieldPostProcess;
  65616. private _createMotionBlurPostProcess;
  65617. private _getDepthTexture;
  65618. private _disposePostProcesses;
  65619. /**
  65620. * Dispose of the pipeline and stop all post processes
  65621. */
  65622. dispose(): void;
  65623. /**
  65624. * Serialize the rendering pipeline (Used when exporting)
  65625. * @returns the serialized object
  65626. */
  65627. serialize(): any;
  65628. /**
  65629. * Parse the serialized pipeline
  65630. * @param source Source pipeline.
  65631. * @param scene The scene to load the pipeline to.
  65632. * @param rootUrl The URL of the serialized pipeline.
  65633. * @returns An instantiated pipeline from the serialized object.
  65634. */
  65635. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65636. /**
  65637. * Luminance steps
  65638. */
  65639. static LuminanceSteps: number;
  65640. }
  65641. }
  65642. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65643. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65644. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65645. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65646. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65647. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65648. }
  65649. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65650. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65651. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65652. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65653. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65654. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65655. }
  65656. declare module "babylonjs/Shaders/tonemap.fragment" {
  65657. /** @hidden */
  65658. export var tonemapPixelShader: {
  65659. name: string;
  65660. shader: string;
  65661. };
  65662. }
  65663. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65664. import { Camera } from "babylonjs/Cameras/camera";
  65665. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65666. import "babylonjs/Shaders/tonemap.fragment";
  65667. import { Engine } from "babylonjs/Engines/engine";
  65668. /** Defines operator used for tonemapping */
  65669. export enum TonemappingOperator {
  65670. /** Hable */
  65671. Hable = 0,
  65672. /** Reinhard */
  65673. Reinhard = 1,
  65674. /** HejiDawson */
  65675. HejiDawson = 2,
  65676. /** Photographic */
  65677. Photographic = 3
  65678. }
  65679. /**
  65680. * Defines a post process to apply tone mapping
  65681. */
  65682. export class TonemapPostProcess extends PostProcess {
  65683. private _operator;
  65684. /** Defines the required exposure adjustement */
  65685. exposureAdjustment: number;
  65686. /**
  65687. * Creates a new TonemapPostProcess
  65688. * @param name defines the name of the postprocess
  65689. * @param _operator defines the operator to use
  65690. * @param exposureAdjustment defines the required exposure adjustement
  65691. * @param camera defines the camera to use (can be null)
  65692. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65693. * @param engine defines the hosting engine (can be ignore if camera is set)
  65694. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65695. */
  65696. constructor(name: string, _operator: TonemappingOperator,
  65697. /** Defines the required exposure adjustement */
  65698. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65699. }
  65700. }
  65701. declare module "babylonjs/Shaders/depth.vertex" {
  65702. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65703. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65704. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65705. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65706. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65707. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65708. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65709. /** @hidden */
  65710. export var depthVertexShader: {
  65711. name: string;
  65712. shader: string;
  65713. };
  65714. }
  65715. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65716. /** @hidden */
  65717. export var volumetricLightScatteringPixelShader: {
  65718. name: string;
  65719. shader: string;
  65720. };
  65721. }
  65722. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65723. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65724. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65725. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65726. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65727. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65728. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65729. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65730. /** @hidden */
  65731. export var volumetricLightScatteringPassVertexShader: {
  65732. name: string;
  65733. shader: string;
  65734. };
  65735. }
  65736. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65737. /** @hidden */
  65738. export var volumetricLightScatteringPassPixelShader: {
  65739. name: string;
  65740. shader: string;
  65741. };
  65742. }
  65743. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65744. import { Vector3 } from "babylonjs/Maths/math.vector";
  65745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65746. import { Mesh } from "babylonjs/Meshes/mesh";
  65747. import { Camera } from "babylonjs/Cameras/camera";
  65748. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65749. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65750. import { Scene } from "babylonjs/scene";
  65751. import "babylonjs/Meshes/Builders/planeBuilder";
  65752. import "babylonjs/Shaders/depth.vertex";
  65753. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65754. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65755. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65756. import { Engine } from "babylonjs/Engines/engine";
  65757. /**
  65758. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65759. */
  65760. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65761. private _volumetricLightScatteringPass;
  65762. private _volumetricLightScatteringRTT;
  65763. private _viewPort;
  65764. private _screenCoordinates;
  65765. private _cachedDefines;
  65766. /**
  65767. * If not undefined, the mesh position is computed from the attached node position
  65768. */
  65769. attachedNode: {
  65770. position: Vector3;
  65771. };
  65772. /**
  65773. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65774. */
  65775. customMeshPosition: Vector3;
  65776. /**
  65777. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65778. */
  65779. useCustomMeshPosition: boolean;
  65780. /**
  65781. * If the post-process should inverse the light scattering direction
  65782. */
  65783. invert: boolean;
  65784. /**
  65785. * The internal mesh used by the post-process
  65786. */
  65787. mesh: Mesh;
  65788. /**
  65789. * @hidden
  65790. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65791. */
  65792. useDiffuseColor: boolean;
  65793. /**
  65794. * Array containing the excluded meshes not rendered in the internal pass
  65795. */
  65796. excludedMeshes: AbstractMesh[];
  65797. /**
  65798. * Controls the overall intensity of the post-process
  65799. */
  65800. exposure: number;
  65801. /**
  65802. * Dissipates each sample's contribution in range [0, 1]
  65803. */
  65804. decay: number;
  65805. /**
  65806. * Controls the overall intensity of each sample
  65807. */
  65808. weight: number;
  65809. /**
  65810. * Controls the density of each sample
  65811. */
  65812. density: number;
  65813. /**
  65814. * @constructor
  65815. * @param name The post-process name
  65816. * @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)
  65817. * @param camera The camera that the post-process will be attached to
  65818. * @param mesh The mesh used to create the light scattering
  65819. * @param samples The post-process quality, default 100
  65820. * @param samplingModeThe post-process filtering mode
  65821. * @param engine The babylon engine
  65822. * @param reusable If the post-process is reusable
  65823. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65824. */
  65825. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65826. /**
  65827. * Returns the string "VolumetricLightScatteringPostProcess"
  65828. * @returns "VolumetricLightScatteringPostProcess"
  65829. */
  65830. getClassName(): string;
  65831. private _isReady;
  65832. /**
  65833. * Sets the new light position for light scattering effect
  65834. * @param position The new custom light position
  65835. */
  65836. setCustomMeshPosition(position: Vector3): void;
  65837. /**
  65838. * Returns the light position for light scattering effect
  65839. * @return Vector3 The custom light position
  65840. */
  65841. getCustomMeshPosition(): Vector3;
  65842. /**
  65843. * Disposes the internal assets and detaches the post-process from the camera
  65844. */
  65845. dispose(camera: Camera): void;
  65846. /**
  65847. * Returns the render target texture used by the post-process
  65848. * @return the render target texture used by the post-process
  65849. */
  65850. getPass(): RenderTargetTexture;
  65851. private _meshExcluded;
  65852. private _createPass;
  65853. private _updateMeshScreenCoordinates;
  65854. /**
  65855. * Creates a default mesh for the Volumeric Light Scattering post-process
  65856. * @param name The mesh name
  65857. * @param scene The scene where to create the mesh
  65858. * @return the default mesh
  65859. */
  65860. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65861. }
  65862. }
  65863. declare module "babylonjs/PostProcesses/index" {
  65864. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65865. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65866. export * from "babylonjs/PostProcesses/bloomEffect";
  65867. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65868. export * from "babylonjs/PostProcesses/blurPostProcess";
  65869. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65870. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65871. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65872. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65873. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65874. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65875. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65876. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65877. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65878. export * from "babylonjs/PostProcesses/filterPostProcess";
  65879. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65880. export * from "babylonjs/PostProcesses/grainPostProcess";
  65881. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65882. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65883. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65884. export * from "babylonjs/PostProcesses/passPostProcess";
  65885. export * from "babylonjs/PostProcesses/postProcess";
  65886. export * from "babylonjs/PostProcesses/postProcessManager";
  65887. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65888. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65889. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65890. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65891. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65892. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65893. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65894. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65895. }
  65896. declare module "babylonjs/Probes/index" {
  65897. export * from "babylonjs/Probes/reflectionProbe";
  65898. }
  65899. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65900. import { Scene } from "babylonjs/scene";
  65901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65902. import { SmartArray } from "babylonjs/Misc/smartArray";
  65903. import { ISceneComponent } from "babylonjs/sceneComponent";
  65904. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65905. import "babylonjs/Meshes/Builders/boxBuilder";
  65906. import "babylonjs/Shaders/color.fragment";
  65907. import "babylonjs/Shaders/color.vertex";
  65908. import { Color3 } from "babylonjs/Maths/math.color";
  65909. module "babylonjs/scene" {
  65910. interface Scene {
  65911. /** @hidden (Backing field) */
  65912. _boundingBoxRenderer: BoundingBoxRenderer;
  65913. /** @hidden (Backing field) */
  65914. _forceShowBoundingBoxes: boolean;
  65915. /**
  65916. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65917. */
  65918. forceShowBoundingBoxes: boolean;
  65919. /**
  65920. * Gets the bounding box renderer associated with the scene
  65921. * @returns a BoundingBoxRenderer
  65922. */
  65923. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65924. }
  65925. }
  65926. module "babylonjs/Meshes/abstractMesh" {
  65927. interface AbstractMesh {
  65928. /** @hidden (Backing field) */
  65929. _showBoundingBox: boolean;
  65930. /**
  65931. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65932. */
  65933. showBoundingBox: boolean;
  65934. }
  65935. }
  65936. /**
  65937. * Component responsible of rendering the bounding box of the meshes in a scene.
  65938. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65939. */
  65940. export class BoundingBoxRenderer implements ISceneComponent {
  65941. /**
  65942. * The component name helpfull to identify the component in the list of scene components.
  65943. */
  65944. readonly name: string;
  65945. /**
  65946. * The scene the component belongs to.
  65947. */
  65948. scene: Scene;
  65949. /**
  65950. * Color of the bounding box lines placed in front of an object
  65951. */
  65952. frontColor: Color3;
  65953. /**
  65954. * Color of the bounding box lines placed behind an object
  65955. */
  65956. backColor: Color3;
  65957. /**
  65958. * Defines if the renderer should show the back lines or not
  65959. */
  65960. showBackLines: boolean;
  65961. /**
  65962. * @hidden
  65963. */
  65964. renderList: SmartArray<BoundingBox>;
  65965. private _colorShader;
  65966. private _vertexBuffers;
  65967. private _indexBuffer;
  65968. private _fillIndexBuffer;
  65969. private _fillIndexData;
  65970. /**
  65971. * Instantiates a new bounding box renderer in a scene.
  65972. * @param scene the scene the renderer renders in
  65973. */
  65974. constructor(scene: Scene);
  65975. /**
  65976. * Registers the component in a given scene
  65977. */
  65978. register(): void;
  65979. private _evaluateSubMesh;
  65980. private _activeMesh;
  65981. private _prepareRessources;
  65982. private _createIndexBuffer;
  65983. /**
  65984. * Rebuilds the elements related to this component in case of
  65985. * context lost for instance.
  65986. */
  65987. rebuild(): void;
  65988. /**
  65989. * @hidden
  65990. */
  65991. reset(): void;
  65992. /**
  65993. * Render the bounding boxes of a specific rendering group
  65994. * @param renderingGroupId defines the rendering group to render
  65995. */
  65996. render(renderingGroupId: number): void;
  65997. /**
  65998. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65999. * @param mesh Define the mesh to render the occlusion bounding box for
  66000. */
  66001. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66002. /**
  66003. * Dispose and release the resources attached to this renderer.
  66004. */
  66005. dispose(): void;
  66006. }
  66007. }
  66008. declare module "babylonjs/Shaders/depth.fragment" {
  66009. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66010. /** @hidden */
  66011. export var depthPixelShader: {
  66012. name: string;
  66013. shader: string;
  66014. };
  66015. }
  66016. declare module "babylonjs/Rendering/depthRenderer" {
  66017. import { Nullable } from "babylonjs/types";
  66018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66019. import { Scene } from "babylonjs/scene";
  66020. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66021. import { Camera } from "babylonjs/Cameras/camera";
  66022. import "babylonjs/Shaders/depth.fragment";
  66023. import "babylonjs/Shaders/depth.vertex";
  66024. /**
  66025. * This represents a depth renderer in Babylon.
  66026. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66027. */
  66028. export class DepthRenderer {
  66029. private _scene;
  66030. private _depthMap;
  66031. private _effect;
  66032. private readonly _storeNonLinearDepth;
  66033. private readonly _clearColor;
  66034. /** Get if the depth renderer is using packed depth or not */
  66035. readonly isPacked: boolean;
  66036. private _cachedDefines;
  66037. private _camera;
  66038. /**
  66039. * Specifiess that the depth renderer will only be used within
  66040. * the camera it is created for.
  66041. * This can help forcing its rendering during the camera processing.
  66042. */
  66043. useOnlyInActiveCamera: boolean;
  66044. /** @hidden */
  66045. static _SceneComponentInitialization: (scene: Scene) => void;
  66046. /**
  66047. * Instantiates a depth renderer
  66048. * @param scene The scene the renderer belongs to
  66049. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66050. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66051. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66052. */
  66053. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66054. /**
  66055. * Creates the depth rendering effect and checks if the effect is ready.
  66056. * @param subMesh The submesh to be used to render the depth map of
  66057. * @param useInstances If multiple world instances should be used
  66058. * @returns if the depth renderer is ready to render the depth map
  66059. */
  66060. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66061. /**
  66062. * Gets the texture which the depth map will be written to.
  66063. * @returns The depth map texture
  66064. */
  66065. getDepthMap(): RenderTargetTexture;
  66066. /**
  66067. * Disposes of the depth renderer.
  66068. */
  66069. dispose(): void;
  66070. }
  66071. }
  66072. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66073. import { Nullable } from "babylonjs/types";
  66074. import { Scene } from "babylonjs/scene";
  66075. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66076. import { Camera } from "babylonjs/Cameras/camera";
  66077. import { ISceneComponent } from "babylonjs/sceneComponent";
  66078. module "babylonjs/scene" {
  66079. interface Scene {
  66080. /** @hidden (Backing field) */
  66081. _depthRenderer: {
  66082. [id: string]: DepthRenderer;
  66083. };
  66084. /**
  66085. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66086. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66087. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66088. * @returns the created depth renderer
  66089. */
  66090. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66091. /**
  66092. * Disables a depth renderer for a given camera
  66093. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66094. */
  66095. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66096. }
  66097. }
  66098. /**
  66099. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66100. * in several rendering techniques.
  66101. */
  66102. export class DepthRendererSceneComponent implements ISceneComponent {
  66103. /**
  66104. * The component name helpfull to identify the component in the list of scene components.
  66105. */
  66106. readonly name: string;
  66107. /**
  66108. * The scene the component belongs to.
  66109. */
  66110. scene: Scene;
  66111. /**
  66112. * Creates a new instance of the component for the given scene
  66113. * @param scene Defines the scene to register the component in
  66114. */
  66115. constructor(scene: Scene);
  66116. /**
  66117. * Registers the component in a given scene
  66118. */
  66119. register(): void;
  66120. /**
  66121. * Rebuilds the elements related to this component in case of
  66122. * context lost for instance.
  66123. */
  66124. rebuild(): void;
  66125. /**
  66126. * Disposes the component and the associated ressources
  66127. */
  66128. dispose(): void;
  66129. private _gatherRenderTargets;
  66130. private _gatherActiveCameraRenderTargets;
  66131. }
  66132. }
  66133. declare module "babylonjs/Shaders/outline.fragment" {
  66134. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66135. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66136. /** @hidden */
  66137. export var outlinePixelShader: {
  66138. name: string;
  66139. shader: string;
  66140. };
  66141. }
  66142. declare module "babylonjs/Shaders/outline.vertex" {
  66143. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66144. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66145. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66146. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66147. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66148. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66149. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66150. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66151. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66152. /** @hidden */
  66153. export var outlineVertexShader: {
  66154. name: string;
  66155. shader: string;
  66156. };
  66157. }
  66158. declare module "babylonjs/Rendering/outlineRenderer" {
  66159. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66160. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66161. import { Scene } from "babylonjs/scene";
  66162. import { ISceneComponent } from "babylonjs/sceneComponent";
  66163. import "babylonjs/Shaders/outline.fragment";
  66164. import "babylonjs/Shaders/outline.vertex";
  66165. module "babylonjs/scene" {
  66166. interface Scene {
  66167. /** @hidden */
  66168. _outlineRenderer: OutlineRenderer;
  66169. /**
  66170. * Gets the outline renderer associated with the scene
  66171. * @returns a OutlineRenderer
  66172. */
  66173. getOutlineRenderer(): OutlineRenderer;
  66174. }
  66175. }
  66176. module "babylonjs/Meshes/abstractMesh" {
  66177. interface AbstractMesh {
  66178. /** @hidden (Backing field) */
  66179. _renderOutline: boolean;
  66180. /**
  66181. * Gets or sets a boolean indicating if the outline must be rendered as well
  66182. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66183. */
  66184. renderOutline: boolean;
  66185. /** @hidden (Backing field) */
  66186. _renderOverlay: boolean;
  66187. /**
  66188. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66189. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66190. */
  66191. renderOverlay: boolean;
  66192. }
  66193. }
  66194. /**
  66195. * This class is responsible to draw bothe outline/overlay of meshes.
  66196. * It should not be used directly but through the available method on mesh.
  66197. */
  66198. export class OutlineRenderer implements ISceneComponent {
  66199. /**
  66200. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66201. */
  66202. private static _StencilReference;
  66203. /**
  66204. * The name of the component. Each component must have a unique name.
  66205. */
  66206. name: string;
  66207. /**
  66208. * The scene the component belongs to.
  66209. */
  66210. scene: Scene;
  66211. /**
  66212. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66213. */
  66214. zOffset: number;
  66215. private _engine;
  66216. private _effect;
  66217. private _cachedDefines;
  66218. private _savedDepthWrite;
  66219. /**
  66220. * Instantiates a new outline renderer. (There could be only one per scene).
  66221. * @param scene Defines the scene it belongs to
  66222. */
  66223. constructor(scene: Scene);
  66224. /**
  66225. * Register the component to one instance of a scene.
  66226. */
  66227. register(): void;
  66228. /**
  66229. * Rebuilds the elements related to this component in case of
  66230. * context lost for instance.
  66231. */
  66232. rebuild(): void;
  66233. /**
  66234. * Disposes the component and the associated ressources.
  66235. */
  66236. dispose(): void;
  66237. /**
  66238. * Renders the outline in the canvas.
  66239. * @param subMesh Defines the sumesh to render
  66240. * @param batch Defines the batch of meshes in case of instances
  66241. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66242. */
  66243. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66244. /**
  66245. * Returns whether or not the outline renderer is ready for a given submesh.
  66246. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66247. * @param subMesh Defines the submesh to check readyness for
  66248. * @param useInstances Defines wheter wee are trying to render instances or not
  66249. * @returns true if ready otherwise false
  66250. */
  66251. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66252. private _beforeRenderingMesh;
  66253. private _afterRenderingMesh;
  66254. }
  66255. }
  66256. declare module "babylonjs/Rendering/index" {
  66257. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66258. export * from "babylonjs/Rendering/depthRenderer";
  66259. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66260. export * from "babylonjs/Rendering/edgesRenderer";
  66261. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66262. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66263. export * from "babylonjs/Rendering/outlineRenderer";
  66264. export * from "babylonjs/Rendering/renderingGroup";
  66265. export * from "babylonjs/Rendering/renderingManager";
  66266. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66267. }
  66268. declare module "babylonjs/Sprites/spritePackedManager" {
  66269. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66270. import { Scene } from "babylonjs/scene";
  66271. /**
  66272. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66273. * @see http://doc.babylonjs.com/babylon101/sprites
  66274. */
  66275. export class SpritePackedManager extends SpriteManager {
  66276. /** defines the packed manager's name */
  66277. name: string;
  66278. /**
  66279. * Creates a new sprite manager from a packed sprite sheet
  66280. * @param name defines the manager's name
  66281. * @param imgUrl defines the sprite sheet url
  66282. * @param capacity defines the maximum allowed number of sprites
  66283. * @param scene defines the hosting scene
  66284. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66285. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66286. * @param samplingMode defines the smapling mode to use with spritesheet
  66287. * @param fromPacked set to true; do not alter
  66288. */
  66289. constructor(
  66290. /** defines the packed manager's name */
  66291. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66292. }
  66293. }
  66294. declare module "babylonjs/Sprites/index" {
  66295. export * from "babylonjs/Sprites/sprite";
  66296. export * from "babylonjs/Sprites/spriteManager";
  66297. export * from "babylonjs/Sprites/spritePackedManager";
  66298. export * from "babylonjs/Sprites/spriteSceneComponent";
  66299. }
  66300. declare module "babylonjs/States/index" {
  66301. export * from "babylonjs/States/alphaCullingState";
  66302. export * from "babylonjs/States/depthCullingState";
  66303. export * from "babylonjs/States/stencilState";
  66304. }
  66305. declare module "babylonjs/Misc/assetsManager" {
  66306. import { Scene } from "babylonjs/scene";
  66307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66308. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66309. import { Skeleton } from "babylonjs/Bones/skeleton";
  66310. import { Observable } from "babylonjs/Misc/observable";
  66311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66312. import { Texture } from "babylonjs/Materials/Textures/texture";
  66313. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66314. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66315. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66316. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66317. /**
  66318. * Defines the list of states available for a task inside a AssetsManager
  66319. */
  66320. export enum AssetTaskState {
  66321. /**
  66322. * Initialization
  66323. */
  66324. INIT = 0,
  66325. /**
  66326. * Running
  66327. */
  66328. RUNNING = 1,
  66329. /**
  66330. * Done
  66331. */
  66332. DONE = 2,
  66333. /**
  66334. * Error
  66335. */
  66336. ERROR = 3
  66337. }
  66338. /**
  66339. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66340. */
  66341. export abstract class AbstractAssetTask {
  66342. /**
  66343. * Task name
  66344. */ name: string;
  66345. /**
  66346. * Callback called when the task is successful
  66347. */
  66348. onSuccess: (task: any) => void;
  66349. /**
  66350. * Callback called when the task is not successful
  66351. */
  66352. onError: (task: any, message?: string, exception?: any) => void;
  66353. /**
  66354. * Creates a new AssetsManager
  66355. * @param name defines the name of the task
  66356. */
  66357. constructor(
  66358. /**
  66359. * Task name
  66360. */ name: string);
  66361. private _isCompleted;
  66362. private _taskState;
  66363. private _errorObject;
  66364. /**
  66365. * Get if the task is completed
  66366. */
  66367. readonly isCompleted: boolean;
  66368. /**
  66369. * Gets the current state of the task
  66370. */
  66371. readonly taskState: AssetTaskState;
  66372. /**
  66373. * Gets the current error object (if task is in error)
  66374. */
  66375. readonly errorObject: {
  66376. message?: string;
  66377. exception?: any;
  66378. };
  66379. /**
  66380. * Internal only
  66381. * @hidden
  66382. */
  66383. _setErrorObject(message?: string, exception?: any): void;
  66384. /**
  66385. * Execute the current task
  66386. * @param scene defines the scene where you want your assets to be loaded
  66387. * @param onSuccess is a callback called when the task is successfully executed
  66388. * @param onError is a callback called if an error occurs
  66389. */
  66390. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66391. /**
  66392. * Execute the current task
  66393. * @param scene defines the scene where you want your assets to be loaded
  66394. * @param onSuccess is a callback called when the task is successfully executed
  66395. * @param onError is a callback called if an error occurs
  66396. */
  66397. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66398. /**
  66399. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66400. * This can be used with failed tasks that have the reason for failure fixed.
  66401. */
  66402. reset(): void;
  66403. private onErrorCallback;
  66404. private onDoneCallback;
  66405. }
  66406. /**
  66407. * Define the interface used by progress events raised during assets loading
  66408. */
  66409. export interface IAssetsProgressEvent {
  66410. /**
  66411. * Defines the number of remaining tasks to process
  66412. */
  66413. remainingCount: number;
  66414. /**
  66415. * Defines the total number of tasks
  66416. */
  66417. totalCount: number;
  66418. /**
  66419. * Defines the task that was just processed
  66420. */
  66421. task: AbstractAssetTask;
  66422. }
  66423. /**
  66424. * Class used to share progress information about assets loading
  66425. */
  66426. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66427. /**
  66428. * Defines the number of remaining tasks to process
  66429. */
  66430. remainingCount: number;
  66431. /**
  66432. * Defines the total number of tasks
  66433. */
  66434. totalCount: number;
  66435. /**
  66436. * Defines the task that was just processed
  66437. */
  66438. task: AbstractAssetTask;
  66439. /**
  66440. * Creates a AssetsProgressEvent
  66441. * @param remainingCount defines the number of remaining tasks to process
  66442. * @param totalCount defines the total number of tasks
  66443. * @param task defines the task that was just processed
  66444. */
  66445. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66446. }
  66447. /**
  66448. * Define a task used by AssetsManager to load meshes
  66449. */
  66450. export class MeshAssetTask extends AbstractAssetTask {
  66451. /**
  66452. * Defines the name of the task
  66453. */
  66454. name: string;
  66455. /**
  66456. * Defines the list of mesh's names you want to load
  66457. */
  66458. meshesNames: any;
  66459. /**
  66460. * Defines the root url to use as a base to load your meshes and associated resources
  66461. */
  66462. rootUrl: string;
  66463. /**
  66464. * Defines the filename of the scene to load from
  66465. */
  66466. sceneFilename: string;
  66467. /**
  66468. * Gets the list of loaded meshes
  66469. */
  66470. loadedMeshes: Array<AbstractMesh>;
  66471. /**
  66472. * Gets the list of loaded particle systems
  66473. */
  66474. loadedParticleSystems: Array<IParticleSystem>;
  66475. /**
  66476. * Gets the list of loaded skeletons
  66477. */
  66478. loadedSkeletons: Array<Skeleton>;
  66479. /**
  66480. * Gets the list of loaded animation groups
  66481. */
  66482. loadedAnimationGroups: Array<AnimationGroup>;
  66483. /**
  66484. * Callback called when the task is successful
  66485. */
  66486. onSuccess: (task: MeshAssetTask) => void;
  66487. /**
  66488. * Callback called when the task is successful
  66489. */
  66490. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66491. /**
  66492. * Creates a new MeshAssetTask
  66493. * @param name defines the name of the task
  66494. * @param meshesNames defines the list of mesh's names you want to load
  66495. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66496. * @param sceneFilename defines the filename of the scene to load from
  66497. */
  66498. constructor(
  66499. /**
  66500. * Defines the name of the task
  66501. */
  66502. name: string,
  66503. /**
  66504. * Defines the list of mesh's names you want to load
  66505. */
  66506. meshesNames: any,
  66507. /**
  66508. * Defines the root url to use as a base to load your meshes and associated resources
  66509. */
  66510. rootUrl: string,
  66511. /**
  66512. * Defines the filename of the scene to load from
  66513. */
  66514. sceneFilename: string);
  66515. /**
  66516. * Execute the current task
  66517. * @param scene defines the scene where you want your assets to be loaded
  66518. * @param onSuccess is a callback called when the task is successfully executed
  66519. * @param onError is a callback called if an error occurs
  66520. */
  66521. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66522. }
  66523. /**
  66524. * Define a task used by AssetsManager to load text content
  66525. */
  66526. export class TextFileAssetTask extends AbstractAssetTask {
  66527. /**
  66528. * Defines the name of the task
  66529. */
  66530. name: string;
  66531. /**
  66532. * Defines the location of the file to load
  66533. */
  66534. url: string;
  66535. /**
  66536. * Gets the loaded text string
  66537. */
  66538. text: string;
  66539. /**
  66540. * Callback called when the task is successful
  66541. */
  66542. onSuccess: (task: TextFileAssetTask) => void;
  66543. /**
  66544. * Callback called when the task is successful
  66545. */
  66546. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66547. /**
  66548. * Creates a new TextFileAssetTask object
  66549. * @param name defines the name of the task
  66550. * @param url defines the location of the file to load
  66551. */
  66552. constructor(
  66553. /**
  66554. * Defines the name of the task
  66555. */
  66556. name: string,
  66557. /**
  66558. * Defines the location of the file to load
  66559. */
  66560. url: string);
  66561. /**
  66562. * Execute the current task
  66563. * @param scene defines the scene where you want your assets to be loaded
  66564. * @param onSuccess is a callback called when the task is successfully executed
  66565. * @param onError is a callback called if an error occurs
  66566. */
  66567. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66568. }
  66569. /**
  66570. * Define a task used by AssetsManager to load binary data
  66571. */
  66572. export class BinaryFileAssetTask extends AbstractAssetTask {
  66573. /**
  66574. * Defines the name of the task
  66575. */
  66576. name: string;
  66577. /**
  66578. * Defines the location of the file to load
  66579. */
  66580. url: string;
  66581. /**
  66582. * Gets the lodaded data (as an array buffer)
  66583. */
  66584. data: ArrayBuffer;
  66585. /**
  66586. * Callback called when the task is successful
  66587. */
  66588. onSuccess: (task: BinaryFileAssetTask) => void;
  66589. /**
  66590. * Callback called when the task is successful
  66591. */
  66592. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66593. /**
  66594. * Creates a new BinaryFileAssetTask object
  66595. * @param name defines the name of the new task
  66596. * @param url defines the location of the file to load
  66597. */
  66598. constructor(
  66599. /**
  66600. * Defines the name of the task
  66601. */
  66602. name: string,
  66603. /**
  66604. * Defines the location of the file to load
  66605. */
  66606. url: string);
  66607. /**
  66608. * Execute the current task
  66609. * @param scene defines the scene where you want your assets to be loaded
  66610. * @param onSuccess is a callback called when the task is successfully executed
  66611. * @param onError is a callback called if an error occurs
  66612. */
  66613. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66614. }
  66615. /**
  66616. * Define a task used by AssetsManager to load images
  66617. */
  66618. export class ImageAssetTask extends AbstractAssetTask {
  66619. /**
  66620. * Defines the name of the task
  66621. */
  66622. name: string;
  66623. /**
  66624. * Defines the location of the image to load
  66625. */
  66626. url: string;
  66627. /**
  66628. * Gets the loaded images
  66629. */
  66630. image: HTMLImageElement;
  66631. /**
  66632. * Callback called when the task is successful
  66633. */
  66634. onSuccess: (task: ImageAssetTask) => void;
  66635. /**
  66636. * Callback called when the task is successful
  66637. */
  66638. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66639. /**
  66640. * Creates a new ImageAssetTask
  66641. * @param name defines the name of the task
  66642. * @param url defines the location of the image to load
  66643. */
  66644. constructor(
  66645. /**
  66646. * Defines the name of the task
  66647. */
  66648. name: string,
  66649. /**
  66650. * Defines the location of the image to load
  66651. */
  66652. url: string);
  66653. /**
  66654. * Execute the current task
  66655. * @param scene defines the scene where you want your assets to be loaded
  66656. * @param onSuccess is a callback called when the task is successfully executed
  66657. * @param onError is a callback called if an error occurs
  66658. */
  66659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66660. }
  66661. /**
  66662. * Defines the interface used by texture loading tasks
  66663. */
  66664. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66665. /**
  66666. * Gets the loaded texture
  66667. */
  66668. texture: TEX;
  66669. }
  66670. /**
  66671. * Define a task used by AssetsManager to load 2D textures
  66672. */
  66673. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66674. /**
  66675. * Defines the name of the task
  66676. */
  66677. name: string;
  66678. /**
  66679. * Defines the location of the file to load
  66680. */
  66681. url: string;
  66682. /**
  66683. * Defines if mipmap should not be generated (default is false)
  66684. */
  66685. noMipmap?: boolean | undefined;
  66686. /**
  66687. * Defines if texture must be inverted on Y axis (default is false)
  66688. */
  66689. invertY?: boolean | undefined;
  66690. /**
  66691. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66692. */
  66693. samplingMode: number;
  66694. /**
  66695. * Gets the loaded texture
  66696. */
  66697. texture: Texture;
  66698. /**
  66699. * Callback called when the task is successful
  66700. */
  66701. onSuccess: (task: TextureAssetTask) => void;
  66702. /**
  66703. * Callback called when the task is successful
  66704. */
  66705. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66706. /**
  66707. * Creates a new TextureAssetTask object
  66708. * @param name defines the name of the task
  66709. * @param url defines the location of the file to load
  66710. * @param noMipmap defines if mipmap should not be generated (default is false)
  66711. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66712. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66713. */
  66714. constructor(
  66715. /**
  66716. * Defines the name of the task
  66717. */
  66718. name: string,
  66719. /**
  66720. * Defines the location of the file to load
  66721. */
  66722. url: string,
  66723. /**
  66724. * Defines if mipmap should not be generated (default is false)
  66725. */
  66726. noMipmap?: boolean | undefined,
  66727. /**
  66728. * Defines if texture must be inverted on Y axis (default is false)
  66729. */
  66730. invertY?: boolean | undefined,
  66731. /**
  66732. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66733. */
  66734. samplingMode?: number);
  66735. /**
  66736. * Execute the current task
  66737. * @param scene defines the scene where you want your assets to be loaded
  66738. * @param onSuccess is a callback called when the task is successfully executed
  66739. * @param onError is a callback called if an error occurs
  66740. */
  66741. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66742. }
  66743. /**
  66744. * Define a task used by AssetsManager to load cube textures
  66745. */
  66746. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66747. /**
  66748. * Defines the name of the task
  66749. */
  66750. name: string;
  66751. /**
  66752. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66753. */
  66754. url: string;
  66755. /**
  66756. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66757. */
  66758. extensions?: string[] | undefined;
  66759. /**
  66760. * Defines if mipmaps should not be generated (default is false)
  66761. */
  66762. noMipmap?: boolean | undefined;
  66763. /**
  66764. * Defines the explicit list of files (undefined by default)
  66765. */
  66766. files?: string[] | undefined;
  66767. /**
  66768. * Gets the loaded texture
  66769. */
  66770. texture: CubeTexture;
  66771. /**
  66772. * Callback called when the task is successful
  66773. */
  66774. onSuccess: (task: CubeTextureAssetTask) => void;
  66775. /**
  66776. * Callback called when the task is successful
  66777. */
  66778. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66779. /**
  66780. * Creates a new CubeTextureAssetTask
  66781. * @param name defines the name of the task
  66782. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66783. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66784. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66785. * @param files defines the explicit list of files (undefined by default)
  66786. */
  66787. constructor(
  66788. /**
  66789. * Defines the name of the task
  66790. */
  66791. name: string,
  66792. /**
  66793. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66794. */
  66795. url: string,
  66796. /**
  66797. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66798. */
  66799. extensions?: string[] | undefined,
  66800. /**
  66801. * Defines if mipmaps should not be generated (default is false)
  66802. */
  66803. noMipmap?: boolean | undefined,
  66804. /**
  66805. * Defines the explicit list of files (undefined by default)
  66806. */
  66807. files?: string[] | undefined);
  66808. /**
  66809. * Execute the current task
  66810. * @param scene defines the scene where you want your assets to be loaded
  66811. * @param onSuccess is a callback called when the task is successfully executed
  66812. * @param onError is a callback called if an error occurs
  66813. */
  66814. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66815. }
  66816. /**
  66817. * Define a task used by AssetsManager to load HDR cube textures
  66818. */
  66819. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66820. /**
  66821. * Defines the name of the task
  66822. */
  66823. name: string;
  66824. /**
  66825. * Defines the location of the file to load
  66826. */
  66827. url: string;
  66828. /**
  66829. * Defines the desired size (the more it increases the longer the generation will be)
  66830. */
  66831. size: number;
  66832. /**
  66833. * Defines if mipmaps should not be generated (default is false)
  66834. */
  66835. noMipmap: boolean;
  66836. /**
  66837. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66838. */
  66839. generateHarmonics: boolean;
  66840. /**
  66841. * 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)
  66842. */
  66843. gammaSpace: boolean;
  66844. /**
  66845. * Internal Use Only
  66846. */
  66847. reserved: boolean;
  66848. /**
  66849. * Gets the loaded texture
  66850. */
  66851. texture: HDRCubeTexture;
  66852. /**
  66853. * Callback called when the task is successful
  66854. */
  66855. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66856. /**
  66857. * Callback called when the task is successful
  66858. */
  66859. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66860. /**
  66861. * Creates a new HDRCubeTextureAssetTask object
  66862. * @param name defines the name of the task
  66863. * @param url defines the location of the file to load
  66864. * @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.
  66865. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66866. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66867. * @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)
  66868. * @param reserved Internal use only
  66869. */
  66870. constructor(
  66871. /**
  66872. * Defines the name of the task
  66873. */
  66874. name: string,
  66875. /**
  66876. * Defines the location of the file to load
  66877. */
  66878. url: string,
  66879. /**
  66880. * Defines the desired size (the more it increases the longer the generation will be)
  66881. */
  66882. size: number,
  66883. /**
  66884. * Defines if mipmaps should not be generated (default is false)
  66885. */
  66886. noMipmap?: boolean,
  66887. /**
  66888. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66889. */
  66890. generateHarmonics?: boolean,
  66891. /**
  66892. * 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)
  66893. */
  66894. gammaSpace?: boolean,
  66895. /**
  66896. * Internal Use Only
  66897. */
  66898. reserved?: boolean);
  66899. /**
  66900. * Execute the current task
  66901. * @param scene defines the scene where you want your assets to be loaded
  66902. * @param onSuccess is a callback called when the task is successfully executed
  66903. * @param onError is a callback called if an error occurs
  66904. */
  66905. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66906. }
  66907. /**
  66908. * Define a task used by AssetsManager to load Equirectangular cube textures
  66909. */
  66910. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66911. /**
  66912. * Defines the name of the task
  66913. */
  66914. name: string;
  66915. /**
  66916. * Defines the location of the file to load
  66917. */
  66918. url: string;
  66919. /**
  66920. * Defines the desired size (the more it increases the longer the generation will be)
  66921. */
  66922. size: number;
  66923. /**
  66924. * Defines if mipmaps should not be generated (default is false)
  66925. */
  66926. noMipmap: boolean;
  66927. /**
  66928. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66929. * but the standard material would require them in Gamma space) (default is true)
  66930. */
  66931. gammaSpace: boolean;
  66932. /**
  66933. * Gets the loaded texture
  66934. */
  66935. texture: EquiRectangularCubeTexture;
  66936. /**
  66937. * Callback called when the task is successful
  66938. */
  66939. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66940. /**
  66941. * Callback called when the task is successful
  66942. */
  66943. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66944. /**
  66945. * Creates a new EquiRectangularCubeTextureAssetTask object
  66946. * @param name defines the name of the task
  66947. * @param url defines the location of the file to load
  66948. * @param size defines the desired size (the more it increases the longer the generation will be)
  66949. * If the size is omitted this implies you are using a preprocessed cubemap.
  66950. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66951. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66952. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66953. * (default is true)
  66954. */
  66955. constructor(
  66956. /**
  66957. * Defines the name of the task
  66958. */
  66959. name: string,
  66960. /**
  66961. * Defines the location of the file to load
  66962. */
  66963. url: string,
  66964. /**
  66965. * Defines the desired size (the more it increases the longer the generation will be)
  66966. */
  66967. size: number,
  66968. /**
  66969. * Defines if mipmaps should not be generated (default is false)
  66970. */
  66971. noMipmap?: boolean,
  66972. /**
  66973. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66974. * but the standard material would require them in Gamma space) (default is true)
  66975. */
  66976. gammaSpace?: boolean);
  66977. /**
  66978. * Execute the current task
  66979. * @param scene defines the scene where you want your assets to be loaded
  66980. * @param onSuccess is a callback called when the task is successfully executed
  66981. * @param onError is a callback called if an error occurs
  66982. */
  66983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66984. }
  66985. /**
  66986. * This class can be used to easily import assets into a scene
  66987. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66988. */
  66989. export class AssetsManager {
  66990. private _scene;
  66991. private _isLoading;
  66992. protected _tasks: AbstractAssetTask[];
  66993. protected _waitingTasksCount: number;
  66994. protected _totalTasksCount: number;
  66995. /**
  66996. * Callback called when all tasks are processed
  66997. */
  66998. onFinish: (tasks: AbstractAssetTask[]) => void;
  66999. /**
  67000. * Callback called when a task is successful
  67001. */
  67002. onTaskSuccess: (task: AbstractAssetTask) => void;
  67003. /**
  67004. * Callback called when a task had an error
  67005. */
  67006. onTaskError: (task: AbstractAssetTask) => void;
  67007. /**
  67008. * Callback called when a task is done (whatever the result is)
  67009. */
  67010. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67011. /**
  67012. * Observable called when all tasks are processed
  67013. */
  67014. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67015. /**
  67016. * Observable called when a task had an error
  67017. */
  67018. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67019. /**
  67020. * Observable called when all tasks were executed
  67021. */
  67022. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67023. /**
  67024. * Observable called when a task is done (whatever the result is)
  67025. */
  67026. onProgressObservable: Observable<IAssetsProgressEvent>;
  67027. /**
  67028. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67029. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67030. */
  67031. useDefaultLoadingScreen: boolean;
  67032. /**
  67033. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67034. * when all assets have been downloaded.
  67035. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67036. */
  67037. autoHideLoadingUI: boolean;
  67038. /**
  67039. * Creates a new AssetsManager
  67040. * @param scene defines the scene to work on
  67041. */
  67042. constructor(scene: Scene);
  67043. /**
  67044. * Add a MeshAssetTask to the list of active tasks
  67045. * @param taskName defines the name of the new task
  67046. * @param meshesNames defines the name of meshes to load
  67047. * @param rootUrl defines the root url to use to locate files
  67048. * @param sceneFilename defines the filename of the scene file
  67049. * @returns a new MeshAssetTask object
  67050. */
  67051. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67052. /**
  67053. * Add a TextFileAssetTask to the list of active tasks
  67054. * @param taskName defines the name of the new task
  67055. * @param url defines the url of the file to load
  67056. * @returns a new TextFileAssetTask object
  67057. */
  67058. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67059. /**
  67060. * Add a BinaryFileAssetTask to the list of active tasks
  67061. * @param taskName defines the name of the new task
  67062. * @param url defines the url of the file to load
  67063. * @returns a new BinaryFileAssetTask object
  67064. */
  67065. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67066. /**
  67067. * Add a ImageAssetTask to the list of active tasks
  67068. * @param taskName defines the name of the new task
  67069. * @param url defines the url of the file to load
  67070. * @returns a new ImageAssetTask object
  67071. */
  67072. addImageTask(taskName: string, url: string): ImageAssetTask;
  67073. /**
  67074. * Add a TextureAssetTask to the list of active tasks
  67075. * @param taskName defines the name of the new task
  67076. * @param url defines the url of the file to load
  67077. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67078. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67079. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67080. * @returns a new TextureAssetTask object
  67081. */
  67082. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67083. /**
  67084. * Add a CubeTextureAssetTask to the list of active tasks
  67085. * @param taskName defines the name of the new task
  67086. * @param url defines the url of the file to load
  67087. * @param extensions defines the extension to use to load the cube map (can be null)
  67088. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67089. * @param files defines the list of files to load (can be null)
  67090. * @returns a new CubeTextureAssetTask object
  67091. */
  67092. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67093. /**
  67094. *
  67095. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67096. * @param taskName defines the name of the new task
  67097. * @param url defines the url of the file to load
  67098. * @param size defines the size you want for the cubemap (can be null)
  67099. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67100. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67101. * @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)
  67102. * @param reserved Internal use only
  67103. * @returns a new HDRCubeTextureAssetTask object
  67104. */
  67105. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67106. /**
  67107. *
  67108. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67109. * @param taskName defines the name of the new task
  67110. * @param url defines the url of the file to load
  67111. * @param size defines the size you want for the cubemap (can be null)
  67112. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67113. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67114. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67115. * @returns a new EquiRectangularCubeTextureAssetTask object
  67116. */
  67117. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67118. /**
  67119. * Remove a task from the assets manager.
  67120. * @param task the task to remove
  67121. */
  67122. removeTask(task: AbstractAssetTask): void;
  67123. private _decreaseWaitingTasksCount;
  67124. private _runTask;
  67125. /**
  67126. * Reset the AssetsManager and remove all tasks
  67127. * @return the current instance of the AssetsManager
  67128. */
  67129. reset(): AssetsManager;
  67130. /**
  67131. * Start the loading process
  67132. * @return the current instance of the AssetsManager
  67133. */
  67134. load(): AssetsManager;
  67135. /**
  67136. * Start the loading process as an async operation
  67137. * @return a promise returning the list of failed tasks
  67138. */
  67139. loadAsync(): Promise<void>;
  67140. }
  67141. }
  67142. declare module "babylonjs/Misc/deferred" {
  67143. /**
  67144. * Wrapper class for promise with external resolve and reject.
  67145. */
  67146. export class Deferred<T> {
  67147. /**
  67148. * The promise associated with this deferred object.
  67149. */
  67150. readonly promise: Promise<T>;
  67151. private _resolve;
  67152. private _reject;
  67153. /**
  67154. * The resolve method of the promise associated with this deferred object.
  67155. */
  67156. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67157. /**
  67158. * The reject method of the promise associated with this deferred object.
  67159. */
  67160. readonly reject: (reason?: any) => void;
  67161. /**
  67162. * Constructor for this deferred object.
  67163. */
  67164. constructor();
  67165. }
  67166. }
  67167. declare module "babylonjs/Misc/meshExploder" {
  67168. import { Mesh } from "babylonjs/Meshes/mesh";
  67169. /**
  67170. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67171. */
  67172. export class MeshExploder {
  67173. private _centerMesh;
  67174. private _meshes;
  67175. private _meshesOrigins;
  67176. private _toCenterVectors;
  67177. private _scaledDirection;
  67178. private _newPosition;
  67179. private _centerPosition;
  67180. /**
  67181. * Explodes meshes from a center mesh.
  67182. * @param meshes The meshes to explode.
  67183. * @param centerMesh The mesh to be center of explosion.
  67184. */
  67185. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67186. private _setCenterMesh;
  67187. /**
  67188. * Get class name
  67189. * @returns "MeshExploder"
  67190. */
  67191. getClassName(): string;
  67192. /**
  67193. * "Exploded meshes"
  67194. * @returns Array of meshes with the centerMesh at index 0.
  67195. */
  67196. getMeshes(): Array<Mesh>;
  67197. /**
  67198. * Explodes meshes giving a specific direction
  67199. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67200. */
  67201. explode(direction?: number): void;
  67202. }
  67203. }
  67204. declare module "babylonjs/Misc/filesInput" {
  67205. import { Engine } from "babylonjs/Engines/engine";
  67206. import { Scene } from "babylonjs/scene";
  67207. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67208. /**
  67209. * Class used to help managing file picking and drag'n'drop
  67210. */
  67211. export class FilesInput {
  67212. /**
  67213. * List of files ready to be loaded
  67214. */
  67215. static readonly FilesToLoad: {
  67216. [key: string]: File;
  67217. };
  67218. /**
  67219. * Callback called when a file is processed
  67220. */
  67221. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67222. private _engine;
  67223. private _currentScene;
  67224. private _sceneLoadedCallback;
  67225. private _progressCallback;
  67226. private _additionalRenderLoopLogicCallback;
  67227. private _textureLoadingCallback;
  67228. private _startingProcessingFilesCallback;
  67229. private _onReloadCallback;
  67230. private _errorCallback;
  67231. private _elementToMonitor;
  67232. private _sceneFileToLoad;
  67233. private _filesToLoad;
  67234. /**
  67235. * Creates a new FilesInput
  67236. * @param engine defines the rendering engine
  67237. * @param scene defines the hosting scene
  67238. * @param sceneLoadedCallback callback called when scene is loaded
  67239. * @param progressCallback callback called to track progress
  67240. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67241. * @param textureLoadingCallback callback called when a texture is loading
  67242. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67243. * @param onReloadCallback callback called when a reload is requested
  67244. * @param errorCallback callback call if an error occurs
  67245. */
  67246. 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);
  67247. private _dragEnterHandler;
  67248. private _dragOverHandler;
  67249. private _dropHandler;
  67250. /**
  67251. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67252. * @param elementToMonitor defines the DOM element to track
  67253. */
  67254. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67255. /**
  67256. * Release all associated resources
  67257. */
  67258. dispose(): void;
  67259. private renderFunction;
  67260. private drag;
  67261. private drop;
  67262. private _traverseFolder;
  67263. private _processFiles;
  67264. /**
  67265. * Load files from a drop event
  67266. * @param event defines the drop event to use as source
  67267. */
  67268. loadFiles(event: any): void;
  67269. private _processReload;
  67270. /**
  67271. * Reload the current scene from the loaded files
  67272. */
  67273. reload(): void;
  67274. }
  67275. }
  67276. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67277. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67278. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67279. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67280. }
  67281. declare module "babylonjs/Misc/sceneOptimizer" {
  67282. import { Scene, IDisposable } from "babylonjs/scene";
  67283. import { Observable } from "babylonjs/Misc/observable";
  67284. /**
  67285. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67286. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67287. */
  67288. export class SceneOptimization {
  67289. /**
  67290. * Defines the priority of this optimization (0 by default which means first in the list)
  67291. */
  67292. priority: number;
  67293. /**
  67294. * Gets a string describing the action executed by the current optimization
  67295. * @returns description string
  67296. */
  67297. getDescription(): string;
  67298. /**
  67299. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67300. * @param scene defines the current scene where to apply this optimization
  67301. * @param optimizer defines the current optimizer
  67302. * @returns true if everything that can be done was applied
  67303. */
  67304. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67305. /**
  67306. * Creates the SceneOptimization object
  67307. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67308. * @param desc defines the description associated with the optimization
  67309. */
  67310. constructor(
  67311. /**
  67312. * Defines the priority of this optimization (0 by default which means first in the list)
  67313. */
  67314. priority?: number);
  67315. }
  67316. /**
  67317. * Defines an optimization used to reduce the size of render target textures
  67318. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67319. */
  67320. export class TextureOptimization extends SceneOptimization {
  67321. /**
  67322. * Defines the priority of this optimization (0 by default which means first in the list)
  67323. */
  67324. priority: number;
  67325. /**
  67326. * 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
  67327. */
  67328. maximumSize: number;
  67329. /**
  67330. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67331. */
  67332. step: number;
  67333. /**
  67334. * Gets a string describing the action executed by the current optimization
  67335. * @returns description string
  67336. */
  67337. getDescription(): string;
  67338. /**
  67339. * Creates the TextureOptimization object
  67340. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67341. * @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
  67342. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67343. */
  67344. constructor(
  67345. /**
  67346. * Defines the priority of this optimization (0 by default which means first in the list)
  67347. */
  67348. priority?: number,
  67349. /**
  67350. * 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
  67351. */
  67352. maximumSize?: number,
  67353. /**
  67354. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67355. */
  67356. step?: number);
  67357. /**
  67358. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67359. * @param scene defines the current scene where to apply this optimization
  67360. * @param optimizer defines the current optimizer
  67361. * @returns true if everything that can be done was applied
  67362. */
  67363. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67364. }
  67365. /**
  67366. * Defines an optimization used to increase or decrease the rendering resolution
  67367. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67368. */
  67369. export class HardwareScalingOptimization extends SceneOptimization {
  67370. /**
  67371. * Defines the priority of this optimization (0 by default which means first in the list)
  67372. */
  67373. priority: number;
  67374. /**
  67375. * Defines the maximum scale to use (2 by default)
  67376. */
  67377. maximumScale: number;
  67378. /**
  67379. * Defines the step to use between two passes (0.5 by default)
  67380. */
  67381. step: number;
  67382. private _currentScale;
  67383. private _directionOffset;
  67384. /**
  67385. * Gets a string describing the action executed by the current optimization
  67386. * @return description string
  67387. */
  67388. getDescription(): string;
  67389. /**
  67390. * Creates the HardwareScalingOptimization object
  67391. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67392. * @param maximumScale defines the maximum scale to use (2 by default)
  67393. * @param step defines the step to use between two passes (0.5 by default)
  67394. */
  67395. constructor(
  67396. /**
  67397. * Defines the priority of this optimization (0 by default which means first in the list)
  67398. */
  67399. priority?: number,
  67400. /**
  67401. * Defines the maximum scale to use (2 by default)
  67402. */
  67403. maximumScale?: number,
  67404. /**
  67405. * Defines the step to use between two passes (0.5 by default)
  67406. */
  67407. step?: number);
  67408. /**
  67409. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67410. * @param scene defines the current scene where to apply this optimization
  67411. * @param optimizer defines the current optimizer
  67412. * @returns true if everything that can be done was applied
  67413. */
  67414. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67415. }
  67416. /**
  67417. * Defines an optimization used to remove shadows
  67418. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67419. */
  67420. export class ShadowsOptimization extends SceneOptimization {
  67421. /**
  67422. * Gets a string describing the action executed by the current optimization
  67423. * @return description string
  67424. */
  67425. getDescription(): string;
  67426. /**
  67427. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67428. * @param scene defines the current scene where to apply this optimization
  67429. * @param optimizer defines the current optimizer
  67430. * @returns true if everything that can be done was applied
  67431. */
  67432. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67433. }
  67434. /**
  67435. * Defines an optimization used to turn post-processes off
  67436. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67437. */
  67438. export class PostProcessesOptimization extends SceneOptimization {
  67439. /**
  67440. * Gets a string describing the action executed by the current optimization
  67441. * @return description string
  67442. */
  67443. getDescription(): string;
  67444. /**
  67445. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67446. * @param scene defines the current scene where to apply this optimization
  67447. * @param optimizer defines the current optimizer
  67448. * @returns true if everything that can be done was applied
  67449. */
  67450. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67451. }
  67452. /**
  67453. * Defines an optimization used to turn lens flares off
  67454. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67455. */
  67456. export class LensFlaresOptimization extends SceneOptimization {
  67457. /**
  67458. * Gets a string describing the action executed by the current optimization
  67459. * @return description string
  67460. */
  67461. getDescription(): string;
  67462. /**
  67463. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67464. * @param scene defines the current scene where to apply this optimization
  67465. * @param optimizer defines the current optimizer
  67466. * @returns true if everything that can be done was applied
  67467. */
  67468. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67469. }
  67470. /**
  67471. * Defines an optimization based on user defined callback.
  67472. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67473. */
  67474. export class CustomOptimization extends SceneOptimization {
  67475. /**
  67476. * Callback called to apply the custom optimization.
  67477. */
  67478. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67479. /**
  67480. * Callback called to get custom description
  67481. */
  67482. onGetDescription: () => string;
  67483. /**
  67484. * Gets a string describing the action executed by the current optimization
  67485. * @returns description string
  67486. */
  67487. getDescription(): string;
  67488. /**
  67489. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67490. * @param scene defines the current scene where to apply this optimization
  67491. * @param optimizer defines the current optimizer
  67492. * @returns true if everything that can be done was applied
  67493. */
  67494. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67495. }
  67496. /**
  67497. * Defines an optimization used to turn particles off
  67498. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67499. */
  67500. export class ParticlesOptimization extends SceneOptimization {
  67501. /**
  67502. * Gets a string describing the action executed by the current optimization
  67503. * @return description string
  67504. */
  67505. getDescription(): string;
  67506. /**
  67507. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67508. * @param scene defines the current scene where to apply this optimization
  67509. * @param optimizer defines the current optimizer
  67510. * @returns true if everything that can be done was applied
  67511. */
  67512. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67513. }
  67514. /**
  67515. * Defines an optimization used to turn render targets off
  67516. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67517. */
  67518. export class RenderTargetsOptimization extends SceneOptimization {
  67519. /**
  67520. * Gets a string describing the action executed by the current optimization
  67521. * @return description string
  67522. */
  67523. getDescription(): string;
  67524. /**
  67525. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67526. * @param scene defines the current scene where to apply this optimization
  67527. * @param optimizer defines the current optimizer
  67528. * @returns true if everything that can be done was applied
  67529. */
  67530. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67531. }
  67532. /**
  67533. * Defines an optimization used to merge meshes with compatible materials
  67534. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67535. */
  67536. export class MergeMeshesOptimization extends SceneOptimization {
  67537. private static _UpdateSelectionTree;
  67538. /**
  67539. * Gets or sets a boolean which defines if optimization octree has to be updated
  67540. */
  67541. /**
  67542. * Gets or sets a boolean which defines if optimization octree has to be updated
  67543. */
  67544. static UpdateSelectionTree: boolean;
  67545. /**
  67546. * Gets a string describing the action executed by the current optimization
  67547. * @return description string
  67548. */
  67549. getDescription(): string;
  67550. private _canBeMerged;
  67551. /**
  67552. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67553. * @param scene defines the current scene where to apply this optimization
  67554. * @param optimizer defines the current optimizer
  67555. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67556. * @returns true if everything that can be done was applied
  67557. */
  67558. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67559. }
  67560. /**
  67561. * Defines a list of options used by SceneOptimizer
  67562. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67563. */
  67564. export class SceneOptimizerOptions {
  67565. /**
  67566. * Defines the target frame rate to reach (60 by default)
  67567. */
  67568. targetFrameRate: number;
  67569. /**
  67570. * Defines the interval between two checkes (2000ms by default)
  67571. */
  67572. trackerDuration: number;
  67573. /**
  67574. * Gets the list of optimizations to apply
  67575. */
  67576. optimizations: SceneOptimization[];
  67577. /**
  67578. * Creates a new list of options used by SceneOptimizer
  67579. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67580. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67581. */
  67582. constructor(
  67583. /**
  67584. * Defines the target frame rate to reach (60 by default)
  67585. */
  67586. targetFrameRate?: number,
  67587. /**
  67588. * Defines the interval between two checkes (2000ms by default)
  67589. */
  67590. trackerDuration?: number);
  67591. /**
  67592. * Add a new optimization
  67593. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67594. * @returns the current SceneOptimizerOptions
  67595. */
  67596. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67597. /**
  67598. * Add a new custom optimization
  67599. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67600. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67601. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67602. * @returns the current SceneOptimizerOptions
  67603. */
  67604. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67605. /**
  67606. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67607. * @param targetFrameRate defines the target frame rate (60 by default)
  67608. * @returns a SceneOptimizerOptions object
  67609. */
  67610. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67611. /**
  67612. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67613. * @param targetFrameRate defines the target frame rate (60 by default)
  67614. * @returns a SceneOptimizerOptions object
  67615. */
  67616. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67617. /**
  67618. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67619. * @param targetFrameRate defines the target frame rate (60 by default)
  67620. * @returns a SceneOptimizerOptions object
  67621. */
  67622. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67623. }
  67624. /**
  67625. * Class used to run optimizations in order to reach a target frame rate
  67626. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67627. */
  67628. export class SceneOptimizer implements IDisposable {
  67629. private _isRunning;
  67630. private _options;
  67631. private _scene;
  67632. private _currentPriorityLevel;
  67633. private _targetFrameRate;
  67634. private _trackerDuration;
  67635. private _currentFrameRate;
  67636. private _sceneDisposeObserver;
  67637. private _improvementMode;
  67638. /**
  67639. * Defines an observable called when the optimizer reaches the target frame rate
  67640. */
  67641. onSuccessObservable: Observable<SceneOptimizer>;
  67642. /**
  67643. * Defines an observable called when the optimizer enables an optimization
  67644. */
  67645. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67646. /**
  67647. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67648. */
  67649. onFailureObservable: Observable<SceneOptimizer>;
  67650. /**
  67651. * Gets a boolean indicating if the optimizer is in improvement mode
  67652. */
  67653. readonly isInImprovementMode: boolean;
  67654. /**
  67655. * Gets the current priority level (0 at start)
  67656. */
  67657. readonly currentPriorityLevel: number;
  67658. /**
  67659. * Gets the current frame rate checked by the SceneOptimizer
  67660. */
  67661. readonly currentFrameRate: number;
  67662. /**
  67663. * Gets or sets the current target frame rate (60 by default)
  67664. */
  67665. /**
  67666. * Gets or sets the current target frame rate (60 by default)
  67667. */
  67668. targetFrameRate: number;
  67669. /**
  67670. * Gets or sets the current interval between two checks (every 2000ms by default)
  67671. */
  67672. /**
  67673. * Gets or sets the current interval between two checks (every 2000ms by default)
  67674. */
  67675. trackerDuration: number;
  67676. /**
  67677. * Gets the list of active optimizations
  67678. */
  67679. readonly optimizations: SceneOptimization[];
  67680. /**
  67681. * Creates a new SceneOptimizer
  67682. * @param scene defines the scene to work on
  67683. * @param options defines the options to use with the SceneOptimizer
  67684. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67685. * @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)
  67686. */
  67687. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67688. /**
  67689. * Stops the current optimizer
  67690. */
  67691. stop(): void;
  67692. /**
  67693. * Reset the optimizer to initial step (current priority level = 0)
  67694. */
  67695. reset(): void;
  67696. /**
  67697. * Start the optimizer. By default it will try to reach a specific framerate
  67698. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67699. */
  67700. start(): void;
  67701. private _checkCurrentState;
  67702. /**
  67703. * Release all resources
  67704. */
  67705. dispose(): void;
  67706. /**
  67707. * Helper function to create a SceneOptimizer with one single line of code
  67708. * @param scene defines the scene to work on
  67709. * @param options defines the options to use with the SceneOptimizer
  67710. * @param onSuccess defines a callback to call on success
  67711. * @param onFailure defines a callback to call on failure
  67712. * @returns the new SceneOptimizer object
  67713. */
  67714. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67715. }
  67716. }
  67717. declare module "babylonjs/Misc/sceneSerializer" {
  67718. import { Scene } from "babylonjs/scene";
  67719. /**
  67720. * Class used to serialize a scene into a string
  67721. */
  67722. export class SceneSerializer {
  67723. /**
  67724. * Clear cache used by a previous serialization
  67725. */
  67726. static ClearCache(): void;
  67727. /**
  67728. * Serialize a scene into a JSON compatible object
  67729. * @param scene defines the scene to serialize
  67730. * @returns a JSON compatible object
  67731. */
  67732. static Serialize(scene: Scene): any;
  67733. /**
  67734. * Serialize a mesh into a JSON compatible object
  67735. * @param toSerialize defines the mesh to serialize
  67736. * @param withParents defines if parents must be serialized as well
  67737. * @param withChildren defines if children must be serialized as well
  67738. * @returns a JSON compatible object
  67739. */
  67740. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67741. }
  67742. }
  67743. declare module "babylonjs/Misc/textureTools" {
  67744. import { Texture } from "babylonjs/Materials/Textures/texture";
  67745. /**
  67746. * Class used to host texture specific utilities
  67747. */
  67748. export class TextureTools {
  67749. /**
  67750. * Uses the GPU to create a copy texture rescaled at a given size
  67751. * @param texture Texture to copy from
  67752. * @param width defines the desired width
  67753. * @param height defines the desired height
  67754. * @param useBilinearMode defines if bilinear mode has to be used
  67755. * @return the generated texture
  67756. */
  67757. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67758. }
  67759. }
  67760. declare module "babylonjs/Misc/videoRecorder" {
  67761. import { Nullable } from "babylonjs/types";
  67762. import { Engine } from "babylonjs/Engines/engine";
  67763. /**
  67764. * This represents the different options available for the video capture.
  67765. */
  67766. export interface VideoRecorderOptions {
  67767. /** Defines the mime type of the video. */
  67768. mimeType: string;
  67769. /** Defines the FPS the video should be recorded at. */
  67770. fps: number;
  67771. /** Defines the chunk size for the recording data. */
  67772. recordChunckSize: number;
  67773. /** The audio tracks to attach to the recording. */
  67774. audioTracks?: MediaStreamTrack[];
  67775. }
  67776. /**
  67777. * This can help with recording videos from BabylonJS.
  67778. * This is based on the available WebRTC functionalities of the browser.
  67779. *
  67780. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67781. */
  67782. export class VideoRecorder {
  67783. private static readonly _defaultOptions;
  67784. /**
  67785. * Returns whether or not the VideoRecorder is available in your browser.
  67786. * @param engine Defines the Babylon Engine.
  67787. * @returns true if supported otherwise false.
  67788. */
  67789. static IsSupported(engine: Engine): boolean;
  67790. private readonly _options;
  67791. private _canvas;
  67792. private _mediaRecorder;
  67793. private _recordedChunks;
  67794. private _fileName;
  67795. private _resolve;
  67796. private _reject;
  67797. /**
  67798. * True when a recording is already in progress.
  67799. */
  67800. readonly isRecording: boolean;
  67801. /**
  67802. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67803. * @param engine Defines the BabylonJS Engine you wish to record.
  67804. * @param options Defines options that can be used to customize the capture.
  67805. */
  67806. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67807. /**
  67808. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67809. */
  67810. stopRecording(): void;
  67811. /**
  67812. * Starts recording the canvas for a max duration specified in parameters.
  67813. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67814. * If null no automatic download will start and you can rely on the promise to get the data back.
  67815. * @param maxDuration Defines the maximum recording time in seconds.
  67816. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67817. * @return A promise callback at the end of the recording with the video data in Blob.
  67818. */
  67819. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67820. /**
  67821. * Releases internal resources used during the recording.
  67822. */
  67823. dispose(): void;
  67824. private _handleDataAvailable;
  67825. private _handleError;
  67826. private _handleStop;
  67827. }
  67828. }
  67829. declare module "babylonjs/Misc/screenshotTools" {
  67830. import { Camera } from "babylonjs/Cameras/camera";
  67831. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67832. import { Engine } from "babylonjs/Engines/engine";
  67833. /**
  67834. * Class containing a set of static utilities functions for screenshots
  67835. */
  67836. export class ScreenshotTools {
  67837. /**
  67838. * Captures a screenshot of the current rendering
  67839. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67840. * @param engine defines the rendering engine
  67841. * @param camera defines the source camera
  67842. * @param size This parameter can be set to a single number or to an object with the
  67843. * following (optional) properties: precision, width, height. If a single number is passed,
  67844. * it will be used for both width and height. If an object is passed, the screenshot size
  67845. * will be derived from the parameters. The precision property is a multiplier allowing
  67846. * rendering at a higher or lower resolution
  67847. * @param successCallback defines the callback receives a single parameter which contains the
  67848. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67849. * src parameter of an <img> to display it
  67850. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67851. * Check your browser for supported MIME types
  67852. */
  67853. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67854. /**
  67855. * Captures a screenshot of the current rendering
  67856. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67857. * @param engine defines the rendering engine
  67858. * @param camera defines the source camera
  67859. * @param size This parameter can be set to a single number or to an object with the
  67860. * following (optional) properties: precision, width, height. If a single number is passed,
  67861. * it will be used for both width and height. If an object is passed, the screenshot size
  67862. * will be derived from the parameters. The precision property is a multiplier allowing
  67863. * rendering at a higher or lower resolution
  67864. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67865. * Check your browser for supported MIME types
  67866. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67867. * to the src parameter of an <img> to display it
  67868. */
  67869. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67870. /**
  67871. * Generates an image screenshot from the specified camera.
  67872. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67873. * @param engine The engine to use for rendering
  67874. * @param camera The camera to use for rendering
  67875. * @param size This parameter can be set to a single number or to an object with the
  67876. * following (optional) properties: precision, width, height. If a single number is passed,
  67877. * it will be used for both width and height. If an object is passed, the screenshot size
  67878. * will be derived from the parameters. The precision property is a multiplier allowing
  67879. * rendering at a higher or lower resolution
  67880. * @param successCallback The callback receives a single parameter which contains the
  67881. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67882. * src parameter of an <img> to display it
  67883. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67884. * Check your browser for supported MIME types
  67885. * @param samples Texture samples (default: 1)
  67886. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67887. * @param fileName A name for for the downloaded file.
  67888. */
  67889. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67890. /**
  67891. * Generates an image screenshot from the specified camera.
  67892. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67893. * @param engine The engine to use for rendering
  67894. * @param camera The camera to use for rendering
  67895. * @param size This parameter can be set to a single number or to an object with the
  67896. * following (optional) properties: precision, width, height. If a single number is passed,
  67897. * it will be used for both width and height. If an object is passed, the screenshot size
  67898. * will be derived from the parameters. The precision property is a multiplier allowing
  67899. * rendering at a higher or lower resolution
  67900. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67901. * Check your browser for supported MIME types
  67902. * @param samples Texture samples (default: 1)
  67903. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67904. * @param fileName A name for for the downloaded file.
  67905. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67906. * to the src parameter of an <img> to display it
  67907. */
  67908. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67909. /**
  67910. * Gets height and width for screenshot size
  67911. * @private
  67912. */
  67913. private static _getScreenshotSize;
  67914. }
  67915. }
  67916. declare module "babylonjs/Misc/dataReader" {
  67917. /**
  67918. * Interface for a data buffer
  67919. */
  67920. export interface IDataBuffer {
  67921. /**
  67922. * Reads bytes from the data buffer.
  67923. * @param byteOffset The byte offset to read
  67924. * @param byteLength The byte length to read
  67925. * @returns A promise that resolves when the bytes are read
  67926. */
  67927. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  67928. /**
  67929. * The byte length of the buffer.
  67930. */
  67931. readonly byteLength: number;
  67932. }
  67933. /**
  67934. * Utility class for reading from a data buffer
  67935. */
  67936. export class DataReader {
  67937. /**
  67938. * The data buffer associated with this data reader.
  67939. */
  67940. readonly buffer: IDataBuffer;
  67941. /**
  67942. * The current byte offset from the beginning of the data buffer.
  67943. */
  67944. byteOffset: number;
  67945. private _dataView;
  67946. private _dataByteOffset;
  67947. /**
  67948. * Constructor
  67949. * @param buffer The buffer to read
  67950. */
  67951. constructor(buffer: IDataBuffer);
  67952. /**
  67953. * Loads the given byte length.
  67954. * @param byteLength The byte length to load
  67955. * @returns A promise that resolves when the load is complete
  67956. */
  67957. loadAsync(byteLength: number): Promise<void>;
  67958. /**
  67959. * Read a unsigned 32-bit integer from the currently loaded data range.
  67960. * @returns The 32-bit integer read
  67961. */
  67962. readUint32(): number;
  67963. /**
  67964. * Read a byte array from the currently loaded data range.
  67965. * @param byteLength The byte length to read
  67966. * @returns The byte array read
  67967. */
  67968. readUint8Array(byteLength: number): Uint8Array;
  67969. /**
  67970. * Read a string from the currently loaded data range.
  67971. * @param byteLength The byte length to read
  67972. * @returns The string read
  67973. */
  67974. readString(byteLength: number): string;
  67975. /**
  67976. * Skips the given byte length the currently loaded data range.
  67977. * @param byteLength The byte length to skip
  67978. */
  67979. skipBytes(byteLength: number): void;
  67980. }
  67981. }
  67982. declare module "babylonjs/Misc/index" {
  67983. export * from "babylonjs/Misc/andOrNotEvaluator";
  67984. export * from "babylonjs/Misc/assetsManager";
  67985. export * from "babylonjs/Misc/dds";
  67986. export * from "babylonjs/Misc/decorators";
  67987. export * from "babylonjs/Misc/deferred";
  67988. export * from "babylonjs/Misc/environmentTextureTools";
  67989. export * from "babylonjs/Misc/meshExploder";
  67990. export * from "babylonjs/Misc/filesInput";
  67991. export * from "babylonjs/Misc/HighDynamicRange/index";
  67992. export * from "babylonjs/Misc/khronosTextureContainer";
  67993. export * from "babylonjs/Misc/observable";
  67994. export * from "babylonjs/Misc/performanceMonitor";
  67995. export * from "babylonjs/Misc/promise";
  67996. export * from "babylonjs/Misc/sceneOptimizer";
  67997. export * from "babylonjs/Misc/sceneSerializer";
  67998. export * from "babylonjs/Misc/smartArray";
  67999. export * from "babylonjs/Misc/stringDictionary";
  68000. export * from "babylonjs/Misc/tags";
  68001. export * from "babylonjs/Misc/textureTools";
  68002. export * from "babylonjs/Misc/tga";
  68003. export * from "babylonjs/Misc/tools";
  68004. export * from "babylonjs/Misc/videoRecorder";
  68005. export * from "babylonjs/Misc/virtualJoystick";
  68006. export * from "babylonjs/Misc/workerPool";
  68007. export * from "babylonjs/Misc/logger";
  68008. export * from "babylonjs/Misc/typeStore";
  68009. export * from "babylonjs/Misc/filesInputStore";
  68010. export * from "babylonjs/Misc/deepCopier";
  68011. export * from "babylonjs/Misc/pivotTools";
  68012. export * from "babylonjs/Misc/precisionDate";
  68013. export * from "babylonjs/Misc/screenshotTools";
  68014. export * from "babylonjs/Misc/typeStore";
  68015. export * from "babylonjs/Misc/webRequest";
  68016. export * from "babylonjs/Misc/iInspectable";
  68017. export * from "babylonjs/Misc/brdfTextureTools";
  68018. export * from "babylonjs/Misc/rgbdTextureTools";
  68019. export * from "babylonjs/Misc/gradients";
  68020. export * from "babylonjs/Misc/perfCounter";
  68021. export * from "babylonjs/Misc/fileRequest";
  68022. export * from "babylonjs/Misc/customAnimationFrameRequester";
  68023. export * from "babylonjs/Misc/retryStrategy";
  68024. export * from "babylonjs/Misc/interfaces/screenshotSize";
  68025. export * from "babylonjs/Misc/canvasGenerator";
  68026. export * from "babylonjs/Misc/fileTools";
  68027. export * from "babylonjs/Misc/stringTools";
  68028. export * from "babylonjs/Misc/dataReader";
  68029. }
  68030. declare module "babylonjs/index" {
  68031. export * from "babylonjs/abstractScene";
  68032. export * from "babylonjs/Actions/index";
  68033. export * from "babylonjs/Animations/index";
  68034. export * from "babylonjs/assetContainer";
  68035. export * from "babylonjs/Audio/index";
  68036. export * from "babylonjs/Behaviors/index";
  68037. export * from "babylonjs/Bones/index";
  68038. export * from "babylonjs/Cameras/index";
  68039. export * from "babylonjs/Collisions/index";
  68040. export * from "babylonjs/Culling/index";
  68041. export * from "babylonjs/Debug/index";
  68042. export * from "babylonjs/Engines/index";
  68043. export * from "babylonjs/Events/index";
  68044. export * from "babylonjs/Gamepads/index";
  68045. export * from "babylonjs/Gizmos/index";
  68046. export * from "babylonjs/Helpers/index";
  68047. export * from "babylonjs/Instrumentation/index";
  68048. export * from "babylonjs/Layers/index";
  68049. export * from "babylonjs/LensFlares/index";
  68050. export * from "babylonjs/Lights/index";
  68051. export * from "babylonjs/Loading/index";
  68052. export * from "babylonjs/Materials/index";
  68053. export * from "babylonjs/Maths/index";
  68054. export * from "babylonjs/Meshes/index";
  68055. export * from "babylonjs/Morph/index";
  68056. export * from "babylonjs/Navigation/index";
  68057. export * from "babylonjs/node";
  68058. export * from "babylonjs/Offline/index";
  68059. export * from "babylonjs/Particles/index";
  68060. export * from "babylonjs/Physics/index";
  68061. export * from "babylonjs/PostProcesses/index";
  68062. export * from "babylonjs/Probes/index";
  68063. export * from "babylonjs/Rendering/index";
  68064. export * from "babylonjs/scene";
  68065. export * from "babylonjs/sceneComponent";
  68066. export * from "babylonjs/Sprites/index";
  68067. export * from "babylonjs/States/index";
  68068. export * from "babylonjs/Misc/index";
  68069. export * from "babylonjs/types";
  68070. }
  68071. declare module "babylonjs/Animations/pathCursor" {
  68072. import { Vector3 } from "babylonjs/Maths/math.vector";
  68073. import { Path2 } from "babylonjs/Maths/math.path";
  68074. /**
  68075. * A cursor which tracks a point on a path
  68076. */
  68077. export class PathCursor {
  68078. private path;
  68079. /**
  68080. * Stores path cursor callbacks for when an onchange event is triggered
  68081. */
  68082. private _onchange;
  68083. /**
  68084. * The value of the path cursor
  68085. */
  68086. value: number;
  68087. /**
  68088. * The animation array of the path cursor
  68089. */
  68090. animations: Animation[];
  68091. /**
  68092. * Initializes the path cursor
  68093. * @param path The path to track
  68094. */
  68095. constructor(path: Path2);
  68096. /**
  68097. * Gets the cursor point on the path
  68098. * @returns A point on the path cursor at the cursor location
  68099. */
  68100. getPoint(): Vector3;
  68101. /**
  68102. * Moves the cursor ahead by the step amount
  68103. * @param step The amount to move the cursor forward
  68104. * @returns This path cursor
  68105. */
  68106. moveAhead(step?: number): PathCursor;
  68107. /**
  68108. * Moves the cursor behind by the step amount
  68109. * @param step The amount to move the cursor back
  68110. * @returns This path cursor
  68111. */
  68112. moveBack(step?: number): PathCursor;
  68113. /**
  68114. * Moves the cursor by the step amount
  68115. * If the step amount is greater than one, an exception is thrown
  68116. * @param step The amount to move the cursor
  68117. * @returns This path cursor
  68118. */
  68119. move(step: number): PathCursor;
  68120. /**
  68121. * Ensures that the value is limited between zero and one
  68122. * @returns This path cursor
  68123. */
  68124. private ensureLimits;
  68125. /**
  68126. * Runs onchange callbacks on change (used by the animation engine)
  68127. * @returns This path cursor
  68128. */
  68129. private raiseOnChange;
  68130. /**
  68131. * Executes a function on change
  68132. * @param f A path cursor onchange callback
  68133. * @returns This path cursor
  68134. */
  68135. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68136. }
  68137. }
  68138. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68139. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68140. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68141. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68142. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68143. }
  68144. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68145. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68146. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68147. }
  68148. declare module "babylonjs/Engines/Processors/index" {
  68149. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68150. export * from "babylonjs/Engines/Processors/Expressions/index";
  68151. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68152. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68153. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68154. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68155. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68156. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68157. }
  68158. declare module "babylonjs/Legacy/legacy" {
  68159. import * as Babylon from "babylonjs/index";
  68160. export * from "babylonjs/index";
  68161. }
  68162. declare module "babylonjs/Shaders/blur.fragment" {
  68163. /** @hidden */
  68164. export var blurPixelShader: {
  68165. name: string;
  68166. shader: string;
  68167. };
  68168. }
  68169. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68170. /** @hidden */
  68171. export var pointCloudVertexDeclaration: {
  68172. name: string;
  68173. shader: string;
  68174. };
  68175. }
  68176. declare module "babylonjs" {
  68177. export * from "babylonjs/Legacy/legacy";
  68178. }
  68179. declare module BABYLON {
  68180. /** Alias type for value that can be null */
  68181. export type Nullable<T> = T | null;
  68182. /**
  68183. * Alias type for number that are floats
  68184. * @ignorenaming
  68185. */
  68186. export type float = number;
  68187. /**
  68188. * Alias type for number that are doubles.
  68189. * @ignorenaming
  68190. */
  68191. export type double = number;
  68192. /**
  68193. * Alias type for number that are integer
  68194. * @ignorenaming
  68195. */
  68196. export type int = number;
  68197. /** Alias type for number array or Float32Array */
  68198. export type FloatArray = number[] | Float32Array;
  68199. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68200. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68201. /**
  68202. * Alias for types that can be used by a Buffer or VertexBuffer.
  68203. */
  68204. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68205. /**
  68206. * Alias type for primitive types
  68207. * @ignorenaming
  68208. */
  68209. type Primitive = undefined | null | boolean | string | number | Function;
  68210. /**
  68211. * Type modifier to make all the properties of an object Readonly
  68212. */
  68213. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68214. /**
  68215. * Type modifier to make all the properties of an object Readonly recursively
  68216. */
  68217. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68218. /**
  68219. * Type modifier to make object properties readonly.
  68220. */
  68221. export type DeepImmutableObject<T> = {
  68222. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68223. };
  68224. /** @hidden */
  68225. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68226. }
  68227. }
  68228. declare module BABYLON {
  68229. /**
  68230. * A class serves as a medium between the observable and its observers
  68231. */
  68232. export class EventState {
  68233. /**
  68234. * Create a new EventState
  68235. * @param mask defines the mask associated with this state
  68236. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68237. * @param target defines the original target of the state
  68238. * @param currentTarget defines the current target of the state
  68239. */
  68240. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68241. /**
  68242. * Initialize the current event state
  68243. * @param mask defines the mask associated with this state
  68244. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68245. * @param target defines the original target of the state
  68246. * @param currentTarget defines the current target of the state
  68247. * @returns the current event state
  68248. */
  68249. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68250. /**
  68251. * An Observer can set this property to true to prevent subsequent observers of being notified
  68252. */
  68253. skipNextObservers: boolean;
  68254. /**
  68255. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68256. */
  68257. mask: number;
  68258. /**
  68259. * The object that originally notified the event
  68260. */
  68261. target?: any;
  68262. /**
  68263. * The current object in the bubbling phase
  68264. */
  68265. currentTarget?: any;
  68266. /**
  68267. * This will be populated with the return value of the last function that was executed.
  68268. * If it is the first function in the callback chain it will be the event data.
  68269. */
  68270. lastReturnValue?: any;
  68271. }
  68272. /**
  68273. * Represent an Observer registered to a given Observable object.
  68274. */
  68275. export class Observer<T> {
  68276. /**
  68277. * Defines the callback to call when the observer is notified
  68278. */
  68279. callback: (eventData: T, eventState: EventState) => void;
  68280. /**
  68281. * Defines the mask of the observer (used to filter notifications)
  68282. */
  68283. mask: number;
  68284. /**
  68285. * Defines the current scope used to restore the JS context
  68286. */
  68287. scope: any;
  68288. /** @hidden */
  68289. _willBeUnregistered: boolean;
  68290. /**
  68291. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68292. */
  68293. unregisterOnNextCall: boolean;
  68294. /**
  68295. * Creates a new observer
  68296. * @param callback defines the callback to call when the observer is notified
  68297. * @param mask defines the mask of the observer (used to filter notifications)
  68298. * @param scope defines the current scope used to restore the JS context
  68299. */
  68300. constructor(
  68301. /**
  68302. * Defines the callback to call when the observer is notified
  68303. */
  68304. callback: (eventData: T, eventState: EventState) => void,
  68305. /**
  68306. * Defines the mask of the observer (used to filter notifications)
  68307. */
  68308. mask: number,
  68309. /**
  68310. * Defines the current scope used to restore the JS context
  68311. */
  68312. scope?: any);
  68313. }
  68314. /**
  68315. * Represent a list of observers registered to multiple Observables object.
  68316. */
  68317. export class MultiObserver<T> {
  68318. private _observers;
  68319. private _observables;
  68320. /**
  68321. * Release associated resources
  68322. */
  68323. dispose(): void;
  68324. /**
  68325. * Raise a callback when one of the observable will notify
  68326. * @param observables defines a list of observables to watch
  68327. * @param callback defines the callback to call on notification
  68328. * @param mask defines the mask used to filter notifications
  68329. * @param scope defines the current scope used to restore the JS context
  68330. * @returns the new MultiObserver
  68331. */
  68332. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68333. }
  68334. /**
  68335. * The Observable class is a simple implementation of the Observable pattern.
  68336. *
  68337. * 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.
  68338. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68339. * 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).
  68340. * 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.
  68341. */
  68342. export class Observable<T> {
  68343. private _observers;
  68344. private _eventState;
  68345. private _onObserverAdded;
  68346. /**
  68347. * Gets the list of observers
  68348. */
  68349. readonly observers: Array<Observer<T>>;
  68350. /**
  68351. * Creates a new observable
  68352. * @param onObserverAdded defines a callback to call when a new observer is added
  68353. */
  68354. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68355. /**
  68356. * Create a new Observer with the specified callback
  68357. * @param callback the callback that will be executed for that Observer
  68358. * @param mask the mask used to filter observers
  68359. * @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.
  68360. * @param scope optional scope for the callback to be called from
  68361. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68362. * @returns the new observer created for the callback
  68363. */
  68364. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68365. /**
  68366. * Create a new Observer with the specified callback and unregisters after the next notification
  68367. * @param callback the callback that will be executed for that Observer
  68368. * @returns the new observer created for the callback
  68369. */
  68370. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68371. /**
  68372. * Remove an Observer from the Observable object
  68373. * @param observer the instance of the Observer to remove
  68374. * @returns false if it doesn't belong to this Observable
  68375. */
  68376. remove(observer: Nullable<Observer<T>>): boolean;
  68377. /**
  68378. * Remove a callback from the Observable object
  68379. * @param callback the callback to remove
  68380. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68381. * @returns false if it doesn't belong to this Observable
  68382. */
  68383. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68384. private _deferUnregister;
  68385. private _remove;
  68386. /**
  68387. * Moves the observable to the top of the observer list making it get called first when notified
  68388. * @param observer the observer to move
  68389. */
  68390. makeObserverTopPriority(observer: Observer<T>): void;
  68391. /**
  68392. * Moves the observable to the bottom of the observer list making it get called last when notified
  68393. * @param observer the observer to move
  68394. */
  68395. makeObserverBottomPriority(observer: Observer<T>): void;
  68396. /**
  68397. * Notify all Observers by calling their respective callback with the given data
  68398. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68399. * @param eventData defines the data to send to all observers
  68400. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68401. * @param target defines the original target of the state
  68402. * @param currentTarget defines the current target of the state
  68403. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68404. */
  68405. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68406. /**
  68407. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68408. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68409. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68410. * and it is crucial that all callbacks will be executed.
  68411. * The order of the callbacks is kept, callbacks are not executed parallel.
  68412. *
  68413. * @param eventData The data to be sent to each callback
  68414. * @param mask is used to filter observers defaults to -1
  68415. * @param target defines the callback target (see EventState)
  68416. * @param currentTarget defines he current object in the bubbling phase
  68417. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68418. */
  68419. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68420. /**
  68421. * Notify a specific observer
  68422. * @param observer defines the observer to notify
  68423. * @param eventData defines the data to be sent to each callback
  68424. * @param mask is used to filter observers defaults to -1
  68425. */
  68426. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68427. /**
  68428. * Gets a boolean indicating if the observable has at least one observer
  68429. * @returns true is the Observable has at least one Observer registered
  68430. */
  68431. hasObservers(): boolean;
  68432. /**
  68433. * Clear the list of observers
  68434. */
  68435. clear(): void;
  68436. /**
  68437. * Clone the current observable
  68438. * @returns a new observable
  68439. */
  68440. clone(): Observable<T>;
  68441. /**
  68442. * Does this observable handles observer registered with a given mask
  68443. * @param mask defines the mask to be tested
  68444. * @return whether or not one observer registered with the given mask is handeled
  68445. **/
  68446. hasSpecificMask(mask?: number): boolean;
  68447. }
  68448. }
  68449. declare module BABYLON {
  68450. /**
  68451. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68452. * Babylon.js
  68453. */
  68454. export class DomManagement {
  68455. /**
  68456. * Checks if the window object exists
  68457. * @returns true if the window object exists
  68458. */
  68459. static IsWindowObjectExist(): boolean;
  68460. /**
  68461. * Checks if the navigator object exists
  68462. * @returns true if the navigator object exists
  68463. */
  68464. static IsNavigatorAvailable(): boolean;
  68465. /**
  68466. * Extracts text content from a DOM element hierarchy
  68467. * @param element defines the root element
  68468. * @returns a string
  68469. */
  68470. static GetDOMTextContent(element: HTMLElement): string;
  68471. }
  68472. }
  68473. declare module BABYLON {
  68474. /**
  68475. * Logger used througouht the application to allow configuration of
  68476. * the log level required for the messages.
  68477. */
  68478. export class Logger {
  68479. /**
  68480. * No log
  68481. */
  68482. static readonly NoneLogLevel: number;
  68483. /**
  68484. * Only message logs
  68485. */
  68486. static readonly MessageLogLevel: number;
  68487. /**
  68488. * Only warning logs
  68489. */
  68490. static readonly WarningLogLevel: number;
  68491. /**
  68492. * Only error logs
  68493. */
  68494. static readonly ErrorLogLevel: number;
  68495. /**
  68496. * All logs
  68497. */
  68498. static readonly AllLogLevel: number;
  68499. private static _LogCache;
  68500. /**
  68501. * Gets a value indicating the number of loading errors
  68502. * @ignorenaming
  68503. */
  68504. static errorsCount: number;
  68505. /**
  68506. * Callback called when a new log is added
  68507. */
  68508. static OnNewCacheEntry: (entry: string) => void;
  68509. private static _AddLogEntry;
  68510. private static _FormatMessage;
  68511. private static _LogDisabled;
  68512. private static _LogEnabled;
  68513. private static _WarnDisabled;
  68514. private static _WarnEnabled;
  68515. private static _ErrorDisabled;
  68516. private static _ErrorEnabled;
  68517. /**
  68518. * Log a message to the console
  68519. */
  68520. static Log: (message: string) => void;
  68521. /**
  68522. * Write a warning message to the console
  68523. */
  68524. static Warn: (message: string) => void;
  68525. /**
  68526. * Write an error message to the console
  68527. */
  68528. static Error: (message: string) => void;
  68529. /**
  68530. * Gets current log cache (list of logs)
  68531. */
  68532. static readonly LogCache: string;
  68533. /**
  68534. * Clears the log cache
  68535. */
  68536. static ClearLogCache(): void;
  68537. /**
  68538. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68539. */
  68540. static LogLevels: number;
  68541. }
  68542. }
  68543. declare module BABYLON {
  68544. /** @hidden */
  68545. export class _TypeStore {
  68546. /** @hidden */
  68547. static RegisteredTypes: {
  68548. [key: string]: Object;
  68549. };
  68550. /** @hidden */
  68551. static GetClass(fqdn: string): any;
  68552. }
  68553. }
  68554. declare module BABYLON {
  68555. /**
  68556. * Helper to manipulate strings
  68557. */
  68558. export class StringTools {
  68559. /**
  68560. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68561. * @param str Source string
  68562. * @param suffix Suffix to search for in the source string
  68563. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68564. */
  68565. static EndsWith(str: string, suffix: string): boolean;
  68566. /**
  68567. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68568. * @param str Source string
  68569. * @param suffix Suffix to search for in the source string
  68570. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68571. */
  68572. static StartsWith(str: string, suffix: string): boolean;
  68573. /**
  68574. * Decodes a buffer into a string
  68575. * @param buffer The buffer to decode
  68576. * @returns The decoded string
  68577. */
  68578. static Decode(buffer: Uint8Array | Uint16Array): string;
  68579. /**
  68580. * Encode a buffer to a base64 string
  68581. * @param buffer defines the buffer to encode
  68582. * @returns the encoded string
  68583. */
  68584. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68585. }
  68586. }
  68587. declare module BABYLON {
  68588. /**
  68589. * Class containing a set of static utilities functions for deep copy.
  68590. */
  68591. export class DeepCopier {
  68592. /**
  68593. * Tries to copy an object by duplicating every property
  68594. * @param source defines the source object
  68595. * @param destination defines the target object
  68596. * @param doNotCopyList defines a list of properties to avoid
  68597. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68598. */
  68599. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68600. }
  68601. }
  68602. declare module BABYLON {
  68603. /**
  68604. * Class containing a set of static utilities functions for precision date
  68605. */
  68606. export class PrecisionDate {
  68607. /**
  68608. * Gets either window.performance.now() if supported or Date.now() else
  68609. */
  68610. static readonly Now: number;
  68611. }
  68612. }
  68613. declare module BABYLON {
  68614. /** @hidden */
  68615. export class _DevTools {
  68616. static WarnImport(name: string): string;
  68617. }
  68618. }
  68619. declare module BABYLON {
  68620. /**
  68621. * Interface used to define the mechanism to get data from the network
  68622. */
  68623. export interface IWebRequest {
  68624. /**
  68625. * Returns client's response url
  68626. */
  68627. responseURL: string;
  68628. /**
  68629. * Returns client's status
  68630. */
  68631. status: number;
  68632. /**
  68633. * Returns client's status as a text
  68634. */
  68635. statusText: string;
  68636. }
  68637. }
  68638. declare module BABYLON {
  68639. /**
  68640. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68641. */
  68642. export class WebRequest implements IWebRequest {
  68643. private _xhr;
  68644. /**
  68645. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68646. * i.e. when loading files, where the server/service expects an Authorization header
  68647. */
  68648. static CustomRequestHeaders: {
  68649. [key: string]: string;
  68650. };
  68651. /**
  68652. * Add callback functions in this array to update all the requests before they get sent to the network
  68653. */
  68654. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68655. private _injectCustomRequestHeaders;
  68656. /**
  68657. * Gets or sets a function to be called when loading progress changes
  68658. */
  68659. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68660. /**
  68661. * Returns client's state
  68662. */
  68663. readonly readyState: number;
  68664. /**
  68665. * Returns client's status
  68666. */
  68667. readonly status: number;
  68668. /**
  68669. * Returns client's status as a text
  68670. */
  68671. readonly statusText: string;
  68672. /**
  68673. * Returns client's response
  68674. */
  68675. readonly response: any;
  68676. /**
  68677. * Returns client's response url
  68678. */
  68679. readonly responseURL: string;
  68680. /**
  68681. * Returns client's response as text
  68682. */
  68683. readonly responseText: string;
  68684. /**
  68685. * Gets or sets the expected response type
  68686. */
  68687. responseType: XMLHttpRequestResponseType;
  68688. /** @hidden */
  68689. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68690. /** @hidden */
  68691. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68692. /**
  68693. * Cancels any network activity
  68694. */
  68695. abort(): void;
  68696. /**
  68697. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68698. * @param body defines an optional request body
  68699. */
  68700. send(body?: Document | BodyInit | null): void;
  68701. /**
  68702. * Sets the request method, request URL
  68703. * @param method defines the method to use (GET, POST, etc..)
  68704. * @param url defines the url to connect with
  68705. */
  68706. open(method: string, url: string): void;
  68707. /**
  68708. * Sets the value of a request header.
  68709. * @param name The name of the header whose value is to be set
  68710. * @param value The value to set as the body of the header
  68711. */
  68712. setRequestHeader(name: string, value: string): void;
  68713. /**
  68714. * Get the string containing the text of a particular header's value.
  68715. * @param name The name of the header
  68716. * @returns The string containing the text of the given header name
  68717. */
  68718. getResponseHeader(name: string): Nullable<string>;
  68719. }
  68720. }
  68721. declare module BABYLON {
  68722. /**
  68723. * File request interface
  68724. */
  68725. export interface IFileRequest {
  68726. /**
  68727. * Raised when the request is complete (success or error).
  68728. */
  68729. onCompleteObservable: Observable<IFileRequest>;
  68730. /**
  68731. * Aborts the request for a file.
  68732. */
  68733. abort: () => void;
  68734. }
  68735. }
  68736. declare module BABYLON {
  68737. /**
  68738. * Define options used to create a render target texture
  68739. */
  68740. export class RenderTargetCreationOptions {
  68741. /**
  68742. * Specifies is mipmaps must be generated
  68743. */
  68744. generateMipMaps?: boolean;
  68745. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68746. generateDepthBuffer?: boolean;
  68747. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68748. generateStencilBuffer?: boolean;
  68749. /** Defines texture type (int by default) */
  68750. type?: number;
  68751. /** Defines sampling mode (trilinear by default) */
  68752. samplingMode?: number;
  68753. /** Defines format (RGBA by default) */
  68754. format?: number;
  68755. }
  68756. }
  68757. declare module BABYLON {
  68758. /**
  68759. * @hidden
  68760. **/
  68761. export class _TimeToken {
  68762. _startTimeQuery: Nullable<WebGLQuery>;
  68763. _endTimeQuery: Nullable<WebGLQuery>;
  68764. _timeElapsedQuery: Nullable<WebGLQuery>;
  68765. _timeElapsedQueryEnded: boolean;
  68766. }
  68767. }
  68768. declare module BABYLON {
  68769. /** Defines the cross module used constants to avoid circular dependncies */
  68770. export class Constants {
  68771. /** Defines that alpha blending is disabled */
  68772. static readonly ALPHA_DISABLE: number;
  68773. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68774. static readonly ALPHA_ADD: number;
  68775. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68776. static readonly ALPHA_COMBINE: number;
  68777. /** Defines that alpha blending to DEST - SRC * DEST */
  68778. static readonly ALPHA_SUBTRACT: number;
  68779. /** Defines that alpha blending to SRC * DEST */
  68780. static readonly ALPHA_MULTIPLY: number;
  68781. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68782. static readonly ALPHA_MAXIMIZED: number;
  68783. /** Defines that alpha blending to SRC + DEST */
  68784. static readonly ALPHA_ONEONE: number;
  68785. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68786. static readonly ALPHA_PREMULTIPLIED: number;
  68787. /**
  68788. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68789. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68790. */
  68791. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68792. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68793. static readonly ALPHA_INTERPOLATE: number;
  68794. /**
  68795. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68796. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68797. */
  68798. static readonly ALPHA_SCREENMODE: number;
  68799. /**
  68800. * Defines that alpha blending to SRC + DST
  68801. * Alpha will be set to SRC ALPHA + DST ALPHA
  68802. */
  68803. static readonly ALPHA_ONEONE_ONEONE: number;
  68804. /**
  68805. * Defines that alpha blending to SRC * DST ALPHA + DST
  68806. * Alpha will be set to 0
  68807. */
  68808. static readonly ALPHA_ALPHATOCOLOR: number;
  68809. /**
  68810. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68811. */
  68812. static readonly ALPHA_REVERSEONEMINUS: number;
  68813. /**
  68814. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68815. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68816. */
  68817. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68818. /**
  68819. * Defines that alpha blending to SRC + DST
  68820. * Alpha will be set to SRC ALPHA
  68821. */
  68822. static readonly ALPHA_ONEONE_ONEZERO: number;
  68823. /** Defines that alpha blending equation a SUM */
  68824. static readonly ALPHA_EQUATION_ADD: number;
  68825. /** Defines that alpha blending equation a SUBSTRACTION */
  68826. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68827. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68828. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68829. /** Defines that alpha blending equation a MAX operation */
  68830. static readonly ALPHA_EQUATION_MAX: number;
  68831. /** Defines that alpha blending equation a MIN operation */
  68832. static readonly ALPHA_EQUATION_MIN: number;
  68833. /**
  68834. * Defines that alpha blending equation a DARKEN operation:
  68835. * It takes the min of the src and sums the alpha channels.
  68836. */
  68837. static readonly ALPHA_EQUATION_DARKEN: number;
  68838. /** Defines that the ressource is not delayed*/
  68839. static readonly DELAYLOADSTATE_NONE: number;
  68840. /** Defines that the ressource was successfully delay loaded */
  68841. static readonly DELAYLOADSTATE_LOADED: number;
  68842. /** Defines that the ressource is currently delay loading */
  68843. static readonly DELAYLOADSTATE_LOADING: number;
  68844. /** Defines that the ressource is delayed and has not started loading */
  68845. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68846. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68847. static readonly NEVER: number;
  68848. /** 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 */
  68849. static readonly ALWAYS: number;
  68850. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68851. static readonly LESS: number;
  68852. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68853. static readonly EQUAL: number;
  68854. /** 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 */
  68855. static readonly LEQUAL: number;
  68856. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68857. static readonly GREATER: number;
  68858. /** 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 */
  68859. static readonly GEQUAL: number;
  68860. /** 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 */
  68861. static readonly NOTEQUAL: number;
  68862. /** Passed to stencilOperation to specify that stencil value must be kept */
  68863. static readonly KEEP: number;
  68864. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68865. static readonly REPLACE: number;
  68866. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68867. static readonly INCR: number;
  68868. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68869. static readonly DECR: number;
  68870. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68871. static readonly INVERT: number;
  68872. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68873. static readonly INCR_WRAP: number;
  68874. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68875. static readonly DECR_WRAP: number;
  68876. /** Texture is not repeating outside of 0..1 UVs */
  68877. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68878. /** Texture is repeating outside of 0..1 UVs */
  68879. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68880. /** Texture is repeating and mirrored */
  68881. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68882. /** ALPHA */
  68883. static readonly TEXTUREFORMAT_ALPHA: number;
  68884. /** LUMINANCE */
  68885. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68886. /** LUMINANCE_ALPHA */
  68887. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68888. /** RGB */
  68889. static readonly TEXTUREFORMAT_RGB: number;
  68890. /** RGBA */
  68891. static readonly TEXTUREFORMAT_RGBA: number;
  68892. /** RED */
  68893. static readonly TEXTUREFORMAT_RED: number;
  68894. /** RED (2nd reference) */
  68895. static readonly TEXTUREFORMAT_R: number;
  68896. /** RG */
  68897. static readonly TEXTUREFORMAT_RG: number;
  68898. /** RED_INTEGER */
  68899. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68900. /** RED_INTEGER (2nd reference) */
  68901. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68902. /** RG_INTEGER */
  68903. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68904. /** RGB_INTEGER */
  68905. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68906. /** RGBA_INTEGER */
  68907. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68908. /** UNSIGNED_BYTE */
  68909. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68910. /** UNSIGNED_BYTE (2nd reference) */
  68911. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68912. /** FLOAT */
  68913. static readonly TEXTURETYPE_FLOAT: number;
  68914. /** HALF_FLOAT */
  68915. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68916. /** BYTE */
  68917. static readonly TEXTURETYPE_BYTE: number;
  68918. /** SHORT */
  68919. static readonly TEXTURETYPE_SHORT: number;
  68920. /** UNSIGNED_SHORT */
  68921. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68922. /** INT */
  68923. static readonly TEXTURETYPE_INT: number;
  68924. /** UNSIGNED_INT */
  68925. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68926. /** UNSIGNED_SHORT_4_4_4_4 */
  68927. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68928. /** UNSIGNED_SHORT_5_5_5_1 */
  68929. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68930. /** UNSIGNED_SHORT_5_6_5 */
  68931. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68932. /** UNSIGNED_INT_2_10_10_10_REV */
  68933. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68934. /** UNSIGNED_INT_24_8 */
  68935. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68936. /** UNSIGNED_INT_10F_11F_11F_REV */
  68937. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68938. /** UNSIGNED_INT_5_9_9_9_REV */
  68939. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68940. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68941. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68942. /** nearest is mag = nearest and min = nearest and mip = linear */
  68943. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68944. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68945. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68946. /** Trilinear is mag = linear and min = linear and mip = linear */
  68947. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68948. /** nearest is mag = nearest and min = nearest and mip = linear */
  68949. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68950. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68951. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68952. /** Trilinear is mag = linear and min = linear and mip = linear */
  68953. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68954. /** mag = nearest and min = nearest and mip = nearest */
  68955. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68956. /** mag = nearest and min = linear and mip = nearest */
  68957. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68958. /** mag = nearest and min = linear and mip = linear */
  68959. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68960. /** mag = nearest and min = linear and mip = none */
  68961. static readonly TEXTURE_NEAREST_LINEAR: number;
  68962. /** mag = nearest and min = nearest and mip = none */
  68963. static readonly TEXTURE_NEAREST_NEAREST: number;
  68964. /** mag = linear and min = nearest and mip = nearest */
  68965. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68966. /** mag = linear and min = nearest and mip = linear */
  68967. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68968. /** mag = linear and min = linear and mip = none */
  68969. static readonly TEXTURE_LINEAR_LINEAR: number;
  68970. /** mag = linear and min = nearest and mip = none */
  68971. static readonly TEXTURE_LINEAR_NEAREST: number;
  68972. /** Explicit coordinates mode */
  68973. static readonly TEXTURE_EXPLICIT_MODE: number;
  68974. /** Spherical coordinates mode */
  68975. static readonly TEXTURE_SPHERICAL_MODE: number;
  68976. /** Planar coordinates mode */
  68977. static readonly TEXTURE_PLANAR_MODE: number;
  68978. /** Cubic coordinates mode */
  68979. static readonly TEXTURE_CUBIC_MODE: number;
  68980. /** Projection coordinates mode */
  68981. static readonly TEXTURE_PROJECTION_MODE: number;
  68982. /** Skybox coordinates mode */
  68983. static readonly TEXTURE_SKYBOX_MODE: number;
  68984. /** Inverse Cubic coordinates mode */
  68985. static readonly TEXTURE_INVCUBIC_MODE: number;
  68986. /** Equirectangular coordinates mode */
  68987. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68988. /** Equirectangular Fixed coordinates mode */
  68989. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68990. /** Equirectangular Fixed Mirrored coordinates mode */
  68991. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68992. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68993. static readonly SCALEMODE_FLOOR: number;
  68994. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68995. static readonly SCALEMODE_NEAREST: number;
  68996. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68997. static readonly SCALEMODE_CEILING: number;
  68998. /**
  68999. * The dirty texture flag value
  69000. */
  69001. static readonly MATERIAL_TextureDirtyFlag: number;
  69002. /**
  69003. * The dirty light flag value
  69004. */
  69005. static readonly MATERIAL_LightDirtyFlag: number;
  69006. /**
  69007. * The dirty fresnel flag value
  69008. */
  69009. static readonly MATERIAL_FresnelDirtyFlag: number;
  69010. /**
  69011. * The dirty attribute flag value
  69012. */
  69013. static readonly MATERIAL_AttributesDirtyFlag: number;
  69014. /**
  69015. * The dirty misc flag value
  69016. */
  69017. static readonly MATERIAL_MiscDirtyFlag: number;
  69018. /**
  69019. * The all dirty flag value
  69020. */
  69021. static readonly MATERIAL_AllDirtyFlag: number;
  69022. /**
  69023. * Returns the triangle fill mode
  69024. */
  69025. static readonly MATERIAL_TriangleFillMode: number;
  69026. /**
  69027. * Returns the wireframe mode
  69028. */
  69029. static readonly MATERIAL_WireFrameFillMode: number;
  69030. /**
  69031. * Returns the point fill mode
  69032. */
  69033. static readonly MATERIAL_PointFillMode: number;
  69034. /**
  69035. * Returns the point list draw mode
  69036. */
  69037. static readonly MATERIAL_PointListDrawMode: number;
  69038. /**
  69039. * Returns the line list draw mode
  69040. */
  69041. static readonly MATERIAL_LineListDrawMode: number;
  69042. /**
  69043. * Returns the line loop draw mode
  69044. */
  69045. static readonly MATERIAL_LineLoopDrawMode: number;
  69046. /**
  69047. * Returns the line strip draw mode
  69048. */
  69049. static readonly MATERIAL_LineStripDrawMode: number;
  69050. /**
  69051. * Returns the triangle strip draw mode
  69052. */
  69053. static readonly MATERIAL_TriangleStripDrawMode: number;
  69054. /**
  69055. * Returns the triangle fan draw mode
  69056. */
  69057. static readonly MATERIAL_TriangleFanDrawMode: number;
  69058. /**
  69059. * Stores the clock-wise side orientation
  69060. */
  69061. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69062. /**
  69063. * Stores the counter clock-wise side orientation
  69064. */
  69065. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69066. /**
  69067. * Nothing
  69068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69069. */
  69070. static readonly ACTION_NothingTrigger: number;
  69071. /**
  69072. * On pick
  69073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69074. */
  69075. static readonly ACTION_OnPickTrigger: number;
  69076. /**
  69077. * On left pick
  69078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69079. */
  69080. static readonly ACTION_OnLeftPickTrigger: number;
  69081. /**
  69082. * On right pick
  69083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69084. */
  69085. static readonly ACTION_OnRightPickTrigger: number;
  69086. /**
  69087. * On center pick
  69088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69089. */
  69090. static readonly ACTION_OnCenterPickTrigger: number;
  69091. /**
  69092. * On pick down
  69093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69094. */
  69095. static readonly ACTION_OnPickDownTrigger: number;
  69096. /**
  69097. * On double pick
  69098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69099. */
  69100. static readonly ACTION_OnDoublePickTrigger: number;
  69101. /**
  69102. * On pick up
  69103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69104. */
  69105. static readonly ACTION_OnPickUpTrigger: number;
  69106. /**
  69107. * On pick out.
  69108. * This trigger will only be raised if you also declared a OnPickDown
  69109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69110. */
  69111. static readonly ACTION_OnPickOutTrigger: number;
  69112. /**
  69113. * On long press
  69114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69115. */
  69116. static readonly ACTION_OnLongPressTrigger: number;
  69117. /**
  69118. * On pointer over
  69119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69120. */
  69121. static readonly ACTION_OnPointerOverTrigger: number;
  69122. /**
  69123. * On pointer out
  69124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69125. */
  69126. static readonly ACTION_OnPointerOutTrigger: number;
  69127. /**
  69128. * On every frame
  69129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69130. */
  69131. static readonly ACTION_OnEveryFrameTrigger: number;
  69132. /**
  69133. * On intersection enter
  69134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69135. */
  69136. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69137. /**
  69138. * On intersection exit
  69139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69140. */
  69141. static readonly ACTION_OnIntersectionExitTrigger: number;
  69142. /**
  69143. * On key down
  69144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69145. */
  69146. static readonly ACTION_OnKeyDownTrigger: number;
  69147. /**
  69148. * On key up
  69149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69150. */
  69151. static readonly ACTION_OnKeyUpTrigger: number;
  69152. /**
  69153. * Billboard mode will only apply to Y axis
  69154. */
  69155. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69156. /**
  69157. * Billboard mode will apply to all axes
  69158. */
  69159. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69160. /**
  69161. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69162. */
  69163. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69164. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69165. * Test order :
  69166. * Is the bounding sphere outside the frustum ?
  69167. * If not, are the bounding box vertices outside the frustum ?
  69168. * It not, then the cullable object is in the frustum.
  69169. */
  69170. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69171. /** Culling strategy : Bounding Sphere Only.
  69172. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69173. * It's also less accurate than the standard because some not visible objects can still be selected.
  69174. * Test : is the bounding sphere outside the frustum ?
  69175. * If not, then the cullable object is in the frustum.
  69176. */
  69177. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69178. /** Culling strategy : Optimistic Inclusion.
  69179. * This in an inclusion test first, then the standard exclusion test.
  69180. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69181. * 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.
  69182. * Anyway, it's as accurate as the standard strategy.
  69183. * Test :
  69184. * Is the cullable object bounding sphere center in the frustum ?
  69185. * If not, apply the default culling strategy.
  69186. */
  69187. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69188. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69189. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69190. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69191. * 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.
  69192. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69193. * Test :
  69194. * Is the cullable object bounding sphere center in the frustum ?
  69195. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69196. */
  69197. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69198. /**
  69199. * No logging while loading
  69200. */
  69201. static readonly SCENELOADER_NO_LOGGING: number;
  69202. /**
  69203. * Minimal logging while loading
  69204. */
  69205. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69206. /**
  69207. * Summary logging while loading
  69208. */
  69209. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69210. /**
  69211. * Detailled logging while loading
  69212. */
  69213. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69214. }
  69215. }
  69216. declare module BABYLON {
  69217. /**
  69218. * This represents the required contract to create a new type of texture loader.
  69219. */
  69220. export interface IInternalTextureLoader {
  69221. /**
  69222. * Defines wether the loader supports cascade loading the different faces.
  69223. */
  69224. supportCascades: boolean;
  69225. /**
  69226. * This returns if the loader support the current file information.
  69227. * @param extension defines the file extension of the file being loaded
  69228. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69229. * @param fallback defines the fallback internal texture if any
  69230. * @param isBase64 defines whether the texture is encoded as a base64
  69231. * @param isBuffer defines whether the texture data are stored as a buffer
  69232. * @returns true if the loader can load the specified file
  69233. */
  69234. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69235. /**
  69236. * Transform the url before loading if required.
  69237. * @param rootUrl the url of the texture
  69238. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69239. * @returns the transformed texture
  69240. */
  69241. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69242. /**
  69243. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69244. * @param rootUrl the url of the texture
  69245. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69246. * @returns the fallback texture
  69247. */
  69248. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69249. /**
  69250. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69251. * @param data contains the texture data
  69252. * @param texture defines the BabylonJS internal texture
  69253. * @param createPolynomials will be true if polynomials have been requested
  69254. * @param onLoad defines the callback to trigger once the texture is ready
  69255. * @param onError defines the callback to trigger in case of error
  69256. */
  69257. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69258. /**
  69259. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69260. * @param data contains the texture data
  69261. * @param texture defines the BabylonJS internal texture
  69262. * @param callback defines the method to call once ready to upload
  69263. */
  69264. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69265. }
  69266. }
  69267. declare module BABYLON {
  69268. /**
  69269. * Class used to store and describe the pipeline context associated with an effect
  69270. */
  69271. export interface IPipelineContext {
  69272. /**
  69273. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69274. */
  69275. isAsync: boolean;
  69276. /**
  69277. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69278. */
  69279. isReady: boolean;
  69280. /** @hidden */
  69281. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69282. }
  69283. }
  69284. declare module BABYLON {
  69285. /**
  69286. * Class used to store gfx data (like WebGLBuffer)
  69287. */
  69288. export class DataBuffer {
  69289. /**
  69290. * Gets or sets the number of objects referencing this buffer
  69291. */
  69292. references: number;
  69293. /** Gets or sets the size of the underlying buffer */
  69294. capacity: number;
  69295. /**
  69296. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69297. */
  69298. is32Bits: boolean;
  69299. /**
  69300. * Gets the underlying buffer
  69301. */
  69302. readonly underlyingResource: any;
  69303. }
  69304. }
  69305. declare module BABYLON {
  69306. /** @hidden */
  69307. export interface IShaderProcessor {
  69308. attributeProcessor?: (attribute: string) => string;
  69309. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69310. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69311. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69312. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69313. lineProcessor?: (line: string, isFragment: boolean) => string;
  69314. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69315. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69316. }
  69317. }
  69318. declare module BABYLON {
  69319. /** @hidden */
  69320. export interface ProcessingOptions {
  69321. defines: string[];
  69322. indexParameters: any;
  69323. isFragment: boolean;
  69324. shouldUseHighPrecisionShader: boolean;
  69325. supportsUniformBuffers: boolean;
  69326. shadersRepository: string;
  69327. includesShadersStore: {
  69328. [key: string]: string;
  69329. };
  69330. processor?: IShaderProcessor;
  69331. version: string;
  69332. platformName: string;
  69333. lookForClosingBracketForUniformBuffer?: boolean;
  69334. }
  69335. }
  69336. declare module BABYLON {
  69337. /** @hidden */
  69338. export class ShaderCodeNode {
  69339. line: string;
  69340. children: ShaderCodeNode[];
  69341. additionalDefineKey?: string;
  69342. additionalDefineValue?: string;
  69343. isValid(preprocessors: {
  69344. [key: string]: string;
  69345. }): boolean;
  69346. process(preprocessors: {
  69347. [key: string]: string;
  69348. }, options: ProcessingOptions): string;
  69349. }
  69350. }
  69351. declare module BABYLON {
  69352. /** @hidden */
  69353. export class ShaderCodeCursor {
  69354. private _lines;
  69355. lineIndex: number;
  69356. readonly currentLine: string;
  69357. readonly canRead: boolean;
  69358. lines: string[];
  69359. }
  69360. }
  69361. declare module BABYLON {
  69362. /** @hidden */
  69363. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69364. process(preprocessors: {
  69365. [key: string]: string;
  69366. }, options: ProcessingOptions): string;
  69367. }
  69368. }
  69369. declare module BABYLON {
  69370. /** @hidden */
  69371. export class ShaderDefineExpression {
  69372. isTrue(preprocessors: {
  69373. [key: string]: string;
  69374. }): boolean;
  69375. }
  69376. }
  69377. declare module BABYLON {
  69378. /** @hidden */
  69379. export class ShaderCodeTestNode extends ShaderCodeNode {
  69380. testExpression: ShaderDefineExpression;
  69381. isValid(preprocessors: {
  69382. [key: string]: string;
  69383. }): boolean;
  69384. }
  69385. }
  69386. declare module BABYLON {
  69387. /** @hidden */
  69388. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69389. define: string;
  69390. not: boolean;
  69391. constructor(define: string, not?: boolean);
  69392. isTrue(preprocessors: {
  69393. [key: string]: string;
  69394. }): boolean;
  69395. }
  69396. }
  69397. declare module BABYLON {
  69398. /** @hidden */
  69399. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69400. leftOperand: ShaderDefineExpression;
  69401. rightOperand: ShaderDefineExpression;
  69402. isTrue(preprocessors: {
  69403. [key: string]: string;
  69404. }): boolean;
  69405. }
  69406. }
  69407. declare module BABYLON {
  69408. /** @hidden */
  69409. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69410. leftOperand: ShaderDefineExpression;
  69411. rightOperand: ShaderDefineExpression;
  69412. isTrue(preprocessors: {
  69413. [key: string]: string;
  69414. }): boolean;
  69415. }
  69416. }
  69417. declare module BABYLON {
  69418. /** @hidden */
  69419. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69420. define: string;
  69421. operand: string;
  69422. testValue: string;
  69423. constructor(define: string, operand: string, testValue: string);
  69424. isTrue(preprocessors: {
  69425. [key: string]: string;
  69426. }): boolean;
  69427. }
  69428. }
  69429. declare module BABYLON {
  69430. /**
  69431. * Class used to enable access to offline support
  69432. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69433. */
  69434. export interface IOfflineProvider {
  69435. /**
  69436. * Gets a boolean indicating if scene must be saved in the database
  69437. */
  69438. enableSceneOffline: boolean;
  69439. /**
  69440. * Gets a boolean indicating if textures must be saved in the database
  69441. */
  69442. enableTexturesOffline: boolean;
  69443. /**
  69444. * Open the offline support and make it available
  69445. * @param successCallback defines the callback to call on success
  69446. * @param errorCallback defines the callback to call on error
  69447. */
  69448. open(successCallback: () => void, errorCallback: () => void): void;
  69449. /**
  69450. * Loads an image from the offline support
  69451. * @param url defines the url to load from
  69452. * @param image defines the target DOM image
  69453. */
  69454. loadImage(url: string, image: HTMLImageElement): void;
  69455. /**
  69456. * Loads a file from offline support
  69457. * @param url defines the URL to load from
  69458. * @param sceneLoaded defines a callback to call on success
  69459. * @param progressCallBack defines a callback to call when progress changed
  69460. * @param errorCallback defines a callback to call on error
  69461. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69462. */
  69463. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69464. }
  69465. }
  69466. declare module BABYLON {
  69467. /**
  69468. * Class used to help managing file picking and drag'n'drop
  69469. * File Storage
  69470. */
  69471. export class FilesInputStore {
  69472. /**
  69473. * List of files ready to be loaded
  69474. */
  69475. static FilesToLoad: {
  69476. [key: string]: File;
  69477. };
  69478. }
  69479. }
  69480. declare module BABYLON {
  69481. /**
  69482. * Class used to define a retry strategy when error happens while loading assets
  69483. */
  69484. export class RetryStrategy {
  69485. /**
  69486. * Function used to defines an exponential back off strategy
  69487. * @param maxRetries defines the maximum number of retries (3 by default)
  69488. * @param baseInterval defines the interval between retries
  69489. * @returns the strategy function to use
  69490. */
  69491. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69492. }
  69493. }
  69494. declare module BABYLON {
  69495. /**
  69496. * @ignore
  69497. * Application error to support additional information when loading a file
  69498. */
  69499. export abstract class BaseError extends Error {
  69500. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69501. }
  69502. }
  69503. declare module BABYLON {
  69504. /** @ignore */
  69505. export class LoadFileError extends BaseError {
  69506. request?: WebRequest;
  69507. file?: File;
  69508. /**
  69509. * Creates a new LoadFileError
  69510. * @param message defines the message of the error
  69511. * @param request defines the optional web request
  69512. * @param file defines the optional file
  69513. */
  69514. constructor(message: string, object?: WebRequest | File);
  69515. }
  69516. /** @ignore */
  69517. export class RequestFileError extends BaseError {
  69518. request: WebRequest;
  69519. /**
  69520. * Creates a new LoadFileError
  69521. * @param message defines the message of the error
  69522. * @param request defines the optional web request
  69523. */
  69524. constructor(message: string, request: WebRequest);
  69525. }
  69526. /** @ignore */
  69527. export class ReadFileError extends BaseError {
  69528. file: File;
  69529. /**
  69530. * Creates a new ReadFileError
  69531. * @param message defines the message of the error
  69532. * @param file defines the optional file
  69533. */
  69534. constructor(message: string, file: File);
  69535. }
  69536. /**
  69537. * @hidden
  69538. */
  69539. export class FileTools {
  69540. /**
  69541. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69542. */
  69543. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69544. /**
  69545. * Gets or sets the base URL to use to load assets
  69546. */
  69547. static BaseUrl: string;
  69548. /**
  69549. * Default behaviour for cors in the application.
  69550. * It can be a string if the expected behavior is identical in the entire app.
  69551. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69552. */
  69553. static CorsBehavior: string | ((url: string | string[]) => string);
  69554. /**
  69555. * Gets or sets a function used to pre-process url before using them to load assets
  69556. */
  69557. static PreprocessUrl: (url: string) => string;
  69558. /**
  69559. * Removes unwanted characters from an url
  69560. * @param url defines the url to clean
  69561. * @returns the cleaned url
  69562. */
  69563. private static _CleanUrl;
  69564. /**
  69565. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69566. * @param url define the url we are trying
  69567. * @param element define the dom element where to configure the cors policy
  69568. */
  69569. static SetCorsBehavior(url: string | string[], element: {
  69570. crossOrigin: string | null;
  69571. }): void;
  69572. /**
  69573. * Loads an image as an HTMLImageElement.
  69574. * @param input url string, ArrayBuffer, or Blob to load
  69575. * @param onLoad callback called when the image successfully loads
  69576. * @param onError callback called when the image fails to load
  69577. * @param offlineProvider offline provider for caching
  69578. * @param mimeType optional mime type
  69579. * @returns the HTMLImageElement of the loaded image
  69580. */
  69581. 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>;
  69582. /**
  69583. * Reads a file from a File object
  69584. * @param file defines the file to load
  69585. * @param onSuccess defines the callback to call when data is loaded
  69586. * @param onProgress defines the callback to call during loading process
  69587. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69588. * @param onError defines the callback to call when an error occurs
  69589. * @returns a file request object
  69590. */
  69591. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69592. /**
  69593. * Loads a file from a url
  69594. * @param url url to load
  69595. * @param onSuccess callback called when the file successfully loads
  69596. * @param onProgress callback called while file is loading (if the server supports this mode)
  69597. * @param offlineProvider defines the offline provider for caching
  69598. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69599. * @param onError callback called when the file fails to load
  69600. * @returns a file request object
  69601. */
  69602. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  69603. /**
  69604. * Loads a file
  69605. * @param url url to load
  69606. * @param onSuccess callback called when the file successfully loads
  69607. * @param onProgress callback called while file is loading (if the server supports this mode)
  69608. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69609. * @param onError callback called when the file fails to load
  69610. * @param onOpened callback called when the web request is opened
  69611. * @returns a file request object
  69612. */
  69613. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  69614. /**
  69615. * Checks if the loaded document was accessed via `file:`-Protocol.
  69616. * @returns boolean
  69617. */
  69618. static IsFileURL(): boolean;
  69619. }
  69620. }
  69621. declare module BABYLON {
  69622. /** @hidden */
  69623. export class ShaderProcessor {
  69624. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69625. private static _ProcessPrecision;
  69626. private static _ExtractOperation;
  69627. private static _BuildSubExpression;
  69628. private static _BuildExpression;
  69629. private static _MoveCursorWithinIf;
  69630. private static _MoveCursor;
  69631. private static _EvaluatePreProcessors;
  69632. private static _PreparePreProcessors;
  69633. private static _ProcessShaderConversion;
  69634. private static _ProcessIncludes;
  69635. }
  69636. }
  69637. declare module BABYLON {
  69638. /**
  69639. * @hidden
  69640. */
  69641. export interface IColor4Like {
  69642. r: float;
  69643. g: float;
  69644. b: float;
  69645. a: float;
  69646. }
  69647. /**
  69648. * @hidden
  69649. */
  69650. export interface IColor3Like {
  69651. r: float;
  69652. g: float;
  69653. b: float;
  69654. }
  69655. /**
  69656. * @hidden
  69657. */
  69658. export interface IVector4Like {
  69659. x: float;
  69660. y: float;
  69661. z: float;
  69662. w: float;
  69663. }
  69664. /**
  69665. * @hidden
  69666. */
  69667. export interface IVector3Like {
  69668. x: float;
  69669. y: float;
  69670. z: float;
  69671. }
  69672. /**
  69673. * @hidden
  69674. */
  69675. export interface IVector2Like {
  69676. x: float;
  69677. y: float;
  69678. }
  69679. /**
  69680. * @hidden
  69681. */
  69682. export interface IMatrixLike {
  69683. toArray(): DeepImmutable<Float32Array>;
  69684. updateFlag: int;
  69685. }
  69686. /**
  69687. * @hidden
  69688. */
  69689. export interface IViewportLike {
  69690. x: float;
  69691. y: float;
  69692. width: float;
  69693. height: float;
  69694. }
  69695. /**
  69696. * @hidden
  69697. */
  69698. export interface IPlaneLike {
  69699. normal: IVector3Like;
  69700. d: float;
  69701. normalize(): void;
  69702. }
  69703. }
  69704. declare module BABYLON {
  69705. /**
  69706. * Interface used to define common properties for effect fallbacks
  69707. */
  69708. export interface IEffectFallbacks {
  69709. /**
  69710. * Removes the defines that should be removed when falling back.
  69711. * @param currentDefines defines the current define statements for the shader.
  69712. * @param effect defines the current effect we try to compile
  69713. * @returns The resulting defines with defines of the current rank removed.
  69714. */
  69715. reduce(currentDefines: string, effect: Effect): string;
  69716. /**
  69717. * Removes the fallback from the bound mesh.
  69718. */
  69719. unBindMesh(): void;
  69720. /**
  69721. * Checks to see if more fallbacks are still availible.
  69722. */
  69723. hasMoreFallbacks: boolean;
  69724. }
  69725. }
  69726. declare module BABYLON {
  69727. /**
  69728. * Class used to evalaute queries containing `and` and `or` operators
  69729. */
  69730. export class AndOrNotEvaluator {
  69731. /**
  69732. * Evaluate a query
  69733. * @param query defines the query to evaluate
  69734. * @param evaluateCallback defines the callback used to filter result
  69735. * @returns true if the query matches
  69736. */
  69737. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69738. private static _HandleParenthesisContent;
  69739. private static _SimplifyNegation;
  69740. }
  69741. }
  69742. declare module BABYLON {
  69743. /**
  69744. * Class used to store custom tags
  69745. */
  69746. export class Tags {
  69747. /**
  69748. * Adds support for tags on the given object
  69749. * @param obj defines the object to use
  69750. */
  69751. static EnableFor(obj: any): void;
  69752. /**
  69753. * Removes tags support
  69754. * @param obj defines the object to use
  69755. */
  69756. static DisableFor(obj: any): void;
  69757. /**
  69758. * Gets a boolean indicating if the given object has tags
  69759. * @param obj defines the object to use
  69760. * @returns a boolean
  69761. */
  69762. static HasTags(obj: any): boolean;
  69763. /**
  69764. * Gets the tags available on a given object
  69765. * @param obj defines the object to use
  69766. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69767. * @returns the tags
  69768. */
  69769. static GetTags(obj: any, asString?: boolean): any;
  69770. /**
  69771. * Adds tags to an object
  69772. * @param obj defines the object to use
  69773. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69774. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69775. */
  69776. static AddTagsTo(obj: any, tagsString: string): void;
  69777. /**
  69778. * @hidden
  69779. */
  69780. static _AddTagTo(obj: any, tag: string): void;
  69781. /**
  69782. * Removes specific tags from a specific object
  69783. * @param obj defines the object to use
  69784. * @param tagsString defines the tags to remove
  69785. */
  69786. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69787. /**
  69788. * @hidden
  69789. */
  69790. static _RemoveTagFrom(obj: any, tag: string): void;
  69791. /**
  69792. * Defines if tags hosted on an object match a given query
  69793. * @param obj defines the object to use
  69794. * @param tagsQuery defines the tag query
  69795. * @returns a boolean
  69796. */
  69797. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69798. }
  69799. }
  69800. declare module BABYLON {
  69801. /**
  69802. * Scalar computation library
  69803. */
  69804. export class Scalar {
  69805. /**
  69806. * Two pi constants convenient for computation.
  69807. */
  69808. static TwoPi: number;
  69809. /**
  69810. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69811. * @param a number
  69812. * @param b number
  69813. * @param epsilon (default = 1.401298E-45)
  69814. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69815. */
  69816. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69817. /**
  69818. * Returns a string : the upper case translation of the number i to hexadecimal.
  69819. * @param i number
  69820. * @returns the upper case translation of the number i to hexadecimal.
  69821. */
  69822. static ToHex(i: number): string;
  69823. /**
  69824. * Returns -1 if value is negative and +1 is value is positive.
  69825. * @param value the value
  69826. * @returns the value itself if it's equal to zero.
  69827. */
  69828. static Sign(value: number): number;
  69829. /**
  69830. * Returns the value itself if it's between min and max.
  69831. * Returns min if the value is lower than min.
  69832. * Returns max if the value is greater than max.
  69833. * @param value the value to clmap
  69834. * @param min the min value to clamp to (default: 0)
  69835. * @param max the max value to clamp to (default: 1)
  69836. * @returns the clamped value
  69837. */
  69838. static Clamp(value: number, min?: number, max?: number): number;
  69839. /**
  69840. * the log2 of value.
  69841. * @param value the value to compute log2 of
  69842. * @returns the log2 of value.
  69843. */
  69844. static Log2(value: number): number;
  69845. /**
  69846. * Loops the value, so that it is never larger than length and never smaller than 0.
  69847. *
  69848. * This is similar to the modulo operator but it works with floating point numbers.
  69849. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69850. * With t = 5 and length = 2.5, the result would be 0.0.
  69851. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69852. * @param value the value
  69853. * @param length the length
  69854. * @returns the looped value
  69855. */
  69856. static Repeat(value: number, length: number): number;
  69857. /**
  69858. * Normalize the value between 0.0 and 1.0 using min and max values
  69859. * @param value value to normalize
  69860. * @param min max to normalize between
  69861. * @param max min to normalize between
  69862. * @returns the normalized value
  69863. */
  69864. static Normalize(value: number, min: number, max: number): number;
  69865. /**
  69866. * Denormalize the value from 0.0 and 1.0 using min and max values
  69867. * @param normalized value to denormalize
  69868. * @param min max to denormalize between
  69869. * @param max min to denormalize between
  69870. * @returns the denormalized value
  69871. */
  69872. static Denormalize(normalized: number, min: number, max: number): number;
  69873. /**
  69874. * Calculates the shortest difference between two given angles given in degrees.
  69875. * @param current current angle in degrees
  69876. * @param target target angle in degrees
  69877. * @returns the delta
  69878. */
  69879. static DeltaAngle(current: number, target: number): number;
  69880. /**
  69881. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69882. * @param tx value
  69883. * @param length length
  69884. * @returns The returned value will move back and forth between 0 and length
  69885. */
  69886. static PingPong(tx: number, length: number): number;
  69887. /**
  69888. * Interpolates between min and max with smoothing at the limits.
  69889. *
  69890. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69891. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69892. * @param from from
  69893. * @param to to
  69894. * @param tx value
  69895. * @returns the smooth stepped value
  69896. */
  69897. static SmoothStep(from: number, to: number, tx: number): number;
  69898. /**
  69899. * Moves a value current towards target.
  69900. *
  69901. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69902. * Negative values of maxDelta pushes the value away from target.
  69903. * @param current current value
  69904. * @param target target value
  69905. * @param maxDelta max distance to move
  69906. * @returns resulting value
  69907. */
  69908. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69909. /**
  69910. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69911. *
  69912. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69913. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69914. * @param current current value
  69915. * @param target target value
  69916. * @param maxDelta max distance to move
  69917. * @returns resulting angle
  69918. */
  69919. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69920. /**
  69921. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69922. * @param start start value
  69923. * @param end target value
  69924. * @param amount amount to lerp between
  69925. * @returns the lerped value
  69926. */
  69927. static Lerp(start: number, end: number, amount: number): number;
  69928. /**
  69929. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69930. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69931. * @param start start value
  69932. * @param end target value
  69933. * @param amount amount to lerp between
  69934. * @returns the lerped value
  69935. */
  69936. static LerpAngle(start: number, end: number, amount: number): number;
  69937. /**
  69938. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69939. * @param a start value
  69940. * @param b target value
  69941. * @param value value between a and b
  69942. * @returns the inverseLerp value
  69943. */
  69944. static InverseLerp(a: number, b: number, value: number): number;
  69945. /**
  69946. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69947. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69948. * @param value1 spline value
  69949. * @param tangent1 spline value
  69950. * @param value2 spline value
  69951. * @param tangent2 spline value
  69952. * @param amount input value
  69953. * @returns hermite result
  69954. */
  69955. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69956. /**
  69957. * Returns a random float number between and min and max values
  69958. * @param min min value of random
  69959. * @param max max value of random
  69960. * @returns random value
  69961. */
  69962. static RandomRange(min: number, max: number): number;
  69963. /**
  69964. * This function returns percentage of a number in a given range.
  69965. *
  69966. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69967. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69968. * @param number to convert to percentage
  69969. * @param min min range
  69970. * @param max max range
  69971. * @returns the percentage
  69972. */
  69973. static RangeToPercent(number: number, min: number, max: number): number;
  69974. /**
  69975. * This function returns number that corresponds to the percentage in a given range.
  69976. *
  69977. * PercentToRange(0.34,0,100) will return 34.
  69978. * @param percent to convert to number
  69979. * @param min min range
  69980. * @param max max range
  69981. * @returns the number
  69982. */
  69983. static PercentToRange(percent: number, min: number, max: number): number;
  69984. /**
  69985. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69986. * @param angle The angle to normalize in radian.
  69987. * @return The converted angle.
  69988. */
  69989. static NormalizeRadians(angle: number): number;
  69990. }
  69991. }
  69992. declare module BABYLON {
  69993. /**
  69994. * Constant used to convert a value to gamma space
  69995. * @ignorenaming
  69996. */
  69997. export const ToGammaSpace: number;
  69998. /**
  69999. * Constant used to convert a value to linear space
  70000. * @ignorenaming
  70001. */
  70002. export const ToLinearSpace = 2.2;
  70003. /**
  70004. * Constant used to define the minimal number value in Babylon.js
  70005. * @ignorenaming
  70006. */
  70007. let Epsilon: number;
  70008. }
  70009. declare module BABYLON {
  70010. /**
  70011. * Class used to represent a viewport on screen
  70012. */
  70013. export class Viewport {
  70014. /** viewport left coordinate */
  70015. x: number;
  70016. /** viewport top coordinate */
  70017. y: number;
  70018. /**viewport width */
  70019. width: number;
  70020. /** viewport height */
  70021. height: number;
  70022. /**
  70023. * Creates a Viewport object located at (x, y) and sized (width, height)
  70024. * @param x defines viewport left coordinate
  70025. * @param y defines viewport top coordinate
  70026. * @param width defines the viewport width
  70027. * @param height defines the viewport height
  70028. */
  70029. constructor(
  70030. /** viewport left coordinate */
  70031. x: number,
  70032. /** viewport top coordinate */
  70033. y: number,
  70034. /**viewport width */
  70035. width: number,
  70036. /** viewport height */
  70037. height: number);
  70038. /**
  70039. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70040. * @param renderWidth defines the rendering width
  70041. * @param renderHeight defines the rendering height
  70042. * @returns a new Viewport
  70043. */
  70044. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70045. /**
  70046. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70047. * @param renderWidth defines the rendering width
  70048. * @param renderHeight defines the rendering height
  70049. * @param ref defines the target viewport
  70050. * @returns the current viewport
  70051. */
  70052. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70053. /**
  70054. * Returns a new Viewport copied from the current one
  70055. * @returns a new Viewport
  70056. */
  70057. clone(): Viewport;
  70058. }
  70059. }
  70060. declare module BABYLON {
  70061. /**
  70062. * Class containing a set of static utilities functions for arrays.
  70063. */
  70064. export class ArrayTools {
  70065. /**
  70066. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70067. * @param size the number of element to construct and put in the array
  70068. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70069. * @returns a new array filled with new objects
  70070. */
  70071. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70072. }
  70073. }
  70074. declare module BABYLON {
  70075. /**
  70076. * Class representing a vector containing 2 coordinates
  70077. */
  70078. export class Vector2 {
  70079. /** defines the first coordinate */
  70080. x: number;
  70081. /** defines the second coordinate */
  70082. y: number;
  70083. /**
  70084. * Creates a new Vector2 from the given x and y coordinates
  70085. * @param x defines the first coordinate
  70086. * @param y defines the second coordinate
  70087. */
  70088. constructor(
  70089. /** defines the first coordinate */
  70090. x?: number,
  70091. /** defines the second coordinate */
  70092. y?: number);
  70093. /**
  70094. * Gets a string with the Vector2 coordinates
  70095. * @returns a string with the Vector2 coordinates
  70096. */
  70097. toString(): string;
  70098. /**
  70099. * Gets class name
  70100. * @returns the string "Vector2"
  70101. */
  70102. getClassName(): string;
  70103. /**
  70104. * Gets current vector hash code
  70105. * @returns the Vector2 hash code as a number
  70106. */
  70107. getHashCode(): number;
  70108. /**
  70109. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70110. * @param array defines the source array
  70111. * @param index defines the offset in source array
  70112. * @returns the current Vector2
  70113. */
  70114. toArray(array: FloatArray, index?: number): Vector2;
  70115. /**
  70116. * Copy the current vector to an array
  70117. * @returns a new array with 2 elements: the Vector2 coordinates.
  70118. */
  70119. asArray(): number[];
  70120. /**
  70121. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70122. * @param source defines the source Vector2
  70123. * @returns the current updated Vector2
  70124. */
  70125. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70126. /**
  70127. * Sets the Vector2 coordinates with the given floats
  70128. * @param x defines the first coordinate
  70129. * @param y defines the second coordinate
  70130. * @returns the current updated Vector2
  70131. */
  70132. copyFromFloats(x: number, y: number): Vector2;
  70133. /**
  70134. * Sets the Vector2 coordinates with the given floats
  70135. * @param x defines the first coordinate
  70136. * @param y defines the second coordinate
  70137. * @returns the current updated Vector2
  70138. */
  70139. set(x: number, y: number): Vector2;
  70140. /**
  70141. * Add another vector with the current one
  70142. * @param otherVector defines the other vector
  70143. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70144. */
  70145. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70146. /**
  70147. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70148. * @param otherVector defines the other vector
  70149. * @param result defines the target vector
  70150. * @returns the unmodified current Vector2
  70151. */
  70152. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70153. /**
  70154. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70155. * @param otherVector defines the other vector
  70156. * @returns the current updated Vector2
  70157. */
  70158. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70159. /**
  70160. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70161. * @param otherVector defines the other vector
  70162. * @returns a new Vector2
  70163. */
  70164. addVector3(otherVector: Vector3): Vector2;
  70165. /**
  70166. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70167. * @param otherVector defines the other vector
  70168. * @returns a new Vector2
  70169. */
  70170. subtract(otherVector: Vector2): Vector2;
  70171. /**
  70172. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70173. * @param otherVector defines the other vector
  70174. * @param result defines the target vector
  70175. * @returns the unmodified current Vector2
  70176. */
  70177. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70178. /**
  70179. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70180. * @param otherVector defines the other vector
  70181. * @returns the current updated Vector2
  70182. */
  70183. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70184. /**
  70185. * Multiplies in place the current Vector2 coordinates by the given ones
  70186. * @param otherVector defines the other vector
  70187. * @returns the current updated Vector2
  70188. */
  70189. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70190. /**
  70191. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70192. * @param otherVector defines the other vector
  70193. * @returns a new Vector2
  70194. */
  70195. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70196. /**
  70197. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70198. * @param otherVector defines the other vector
  70199. * @param result defines the target vector
  70200. * @returns the unmodified current Vector2
  70201. */
  70202. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70203. /**
  70204. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70205. * @param x defines the first coordinate
  70206. * @param y defines the second coordinate
  70207. * @returns a new Vector2
  70208. */
  70209. multiplyByFloats(x: number, y: number): Vector2;
  70210. /**
  70211. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70212. * @param otherVector defines the other vector
  70213. * @returns a new Vector2
  70214. */
  70215. divide(otherVector: Vector2): Vector2;
  70216. /**
  70217. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70218. * @param otherVector defines the other vector
  70219. * @param result defines the target vector
  70220. * @returns the unmodified current Vector2
  70221. */
  70222. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70223. /**
  70224. * Divides the current Vector2 coordinates by the given ones
  70225. * @param otherVector defines the other vector
  70226. * @returns the current updated Vector2
  70227. */
  70228. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70229. /**
  70230. * Gets a new Vector2 with current Vector2 negated coordinates
  70231. * @returns a new Vector2
  70232. */
  70233. negate(): Vector2;
  70234. /**
  70235. * Multiply the Vector2 coordinates by scale
  70236. * @param scale defines the scaling factor
  70237. * @returns the current updated Vector2
  70238. */
  70239. scaleInPlace(scale: number): Vector2;
  70240. /**
  70241. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70242. * @param scale defines the scaling factor
  70243. * @returns a new Vector2
  70244. */
  70245. scale(scale: number): Vector2;
  70246. /**
  70247. * Scale the current Vector2 values by a factor to a given Vector2
  70248. * @param scale defines the scale factor
  70249. * @param result defines the Vector2 object where to store the result
  70250. * @returns the unmodified current Vector2
  70251. */
  70252. scaleToRef(scale: number, result: Vector2): Vector2;
  70253. /**
  70254. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70255. * @param scale defines the scale factor
  70256. * @param result defines the Vector2 object where to store the result
  70257. * @returns the unmodified current Vector2
  70258. */
  70259. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70260. /**
  70261. * Gets a boolean if two vectors are equals
  70262. * @param otherVector defines the other vector
  70263. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70264. */
  70265. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70266. /**
  70267. * Gets a boolean if two vectors are equals (using an epsilon value)
  70268. * @param otherVector defines the other vector
  70269. * @param epsilon defines the minimal distance to consider equality
  70270. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70271. */
  70272. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70273. /**
  70274. * Gets a new Vector2 from current Vector2 floored values
  70275. * @returns a new Vector2
  70276. */
  70277. floor(): Vector2;
  70278. /**
  70279. * Gets a new Vector2 from current Vector2 floored values
  70280. * @returns a new Vector2
  70281. */
  70282. fract(): Vector2;
  70283. /**
  70284. * Gets the length of the vector
  70285. * @returns the vector length (float)
  70286. */
  70287. length(): number;
  70288. /**
  70289. * Gets the vector squared length
  70290. * @returns the vector squared length (float)
  70291. */
  70292. lengthSquared(): number;
  70293. /**
  70294. * Normalize the vector
  70295. * @returns the current updated Vector2
  70296. */
  70297. normalize(): Vector2;
  70298. /**
  70299. * Gets a new Vector2 copied from the Vector2
  70300. * @returns a new Vector2
  70301. */
  70302. clone(): Vector2;
  70303. /**
  70304. * Gets a new Vector2(0, 0)
  70305. * @returns a new Vector2
  70306. */
  70307. static Zero(): Vector2;
  70308. /**
  70309. * Gets a new Vector2(1, 1)
  70310. * @returns a new Vector2
  70311. */
  70312. static One(): Vector2;
  70313. /**
  70314. * Gets a new Vector2 set from the given index element of the given array
  70315. * @param array defines the data source
  70316. * @param offset defines the offset in the data source
  70317. * @returns a new Vector2
  70318. */
  70319. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70320. /**
  70321. * Sets "result" from the given index element of the given array
  70322. * @param array defines the data source
  70323. * @param offset defines the offset in the data source
  70324. * @param result defines the target vector
  70325. */
  70326. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70327. /**
  70328. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70329. * @param value1 defines 1st point of control
  70330. * @param value2 defines 2nd point of control
  70331. * @param value3 defines 3rd point of control
  70332. * @param value4 defines 4th point of control
  70333. * @param amount defines the interpolation factor
  70334. * @returns a new Vector2
  70335. */
  70336. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70337. /**
  70338. * 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".
  70339. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70340. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70341. * @param value defines the value to clamp
  70342. * @param min defines the lower limit
  70343. * @param max defines the upper limit
  70344. * @returns a new Vector2
  70345. */
  70346. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70347. /**
  70348. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70349. * @param value1 defines the 1st control point
  70350. * @param tangent1 defines the outgoing tangent
  70351. * @param value2 defines the 2nd control point
  70352. * @param tangent2 defines the incoming tangent
  70353. * @param amount defines the interpolation factor
  70354. * @returns a new Vector2
  70355. */
  70356. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70357. /**
  70358. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70359. * @param start defines the start vector
  70360. * @param end defines the end vector
  70361. * @param amount defines the interpolation factor
  70362. * @returns a new Vector2
  70363. */
  70364. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70365. /**
  70366. * Gets the dot product of the vector "left" and the vector "right"
  70367. * @param left defines first vector
  70368. * @param right defines second vector
  70369. * @returns the dot product (float)
  70370. */
  70371. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70372. /**
  70373. * Returns a new Vector2 equal to the normalized given vector
  70374. * @param vector defines the vector to normalize
  70375. * @returns a new Vector2
  70376. */
  70377. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70378. /**
  70379. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70380. * @param left defines 1st vector
  70381. * @param right defines 2nd vector
  70382. * @returns a new Vector2
  70383. */
  70384. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70385. /**
  70386. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70387. * @param left defines 1st vector
  70388. * @param right defines 2nd vector
  70389. * @returns a new Vector2
  70390. */
  70391. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70392. /**
  70393. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70394. * @param vector defines the vector to transform
  70395. * @param transformation defines the matrix to apply
  70396. * @returns a new Vector2
  70397. */
  70398. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70399. /**
  70400. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70401. * @param vector defines the vector to transform
  70402. * @param transformation defines the matrix to apply
  70403. * @param result defines the target vector
  70404. */
  70405. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70406. /**
  70407. * Determines if a given vector is included in a triangle
  70408. * @param p defines the vector to test
  70409. * @param p0 defines 1st triangle point
  70410. * @param p1 defines 2nd triangle point
  70411. * @param p2 defines 3rd triangle point
  70412. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70413. */
  70414. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70415. /**
  70416. * Gets the distance between the vectors "value1" and "value2"
  70417. * @param value1 defines first vector
  70418. * @param value2 defines second vector
  70419. * @returns the distance between vectors
  70420. */
  70421. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70422. /**
  70423. * Returns the squared distance between the vectors "value1" and "value2"
  70424. * @param value1 defines first vector
  70425. * @param value2 defines second vector
  70426. * @returns the squared distance between vectors
  70427. */
  70428. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70429. /**
  70430. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70431. * @param value1 defines first vector
  70432. * @param value2 defines second vector
  70433. * @returns a new Vector2
  70434. */
  70435. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70436. /**
  70437. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70438. * @param p defines the middle point
  70439. * @param segA defines one point of the segment
  70440. * @param segB defines the other point of the segment
  70441. * @returns the shortest distance
  70442. */
  70443. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70444. }
  70445. /**
  70446. * Classed used to store (x,y,z) vector representation
  70447. * A Vector3 is the main object used in 3D geometry
  70448. * It can represent etiher the coordinates of a point the space, either a direction
  70449. * Reminder: js uses a left handed forward facing system
  70450. */
  70451. export class Vector3 {
  70452. /**
  70453. * Defines the first coordinates (on X axis)
  70454. */
  70455. x: number;
  70456. /**
  70457. * Defines the second coordinates (on Y axis)
  70458. */
  70459. y: number;
  70460. /**
  70461. * Defines the third coordinates (on Z axis)
  70462. */
  70463. z: number;
  70464. private static _UpReadOnly;
  70465. private static _ZeroReadOnly;
  70466. /**
  70467. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70468. * @param x defines the first coordinates (on X axis)
  70469. * @param y defines the second coordinates (on Y axis)
  70470. * @param z defines the third coordinates (on Z axis)
  70471. */
  70472. constructor(
  70473. /**
  70474. * Defines the first coordinates (on X axis)
  70475. */
  70476. x?: number,
  70477. /**
  70478. * Defines the second coordinates (on Y axis)
  70479. */
  70480. y?: number,
  70481. /**
  70482. * Defines the third coordinates (on Z axis)
  70483. */
  70484. z?: number);
  70485. /**
  70486. * Creates a string representation of the Vector3
  70487. * @returns a string with the Vector3 coordinates.
  70488. */
  70489. toString(): string;
  70490. /**
  70491. * Gets the class name
  70492. * @returns the string "Vector3"
  70493. */
  70494. getClassName(): string;
  70495. /**
  70496. * Creates the Vector3 hash code
  70497. * @returns a number which tends to be unique between Vector3 instances
  70498. */
  70499. getHashCode(): number;
  70500. /**
  70501. * Creates an array containing three elements : the coordinates of the Vector3
  70502. * @returns a new array of numbers
  70503. */
  70504. asArray(): number[];
  70505. /**
  70506. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70507. * @param array defines the destination array
  70508. * @param index defines the offset in the destination array
  70509. * @returns the current Vector3
  70510. */
  70511. toArray(array: FloatArray, index?: number): Vector3;
  70512. /**
  70513. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70514. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70515. */
  70516. toQuaternion(): Quaternion;
  70517. /**
  70518. * Adds the given vector to the current Vector3
  70519. * @param otherVector defines the second operand
  70520. * @returns the current updated Vector3
  70521. */
  70522. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70523. /**
  70524. * Adds the given coordinates to the current Vector3
  70525. * @param x defines the x coordinate of the operand
  70526. * @param y defines the y coordinate of the operand
  70527. * @param z defines the z coordinate of the operand
  70528. * @returns the current updated Vector3
  70529. */
  70530. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70531. /**
  70532. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70533. * @param otherVector defines the second operand
  70534. * @returns the resulting Vector3
  70535. */
  70536. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70537. /**
  70538. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70539. * @param otherVector defines the second operand
  70540. * @param result defines the Vector3 object where to store the result
  70541. * @returns the current Vector3
  70542. */
  70543. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70544. /**
  70545. * Subtract the given vector from the current Vector3
  70546. * @param otherVector defines the second operand
  70547. * @returns the current updated Vector3
  70548. */
  70549. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70550. /**
  70551. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70552. * @param otherVector defines the second operand
  70553. * @returns the resulting Vector3
  70554. */
  70555. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70556. /**
  70557. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70558. * @param otherVector defines the second operand
  70559. * @param result defines the Vector3 object where to store the result
  70560. * @returns the current Vector3
  70561. */
  70562. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70563. /**
  70564. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70565. * @param x defines the x coordinate of the operand
  70566. * @param y defines the y coordinate of the operand
  70567. * @param z defines the z coordinate of the operand
  70568. * @returns the resulting Vector3
  70569. */
  70570. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70571. /**
  70572. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70573. * @param x defines the x coordinate of the operand
  70574. * @param y defines the y coordinate of the operand
  70575. * @param z defines the z coordinate of the operand
  70576. * @param result defines the Vector3 object where to store the result
  70577. * @returns the current Vector3
  70578. */
  70579. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70580. /**
  70581. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70582. * @returns a new Vector3
  70583. */
  70584. negate(): Vector3;
  70585. /**
  70586. * Multiplies the Vector3 coordinates by the float "scale"
  70587. * @param scale defines the multiplier factor
  70588. * @returns the current updated Vector3
  70589. */
  70590. scaleInPlace(scale: number): Vector3;
  70591. /**
  70592. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70593. * @param scale defines the multiplier factor
  70594. * @returns a new Vector3
  70595. */
  70596. scale(scale: number): Vector3;
  70597. /**
  70598. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70599. * @param scale defines the multiplier factor
  70600. * @param result defines the Vector3 object where to store the result
  70601. * @returns the current Vector3
  70602. */
  70603. scaleToRef(scale: number, result: Vector3): Vector3;
  70604. /**
  70605. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70606. * @param scale defines the scale factor
  70607. * @param result defines the Vector3 object where to store the result
  70608. * @returns the unmodified current Vector3
  70609. */
  70610. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70611. /**
  70612. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70613. * @param otherVector defines the second operand
  70614. * @returns true if both vectors are equals
  70615. */
  70616. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70617. /**
  70618. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70619. * @param otherVector defines the second operand
  70620. * @param epsilon defines the minimal distance to define values as equals
  70621. * @returns true if both vectors are distant less than epsilon
  70622. */
  70623. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70624. /**
  70625. * Returns true if the current Vector3 coordinates equals the given floats
  70626. * @param x defines the x coordinate of the operand
  70627. * @param y defines the y coordinate of the operand
  70628. * @param z defines the z coordinate of the operand
  70629. * @returns true if both vectors are equals
  70630. */
  70631. equalsToFloats(x: number, y: number, z: number): boolean;
  70632. /**
  70633. * Multiplies the current Vector3 coordinates by the given ones
  70634. * @param otherVector defines the second operand
  70635. * @returns the current updated Vector3
  70636. */
  70637. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70638. /**
  70639. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70640. * @param otherVector defines the second operand
  70641. * @returns the new Vector3
  70642. */
  70643. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70644. /**
  70645. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70646. * @param otherVector defines the second operand
  70647. * @param result defines the Vector3 object where to store the result
  70648. * @returns the current Vector3
  70649. */
  70650. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70651. /**
  70652. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70653. * @param x defines the x coordinate of the operand
  70654. * @param y defines the y coordinate of the operand
  70655. * @param z defines the z coordinate of the operand
  70656. * @returns the new Vector3
  70657. */
  70658. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70659. /**
  70660. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70661. * @param otherVector defines the second operand
  70662. * @returns the new Vector3
  70663. */
  70664. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70665. /**
  70666. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70667. * @param otherVector defines the second operand
  70668. * @param result defines the Vector3 object where to store the result
  70669. * @returns the current Vector3
  70670. */
  70671. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70672. /**
  70673. * Divides the current Vector3 coordinates by the given ones.
  70674. * @param otherVector defines the second operand
  70675. * @returns the current updated Vector3
  70676. */
  70677. divideInPlace(otherVector: Vector3): Vector3;
  70678. /**
  70679. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70680. * @param other defines the second operand
  70681. * @returns the current updated Vector3
  70682. */
  70683. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70684. /**
  70685. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70686. * @param other defines the second operand
  70687. * @returns the current updated Vector3
  70688. */
  70689. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70690. /**
  70691. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70692. * @param x defines the x coordinate of the operand
  70693. * @param y defines the y coordinate of the operand
  70694. * @param z defines the z coordinate of the operand
  70695. * @returns the current updated Vector3
  70696. */
  70697. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70698. /**
  70699. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70700. * @param x defines the x coordinate of the operand
  70701. * @param y defines the y coordinate of the operand
  70702. * @param z defines the z coordinate of the operand
  70703. * @returns the current updated Vector3
  70704. */
  70705. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70706. /**
  70707. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70708. * Check if is non uniform within a certain amount of decimal places to account for this
  70709. * @param epsilon the amount the values can differ
  70710. * @returns if the the vector is non uniform to a certain number of decimal places
  70711. */
  70712. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70713. /**
  70714. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70715. */
  70716. readonly isNonUniform: boolean;
  70717. /**
  70718. * Gets a new Vector3 from current Vector3 floored values
  70719. * @returns a new Vector3
  70720. */
  70721. floor(): Vector3;
  70722. /**
  70723. * Gets a new Vector3 from current Vector3 floored values
  70724. * @returns a new Vector3
  70725. */
  70726. fract(): Vector3;
  70727. /**
  70728. * Gets the length of the Vector3
  70729. * @returns the length of the Vector3
  70730. */
  70731. length(): number;
  70732. /**
  70733. * Gets the squared length of the Vector3
  70734. * @returns squared length of the Vector3
  70735. */
  70736. lengthSquared(): number;
  70737. /**
  70738. * Normalize the current Vector3.
  70739. * Please note that this is an in place operation.
  70740. * @returns the current updated Vector3
  70741. */
  70742. normalize(): Vector3;
  70743. /**
  70744. * Reorders the x y z properties of the vector in place
  70745. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70746. * @returns the current updated vector
  70747. */
  70748. reorderInPlace(order: string): this;
  70749. /**
  70750. * Rotates the vector around 0,0,0 by a quaternion
  70751. * @param quaternion the rotation quaternion
  70752. * @param result vector to store the result
  70753. * @returns the resulting vector
  70754. */
  70755. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70756. /**
  70757. * Rotates a vector around a given point
  70758. * @param quaternion the rotation quaternion
  70759. * @param point the point to rotate around
  70760. * @param result vector to store the result
  70761. * @returns the resulting vector
  70762. */
  70763. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70764. /**
  70765. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70766. * The cross product is then orthogonal to both current and "other"
  70767. * @param other defines the right operand
  70768. * @returns the cross product
  70769. */
  70770. cross(other: Vector3): Vector3;
  70771. /**
  70772. * Normalize the current Vector3 with the given input length.
  70773. * Please note that this is an in place operation.
  70774. * @param len the length of the vector
  70775. * @returns the current updated Vector3
  70776. */
  70777. normalizeFromLength(len: number): Vector3;
  70778. /**
  70779. * Normalize the current Vector3 to a new vector
  70780. * @returns the new Vector3
  70781. */
  70782. normalizeToNew(): Vector3;
  70783. /**
  70784. * Normalize the current Vector3 to the reference
  70785. * @param reference define the Vector3 to update
  70786. * @returns the updated Vector3
  70787. */
  70788. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70789. /**
  70790. * Creates a new Vector3 copied from the current Vector3
  70791. * @returns the new Vector3
  70792. */
  70793. clone(): Vector3;
  70794. /**
  70795. * Copies the given vector coordinates to the current Vector3 ones
  70796. * @param source defines the source Vector3
  70797. * @returns the current updated Vector3
  70798. */
  70799. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70800. /**
  70801. * Copies the given floats to the current Vector3 coordinates
  70802. * @param x defines the x coordinate of the operand
  70803. * @param y defines the y coordinate of the operand
  70804. * @param z defines the z coordinate of the operand
  70805. * @returns the current updated Vector3
  70806. */
  70807. copyFromFloats(x: number, y: number, z: number): Vector3;
  70808. /**
  70809. * Copies the given floats to the current Vector3 coordinates
  70810. * @param x defines the x coordinate of the operand
  70811. * @param y defines the y coordinate of the operand
  70812. * @param z defines the z coordinate of the operand
  70813. * @returns the current updated Vector3
  70814. */
  70815. set(x: number, y: number, z: number): Vector3;
  70816. /**
  70817. * Copies the given float to the current Vector3 coordinates
  70818. * @param v defines the x, y and z coordinates of the operand
  70819. * @returns the current updated Vector3
  70820. */
  70821. setAll(v: number): Vector3;
  70822. /**
  70823. * Get the clip factor between two vectors
  70824. * @param vector0 defines the first operand
  70825. * @param vector1 defines the second operand
  70826. * @param axis defines the axis to use
  70827. * @param size defines the size along the axis
  70828. * @returns the clip factor
  70829. */
  70830. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70831. /**
  70832. * Get angle between two vectors
  70833. * @param vector0 angle between vector0 and vector1
  70834. * @param vector1 angle between vector0 and vector1
  70835. * @param normal direction of the normal
  70836. * @return the angle between vector0 and vector1
  70837. */
  70838. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70839. /**
  70840. * Returns a new Vector3 set from the index "offset" of the given array
  70841. * @param array defines the source array
  70842. * @param offset defines the offset in the source array
  70843. * @returns the new Vector3
  70844. */
  70845. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70846. /**
  70847. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70848. * This function is deprecated. Use FromArray instead
  70849. * @param array defines the source array
  70850. * @param offset defines the offset in the source array
  70851. * @returns the new Vector3
  70852. */
  70853. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70854. /**
  70855. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70856. * @param array defines the source array
  70857. * @param offset defines the offset in the source array
  70858. * @param result defines the Vector3 where to store the result
  70859. */
  70860. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70861. /**
  70862. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70863. * This function is deprecated. Use FromArrayToRef instead.
  70864. * @param array defines the source array
  70865. * @param offset defines the offset in the source array
  70866. * @param result defines the Vector3 where to store the result
  70867. */
  70868. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70869. /**
  70870. * Sets the given vector "result" with the given floats.
  70871. * @param x defines the x coordinate of the source
  70872. * @param y defines the y coordinate of the source
  70873. * @param z defines the z coordinate of the source
  70874. * @param result defines the Vector3 where to store the result
  70875. */
  70876. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70877. /**
  70878. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70879. * @returns a new empty Vector3
  70880. */
  70881. static Zero(): Vector3;
  70882. /**
  70883. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70884. * @returns a new unit Vector3
  70885. */
  70886. static One(): Vector3;
  70887. /**
  70888. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70889. * @returns a new up Vector3
  70890. */
  70891. static Up(): Vector3;
  70892. /**
  70893. * Gets a up Vector3 that must not be updated
  70894. */
  70895. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70896. /**
  70897. * Gets a zero Vector3 that must not be updated
  70898. */
  70899. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70900. /**
  70901. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70902. * @returns a new down Vector3
  70903. */
  70904. static Down(): Vector3;
  70905. /**
  70906. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70907. * @returns a new forward Vector3
  70908. */
  70909. static Forward(): Vector3;
  70910. /**
  70911. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70912. * @returns a new forward Vector3
  70913. */
  70914. static Backward(): Vector3;
  70915. /**
  70916. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70917. * @returns a new right Vector3
  70918. */
  70919. static Right(): Vector3;
  70920. /**
  70921. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70922. * @returns a new left Vector3
  70923. */
  70924. static Left(): Vector3;
  70925. /**
  70926. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70927. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70928. * @param vector defines the Vector3 to transform
  70929. * @param transformation defines the transformation matrix
  70930. * @returns the transformed Vector3
  70931. */
  70932. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70933. /**
  70934. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70935. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70936. * @param vector defines the Vector3 to transform
  70937. * @param transformation defines the transformation matrix
  70938. * @param result defines the Vector3 where to store the result
  70939. */
  70940. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70941. /**
  70942. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70943. * This method computes tranformed coordinates only, not transformed direction vectors
  70944. * @param x define the x coordinate of the source vector
  70945. * @param y define the y coordinate of the source vector
  70946. * @param z define the z coordinate of the source vector
  70947. * @param transformation defines the transformation matrix
  70948. * @param result defines the Vector3 where to store the result
  70949. */
  70950. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70951. /**
  70952. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70953. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70954. * @param vector defines the Vector3 to transform
  70955. * @param transformation defines the transformation matrix
  70956. * @returns the new Vector3
  70957. */
  70958. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70959. /**
  70960. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70961. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70962. * @param vector defines the Vector3 to transform
  70963. * @param transformation defines the transformation matrix
  70964. * @param result defines the Vector3 where to store the result
  70965. */
  70966. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70967. /**
  70968. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70969. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70970. * @param x define the x coordinate of the source vector
  70971. * @param y define the y coordinate of the source vector
  70972. * @param z define the z coordinate of the source vector
  70973. * @param transformation defines the transformation matrix
  70974. * @param result defines the Vector3 where to store the result
  70975. */
  70976. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70977. /**
  70978. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70979. * @param value1 defines the first control point
  70980. * @param value2 defines the second control point
  70981. * @param value3 defines the third control point
  70982. * @param value4 defines the fourth control point
  70983. * @param amount defines the amount on the spline to use
  70984. * @returns the new Vector3
  70985. */
  70986. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70987. /**
  70988. * 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"
  70989. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70990. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70991. * @param value defines the current value
  70992. * @param min defines the lower range value
  70993. * @param max defines the upper range value
  70994. * @returns the new Vector3
  70995. */
  70996. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70997. /**
  70998. * 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"
  70999. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71000. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71001. * @param value defines the current value
  71002. * @param min defines the lower range value
  71003. * @param max defines the upper range value
  71004. * @param result defines the Vector3 where to store the result
  71005. */
  71006. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  71007. /**
  71008. * Checks if a given vector is inside a specific range
  71009. * @param v defines the vector to test
  71010. * @param min defines the minimum range
  71011. * @param max defines the maximum range
  71012. */
  71013. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  71014. /**
  71015. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71016. * @param value1 defines the first control point
  71017. * @param tangent1 defines the first tangent vector
  71018. * @param value2 defines the second control point
  71019. * @param tangent2 defines the second tangent vector
  71020. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71021. * @returns the new Vector3
  71022. */
  71023. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  71024. /**
  71025. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71026. * @param start defines the start value
  71027. * @param end defines the end value
  71028. * @param amount max defines amount between both (between 0 and 1)
  71029. * @returns the new Vector3
  71030. */
  71031. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  71032. /**
  71033. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71034. * @param start defines the start value
  71035. * @param end defines the end value
  71036. * @param amount max defines amount between both (between 0 and 1)
  71037. * @param result defines the Vector3 where to store the result
  71038. */
  71039. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71040. /**
  71041. * Returns the dot product (float) between the vectors "left" and "right"
  71042. * @param left defines the left operand
  71043. * @param right defines the right operand
  71044. * @returns the dot product
  71045. */
  71046. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71047. /**
  71048. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71049. * The cross product is then orthogonal to both "left" and "right"
  71050. * @param left defines the left operand
  71051. * @param right defines the right operand
  71052. * @returns the cross product
  71053. */
  71054. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71055. /**
  71056. * Sets the given vector "result" with the cross product of "left" and "right"
  71057. * The cross product is then orthogonal to both "left" and "right"
  71058. * @param left defines the left operand
  71059. * @param right defines the right operand
  71060. * @param result defines the Vector3 where to store the result
  71061. */
  71062. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71063. /**
  71064. * Returns a new Vector3 as the normalization of the given vector
  71065. * @param vector defines the Vector3 to normalize
  71066. * @returns the new Vector3
  71067. */
  71068. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71069. /**
  71070. * Sets the given vector "result" with the normalization of the given first vector
  71071. * @param vector defines the Vector3 to normalize
  71072. * @param result defines the Vector3 where to store the result
  71073. */
  71074. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71075. /**
  71076. * Project a Vector3 onto screen space
  71077. * @param vector defines the Vector3 to project
  71078. * @param world defines the world matrix to use
  71079. * @param transform defines the transform (view x projection) matrix to use
  71080. * @param viewport defines the screen viewport to use
  71081. * @returns the new Vector3
  71082. */
  71083. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71084. /** @hidden */
  71085. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71086. /**
  71087. * Unproject from screen space to object space
  71088. * @param source defines the screen space Vector3 to use
  71089. * @param viewportWidth defines the current width of the viewport
  71090. * @param viewportHeight defines the current height of the viewport
  71091. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71092. * @param transform defines the transform (view x projection) matrix to use
  71093. * @returns the new Vector3
  71094. */
  71095. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71096. /**
  71097. * Unproject from screen space to object space
  71098. * @param source defines the screen space Vector3 to use
  71099. * @param viewportWidth defines the current width of the viewport
  71100. * @param viewportHeight defines the current height of the viewport
  71101. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71102. * @param view defines the view matrix to use
  71103. * @param projection defines the projection matrix to use
  71104. * @returns the new Vector3
  71105. */
  71106. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71107. /**
  71108. * Unproject from screen space to object space
  71109. * @param source defines the screen space Vector3 to use
  71110. * @param viewportWidth defines the current width of the viewport
  71111. * @param viewportHeight defines the current height of the viewport
  71112. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71113. * @param view defines the view matrix to use
  71114. * @param projection defines the projection matrix to use
  71115. * @param result defines the Vector3 where to store the result
  71116. */
  71117. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71118. /**
  71119. * Unproject from screen space to object space
  71120. * @param sourceX defines the screen space x coordinate to use
  71121. * @param sourceY defines the screen space y coordinate to use
  71122. * @param sourceZ defines the screen space z coordinate to use
  71123. * @param viewportWidth defines the current width of the viewport
  71124. * @param viewportHeight defines the current height of the viewport
  71125. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71126. * @param view defines the view matrix to use
  71127. * @param projection defines the projection matrix to use
  71128. * @param result defines the Vector3 where to store the result
  71129. */
  71130. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71131. /**
  71132. * Gets the minimal coordinate values between two Vector3
  71133. * @param left defines the first operand
  71134. * @param right defines the second operand
  71135. * @returns the new Vector3
  71136. */
  71137. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71138. /**
  71139. * Gets the maximal coordinate values between two Vector3
  71140. * @param left defines the first operand
  71141. * @param right defines the second operand
  71142. * @returns the new Vector3
  71143. */
  71144. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71145. /**
  71146. * Returns the distance between the vectors "value1" and "value2"
  71147. * @param value1 defines the first operand
  71148. * @param value2 defines the second operand
  71149. * @returns the distance
  71150. */
  71151. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71152. /**
  71153. * Returns the squared distance between the vectors "value1" and "value2"
  71154. * @param value1 defines the first operand
  71155. * @param value2 defines the second operand
  71156. * @returns the squared distance
  71157. */
  71158. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71159. /**
  71160. * Returns a new Vector3 located at the center between "value1" and "value2"
  71161. * @param value1 defines the first operand
  71162. * @param value2 defines the second operand
  71163. * @returns the new Vector3
  71164. */
  71165. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71166. /**
  71167. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71168. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71169. * to something in order to rotate it from its local system to the given target system
  71170. * Note: axis1, axis2 and axis3 are normalized during this operation
  71171. * @param axis1 defines the first axis
  71172. * @param axis2 defines the second axis
  71173. * @param axis3 defines the third axis
  71174. * @returns a new Vector3
  71175. */
  71176. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71177. /**
  71178. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71179. * @param axis1 defines the first axis
  71180. * @param axis2 defines the second axis
  71181. * @param axis3 defines the third axis
  71182. * @param ref defines the Vector3 where to store the result
  71183. */
  71184. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71185. }
  71186. /**
  71187. * Vector4 class created for EulerAngle class conversion to Quaternion
  71188. */
  71189. export class Vector4 {
  71190. /** x value of the vector */
  71191. x: number;
  71192. /** y value of the vector */
  71193. y: number;
  71194. /** z value of the vector */
  71195. z: number;
  71196. /** w value of the vector */
  71197. w: number;
  71198. /**
  71199. * Creates a Vector4 object from the given floats.
  71200. * @param x x value of the vector
  71201. * @param y y value of the vector
  71202. * @param z z value of the vector
  71203. * @param w w value of the vector
  71204. */
  71205. constructor(
  71206. /** x value of the vector */
  71207. x: number,
  71208. /** y value of the vector */
  71209. y: number,
  71210. /** z value of the vector */
  71211. z: number,
  71212. /** w value of the vector */
  71213. w: number);
  71214. /**
  71215. * Returns the string with the Vector4 coordinates.
  71216. * @returns a string containing all the vector values
  71217. */
  71218. toString(): string;
  71219. /**
  71220. * Returns the string "Vector4".
  71221. * @returns "Vector4"
  71222. */
  71223. getClassName(): string;
  71224. /**
  71225. * Returns the Vector4 hash code.
  71226. * @returns a unique hash code
  71227. */
  71228. getHashCode(): number;
  71229. /**
  71230. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71231. * @returns the resulting array
  71232. */
  71233. asArray(): number[];
  71234. /**
  71235. * Populates the given array from the given index with the Vector4 coordinates.
  71236. * @param array array to populate
  71237. * @param index index of the array to start at (default: 0)
  71238. * @returns the Vector4.
  71239. */
  71240. toArray(array: FloatArray, index?: number): Vector4;
  71241. /**
  71242. * Adds the given vector to the current Vector4.
  71243. * @param otherVector the vector to add
  71244. * @returns the updated Vector4.
  71245. */
  71246. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71247. /**
  71248. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71249. * @param otherVector the vector to add
  71250. * @returns the resulting vector
  71251. */
  71252. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71253. /**
  71254. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71255. * @param otherVector the vector to add
  71256. * @param result the vector to store the result
  71257. * @returns the current Vector4.
  71258. */
  71259. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71260. /**
  71261. * Subtract in place the given vector from the current Vector4.
  71262. * @param otherVector the vector to subtract
  71263. * @returns the updated Vector4.
  71264. */
  71265. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71266. /**
  71267. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71268. * @param otherVector the vector to add
  71269. * @returns the new vector with the result
  71270. */
  71271. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71272. /**
  71273. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71274. * @param otherVector the vector to subtract
  71275. * @param result the vector to store the result
  71276. * @returns the current Vector4.
  71277. */
  71278. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71279. /**
  71280. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71281. */
  71282. /**
  71283. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71284. * @param x value to subtract
  71285. * @param y value to subtract
  71286. * @param z value to subtract
  71287. * @param w value to subtract
  71288. * @returns new vector containing the result
  71289. */
  71290. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71291. /**
  71292. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71293. * @param x value to subtract
  71294. * @param y value to subtract
  71295. * @param z value to subtract
  71296. * @param w value to subtract
  71297. * @param result the vector to store the result in
  71298. * @returns the current Vector4.
  71299. */
  71300. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71301. /**
  71302. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71303. * @returns a new vector with the negated values
  71304. */
  71305. negate(): Vector4;
  71306. /**
  71307. * Multiplies the current Vector4 coordinates by scale (float).
  71308. * @param scale the number to scale with
  71309. * @returns the updated Vector4.
  71310. */
  71311. scaleInPlace(scale: number): Vector4;
  71312. /**
  71313. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71314. * @param scale the number to scale with
  71315. * @returns a new vector with the result
  71316. */
  71317. scale(scale: number): Vector4;
  71318. /**
  71319. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71320. * @param scale the number to scale with
  71321. * @param result a vector to store the result in
  71322. * @returns the current Vector4.
  71323. */
  71324. scaleToRef(scale: number, result: Vector4): Vector4;
  71325. /**
  71326. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71327. * @param scale defines the scale factor
  71328. * @param result defines the Vector4 object where to store the result
  71329. * @returns the unmodified current Vector4
  71330. */
  71331. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71332. /**
  71333. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71334. * @param otherVector the vector to compare against
  71335. * @returns true if they are equal
  71336. */
  71337. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71338. /**
  71339. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71340. * @param otherVector vector to compare against
  71341. * @param epsilon (Default: very small number)
  71342. * @returns true if they are equal
  71343. */
  71344. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71345. /**
  71346. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71347. * @param x x value to compare against
  71348. * @param y y value to compare against
  71349. * @param z z value to compare against
  71350. * @param w w value to compare against
  71351. * @returns true if equal
  71352. */
  71353. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71354. /**
  71355. * Multiplies in place the current Vector4 by the given one.
  71356. * @param otherVector vector to multiple with
  71357. * @returns the updated Vector4.
  71358. */
  71359. multiplyInPlace(otherVector: Vector4): Vector4;
  71360. /**
  71361. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71362. * @param otherVector vector to multiple with
  71363. * @returns resulting new vector
  71364. */
  71365. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71366. /**
  71367. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71368. * @param otherVector vector to multiple with
  71369. * @param result vector to store the result
  71370. * @returns the current Vector4.
  71371. */
  71372. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71373. /**
  71374. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71375. * @param x x value multiply with
  71376. * @param y y value multiply with
  71377. * @param z z value multiply with
  71378. * @param w w value multiply with
  71379. * @returns resulting new vector
  71380. */
  71381. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71382. /**
  71383. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71384. * @param otherVector vector to devide with
  71385. * @returns resulting new vector
  71386. */
  71387. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71388. /**
  71389. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71390. * @param otherVector vector to devide with
  71391. * @param result vector to store the result
  71392. * @returns the current Vector4.
  71393. */
  71394. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71395. /**
  71396. * Divides the current Vector3 coordinates by the given ones.
  71397. * @param otherVector vector to devide with
  71398. * @returns the updated Vector3.
  71399. */
  71400. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71401. /**
  71402. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71403. * @param other defines the second operand
  71404. * @returns the current updated Vector4
  71405. */
  71406. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71407. /**
  71408. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71409. * @param other defines the second operand
  71410. * @returns the current updated Vector4
  71411. */
  71412. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71413. /**
  71414. * Gets a new Vector4 from current Vector4 floored values
  71415. * @returns a new Vector4
  71416. */
  71417. floor(): Vector4;
  71418. /**
  71419. * Gets a new Vector4 from current Vector3 floored values
  71420. * @returns a new Vector4
  71421. */
  71422. fract(): Vector4;
  71423. /**
  71424. * Returns the Vector4 length (float).
  71425. * @returns the length
  71426. */
  71427. length(): number;
  71428. /**
  71429. * Returns the Vector4 squared length (float).
  71430. * @returns the length squared
  71431. */
  71432. lengthSquared(): number;
  71433. /**
  71434. * Normalizes in place the Vector4.
  71435. * @returns the updated Vector4.
  71436. */
  71437. normalize(): Vector4;
  71438. /**
  71439. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71440. * @returns this converted to a new vector3
  71441. */
  71442. toVector3(): Vector3;
  71443. /**
  71444. * Returns a new Vector4 copied from the current one.
  71445. * @returns the new cloned vector
  71446. */
  71447. clone(): Vector4;
  71448. /**
  71449. * Updates the current Vector4 with the given one coordinates.
  71450. * @param source the source vector to copy from
  71451. * @returns the updated Vector4.
  71452. */
  71453. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71454. /**
  71455. * Updates the current Vector4 coordinates with the given floats.
  71456. * @param x float to copy from
  71457. * @param y float to copy from
  71458. * @param z float to copy from
  71459. * @param w float to copy from
  71460. * @returns the updated Vector4.
  71461. */
  71462. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71463. /**
  71464. * Updates the current Vector4 coordinates with the given floats.
  71465. * @param x float to set from
  71466. * @param y float to set from
  71467. * @param z float to set from
  71468. * @param w float to set from
  71469. * @returns the updated Vector4.
  71470. */
  71471. set(x: number, y: number, z: number, w: number): Vector4;
  71472. /**
  71473. * Copies the given float to the current Vector3 coordinates
  71474. * @param v defines the x, y, z and w coordinates of the operand
  71475. * @returns the current updated Vector3
  71476. */
  71477. setAll(v: number): Vector4;
  71478. /**
  71479. * Returns a new Vector4 set from the starting index of the given array.
  71480. * @param array the array to pull values from
  71481. * @param offset the offset into the array to start at
  71482. * @returns the new vector
  71483. */
  71484. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71485. /**
  71486. * Updates the given vector "result" from the starting index of the given array.
  71487. * @param array the array to pull values from
  71488. * @param offset the offset into the array to start at
  71489. * @param result the vector to store the result in
  71490. */
  71491. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71492. /**
  71493. * Updates the given vector "result" from the starting index of the given Float32Array.
  71494. * @param array the array to pull values from
  71495. * @param offset the offset into the array to start at
  71496. * @param result the vector to store the result in
  71497. */
  71498. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71499. /**
  71500. * Updates the given vector "result" coordinates from the given floats.
  71501. * @param x float to set from
  71502. * @param y float to set from
  71503. * @param z float to set from
  71504. * @param w float to set from
  71505. * @param result the vector to the floats in
  71506. */
  71507. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71508. /**
  71509. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71510. * @returns the new vector
  71511. */
  71512. static Zero(): Vector4;
  71513. /**
  71514. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71515. * @returns the new vector
  71516. */
  71517. static One(): Vector4;
  71518. /**
  71519. * Returns a new normalized Vector4 from the given one.
  71520. * @param vector the vector to normalize
  71521. * @returns the vector
  71522. */
  71523. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71524. /**
  71525. * Updates the given vector "result" from the normalization of the given one.
  71526. * @param vector the vector to normalize
  71527. * @param result the vector to store the result in
  71528. */
  71529. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71530. /**
  71531. * Returns a vector with the minimum values from the left and right vectors
  71532. * @param left left vector to minimize
  71533. * @param right right vector to minimize
  71534. * @returns a new vector with the minimum of the left and right vector values
  71535. */
  71536. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71537. /**
  71538. * Returns a vector with the maximum values from the left and right vectors
  71539. * @param left left vector to maximize
  71540. * @param right right vector to maximize
  71541. * @returns a new vector with the maximum of the left and right vector values
  71542. */
  71543. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71544. /**
  71545. * Returns the distance (float) between the vectors "value1" and "value2".
  71546. * @param value1 value to calulate the distance between
  71547. * @param value2 value to calulate the distance between
  71548. * @return the distance between the two vectors
  71549. */
  71550. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71551. /**
  71552. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71553. * @param value1 value to calulate the distance between
  71554. * @param value2 value to calulate the distance between
  71555. * @return the distance between the two vectors squared
  71556. */
  71557. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71558. /**
  71559. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71560. * @param value1 value to calulate the center between
  71561. * @param value2 value to calulate the center between
  71562. * @return the center between the two vectors
  71563. */
  71564. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71565. /**
  71566. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71567. * This methods computes transformed normalized direction vectors only.
  71568. * @param vector the vector to transform
  71569. * @param transformation the transformation matrix to apply
  71570. * @returns the new vector
  71571. */
  71572. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71573. /**
  71574. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71575. * This methods computes transformed normalized direction vectors only.
  71576. * @param vector the vector to transform
  71577. * @param transformation the transformation matrix to apply
  71578. * @param result the vector to store the result in
  71579. */
  71580. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71581. /**
  71582. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71583. * This methods computes transformed normalized direction vectors only.
  71584. * @param x value to transform
  71585. * @param y value to transform
  71586. * @param z value to transform
  71587. * @param w value to transform
  71588. * @param transformation the transformation matrix to apply
  71589. * @param result the vector to store the results in
  71590. */
  71591. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71592. /**
  71593. * Creates a new Vector4 from a Vector3
  71594. * @param source defines the source data
  71595. * @param w defines the 4th component (default is 0)
  71596. * @returns a new Vector4
  71597. */
  71598. static FromVector3(source: Vector3, w?: number): Vector4;
  71599. }
  71600. /**
  71601. * Class used to store quaternion data
  71602. * @see https://en.wikipedia.org/wiki/Quaternion
  71603. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71604. */
  71605. export class Quaternion {
  71606. /** defines the first component (0 by default) */
  71607. x: number;
  71608. /** defines the second component (0 by default) */
  71609. y: number;
  71610. /** defines the third component (0 by default) */
  71611. z: number;
  71612. /** defines the fourth component (1.0 by default) */
  71613. w: number;
  71614. /**
  71615. * Creates a new Quaternion from the given floats
  71616. * @param x defines the first component (0 by default)
  71617. * @param y defines the second component (0 by default)
  71618. * @param z defines the third component (0 by default)
  71619. * @param w defines the fourth component (1.0 by default)
  71620. */
  71621. constructor(
  71622. /** defines the first component (0 by default) */
  71623. x?: number,
  71624. /** defines the second component (0 by default) */
  71625. y?: number,
  71626. /** defines the third component (0 by default) */
  71627. z?: number,
  71628. /** defines the fourth component (1.0 by default) */
  71629. w?: number);
  71630. /**
  71631. * Gets a string representation for the current quaternion
  71632. * @returns a string with the Quaternion coordinates
  71633. */
  71634. toString(): string;
  71635. /**
  71636. * Gets the class name of the quaternion
  71637. * @returns the string "Quaternion"
  71638. */
  71639. getClassName(): string;
  71640. /**
  71641. * Gets a hash code for this quaternion
  71642. * @returns the quaternion hash code
  71643. */
  71644. getHashCode(): number;
  71645. /**
  71646. * Copy the quaternion to an array
  71647. * @returns a new array populated with 4 elements from the quaternion coordinates
  71648. */
  71649. asArray(): number[];
  71650. /**
  71651. * Check if two quaternions are equals
  71652. * @param otherQuaternion defines the second operand
  71653. * @return true if the current quaternion and the given one coordinates are strictly equals
  71654. */
  71655. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71656. /**
  71657. * Clone the current quaternion
  71658. * @returns a new quaternion copied from the current one
  71659. */
  71660. clone(): Quaternion;
  71661. /**
  71662. * Copy a quaternion to the current one
  71663. * @param other defines the other quaternion
  71664. * @returns the updated current quaternion
  71665. */
  71666. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71667. /**
  71668. * Updates the current quaternion with the given float coordinates
  71669. * @param x defines the x coordinate
  71670. * @param y defines the y coordinate
  71671. * @param z defines the z coordinate
  71672. * @param w defines the w coordinate
  71673. * @returns the updated current quaternion
  71674. */
  71675. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71676. /**
  71677. * Updates the current quaternion from the given float coordinates
  71678. * @param x defines the x coordinate
  71679. * @param y defines the y coordinate
  71680. * @param z defines the z coordinate
  71681. * @param w defines the w coordinate
  71682. * @returns the updated current quaternion
  71683. */
  71684. set(x: number, y: number, z: number, w: number): Quaternion;
  71685. /**
  71686. * Adds two quaternions
  71687. * @param other defines the second operand
  71688. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71689. */
  71690. add(other: DeepImmutable<Quaternion>): Quaternion;
  71691. /**
  71692. * Add a quaternion to the current one
  71693. * @param other defines the quaternion to add
  71694. * @returns the current quaternion
  71695. */
  71696. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71697. /**
  71698. * Subtract two quaternions
  71699. * @param other defines the second operand
  71700. * @returns a new quaternion as the subtraction result of the given one from the current one
  71701. */
  71702. subtract(other: Quaternion): Quaternion;
  71703. /**
  71704. * Multiplies the current quaternion by a scale factor
  71705. * @param value defines the scale factor
  71706. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71707. */
  71708. scale(value: number): Quaternion;
  71709. /**
  71710. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71711. * @param scale defines the scale factor
  71712. * @param result defines the Quaternion object where to store the result
  71713. * @returns the unmodified current quaternion
  71714. */
  71715. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71716. /**
  71717. * Multiplies in place the current quaternion by a scale factor
  71718. * @param value defines the scale factor
  71719. * @returns the current modified quaternion
  71720. */
  71721. scaleInPlace(value: number): Quaternion;
  71722. /**
  71723. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71724. * @param scale defines the scale factor
  71725. * @param result defines the Quaternion object where to store the result
  71726. * @returns the unmodified current quaternion
  71727. */
  71728. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71729. /**
  71730. * Multiplies two quaternions
  71731. * @param q1 defines the second operand
  71732. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71733. */
  71734. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71735. /**
  71736. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71737. * @param q1 defines the second operand
  71738. * @param result defines the target quaternion
  71739. * @returns the current quaternion
  71740. */
  71741. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71742. /**
  71743. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71744. * @param q1 defines the second operand
  71745. * @returns the currentupdated quaternion
  71746. */
  71747. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71748. /**
  71749. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71750. * @param ref defines the target quaternion
  71751. * @returns the current quaternion
  71752. */
  71753. conjugateToRef(ref: Quaternion): Quaternion;
  71754. /**
  71755. * Conjugates in place (1-q) the current quaternion
  71756. * @returns the current updated quaternion
  71757. */
  71758. conjugateInPlace(): Quaternion;
  71759. /**
  71760. * Conjugates in place (1-q) the current quaternion
  71761. * @returns a new quaternion
  71762. */
  71763. conjugate(): Quaternion;
  71764. /**
  71765. * Gets length of current quaternion
  71766. * @returns the quaternion length (float)
  71767. */
  71768. length(): number;
  71769. /**
  71770. * Normalize in place the current quaternion
  71771. * @returns the current updated quaternion
  71772. */
  71773. normalize(): Quaternion;
  71774. /**
  71775. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71776. * @param order is a reserved parameter and is ignore for now
  71777. * @returns a new Vector3 containing the Euler angles
  71778. */
  71779. toEulerAngles(order?: string): Vector3;
  71780. /**
  71781. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71782. * @param result defines the vector which will be filled with the Euler angles
  71783. * @param order is a reserved parameter and is ignore for now
  71784. * @returns the current unchanged quaternion
  71785. */
  71786. toEulerAnglesToRef(result: Vector3): Quaternion;
  71787. /**
  71788. * Updates the given rotation matrix with the current quaternion values
  71789. * @param result defines the target matrix
  71790. * @returns the current unchanged quaternion
  71791. */
  71792. toRotationMatrix(result: Matrix): Quaternion;
  71793. /**
  71794. * Updates the current quaternion from the given rotation matrix values
  71795. * @param matrix defines the source matrix
  71796. * @returns the current updated quaternion
  71797. */
  71798. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71799. /**
  71800. * Creates a new quaternion from a rotation matrix
  71801. * @param matrix defines the source matrix
  71802. * @returns a new quaternion created from the given rotation matrix values
  71803. */
  71804. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71805. /**
  71806. * Updates the given quaternion with the given rotation matrix values
  71807. * @param matrix defines the source matrix
  71808. * @param result defines the target quaternion
  71809. */
  71810. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71811. /**
  71812. * Returns the dot product (float) between the quaternions "left" and "right"
  71813. * @param left defines the left operand
  71814. * @param right defines the right operand
  71815. * @returns the dot product
  71816. */
  71817. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71818. /**
  71819. * Checks if the two quaternions are close to each other
  71820. * @param quat0 defines the first quaternion to check
  71821. * @param quat1 defines the second quaternion to check
  71822. * @returns true if the two quaternions are close to each other
  71823. */
  71824. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71825. /**
  71826. * Creates an empty quaternion
  71827. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71828. */
  71829. static Zero(): Quaternion;
  71830. /**
  71831. * Inverse a given quaternion
  71832. * @param q defines the source quaternion
  71833. * @returns a new quaternion as the inverted current quaternion
  71834. */
  71835. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71836. /**
  71837. * Inverse a given quaternion
  71838. * @param q defines the source quaternion
  71839. * @param result the quaternion the result will be stored in
  71840. * @returns the result quaternion
  71841. */
  71842. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71843. /**
  71844. * Creates an identity quaternion
  71845. * @returns the identity quaternion
  71846. */
  71847. static Identity(): Quaternion;
  71848. /**
  71849. * Gets a boolean indicating if the given quaternion is identity
  71850. * @param quaternion defines the quaternion to check
  71851. * @returns true if the quaternion is identity
  71852. */
  71853. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71854. /**
  71855. * Creates a quaternion from a rotation around an axis
  71856. * @param axis defines the axis to use
  71857. * @param angle defines the angle to use
  71858. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71859. */
  71860. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71861. /**
  71862. * Creates a rotation around an axis and stores it into the given quaternion
  71863. * @param axis defines the axis to use
  71864. * @param angle defines the angle to use
  71865. * @param result defines the target quaternion
  71866. * @returns the target quaternion
  71867. */
  71868. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71869. /**
  71870. * Creates a new quaternion from data stored into an array
  71871. * @param array defines the data source
  71872. * @param offset defines the offset in the source array where the data starts
  71873. * @returns a new quaternion
  71874. */
  71875. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71876. /**
  71877. * Create a quaternion from Euler rotation angles
  71878. * @param x Pitch
  71879. * @param y Yaw
  71880. * @param z Roll
  71881. * @returns the new Quaternion
  71882. */
  71883. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71884. /**
  71885. * Updates a quaternion from Euler rotation angles
  71886. * @param x Pitch
  71887. * @param y Yaw
  71888. * @param z Roll
  71889. * @param result the quaternion to store the result
  71890. * @returns the updated quaternion
  71891. */
  71892. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71893. /**
  71894. * Create a quaternion from Euler rotation vector
  71895. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71896. * @returns the new Quaternion
  71897. */
  71898. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71899. /**
  71900. * Updates a quaternion from Euler rotation vector
  71901. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71902. * @param result the quaternion to store the result
  71903. * @returns the updated quaternion
  71904. */
  71905. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71906. /**
  71907. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71908. * @param yaw defines the rotation around Y axis
  71909. * @param pitch defines the rotation around X axis
  71910. * @param roll defines the rotation around Z axis
  71911. * @returns the new quaternion
  71912. */
  71913. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71914. /**
  71915. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71916. * @param yaw defines the rotation around Y axis
  71917. * @param pitch defines the rotation around X axis
  71918. * @param roll defines the rotation around Z axis
  71919. * @param result defines the target quaternion
  71920. */
  71921. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71922. /**
  71923. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71924. * @param alpha defines the rotation around first axis
  71925. * @param beta defines the rotation around second axis
  71926. * @param gamma defines the rotation around third axis
  71927. * @returns the new quaternion
  71928. */
  71929. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71930. /**
  71931. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71932. * @param alpha defines the rotation around first axis
  71933. * @param beta defines the rotation around second axis
  71934. * @param gamma defines the rotation around third axis
  71935. * @param result defines the target quaternion
  71936. */
  71937. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71938. /**
  71939. * 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)
  71940. * @param axis1 defines the first axis
  71941. * @param axis2 defines the second axis
  71942. * @param axis3 defines the third axis
  71943. * @returns the new quaternion
  71944. */
  71945. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71946. /**
  71947. * 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
  71948. * @param axis1 defines the first axis
  71949. * @param axis2 defines the second axis
  71950. * @param axis3 defines the third axis
  71951. * @param ref defines the target quaternion
  71952. */
  71953. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71954. /**
  71955. * Interpolates between two quaternions
  71956. * @param left defines first quaternion
  71957. * @param right defines second quaternion
  71958. * @param amount defines the gradient to use
  71959. * @returns the new interpolated quaternion
  71960. */
  71961. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71962. /**
  71963. * Interpolates between two quaternions and stores it into a target quaternion
  71964. * @param left defines first quaternion
  71965. * @param right defines second quaternion
  71966. * @param amount defines the gradient to use
  71967. * @param result defines the target quaternion
  71968. */
  71969. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71970. /**
  71971. * Interpolate between two quaternions using Hermite interpolation
  71972. * @param value1 defines first quaternion
  71973. * @param tangent1 defines the incoming tangent
  71974. * @param value2 defines second quaternion
  71975. * @param tangent2 defines the outgoing tangent
  71976. * @param amount defines the target quaternion
  71977. * @returns the new interpolated quaternion
  71978. */
  71979. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71980. }
  71981. /**
  71982. * Class used to store matrix data (4x4)
  71983. */
  71984. export class Matrix {
  71985. private static _updateFlagSeed;
  71986. private static _identityReadOnly;
  71987. private _isIdentity;
  71988. private _isIdentityDirty;
  71989. private _isIdentity3x2;
  71990. private _isIdentity3x2Dirty;
  71991. /**
  71992. * Gets the update flag of the matrix which is an unique number for the matrix.
  71993. * It will be incremented every time the matrix data change.
  71994. * You can use it to speed the comparison between two versions of the same matrix.
  71995. */
  71996. updateFlag: number;
  71997. private readonly _m;
  71998. /**
  71999. * Gets the internal data of the matrix
  72000. */
  72001. readonly m: DeepImmutable<Float32Array>;
  72002. /** @hidden */
  72003. _markAsUpdated(): void;
  72004. /** @hidden */
  72005. private _updateIdentityStatus;
  72006. /**
  72007. * Creates an empty matrix (filled with zeros)
  72008. */
  72009. constructor();
  72010. /**
  72011. * Check if the current matrix is identity
  72012. * @returns true is the matrix is the identity matrix
  72013. */
  72014. isIdentity(): boolean;
  72015. /**
  72016. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  72017. * @returns true is the matrix is the identity matrix
  72018. */
  72019. isIdentityAs3x2(): boolean;
  72020. /**
  72021. * Gets the determinant of the matrix
  72022. * @returns the matrix determinant
  72023. */
  72024. determinant(): number;
  72025. /**
  72026. * Returns the matrix as a Float32Array
  72027. * @returns the matrix underlying array
  72028. */
  72029. toArray(): DeepImmutable<Float32Array>;
  72030. /**
  72031. * Returns the matrix as a Float32Array
  72032. * @returns the matrix underlying array.
  72033. */
  72034. asArray(): DeepImmutable<Float32Array>;
  72035. /**
  72036. * Inverts the current matrix in place
  72037. * @returns the current inverted matrix
  72038. */
  72039. invert(): Matrix;
  72040. /**
  72041. * Sets all the matrix elements to zero
  72042. * @returns the current matrix
  72043. */
  72044. reset(): Matrix;
  72045. /**
  72046. * Adds the current matrix with a second one
  72047. * @param other defines the matrix to add
  72048. * @returns a new matrix as the addition of the current matrix and the given one
  72049. */
  72050. add(other: DeepImmutable<Matrix>): Matrix;
  72051. /**
  72052. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72053. * @param other defines the matrix to add
  72054. * @param result defines the target matrix
  72055. * @returns the current matrix
  72056. */
  72057. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72058. /**
  72059. * Adds in place the given matrix to the current matrix
  72060. * @param other defines the second operand
  72061. * @returns the current updated matrix
  72062. */
  72063. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72064. /**
  72065. * Sets the given matrix to the current inverted Matrix
  72066. * @param other defines the target matrix
  72067. * @returns the unmodified current matrix
  72068. */
  72069. invertToRef(other: Matrix): Matrix;
  72070. /**
  72071. * add a value at the specified position in the current Matrix
  72072. * @param index the index of the value within the matrix. between 0 and 15.
  72073. * @param value the value to be added
  72074. * @returns the current updated matrix
  72075. */
  72076. addAtIndex(index: number, value: number): Matrix;
  72077. /**
  72078. * mutiply the specified position in the current Matrix by a value
  72079. * @param index the index of the value within the matrix. between 0 and 15.
  72080. * @param value the value to be added
  72081. * @returns the current updated matrix
  72082. */
  72083. multiplyAtIndex(index: number, value: number): Matrix;
  72084. /**
  72085. * Inserts the translation vector (using 3 floats) in the current matrix
  72086. * @param x defines the 1st component of the translation
  72087. * @param y defines the 2nd component of the translation
  72088. * @param z defines the 3rd component of the translation
  72089. * @returns the current updated matrix
  72090. */
  72091. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72092. /**
  72093. * Adds the translation vector (using 3 floats) in the current matrix
  72094. * @param x defines the 1st component of the translation
  72095. * @param y defines the 2nd component of the translation
  72096. * @param z defines the 3rd component of the translation
  72097. * @returns the current updated matrix
  72098. */
  72099. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72100. /**
  72101. * Inserts the translation vector in the current matrix
  72102. * @param vector3 defines the translation to insert
  72103. * @returns the current updated matrix
  72104. */
  72105. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72106. /**
  72107. * Gets the translation value of the current matrix
  72108. * @returns a new Vector3 as the extracted translation from the matrix
  72109. */
  72110. getTranslation(): Vector3;
  72111. /**
  72112. * Fill a Vector3 with the extracted translation from the matrix
  72113. * @param result defines the Vector3 where to store the translation
  72114. * @returns the current matrix
  72115. */
  72116. getTranslationToRef(result: Vector3): Matrix;
  72117. /**
  72118. * Remove rotation and scaling part from the matrix
  72119. * @returns the updated matrix
  72120. */
  72121. removeRotationAndScaling(): Matrix;
  72122. /**
  72123. * Multiply two matrices
  72124. * @param other defines the second operand
  72125. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72126. */
  72127. multiply(other: DeepImmutable<Matrix>): Matrix;
  72128. /**
  72129. * Copy the current matrix from the given one
  72130. * @param other defines the source matrix
  72131. * @returns the current updated matrix
  72132. */
  72133. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72134. /**
  72135. * Populates the given array from the starting index with the current matrix values
  72136. * @param array defines the target array
  72137. * @param offset defines the offset in the target array where to start storing values
  72138. * @returns the current matrix
  72139. */
  72140. copyToArray(array: Float32Array, offset?: number): Matrix;
  72141. /**
  72142. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72143. * @param other defines the second operand
  72144. * @param result defines the matrix where to store the multiplication
  72145. * @returns the current matrix
  72146. */
  72147. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72148. /**
  72149. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72150. * @param other defines the second operand
  72151. * @param result defines the array where to store the multiplication
  72152. * @param offset defines the offset in the target array where to start storing values
  72153. * @returns the current matrix
  72154. */
  72155. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72156. /**
  72157. * Check equality between this matrix and a second one
  72158. * @param value defines the second matrix to compare
  72159. * @returns true is the current matrix and the given one values are strictly equal
  72160. */
  72161. equals(value: DeepImmutable<Matrix>): boolean;
  72162. /**
  72163. * Clone the current matrix
  72164. * @returns a new matrix from the current matrix
  72165. */
  72166. clone(): Matrix;
  72167. /**
  72168. * Returns the name of the current matrix class
  72169. * @returns the string "Matrix"
  72170. */
  72171. getClassName(): string;
  72172. /**
  72173. * Gets the hash code of the current matrix
  72174. * @returns the hash code
  72175. */
  72176. getHashCode(): number;
  72177. /**
  72178. * Decomposes the current Matrix into a translation, rotation and scaling components
  72179. * @param scale defines the scale vector3 given as a reference to update
  72180. * @param rotation defines the rotation quaternion given as a reference to update
  72181. * @param translation defines the translation vector3 given as a reference to update
  72182. * @returns true if operation was successful
  72183. */
  72184. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72185. /**
  72186. * Gets specific row of the matrix
  72187. * @param index defines the number of the row to get
  72188. * @returns the index-th row of the current matrix as a new Vector4
  72189. */
  72190. getRow(index: number): Nullable<Vector4>;
  72191. /**
  72192. * Sets the index-th row of the current matrix to the vector4 values
  72193. * @param index defines the number of the row to set
  72194. * @param row defines the target vector4
  72195. * @returns the updated current matrix
  72196. */
  72197. setRow(index: number, row: Vector4): Matrix;
  72198. /**
  72199. * Compute the transpose of the matrix
  72200. * @returns the new transposed matrix
  72201. */
  72202. transpose(): Matrix;
  72203. /**
  72204. * Compute the transpose of the matrix and store it in a given matrix
  72205. * @param result defines the target matrix
  72206. * @returns the current matrix
  72207. */
  72208. transposeToRef(result: Matrix): Matrix;
  72209. /**
  72210. * Sets the index-th row of the current matrix with the given 4 x float values
  72211. * @param index defines the row index
  72212. * @param x defines the x component to set
  72213. * @param y defines the y component to set
  72214. * @param z defines the z component to set
  72215. * @param w defines the w component to set
  72216. * @returns the updated current matrix
  72217. */
  72218. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72219. /**
  72220. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72221. * @param scale defines the scale factor
  72222. * @returns a new matrix
  72223. */
  72224. scale(scale: number): Matrix;
  72225. /**
  72226. * Scale the current matrix values by a factor to a given result matrix
  72227. * @param scale defines the scale factor
  72228. * @param result defines the matrix to store the result
  72229. * @returns the current matrix
  72230. */
  72231. scaleToRef(scale: number, result: Matrix): Matrix;
  72232. /**
  72233. * Scale the current matrix values by a factor and add the result to a given matrix
  72234. * @param scale defines the scale factor
  72235. * @param result defines the Matrix to store the result
  72236. * @returns the current matrix
  72237. */
  72238. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72239. /**
  72240. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72241. * @param ref matrix to store the result
  72242. */
  72243. toNormalMatrix(ref: Matrix): void;
  72244. /**
  72245. * Gets only rotation part of the current matrix
  72246. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72247. */
  72248. getRotationMatrix(): Matrix;
  72249. /**
  72250. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72251. * @param result defines the target matrix to store data to
  72252. * @returns the current matrix
  72253. */
  72254. getRotationMatrixToRef(result: Matrix): Matrix;
  72255. /**
  72256. * Toggles model matrix from being right handed to left handed in place and vice versa
  72257. */
  72258. toggleModelMatrixHandInPlace(): void;
  72259. /**
  72260. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72261. */
  72262. toggleProjectionMatrixHandInPlace(): void;
  72263. /**
  72264. * Creates a matrix from an array
  72265. * @param array defines the source array
  72266. * @param offset defines an offset in the source array
  72267. * @returns a new Matrix set from the starting index of the given array
  72268. */
  72269. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72270. /**
  72271. * Copy the content of an array into a given matrix
  72272. * @param array defines the source array
  72273. * @param offset defines an offset in the source array
  72274. * @param result defines the target matrix
  72275. */
  72276. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72277. /**
  72278. * Stores an array into a matrix after having multiplied each component by a given factor
  72279. * @param array defines the source array
  72280. * @param offset defines the offset in the source array
  72281. * @param scale defines the scaling factor
  72282. * @param result defines the target matrix
  72283. */
  72284. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72285. /**
  72286. * Gets an identity matrix that must not be updated
  72287. */
  72288. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72289. /**
  72290. * Stores a list of values (16) inside a given matrix
  72291. * @param initialM11 defines 1st value of 1st row
  72292. * @param initialM12 defines 2nd value of 1st row
  72293. * @param initialM13 defines 3rd value of 1st row
  72294. * @param initialM14 defines 4th value of 1st row
  72295. * @param initialM21 defines 1st value of 2nd row
  72296. * @param initialM22 defines 2nd value of 2nd row
  72297. * @param initialM23 defines 3rd value of 2nd row
  72298. * @param initialM24 defines 4th value of 2nd row
  72299. * @param initialM31 defines 1st value of 3rd row
  72300. * @param initialM32 defines 2nd value of 3rd row
  72301. * @param initialM33 defines 3rd value of 3rd row
  72302. * @param initialM34 defines 4th value of 3rd row
  72303. * @param initialM41 defines 1st value of 4th row
  72304. * @param initialM42 defines 2nd value of 4th row
  72305. * @param initialM43 defines 3rd value of 4th row
  72306. * @param initialM44 defines 4th value of 4th row
  72307. * @param result defines the target matrix
  72308. */
  72309. 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;
  72310. /**
  72311. * Creates new matrix from a list of values (16)
  72312. * @param initialM11 defines 1st value of 1st row
  72313. * @param initialM12 defines 2nd value of 1st row
  72314. * @param initialM13 defines 3rd value of 1st row
  72315. * @param initialM14 defines 4th value of 1st row
  72316. * @param initialM21 defines 1st value of 2nd row
  72317. * @param initialM22 defines 2nd value of 2nd row
  72318. * @param initialM23 defines 3rd value of 2nd row
  72319. * @param initialM24 defines 4th value of 2nd row
  72320. * @param initialM31 defines 1st value of 3rd row
  72321. * @param initialM32 defines 2nd value of 3rd row
  72322. * @param initialM33 defines 3rd value of 3rd row
  72323. * @param initialM34 defines 4th value of 3rd row
  72324. * @param initialM41 defines 1st value of 4th row
  72325. * @param initialM42 defines 2nd value of 4th row
  72326. * @param initialM43 defines 3rd value of 4th row
  72327. * @param initialM44 defines 4th value of 4th row
  72328. * @returns the new matrix
  72329. */
  72330. 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;
  72331. /**
  72332. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72333. * @param scale defines the scale vector3
  72334. * @param rotation defines the rotation quaternion
  72335. * @param translation defines the translation vector3
  72336. * @returns a new matrix
  72337. */
  72338. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72339. /**
  72340. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72341. * @param scale defines the scale vector3
  72342. * @param rotation defines the rotation quaternion
  72343. * @param translation defines the translation vector3
  72344. * @param result defines the target matrix
  72345. */
  72346. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72347. /**
  72348. * Creates a new identity matrix
  72349. * @returns a new identity matrix
  72350. */
  72351. static Identity(): Matrix;
  72352. /**
  72353. * Creates a new identity matrix and stores the result in a given matrix
  72354. * @param result defines the target matrix
  72355. */
  72356. static IdentityToRef(result: Matrix): void;
  72357. /**
  72358. * Creates a new zero matrix
  72359. * @returns a new zero matrix
  72360. */
  72361. static Zero(): Matrix;
  72362. /**
  72363. * Creates a new rotation matrix for "angle" radians around the X axis
  72364. * @param angle defines the angle (in radians) to use
  72365. * @return the new matrix
  72366. */
  72367. static RotationX(angle: number): Matrix;
  72368. /**
  72369. * Creates a new matrix as the invert of a given matrix
  72370. * @param source defines the source matrix
  72371. * @returns the new matrix
  72372. */
  72373. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72374. /**
  72375. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72376. * @param angle defines the angle (in radians) to use
  72377. * @param result defines the target matrix
  72378. */
  72379. static RotationXToRef(angle: number, result: Matrix): void;
  72380. /**
  72381. * Creates a new rotation matrix for "angle" radians around the Y axis
  72382. * @param angle defines the angle (in radians) to use
  72383. * @return the new matrix
  72384. */
  72385. static RotationY(angle: number): Matrix;
  72386. /**
  72387. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72388. * @param angle defines the angle (in radians) to use
  72389. * @param result defines the target matrix
  72390. */
  72391. static RotationYToRef(angle: number, result: Matrix): void;
  72392. /**
  72393. * Creates a new rotation matrix for "angle" radians around the Z axis
  72394. * @param angle defines the angle (in radians) to use
  72395. * @return the new matrix
  72396. */
  72397. static RotationZ(angle: number): Matrix;
  72398. /**
  72399. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72400. * @param angle defines the angle (in radians) to use
  72401. * @param result defines the target matrix
  72402. */
  72403. static RotationZToRef(angle: number, result: Matrix): void;
  72404. /**
  72405. * Creates a new rotation matrix for "angle" radians around the given axis
  72406. * @param axis defines the axis to use
  72407. * @param angle defines the angle (in radians) to use
  72408. * @return the new matrix
  72409. */
  72410. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72411. /**
  72412. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72413. * @param axis defines the axis to use
  72414. * @param angle defines the angle (in radians) to use
  72415. * @param result defines the target matrix
  72416. */
  72417. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72418. /**
  72419. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72420. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72421. * @param from defines the vector to align
  72422. * @param to defines the vector to align to
  72423. * @param result defines the target matrix
  72424. */
  72425. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72426. /**
  72427. * Creates a rotation matrix
  72428. * @param yaw defines the yaw angle in radians (Y axis)
  72429. * @param pitch defines the pitch angle in radians (X axis)
  72430. * @param roll defines the roll angle in radians (X axis)
  72431. * @returns the new rotation matrix
  72432. */
  72433. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72434. /**
  72435. * Creates a rotation matrix and stores it in a given matrix
  72436. * @param yaw defines the yaw angle in radians (Y axis)
  72437. * @param pitch defines the pitch angle in radians (X axis)
  72438. * @param roll defines the roll angle in radians (X axis)
  72439. * @param result defines the target matrix
  72440. */
  72441. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72442. /**
  72443. * Creates a scaling matrix
  72444. * @param x defines the scale factor on X axis
  72445. * @param y defines the scale factor on Y axis
  72446. * @param z defines the scale factor on Z axis
  72447. * @returns the new matrix
  72448. */
  72449. static Scaling(x: number, y: number, z: number): Matrix;
  72450. /**
  72451. * Creates a scaling matrix and stores it in a given matrix
  72452. * @param x defines the scale factor on X axis
  72453. * @param y defines the scale factor on Y axis
  72454. * @param z defines the scale factor on Z axis
  72455. * @param result defines the target matrix
  72456. */
  72457. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72458. /**
  72459. * Creates a translation matrix
  72460. * @param x defines the translation on X axis
  72461. * @param y defines the translation on Y axis
  72462. * @param z defines the translationon Z axis
  72463. * @returns the new matrix
  72464. */
  72465. static Translation(x: number, y: number, z: number): Matrix;
  72466. /**
  72467. * Creates a translation matrix and stores it in a given matrix
  72468. * @param x defines the translation on X axis
  72469. * @param y defines the translation on Y axis
  72470. * @param z defines the translationon Z axis
  72471. * @param result defines the target matrix
  72472. */
  72473. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72474. /**
  72475. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72476. * @param startValue defines the start value
  72477. * @param endValue defines the end value
  72478. * @param gradient defines the gradient factor
  72479. * @returns the new matrix
  72480. */
  72481. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72482. /**
  72483. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72484. * @param startValue defines the start value
  72485. * @param endValue defines the end value
  72486. * @param gradient defines the gradient factor
  72487. * @param result defines the Matrix object where to store data
  72488. */
  72489. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72490. /**
  72491. * Builds a new matrix whose values are computed by:
  72492. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72493. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72494. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72495. * @param startValue defines the first matrix
  72496. * @param endValue defines the second matrix
  72497. * @param gradient defines the gradient between the two matrices
  72498. * @returns the new matrix
  72499. */
  72500. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72501. /**
  72502. * Update a matrix to values which are computed by:
  72503. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72504. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72505. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72506. * @param startValue defines the first matrix
  72507. * @param endValue defines the second matrix
  72508. * @param gradient defines the gradient between the two matrices
  72509. * @param result defines the target matrix
  72510. */
  72511. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72512. /**
  72513. * 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"
  72514. * This function works in left handed mode
  72515. * @param eye defines the final position of the entity
  72516. * @param target defines where the entity should look at
  72517. * @param up defines the up vector for the entity
  72518. * @returns the new matrix
  72519. */
  72520. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72521. /**
  72522. * 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".
  72523. * This function works in left handed mode
  72524. * @param eye defines the final position of the entity
  72525. * @param target defines where the entity should look at
  72526. * @param up defines the up vector for the entity
  72527. * @param result defines the target matrix
  72528. */
  72529. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72530. /**
  72531. * 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"
  72532. * This function works in right handed mode
  72533. * @param eye defines the final position of the entity
  72534. * @param target defines where the entity should look at
  72535. * @param up defines the up vector for the entity
  72536. * @returns the new matrix
  72537. */
  72538. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72539. /**
  72540. * 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".
  72541. * This function works in right handed mode
  72542. * @param eye defines the final position of the entity
  72543. * @param target defines where the entity should look at
  72544. * @param up defines the up vector for the entity
  72545. * @param result defines the target matrix
  72546. */
  72547. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72548. /**
  72549. * Create a left-handed orthographic projection matrix
  72550. * @param width defines the viewport width
  72551. * @param height defines the viewport height
  72552. * @param znear defines the near clip plane
  72553. * @param zfar defines the far clip plane
  72554. * @returns a new matrix as a left-handed orthographic projection matrix
  72555. */
  72556. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72557. /**
  72558. * Store a left-handed orthographic projection to a given matrix
  72559. * @param width defines the viewport width
  72560. * @param height defines the viewport height
  72561. * @param znear defines the near clip plane
  72562. * @param zfar defines the far clip plane
  72563. * @param result defines the target matrix
  72564. */
  72565. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72566. /**
  72567. * Create a left-handed orthographic projection matrix
  72568. * @param left defines the viewport left coordinate
  72569. * @param right defines the viewport right coordinate
  72570. * @param bottom defines the viewport bottom coordinate
  72571. * @param top defines the viewport top coordinate
  72572. * @param znear defines the near clip plane
  72573. * @param zfar defines the far clip plane
  72574. * @returns a new matrix as a left-handed orthographic projection matrix
  72575. */
  72576. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72577. /**
  72578. * Stores a left-handed orthographic projection into a given matrix
  72579. * @param left defines the viewport left coordinate
  72580. * @param right defines the viewport right coordinate
  72581. * @param bottom defines the viewport bottom coordinate
  72582. * @param top defines the viewport top coordinate
  72583. * @param znear defines the near clip plane
  72584. * @param zfar defines the far clip plane
  72585. * @param result defines the target matrix
  72586. */
  72587. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72588. /**
  72589. * Creates a right-handed orthographic projection matrix
  72590. * @param left defines the viewport left coordinate
  72591. * @param right defines the viewport right coordinate
  72592. * @param bottom defines the viewport bottom coordinate
  72593. * @param top defines the viewport top coordinate
  72594. * @param znear defines the near clip plane
  72595. * @param zfar defines the far clip plane
  72596. * @returns a new matrix as a right-handed orthographic projection matrix
  72597. */
  72598. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72599. /**
  72600. * Stores a right-handed orthographic projection into a given matrix
  72601. * @param left defines the viewport left coordinate
  72602. * @param right defines the viewport right coordinate
  72603. * @param bottom defines the viewport bottom coordinate
  72604. * @param top defines the viewport top coordinate
  72605. * @param znear defines the near clip plane
  72606. * @param zfar defines the far clip plane
  72607. * @param result defines the target matrix
  72608. */
  72609. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72610. /**
  72611. * Creates a left-handed perspective projection matrix
  72612. * @param width defines the viewport width
  72613. * @param height defines the viewport height
  72614. * @param znear defines the near clip plane
  72615. * @param zfar defines the far clip plane
  72616. * @returns a new matrix as a left-handed perspective projection matrix
  72617. */
  72618. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72619. /**
  72620. * Creates a left-handed perspective projection matrix
  72621. * @param fov defines the horizontal field of view
  72622. * @param aspect defines the aspect ratio
  72623. * @param znear defines the near clip plane
  72624. * @param zfar defines the far clip plane
  72625. * @returns a new matrix as a left-handed perspective projection matrix
  72626. */
  72627. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72628. /**
  72629. * Stores a left-handed perspective projection into a given matrix
  72630. * @param fov defines the horizontal field of view
  72631. * @param aspect defines the aspect ratio
  72632. * @param znear defines the near clip plane
  72633. * @param zfar defines the far clip plane
  72634. * @param result defines the target matrix
  72635. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72636. */
  72637. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72638. /**
  72639. * Creates a right-handed perspective projection matrix
  72640. * @param fov defines the horizontal field of view
  72641. * @param aspect defines the aspect ratio
  72642. * @param znear defines the near clip plane
  72643. * @param zfar defines the far clip plane
  72644. * @returns a new matrix as a right-handed perspective projection matrix
  72645. */
  72646. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72647. /**
  72648. * Stores a right-handed perspective projection into a given matrix
  72649. * @param fov defines the horizontal field of view
  72650. * @param aspect defines the aspect ratio
  72651. * @param znear defines the near clip plane
  72652. * @param zfar defines the far clip plane
  72653. * @param result defines the target matrix
  72654. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72655. */
  72656. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72657. /**
  72658. * Stores a perspective projection for WebVR info a given matrix
  72659. * @param fov defines the field of view
  72660. * @param znear defines the near clip plane
  72661. * @param zfar defines the far clip plane
  72662. * @param result defines the target matrix
  72663. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72664. */
  72665. static PerspectiveFovWebVRToRef(fov: {
  72666. upDegrees: number;
  72667. downDegrees: number;
  72668. leftDegrees: number;
  72669. rightDegrees: number;
  72670. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72671. /**
  72672. * Computes a complete transformation matrix
  72673. * @param viewport defines the viewport to use
  72674. * @param world defines the world matrix
  72675. * @param view defines the view matrix
  72676. * @param projection defines the projection matrix
  72677. * @param zmin defines the near clip plane
  72678. * @param zmax defines the far clip plane
  72679. * @returns the transformation matrix
  72680. */
  72681. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72682. /**
  72683. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72684. * @param matrix defines the matrix to use
  72685. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72686. */
  72687. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72688. /**
  72689. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72690. * @param matrix defines the matrix to use
  72691. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72692. */
  72693. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72694. /**
  72695. * Compute the transpose of a given matrix
  72696. * @param matrix defines the matrix to transpose
  72697. * @returns the new matrix
  72698. */
  72699. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72700. /**
  72701. * Compute the transpose of a matrix and store it in a target matrix
  72702. * @param matrix defines the matrix to transpose
  72703. * @param result defines the target matrix
  72704. */
  72705. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72706. /**
  72707. * Computes a reflection matrix from a plane
  72708. * @param plane defines the reflection plane
  72709. * @returns a new matrix
  72710. */
  72711. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72712. /**
  72713. * Computes a reflection matrix from a plane
  72714. * @param plane defines the reflection plane
  72715. * @param result defines the target matrix
  72716. */
  72717. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72718. /**
  72719. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72720. * @param xaxis defines the value of the 1st axis
  72721. * @param yaxis defines the value of the 2nd axis
  72722. * @param zaxis defines the value of the 3rd axis
  72723. * @param result defines the target matrix
  72724. */
  72725. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72726. /**
  72727. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72728. * @param quat defines the quaternion to use
  72729. * @param result defines the target matrix
  72730. */
  72731. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72732. }
  72733. /**
  72734. * @hidden
  72735. */
  72736. export class TmpVectors {
  72737. static Vector2: Vector2[];
  72738. static Vector3: Vector3[];
  72739. static Vector4: Vector4[];
  72740. static Quaternion: Quaternion[];
  72741. static Matrix: Matrix[];
  72742. }
  72743. }
  72744. declare module BABYLON {
  72745. /**
  72746. * Defines potential orientation for back face culling
  72747. */
  72748. export enum Orientation {
  72749. /**
  72750. * Clockwise
  72751. */
  72752. CW = 0,
  72753. /** Counter clockwise */
  72754. CCW = 1
  72755. }
  72756. /** Class used to represent a Bezier curve */
  72757. export class BezierCurve {
  72758. /**
  72759. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72760. * @param t defines the time
  72761. * @param x1 defines the left coordinate on X axis
  72762. * @param y1 defines the left coordinate on Y axis
  72763. * @param x2 defines the right coordinate on X axis
  72764. * @param y2 defines the right coordinate on Y axis
  72765. * @returns the interpolated value
  72766. */
  72767. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72768. }
  72769. /**
  72770. * Defines angle representation
  72771. */
  72772. export class Angle {
  72773. private _radians;
  72774. /**
  72775. * Creates an Angle object of "radians" radians (float).
  72776. * @param radians the angle in radians
  72777. */
  72778. constructor(radians: number);
  72779. /**
  72780. * Get value in degrees
  72781. * @returns the Angle value in degrees (float)
  72782. */
  72783. degrees(): number;
  72784. /**
  72785. * Get value in radians
  72786. * @returns the Angle value in radians (float)
  72787. */
  72788. radians(): number;
  72789. /**
  72790. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72791. * @param a defines first vector
  72792. * @param b defines second vector
  72793. * @returns a new Angle
  72794. */
  72795. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72796. /**
  72797. * Gets a new Angle object from the given float in radians
  72798. * @param radians defines the angle value in radians
  72799. * @returns a new Angle
  72800. */
  72801. static FromRadians(radians: number): Angle;
  72802. /**
  72803. * Gets a new Angle object from the given float in degrees
  72804. * @param degrees defines the angle value in degrees
  72805. * @returns a new Angle
  72806. */
  72807. static FromDegrees(degrees: number): Angle;
  72808. }
  72809. /**
  72810. * This represents an arc in a 2d space.
  72811. */
  72812. export class Arc2 {
  72813. /** Defines the start point of the arc */
  72814. startPoint: Vector2;
  72815. /** Defines the mid point of the arc */
  72816. midPoint: Vector2;
  72817. /** Defines the end point of the arc */
  72818. endPoint: Vector2;
  72819. /**
  72820. * Defines the center point of the arc.
  72821. */
  72822. centerPoint: Vector2;
  72823. /**
  72824. * Defines the radius of the arc.
  72825. */
  72826. radius: number;
  72827. /**
  72828. * Defines the angle of the arc (from mid point to end point).
  72829. */
  72830. angle: Angle;
  72831. /**
  72832. * Defines the start angle of the arc (from start point to middle point).
  72833. */
  72834. startAngle: Angle;
  72835. /**
  72836. * Defines the orientation of the arc (clock wise/counter clock wise).
  72837. */
  72838. orientation: Orientation;
  72839. /**
  72840. * Creates an Arc object from the three given points : start, middle and end.
  72841. * @param startPoint Defines the start point of the arc
  72842. * @param midPoint Defines the midlle point of the arc
  72843. * @param endPoint Defines the end point of the arc
  72844. */
  72845. constructor(
  72846. /** Defines the start point of the arc */
  72847. startPoint: Vector2,
  72848. /** Defines the mid point of the arc */
  72849. midPoint: Vector2,
  72850. /** Defines the end point of the arc */
  72851. endPoint: Vector2);
  72852. }
  72853. /**
  72854. * Represents a 2D path made up of multiple 2D points
  72855. */
  72856. export class Path2 {
  72857. private _points;
  72858. private _length;
  72859. /**
  72860. * If the path start and end point are the same
  72861. */
  72862. closed: boolean;
  72863. /**
  72864. * Creates a Path2 object from the starting 2D coordinates x and y.
  72865. * @param x the starting points x value
  72866. * @param y the starting points y value
  72867. */
  72868. constructor(x: number, y: number);
  72869. /**
  72870. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72871. * @param x the added points x value
  72872. * @param y the added points y value
  72873. * @returns the updated Path2.
  72874. */
  72875. addLineTo(x: number, y: number): Path2;
  72876. /**
  72877. * 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.
  72878. * @param midX middle point x value
  72879. * @param midY middle point y value
  72880. * @param endX end point x value
  72881. * @param endY end point y value
  72882. * @param numberOfSegments (default: 36)
  72883. * @returns the updated Path2.
  72884. */
  72885. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72886. /**
  72887. * Closes the Path2.
  72888. * @returns the Path2.
  72889. */
  72890. close(): Path2;
  72891. /**
  72892. * Gets the sum of the distance between each sequential point in the path
  72893. * @returns the Path2 total length (float).
  72894. */
  72895. length(): number;
  72896. /**
  72897. * Gets the points which construct the path
  72898. * @returns the Path2 internal array of points.
  72899. */
  72900. getPoints(): Vector2[];
  72901. /**
  72902. * Retreives the point at the distance aways from the starting point
  72903. * @param normalizedLengthPosition the length along the path to retreive the point from
  72904. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72905. */
  72906. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72907. /**
  72908. * Creates a new path starting from an x and y position
  72909. * @param x starting x value
  72910. * @param y starting y value
  72911. * @returns a new Path2 starting at the coordinates (x, y).
  72912. */
  72913. static StartingAt(x: number, y: number): Path2;
  72914. }
  72915. /**
  72916. * Represents a 3D path made up of multiple 3D points
  72917. */
  72918. export class Path3D {
  72919. /**
  72920. * an array of Vector3, the curve axis of the Path3D
  72921. */
  72922. path: Vector3[];
  72923. private _curve;
  72924. private _distances;
  72925. private _tangents;
  72926. private _normals;
  72927. private _binormals;
  72928. private _raw;
  72929. private _alignTangentsWithPath;
  72930. private readonly _pointAtData;
  72931. /**
  72932. * new Path3D(path, normal, raw)
  72933. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72934. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72935. * @param path an array of Vector3, the curve axis of the Path3D
  72936. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72937. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72938. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  72939. */
  72940. constructor(
  72941. /**
  72942. * an array of Vector3, the curve axis of the Path3D
  72943. */
  72944. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  72945. /**
  72946. * Returns the Path3D array of successive Vector3 designing its curve.
  72947. * @returns the Path3D array of successive Vector3 designing its curve.
  72948. */
  72949. getCurve(): Vector3[];
  72950. /**
  72951. * Returns the Path3D array of successive Vector3 designing its curve.
  72952. * @returns the Path3D array of successive Vector3 designing its curve.
  72953. */
  72954. getPoints(): Vector3[];
  72955. /**
  72956. * @returns the computed length (float) of the path.
  72957. */
  72958. length(): number;
  72959. /**
  72960. * Returns an array populated with tangent vectors on each Path3D curve point.
  72961. * @returns an array populated with tangent vectors on each Path3D curve point.
  72962. */
  72963. getTangents(): Vector3[];
  72964. /**
  72965. * Returns an array populated with normal vectors on each Path3D curve point.
  72966. * @returns an array populated with normal vectors on each Path3D curve point.
  72967. */
  72968. getNormals(): Vector3[];
  72969. /**
  72970. * Returns an array populated with binormal vectors on each Path3D curve point.
  72971. * @returns an array populated with binormal vectors on each Path3D curve point.
  72972. */
  72973. getBinormals(): Vector3[];
  72974. /**
  72975. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72976. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72977. */
  72978. getDistances(): number[];
  72979. /**
  72980. * Returns an interpolated point along this path
  72981. * @param position the position of the point along this path, from 0.0 to 1.0
  72982. * @returns a new Vector3 as the point
  72983. */
  72984. getPointAt(position: number): Vector3;
  72985. /**
  72986. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  72987. * @param position the position of the point along this path, from 0.0 to 1.0
  72988. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  72989. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  72990. */
  72991. getTangentAt(position: number, interpolated?: boolean): Vector3;
  72992. /**
  72993. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  72994. * @param position the position of the point along this path, from 0.0 to 1.0
  72995. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  72996. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  72997. */
  72998. getNormalAt(position: number, interpolated?: boolean): Vector3;
  72999. /**
  73000. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  73001. * @param position the position of the point along this path, from 0.0 to 1.0
  73002. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  73003. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  73004. */
  73005. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  73006. /**
  73007. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  73008. * @param position the position of the point along this path, from 0.0 to 1.0
  73009. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  73010. */
  73011. getDistanceAt(position: number): number;
  73012. /**
  73013. * Returns the array index of the previous point of an interpolated point along this path
  73014. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73015. * @returns the array index
  73016. */
  73017. getPreviousPointIndexAt(position: number): number;
  73018. /**
  73019. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  73020. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73021. * @returns the sub position
  73022. */
  73023. getSubPositionAt(position: number): number;
  73024. /**
  73025. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  73026. * @param target the vector of which to get the closest position to
  73027. * @returns the position of the closest virtual point on this path to the target vector
  73028. */
  73029. getClosestPositionTo(target: Vector3): number;
  73030. /**
  73031. * Returns a sub path (slice) of this path
  73032. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  73033. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  73034. * @returns a sub path (slice) of this path
  73035. */
  73036. slice(start?: number, end?: number): Path3D;
  73037. /**
  73038. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73039. * @param path path which all values are copied into the curves points
  73040. * @param firstNormal which should be projected onto the curve
  73041. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73042. * @returns the same object updated.
  73043. */
  73044. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73045. private _compute;
  73046. private _getFirstNonNullVector;
  73047. private _getLastNonNullVector;
  73048. private _normalVector;
  73049. /**
  73050. * Updates the point at data for an interpolated point along this curve
  73051. * @param position the position of the point along this curve, from 0.0 to 1.0
  73052. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73053. * @returns the (updated) point at data
  73054. */
  73055. private _updatePointAtData;
  73056. /**
  73057. * Updates the point at data from the specified parameters
  73058. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73059. * @param point the interpolated point
  73060. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73061. */
  73062. private _setPointAtData;
  73063. /**
  73064. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73065. */
  73066. private _updateInterpolationMatrix;
  73067. }
  73068. /**
  73069. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73070. * A Curve3 is designed from a series of successive Vector3.
  73071. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73072. */
  73073. export class Curve3 {
  73074. private _points;
  73075. private _length;
  73076. /**
  73077. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73078. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73079. * @param v1 (Vector3) the control point
  73080. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73081. * @param nbPoints (integer) the wanted number of points in the curve
  73082. * @returns the created Curve3
  73083. */
  73084. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73085. /**
  73086. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73087. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73088. * @param v1 (Vector3) the first control point
  73089. * @param v2 (Vector3) the second control point
  73090. * @param v3 (Vector3) the end point of the Cubic Bezier
  73091. * @param nbPoints (integer) the wanted number of points in the curve
  73092. * @returns the created Curve3
  73093. */
  73094. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73095. /**
  73096. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73097. * @param p1 (Vector3) the origin point of the Hermite Spline
  73098. * @param t1 (Vector3) the tangent vector at the origin point
  73099. * @param p2 (Vector3) the end point of the Hermite Spline
  73100. * @param t2 (Vector3) the tangent vector at the end point
  73101. * @param nbPoints (integer) the wanted number of points in the curve
  73102. * @returns the created Curve3
  73103. */
  73104. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73105. /**
  73106. * Returns a Curve3 object along a CatmullRom Spline curve :
  73107. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73108. * @param nbPoints (integer) the wanted number of points between each curve control points
  73109. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73110. * @returns the created Curve3
  73111. */
  73112. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73113. /**
  73114. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73115. * A Curve3 is designed from a series of successive Vector3.
  73116. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73117. * @param points points which make up the curve
  73118. */
  73119. constructor(points: Vector3[]);
  73120. /**
  73121. * @returns the Curve3 stored array of successive Vector3
  73122. */
  73123. getPoints(): Vector3[];
  73124. /**
  73125. * @returns the computed length (float) of the curve.
  73126. */
  73127. length(): number;
  73128. /**
  73129. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73130. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73131. * curveA and curveB keep unchanged.
  73132. * @param curve the curve to continue from this curve
  73133. * @returns the newly constructed curve
  73134. */
  73135. continue(curve: DeepImmutable<Curve3>): Curve3;
  73136. private _computeLength;
  73137. }
  73138. }
  73139. declare module BABYLON {
  73140. /**
  73141. * This represents the main contract an easing function should follow.
  73142. * Easing functions are used throughout the animation system.
  73143. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73144. */
  73145. export interface IEasingFunction {
  73146. /**
  73147. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73148. * of the easing function.
  73149. * The link below provides some of the most common examples of easing functions.
  73150. * @see https://easings.net/
  73151. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73152. * @returns the corresponding value on the curve defined by the easing function
  73153. */
  73154. ease(gradient: number): number;
  73155. }
  73156. /**
  73157. * Base class used for every default easing function.
  73158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73159. */
  73160. export class EasingFunction implements IEasingFunction {
  73161. /**
  73162. * Interpolation follows the mathematical formula associated with the easing function.
  73163. */
  73164. static readonly EASINGMODE_EASEIN: number;
  73165. /**
  73166. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73167. */
  73168. static readonly EASINGMODE_EASEOUT: number;
  73169. /**
  73170. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73171. */
  73172. static readonly EASINGMODE_EASEINOUT: number;
  73173. private _easingMode;
  73174. /**
  73175. * Sets the easing mode of the current function.
  73176. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73177. */
  73178. setEasingMode(easingMode: number): void;
  73179. /**
  73180. * Gets the current easing mode.
  73181. * @returns the easing mode
  73182. */
  73183. getEasingMode(): number;
  73184. /**
  73185. * @hidden
  73186. */
  73187. easeInCore(gradient: number): number;
  73188. /**
  73189. * Given an input gradient between 0 and 1, this returns the corresponding value
  73190. * of the easing function.
  73191. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73192. * @returns the corresponding value on the curve defined by the easing function
  73193. */
  73194. ease(gradient: number): number;
  73195. }
  73196. /**
  73197. * Easing function with a circle shape (see link below).
  73198. * @see https://easings.net/#easeInCirc
  73199. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73200. */
  73201. export class CircleEase extends EasingFunction implements IEasingFunction {
  73202. /** @hidden */
  73203. easeInCore(gradient: number): number;
  73204. }
  73205. /**
  73206. * Easing function with a ease back shape (see link below).
  73207. * @see https://easings.net/#easeInBack
  73208. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73209. */
  73210. export class BackEase extends EasingFunction implements IEasingFunction {
  73211. /** Defines the amplitude of the function */
  73212. amplitude: number;
  73213. /**
  73214. * Instantiates a back ease easing
  73215. * @see https://easings.net/#easeInBack
  73216. * @param amplitude Defines the amplitude of the function
  73217. */
  73218. constructor(
  73219. /** Defines the amplitude of the function */
  73220. amplitude?: number);
  73221. /** @hidden */
  73222. easeInCore(gradient: number): number;
  73223. }
  73224. /**
  73225. * Easing function with a bouncing shape (see link below).
  73226. * @see https://easings.net/#easeInBounce
  73227. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73228. */
  73229. export class BounceEase extends EasingFunction implements IEasingFunction {
  73230. /** Defines the number of bounces */
  73231. bounces: number;
  73232. /** Defines the amplitude of the bounce */
  73233. bounciness: number;
  73234. /**
  73235. * Instantiates a bounce easing
  73236. * @see https://easings.net/#easeInBounce
  73237. * @param bounces Defines the number of bounces
  73238. * @param bounciness Defines the amplitude of the bounce
  73239. */
  73240. constructor(
  73241. /** Defines the number of bounces */
  73242. bounces?: number,
  73243. /** Defines the amplitude of the bounce */
  73244. bounciness?: number);
  73245. /** @hidden */
  73246. easeInCore(gradient: number): number;
  73247. }
  73248. /**
  73249. * Easing function with a power of 3 shape (see link below).
  73250. * @see https://easings.net/#easeInCubic
  73251. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73252. */
  73253. export class CubicEase extends EasingFunction implements IEasingFunction {
  73254. /** @hidden */
  73255. easeInCore(gradient: number): number;
  73256. }
  73257. /**
  73258. * Easing function with an elastic shape (see link below).
  73259. * @see https://easings.net/#easeInElastic
  73260. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73261. */
  73262. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73263. /** Defines the number of oscillations*/
  73264. oscillations: number;
  73265. /** Defines the amplitude of the oscillations*/
  73266. springiness: number;
  73267. /**
  73268. * Instantiates an elastic easing function
  73269. * @see https://easings.net/#easeInElastic
  73270. * @param oscillations Defines the number of oscillations
  73271. * @param springiness Defines the amplitude of the oscillations
  73272. */
  73273. constructor(
  73274. /** Defines the number of oscillations*/
  73275. oscillations?: number,
  73276. /** Defines the amplitude of the oscillations*/
  73277. springiness?: number);
  73278. /** @hidden */
  73279. easeInCore(gradient: number): number;
  73280. }
  73281. /**
  73282. * Easing function with an exponential shape (see link below).
  73283. * @see https://easings.net/#easeInExpo
  73284. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73285. */
  73286. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  73287. /** Defines the exponent of the function */
  73288. exponent: number;
  73289. /**
  73290. * Instantiates an exponential easing function
  73291. * @see https://easings.net/#easeInExpo
  73292. * @param exponent Defines the exponent of the function
  73293. */
  73294. constructor(
  73295. /** Defines the exponent of the function */
  73296. exponent?: number);
  73297. /** @hidden */
  73298. easeInCore(gradient: number): number;
  73299. }
  73300. /**
  73301. * Easing function with a power shape (see link below).
  73302. * @see https://easings.net/#easeInQuad
  73303. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73304. */
  73305. export class PowerEase extends EasingFunction implements IEasingFunction {
  73306. /** Defines the power of the function */
  73307. power: number;
  73308. /**
  73309. * Instantiates an power base easing function
  73310. * @see https://easings.net/#easeInQuad
  73311. * @param power Defines the power of the function
  73312. */
  73313. constructor(
  73314. /** Defines the power of the function */
  73315. power?: number);
  73316. /** @hidden */
  73317. easeInCore(gradient: number): number;
  73318. }
  73319. /**
  73320. * Easing function with a power of 2 shape (see link below).
  73321. * @see https://easings.net/#easeInQuad
  73322. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73323. */
  73324. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  73325. /** @hidden */
  73326. easeInCore(gradient: number): number;
  73327. }
  73328. /**
  73329. * Easing function with a power of 4 shape (see link below).
  73330. * @see https://easings.net/#easeInQuart
  73331. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73332. */
  73333. export class QuarticEase extends EasingFunction implements IEasingFunction {
  73334. /** @hidden */
  73335. easeInCore(gradient: number): number;
  73336. }
  73337. /**
  73338. * Easing function with a power of 5 shape (see link below).
  73339. * @see https://easings.net/#easeInQuint
  73340. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73341. */
  73342. export class QuinticEase extends EasingFunction implements IEasingFunction {
  73343. /** @hidden */
  73344. easeInCore(gradient: number): number;
  73345. }
  73346. /**
  73347. * Easing function with a sin shape (see link below).
  73348. * @see https://easings.net/#easeInSine
  73349. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73350. */
  73351. export class SineEase extends EasingFunction implements IEasingFunction {
  73352. /** @hidden */
  73353. easeInCore(gradient: number): number;
  73354. }
  73355. /**
  73356. * Easing function with a bezier shape (see link below).
  73357. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73358. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73359. */
  73360. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  73361. /** Defines the x component of the start tangent in the bezier curve */
  73362. x1: number;
  73363. /** Defines the y component of the start tangent in the bezier curve */
  73364. y1: number;
  73365. /** Defines the x component of the end tangent in the bezier curve */
  73366. x2: number;
  73367. /** Defines the y component of the end tangent in the bezier curve */
  73368. y2: number;
  73369. /**
  73370. * Instantiates a bezier function
  73371. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73372. * @param x1 Defines the x component of the start tangent in the bezier curve
  73373. * @param y1 Defines the y component of the start tangent in the bezier curve
  73374. * @param x2 Defines the x component of the end tangent in the bezier curve
  73375. * @param y2 Defines the y component of the end tangent in the bezier curve
  73376. */
  73377. constructor(
  73378. /** Defines the x component of the start tangent in the bezier curve */
  73379. x1?: number,
  73380. /** Defines the y component of the start tangent in the bezier curve */
  73381. y1?: number,
  73382. /** Defines the x component of the end tangent in the bezier curve */
  73383. x2?: number,
  73384. /** Defines the y component of the end tangent in the bezier curve */
  73385. y2?: number);
  73386. /** @hidden */
  73387. easeInCore(gradient: number): number;
  73388. }
  73389. }
  73390. declare module BABYLON {
  73391. /**
  73392. * Class used to hold a RBG color
  73393. */
  73394. export class Color3 {
  73395. /**
  73396. * Defines the red component (between 0 and 1, default is 0)
  73397. */
  73398. r: number;
  73399. /**
  73400. * Defines the green component (between 0 and 1, default is 0)
  73401. */
  73402. g: number;
  73403. /**
  73404. * Defines the blue component (between 0 and 1, default is 0)
  73405. */
  73406. b: number;
  73407. /**
  73408. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73409. * @param r defines the red component (between 0 and 1, default is 0)
  73410. * @param g defines the green component (between 0 and 1, default is 0)
  73411. * @param b defines the blue component (between 0 and 1, default is 0)
  73412. */
  73413. constructor(
  73414. /**
  73415. * Defines the red component (between 0 and 1, default is 0)
  73416. */
  73417. r?: number,
  73418. /**
  73419. * Defines the green component (between 0 and 1, default is 0)
  73420. */
  73421. g?: number,
  73422. /**
  73423. * Defines the blue component (between 0 and 1, default is 0)
  73424. */
  73425. b?: number);
  73426. /**
  73427. * Creates a string with the Color3 current values
  73428. * @returns the string representation of the Color3 object
  73429. */
  73430. toString(): string;
  73431. /**
  73432. * Returns the string "Color3"
  73433. * @returns "Color3"
  73434. */
  73435. getClassName(): string;
  73436. /**
  73437. * Compute the Color3 hash code
  73438. * @returns an unique number that can be used to hash Color3 objects
  73439. */
  73440. getHashCode(): number;
  73441. /**
  73442. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73443. * @param array defines the array where to store the r,g,b components
  73444. * @param index defines an optional index in the target array to define where to start storing values
  73445. * @returns the current Color3 object
  73446. */
  73447. toArray(array: FloatArray, index?: number): Color3;
  73448. /**
  73449. * Returns a new Color4 object from the current Color3 and the given alpha
  73450. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73451. * @returns a new Color4 object
  73452. */
  73453. toColor4(alpha?: number): Color4;
  73454. /**
  73455. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73456. * @returns the new array
  73457. */
  73458. asArray(): number[];
  73459. /**
  73460. * Returns the luminance value
  73461. * @returns a float value
  73462. */
  73463. toLuminance(): number;
  73464. /**
  73465. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73466. * @param otherColor defines the second operand
  73467. * @returns the new Color3 object
  73468. */
  73469. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73470. /**
  73471. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73472. * @param otherColor defines the second operand
  73473. * @param result defines the Color3 object where to store the result
  73474. * @returns the current Color3
  73475. */
  73476. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73477. /**
  73478. * Determines equality between Color3 objects
  73479. * @param otherColor defines the second operand
  73480. * @returns true if the rgb values are equal to the given ones
  73481. */
  73482. equals(otherColor: DeepImmutable<Color3>): boolean;
  73483. /**
  73484. * Determines equality between the current Color3 object and a set of r,b,g values
  73485. * @param r defines the red component to check
  73486. * @param g defines the green component to check
  73487. * @param b defines the blue component to check
  73488. * @returns true if the rgb values are equal to the given ones
  73489. */
  73490. equalsFloats(r: number, g: number, b: number): boolean;
  73491. /**
  73492. * Multiplies in place each rgb value by scale
  73493. * @param scale defines the scaling factor
  73494. * @returns the updated Color3
  73495. */
  73496. scale(scale: number): Color3;
  73497. /**
  73498. * Multiplies the rgb values by scale and stores the result into "result"
  73499. * @param scale defines the scaling factor
  73500. * @param result defines the Color3 object where to store the result
  73501. * @returns the unmodified current Color3
  73502. */
  73503. scaleToRef(scale: number, result: Color3): Color3;
  73504. /**
  73505. * Scale the current Color3 values by a factor and add the result to a given Color3
  73506. * @param scale defines the scale factor
  73507. * @param result defines color to store the result into
  73508. * @returns the unmodified current Color3
  73509. */
  73510. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73511. /**
  73512. * Clamps the rgb values by the min and max values and stores the result into "result"
  73513. * @param min defines minimum clamping value (default is 0)
  73514. * @param max defines maximum clamping value (default is 1)
  73515. * @param result defines color to store the result into
  73516. * @returns the original Color3
  73517. */
  73518. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73519. /**
  73520. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73521. * @param otherColor defines the second operand
  73522. * @returns the new Color3
  73523. */
  73524. add(otherColor: DeepImmutable<Color3>): Color3;
  73525. /**
  73526. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73527. * @param otherColor defines the second operand
  73528. * @param result defines Color3 object to store the result into
  73529. * @returns the unmodified current Color3
  73530. */
  73531. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73532. /**
  73533. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73534. * @param otherColor defines the second operand
  73535. * @returns the new Color3
  73536. */
  73537. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73538. /**
  73539. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73540. * @param otherColor defines the second operand
  73541. * @param result defines Color3 object to store the result into
  73542. * @returns the unmodified current Color3
  73543. */
  73544. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73545. /**
  73546. * Copy the current object
  73547. * @returns a new Color3 copied the current one
  73548. */
  73549. clone(): Color3;
  73550. /**
  73551. * Copies the rgb values from the source in the current Color3
  73552. * @param source defines the source Color3 object
  73553. * @returns the updated Color3 object
  73554. */
  73555. copyFrom(source: DeepImmutable<Color3>): Color3;
  73556. /**
  73557. * Updates the Color3 rgb values from the given floats
  73558. * @param r defines the red component to read from
  73559. * @param g defines the green component to read from
  73560. * @param b defines the blue component to read from
  73561. * @returns the current Color3 object
  73562. */
  73563. copyFromFloats(r: number, g: number, b: number): Color3;
  73564. /**
  73565. * Updates the Color3 rgb values from the given floats
  73566. * @param r defines the red component to read from
  73567. * @param g defines the green component to read from
  73568. * @param b defines the blue component to read from
  73569. * @returns the current Color3 object
  73570. */
  73571. set(r: number, g: number, b: number): Color3;
  73572. /**
  73573. * Compute the Color3 hexadecimal code as a string
  73574. * @returns a string containing the hexadecimal representation of the Color3 object
  73575. */
  73576. toHexString(): string;
  73577. /**
  73578. * Computes a new Color3 converted from the current one to linear space
  73579. * @returns a new Color3 object
  73580. */
  73581. toLinearSpace(): Color3;
  73582. /**
  73583. * Converts current color in rgb space to HSV values
  73584. * @returns a new color3 representing the HSV values
  73585. */
  73586. toHSV(): Color3;
  73587. /**
  73588. * Converts current color in rgb space to HSV values
  73589. * @param result defines the Color3 where to store the HSV values
  73590. */
  73591. toHSVToRef(result: Color3): void;
  73592. /**
  73593. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73594. * @param convertedColor defines the Color3 object where to store the linear space version
  73595. * @returns the unmodified Color3
  73596. */
  73597. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73598. /**
  73599. * Computes a new Color3 converted from the current one to gamma space
  73600. * @returns a new Color3 object
  73601. */
  73602. toGammaSpace(): Color3;
  73603. /**
  73604. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73605. * @param convertedColor defines the Color3 object where to store the gamma space version
  73606. * @returns the unmodified Color3
  73607. */
  73608. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73609. private static _BlackReadOnly;
  73610. /**
  73611. * Convert Hue, saturation and value to a Color3 (RGB)
  73612. * @param hue defines the hue
  73613. * @param saturation defines the saturation
  73614. * @param value defines the value
  73615. * @param result defines the Color3 where to store the RGB values
  73616. */
  73617. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73618. /**
  73619. * Creates a new Color3 from the string containing valid hexadecimal values
  73620. * @param hex defines a string containing valid hexadecimal values
  73621. * @returns a new Color3 object
  73622. */
  73623. static FromHexString(hex: string): Color3;
  73624. /**
  73625. * Creates a new Color3 from the starting index of the given array
  73626. * @param array defines the source array
  73627. * @param offset defines an offset in the source array
  73628. * @returns a new Color3 object
  73629. */
  73630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73631. /**
  73632. * Creates a new Color3 from integer values (< 256)
  73633. * @param r defines the red component to read from (value between 0 and 255)
  73634. * @param g defines the green component to read from (value between 0 and 255)
  73635. * @param b defines the blue component to read from (value between 0 and 255)
  73636. * @returns a new Color3 object
  73637. */
  73638. static FromInts(r: number, g: number, b: number): Color3;
  73639. /**
  73640. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73641. * @param start defines the start Color3 value
  73642. * @param end defines the end Color3 value
  73643. * @param amount defines the gradient value between start and end
  73644. * @returns a new Color3 object
  73645. */
  73646. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73647. /**
  73648. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73649. * @param left defines the start value
  73650. * @param right defines the end value
  73651. * @param amount defines the gradient factor
  73652. * @param result defines the Color3 object where to store the result
  73653. */
  73654. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73655. /**
  73656. * Returns a Color3 value containing a red color
  73657. * @returns a new Color3 object
  73658. */
  73659. static Red(): Color3;
  73660. /**
  73661. * Returns a Color3 value containing a green color
  73662. * @returns a new Color3 object
  73663. */
  73664. static Green(): Color3;
  73665. /**
  73666. * Returns a Color3 value containing a blue color
  73667. * @returns a new Color3 object
  73668. */
  73669. static Blue(): Color3;
  73670. /**
  73671. * Returns a Color3 value containing a black color
  73672. * @returns a new Color3 object
  73673. */
  73674. static Black(): Color3;
  73675. /**
  73676. * Gets a Color3 value containing a black color that must not be updated
  73677. */
  73678. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73679. /**
  73680. * Returns a Color3 value containing a white color
  73681. * @returns a new Color3 object
  73682. */
  73683. static White(): Color3;
  73684. /**
  73685. * Returns a Color3 value containing a purple color
  73686. * @returns a new Color3 object
  73687. */
  73688. static Purple(): Color3;
  73689. /**
  73690. * Returns a Color3 value containing a magenta color
  73691. * @returns a new Color3 object
  73692. */
  73693. static Magenta(): Color3;
  73694. /**
  73695. * Returns a Color3 value containing a yellow color
  73696. * @returns a new Color3 object
  73697. */
  73698. static Yellow(): Color3;
  73699. /**
  73700. * Returns a Color3 value containing a gray color
  73701. * @returns a new Color3 object
  73702. */
  73703. static Gray(): Color3;
  73704. /**
  73705. * Returns a Color3 value containing a teal color
  73706. * @returns a new Color3 object
  73707. */
  73708. static Teal(): Color3;
  73709. /**
  73710. * Returns a Color3 value containing a random color
  73711. * @returns a new Color3 object
  73712. */
  73713. static Random(): Color3;
  73714. }
  73715. /**
  73716. * Class used to hold a RBGA color
  73717. */
  73718. export class Color4 {
  73719. /**
  73720. * Defines the red component (between 0 and 1, default is 0)
  73721. */
  73722. r: number;
  73723. /**
  73724. * Defines the green component (between 0 and 1, default is 0)
  73725. */
  73726. g: number;
  73727. /**
  73728. * Defines the blue component (between 0 and 1, default is 0)
  73729. */
  73730. b: number;
  73731. /**
  73732. * Defines the alpha component (between 0 and 1, default is 1)
  73733. */
  73734. a: number;
  73735. /**
  73736. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73737. * @param r defines the red component (between 0 and 1, default is 0)
  73738. * @param g defines the green component (between 0 and 1, default is 0)
  73739. * @param b defines the blue component (between 0 and 1, default is 0)
  73740. * @param a defines the alpha component (between 0 and 1, default is 1)
  73741. */
  73742. constructor(
  73743. /**
  73744. * Defines the red component (between 0 and 1, default is 0)
  73745. */
  73746. r?: number,
  73747. /**
  73748. * Defines the green component (between 0 and 1, default is 0)
  73749. */
  73750. g?: number,
  73751. /**
  73752. * Defines the blue component (between 0 and 1, default is 0)
  73753. */
  73754. b?: number,
  73755. /**
  73756. * Defines the alpha component (between 0 and 1, default is 1)
  73757. */
  73758. a?: number);
  73759. /**
  73760. * Adds in place the given Color4 values to the current Color4 object
  73761. * @param right defines the second operand
  73762. * @returns the current updated Color4 object
  73763. */
  73764. addInPlace(right: DeepImmutable<Color4>): Color4;
  73765. /**
  73766. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73767. * @returns the new array
  73768. */
  73769. asArray(): number[];
  73770. /**
  73771. * Stores from the starting index in the given array the Color4 successive values
  73772. * @param array defines the array where to store the r,g,b components
  73773. * @param index defines an optional index in the target array to define where to start storing values
  73774. * @returns the current Color4 object
  73775. */
  73776. toArray(array: number[], index?: number): Color4;
  73777. /**
  73778. * Determines equality between Color4 objects
  73779. * @param otherColor defines the second operand
  73780. * @returns true if the rgba values are equal to the given ones
  73781. */
  73782. equals(otherColor: DeepImmutable<Color4>): boolean;
  73783. /**
  73784. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73785. * @param right defines the second operand
  73786. * @returns a new Color4 object
  73787. */
  73788. add(right: DeepImmutable<Color4>): Color4;
  73789. /**
  73790. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73791. * @param right defines the second operand
  73792. * @returns a new Color4 object
  73793. */
  73794. subtract(right: DeepImmutable<Color4>): Color4;
  73795. /**
  73796. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73797. * @param right defines the second operand
  73798. * @param result defines the Color4 object where to store the result
  73799. * @returns the current Color4 object
  73800. */
  73801. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  73802. /**
  73803. * Creates a new Color4 with the current Color4 values multiplied by scale
  73804. * @param scale defines the scaling factor to apply
  73805. * @returns a new Color4 object
  73806. */
  73807. scale(scale: number): Color4;
  73808. /**
  73809. * Multiplies the current Color4 values by scale and stores the result in "result"
  73810. * @param scale defines the scaling factor to apply
  73811. * @param result defines the Color4 object where to store the result
  73812. * @returns the current unmodified Color4
  73813. */
  73814. scaleToRef(scale: number, result: Color4): Color4;
  73815. /**
  73816. * Scale the current Color4 values by a factor and add the result to a given Color4
  73817. * @param scale defines the scale factor
  73818. * @param result defines the Color4 object where to store the result
  73819. * @returns the unmodified current Color4
  73820. */
  73821. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73822. /**
  73823. * Clamps the rgb values by the min and max values and stores the result into "result"
  73824. * @param min defines minimum clamping value (default is 0)
  73825. * @param max defines maximum clamping value (default is 1)
  73826. * @param result defines color to store the result into.
  73827. * @returns the cuurent Color4
  73828. */
  73829. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73830. /**
  73831. * Multipy an Color4 value by another and return a new Color4 object
  73832. * @param color defines the Color4 value to multiply by
  73833. * @returns a new Color4 object
  73834. */
  73835. multiply(color: Color4): Color4;
  73836. /**
  73837. * Multipy a Color4 value by another and push the result in a reference value
  73838. * @param color defines the Color4 value to multiply by
  73839. * @param result defines the Color4 to fill the result in
  73840. * @returns the result Color4
  73841. */
  73842. multiplyToRef(color: Color4, result: Color4): Color4;
  73843. /**
  73844. * Creates a string with the Color4 current values
  73845. * @returns the string representation of the Color4 object
  73846. */
  73847. toString(): string;
  73848. /**
  73849. * Returns the string "Color4"
  73850. * @returns "Color4"
  73851. */
  73852. getClassName(): string;
  73853. /**
  73854. * Compute the Color4 hash code
  73855. * @returns an unique number that can be used to hash Color4 objects
  73856. */
  73857. getHashCode(): number;
  73858. /**
  73859. * Creates a new Color4 copied from the current one
  73860. * @returns a new Color4 object
  73861. */
  73862. clone(): Color4;
  73863. /**
  73864. * Copies the given Color4 values into the current one
  73865. * @param source defines the source Color4 object
  73866. * @returns the current updated Color4 object
  73867. */
  73868. copyFrom(source: Color4): Color4;
  73869. /**
  73870. * Copies the given float values into the current one
  73871. * @param r defines the red component to read from
  73872. * @param g defines the green component to read from
  73873. * @param b defines the blue component to read from
  73874. * @param a defines the alpha component to read from
  73875. * @returns the current updated Color4 object
  73876. */
  73877. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73878. /**
  73879. * Copies the given float values into the current one
  73880. * @param r defines the red component to read from
  73881. * @param g defines the green component to read from
  73882. * @param b defines the blue component to read from
  73883. * @param a defines the alpha component to read from
  73884. * @returns the current updated Color4 object
  73885. */
  73886. set(r: number, g: number, b: number, a: number): Color4;
  73887. /**
  73888. * Compute the Color4 hexadecimal code as a string
  73889. * @returns a string containing the hexadecimal representation of the Color4 object
  73890. */
  73891. toHexString(): string;
  73892. /**
  73893. * Computes a new Color4 converted from the current one to linear space
  73894. * @returns a new Color4 object
  73895. */
  73896. toLinearSpace(): Color4;
  73897. /**
  73898. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73899. * @param convertedColor defines the Color4 object where to store the linear space version
  73900. * @returns the unmodified Color4
  73901. */
  73902. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73903. /**
  73904. * Computes a new Color4 converted from the current one to gamma space
  73905. * @returns a new Color4 object
  73906. */
  73907. toGammaSpace(): Color4;
  73908. /**
  73909. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73910. * @param convertedColor defines the Color4 object where to store the gamma space version
  73911. * @returns the unmodified Color4
  73912. */
  73913. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73914. /**
  73915. * Creates a new Color4 from the string containing valid hexadecimal values
  73916. * @param hex defines a string containing valid hexadecimal values
  73917. * @returns a new Color4 object
  73918. */
  73919. static FromHexString(hex: string): Color4;
  73920. /**
  73921. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73922. * @param left defines the start value
  73923. * @param right defines the end value
  73924. * @param amount defines the gradient factor
  73925. * @returns a new Color4 object
  73926. */
  73927. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73928. /**
  73929. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73930. * @param left defines the start value
  73931. * @param right defines the end value
  73932. * @param amount defines the gradient factor
  73933. * @param result defines the Color4 object where to store data
  73934. */
  73935. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73936. /**
  73937. * Creates a new Color4 from a Color3 and an alpha value
  73938. * @param color3 defines the source Color3 to read from
  73939. * @param alpha defines the alpha component (1.0 by default)
  73940. * @returns a new Color4 object
  73941. */
  73942. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73943. /**
  73944. * Creates a new Color4 from the starting index element of the given array
  73945. * @param array defines the source array to read from
  73946. * @param offset defines the offset in the source array
  73947. * @returns a new Color4 object
  73948. */
  73949. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73950. /**
  73951. * Creates a new Color3 from integer values (< 256)
  73952. * @param r defines the red component to read from (value between 0 and 255)
  73953. * @param g defines the green component to read from (value between 0 and 255)
  73954. * @param b defines the blue component to read from (value between 0 and 255)
  73955. * @param a defines the alpha component to read from (value between 0 and 255)
  73956. * @returns a new Color3 object
  73957. */
  73958. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73959. /**
  73960. * Check the content of a given array and convert it to an array containing RGBA data
  73961. * If the original array was already containing count * 4 values then it is returned directly
  73962. * @param colors defines the array to check
  73963. * @param count defines the number of RGBA data to expect
  73964. * @returns an array containing count * 4 values (RGBA)
  73965. */
  73966. static CheckColors4(colors: number[], count: number): number[];
  73967. }
  73968. /**
  73969. * @hidden
  73970. */
  73971. export class TmpColors {
  73972. static Color3: Color3[];
  73973. static Color4: Color4[];
  73974. }
  73975. }
  73976. declare module BABYLON {
  73977. /**
  73978. * Defines an interface which represents an animation key frame
  73979. */
  73980. export interface IAnimationKey {
  73981. /**
  73982. * Frame of the key frame
  73983. */
  73984. frame: number;
  73985. /**
  73986. * Value at the specifies key frame
  73987. */
  73988. value: any;
  73989. /**
  73990. * The input tangent for the cubic hermite spline
  73991. */
  73992. inTangent?: any;
  73993. /**
  73994. * The output tangent for the cubic hermite spline
  73995. */
  73996. outTangent?: any;
  73997. /**
  73998. * The animation interpolation type
  73999. */
  74000. interpolation?: AnimationKeyInterpolation;
  74001. }
  74002. /**
  74003. * Enum for the animation key frame interpolation type
  74004. */
  74005. export enum AnimationKeyInterpolation {
  74006. /**
  74007. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  74008. */
  74009. STEP = 1
  74010. }
  74011. }
  74012. declare module BABYLON {
  74013. /**
  74014. * Represents the range of an animation
  74015. */
  74016. export class AnimationRange {
  74017. /**The name of the animation range**/
  74018. name: string;
  74019. /**The starting frame of the animation */
  74020. from: number;
  74021. /**The ending frame of the animation*/
  74022. to: number;
  74023. /**
  74024. * Initializes the range of an animation
  74025. * @param name The name of the animation range
  74026. * @param from The starting frame of the animation
  74027. * @param to The ending frame of the animation
  74028. */
  74029. constructor(
  74030. /**The name of the animation range**/
  74031. name: string,
  74032. /**The starting frame of the animation */
  74033. from: number,
  74034. /**The ending frame of the animation*/
  74035. to: number);
  74036. /**
  74037. * Makes a copy of the animation range
  74038. * @returns A copy of the animation range
  74039. */
  74040. clone(): AnimationRange;
  74041. }
  74042. }
  74043. declare module BABYLON {
  74044. /**
  74045. * Composed of a frame, and an action function
  74046. */
  74047. export class AnimationEvent {
  74048. /** The frame for which the event is triggered **/
  74049. frame: number;
  74050. /** The event to perform when triggered **/
  74051. action: (currentFrame: number) => void;
  74052. /** Specifies if the event should be triggered only once**/
  74053. onlyOnce?: boolean | undefined;
  74054. /**
  74055. * Specifies if the animation event is done
  74056. */
  74057. isDone: boolean;
  74058. /**
  74059. * Initializes the animation event
  74060. * @param frame The frame for which the event is triggered
  74061. * @param action The event to perform when triggered
  74062. * @param onlyOnce Specifies if the event should be triggered only once
  74063. */
  74064. constructor(
  74065. /** The frame for which the event is triggered **/
  74066. frame: number,
  74067. /** The event to perform when triggered **/
  74068. action: (currentFrame: number) => void,
  74069. /** Specifies if the event should be triggered only once**/
  74070. onlyOnce?: boolean | undefined);
  74071. /** @hidden */
  74072. _clone(): AnimationEvent;
  74073. }
  74074. }
  74075. declare module BABYLON {
  74076. /**
  74077. * Interface used to define a behavior
  74078. */
  74079. export interface Behavior<T> {
  74080. /** gets or sets behavior's name */
  74081. name: string;
  74082. /**
  74083. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74084. */
  74085. init(): void;
  74086. /**
  74087. * Called when the behavior is attached to a target
  74088. * @param target defines the target where the behavior is attached to
  74089. */
  74090. attach(target: T): void;
  74091. /**
  74092. * Called when the behavior is detached from its target
  74093. */
  74094. detach(): void;
  74095. }
  74096. /**
  74097. * Interface implemented by classes supporting behaviors
  74098. */
  74099. export interface IBehaviorAware<T> {
  74100. /**
  74101. * Attach a behavior
  74102. * @param behavior defines the behavior to attach
  74103. * @returns the current host
  74104. */
  74105. addBehavior(behavior: Behavior<T>): T;
  74106. /**
  74107. * Remove a behavior from the current object
  74108. * @param behavior defines the behavior to detach
  74109. * @returns the current host
  74110. */
  74111. removeBehavior(behavior: Behavior<T>): T;
  74112. /**
  74113. * Gets a behavior using its name to search
  74114. * @param name defines the name to search
  74115. * @returns the behavior or null if not found
  74116. */
  74117. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74118. }
  74119. }
  74120. declare module BABYLON {
  74121. /**
  74122. * Defines an array and its length.
  74123. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74124. */
  74125. export interface ISmartArrayLike<T> {
  74126. /**
  74127. * The data of the array.
  74128. */
  74129. data: Array<T>;
  74130. /**
  74131. * The active length of the array.
  74132. */
  74133. length: number;
  74134. }
  74135. /**
  74136. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74137. */
  74138. export class SmartArray<T> implements ISmartArrayLike<T> {
  74139. /**
  74140. * The full set of data from the array.
  74141. */
  74142. data: Array<T>;
  74143. /**
  74144. * The active length of the array.
  74145. */
  74146. length: number;
  74147. protected _id: number;
  74148. /**
  74149. * Instantiates a Smart Array.
  74150. * @param capacity defines the default capacity of the array.
  74151. */
  74152. constructor(capacity: number);
  74153. /**
  74154. * Pushes a value at the end of the active data.
  74155. * @param value defines the object to push in the array.
  74156. */
  74157. push(value: T): void;
  74158. /**
  74159. * Iterates over the active data and apply the lambda to them.
  74160. * @param func defines the action to apply on each value.
  74161. */
  74162. forEach(func: (content: T) => void): void;
  74163. /**
  74164. * Sorts the full sets of data.
  74165. * @param compareFn defines the comparison function to apply.
  74166. */
  74167. sort(compareFn: (a: T, b: T) => number): void;
  74168. /**
  74169. * Resets the active data to an empty array.
  74170. */
  74171. reset(): void;
  74172. /**
  74173. * Releases all the data from the array as well as the array.
  74174. */
  74175. dispose(): void;
  74176. /**
  74177. * Concats the active data with a given array.
  74178. * @param array defines the data to concatenate with.
  74179. */
  74180. concat(array: any): void;
  74181. /**
  74182. * Returns the position of a value in the active data.
  74183. * @param value defines the value to find the index for
  74184. * @returns the index if found in the active data otherwise -1
  74185. */
  74186. indexOf(value: T): number;
  74187. /**
  74188. * Returns whether an element is part of the active data.
  74189. * @param value defines the value to look for
  74190. * @returns true if found in the active data otherwise false
  74191. */
  74192. contains(value: T): boolean;
  74193. private static _GlobalId;
  74194. }
  74195. /**
  74196. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74197. * The data in this array can only be present once
  74198. */
  74199. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  74200. private _duplicateId;
  74201. /**
  74202. * Pushes a value at the end of the active data.
  74203. * THIS DOES NOT PREVENT DUPPLICATE DATA
  74204. * @param value defines the object to push in the array.
  74205. */
  74206. push(value: T): void;
  74207. /**
  74208. * Pushes a value at the end of the active data.
  74209. * If the data is already present, it won t be added again
  74210. * @param value defines the object to push in the array.
  74211. * @returns true if added false if it was already present
  74212. */
  74213. pushNoDuplicate(value: T): boolean;
  74214. /**
  74215. * Resets the active data to an empty array.
  74216. */
  74217. reset(): void;
  74218. /**
  74219. * Concats the active data with a given array.
  74220. * This ensures no dupplicate will be present in the result.
  74221. * @param array defines the data to concatenate with.
  74222. */
  74223. concatWithNoDuplicate(array: any): void;
  74224. }
  74225. }
  74226. declare module BABYLON {
  74227. /**
  74228. * @ignore
  74229. * This is a list of all the different input types that are available in the application.
  74230. * Fo instance: ArcRotateCameraGamepadInput...
  74231. */
  74232. export var CameraInputTypes: {};
  74233. /**
  74234. * This is the contract to implement in order to create a new input class.
  74235. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  74236. */
  74237. export interface ICameraInput<TCamera extends Camera> {
  74238. /**
  74239. * Defines the camera the input is attached to.
  74240. */
  74241. camera: Nullable<TCamera>;
  74242. /**
  74243. * Gets the class name of the current intput.
  74244. * @returns the class name
  74245. */
  74246. getClassName(): string;
  74247. /**
  74248. * Get the friendly name associated with the input class.
  74249. * @returns the input friendly name
  74250. */
  74251. getSimpleName(): string;
  74252. /**
  74253. * Attach the input controls to a specific dom element to get the input from.
  74254. * @param element Defines the element the controls should be listened from
  74255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74256. */
  74257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74258. /**
  74259. * Detach the current controls from the specified dom element.
  74260. * @param element Defines the element to stop listening the inputs from
  74261. */
  74262. detachControl(element: Nullable<HTMLElement>): void;
  74263. /**
  74264. * Update the current camera state depending on the inputs that have been used this frame.
  74265. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74266. */
  74267. checkInputs?: () => void;
  74268. }
  74269. /**
  74270. * Represents a map of input types to input instance or input index to input instance.
  74271. */
  74272. export interface CameraInputsMap<TCamera extends Camera> {
  74273. /**
  74274. * Accessor to the input by input type.
  74275. */
  74276. [name: string]: ICameraInput<TCamera>;
  74277. /**
  74278. * Accessor to the input by input index.
  74279. */
  74280. [idx: number]: ICameraInput<TCamera>;
  74281. }
  74282. /**
  74283. * This represents the input manager used within a camera.
  74284. * It helps dealing with all the different kind of input attached to a camera.
  74285. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74286. */
  74287. export class CameraInputsManager<TCamera extends Camera> {
  74288. /**
  74289. * Defines the list of inputs attahed to the camera.
  74290. */
  74291. attached: CameraInputsMap<TCamera>;
  74292. /**
  74293. * Defines the dom element the camera is collecting inputs from.
  74294. * This is null if the controls have not been attached.
  74295. */
  74296. attachedElement: Nullable<HTMLElement>;
  74297. /**
  74298. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74299. */
  74300. noPreventDefault: boolean;
  74301. /**
  74302. * Defined the camera the input manager belongs to.
  74303. */
  74304. camera: TCamera;
  74305. /**
  74306. * Update the current camera state depending on the inputs that have been used this frame.
  74307. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74308. */
  74309. checkInputs: () => void;
  74310. /**
  74311. * Instantiate a new Camera Input Manager.
  74312. * @param camera Defines the camera the input manager blongs to
  74313. */
  74314. constructor(camera: TCamera);
  74315. /**
  74316. * Add an input method to a camera
  74317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74318. * @param input camera input method
  74319. */
  74320. add(input: ICameraInput<TCamera>): void;
  74321. /**
  74322. * Remove a specific input method from a camera
  74323. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  74324. * @param inputToRemove camera input method
  74325. */
  74326. remove(inputToRemove: ICameraInput<TCamera>): void;
  74327. /**
  74328. * Remove a specific input type from a camera
  74329. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  74330. * @param inputType the type of the input to remove
  74331. */
  74332. removeByType(inputType: string): void;
  74333. private _addCheckInputs;
  74334. /**
  74335. * Attach the input controls to the currently attached dom element to listen the events from.
  74336. * @param input Defines the input to attach
  74337. */
  74338. attachInput(input: ICameraInput<TCamera>): void;
  74339. /**
  74340. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  74341. * @param element Defines the dom element to collect the events from
  74342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74343. */
  74344. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  74345. /**
  74346. * Detach the current manager inputs controls from a specific dom element.
  74347. * @param element Defines the dom element to collect the events from
  74348. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  74349. */
  74350. detachElement(element: HTMLElement, disconnect?: boolean): void;
  74351. /**
  74352. * Rebuild the dynamic inputCheck function from the current list of
  74353. * defined inputs in the manager.
  74354. */
  74355. rebuildInputCheck(): void;
  74356. /**
  74357. * Remove all attached input methods from a camera
  74358. */
  74359. clear(): void;
  74360. /**
  74361. * Serialize the current input manager attached to a camera.
  74362. * This ensures than once parsed,
  74363. * the input associated to the camera will be identical to the current ones
  74364. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  74365. */
  74366. serialize(serializedCamera: any): void;
  74367. /**
  74368. * Parses an input manager serialized JSON to restore the previous list of inputs
  74369. * and states associated to a camera.
  74370. * @param parsedCamera Defines the JSON to parse
  74371. */
  74372. parse(parsedCamera: any): void;
  74373. }
  74374. }
  74375. declare module BABYLON {
  74376. /**
  74377. * Class used to store data that will be store in GPU memory
  74378. */
  74379. export class Buffer {
  74380. private _engine;
  74381. private _buffer;
  74382. /** @hidden */
  74383. _data: Nullable<DataArray>;
  74384. private _updatable;
  74385. private _instanced;
  74386. private _divisor;
  74387. /**
  74388. * Gets the byte stride.
  74389. */
  74390. readonly byteStride: number;
  74391. /**
  74392. * Constructor
  74393. * @param engine the engine
  74394. * @param data the data to use for this buffer
  74395. * @param updatable whether the data is updatable
  74396. * @param stride the stride (optional)
  74397. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74398. * @param instanced whether the buffer is instanced (optional)
  74399. * @param useBytes set to true if the stride in in bytes (optional)
  74400. * @param divisor sets an optional divisor for instances (1 by default)
  74401. */
  74402. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74403. /**
  74404. * Create a new VertexBuffer based on the current buffer
  74405. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74406. * @param offset defines offset in the buffer (0 by default)
  74407. * @param size defines the size in floats of attributes (position is 3 for instance)
  74408. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74409. * @param instanced defines if the vertex buffer contains indexed data
  74410. * @param useBytes defines if the offset and stride are in bytes *
  74411. * @param divisor sets an optional divisor for instances (1 by default)
  74412. * @returns the new vertex buffer
  74413. */
  74414. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74415. /**
  74416. * Gets a boolean indicating if the Buffer is updatable?
  74417. * @returns true if the buffer is updatable
  74418. */
  74419. isUpdatable(): boolean;
  74420. /**
  74421. * Gets current buffer's data
  74422. * @returns a DataArray or null
  74423. */
  74424. getData(): Nullable<DataArray>;
  74425. /**
  74426. * Gets underlying native buffer
  74427. * @returns underlying native buffer
  74428. */
  74429. getBuffer(): Nullable<DataBuffer>;
  74430. /**
  74431. * Gets the stride in float32 units (i.e. byte stride / 4).
  74432. * May not be an integer if the byte stride is not divisible by 4.
  74433. * DEPRECATED. Use byteStride instead.
  74434. * @returns the stride in float32 units
  74435. */
  74436. getStrideSize(): number;
  74437. /**
  74438. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74439. * @param data defines the data to store
  74440. */
  74441. create(data?: Nullable<DataArray>): void;
  74442. /** @hidden */
  74443. _rebuild(): void;
  74444. /**
  74445. * Update current buffer data
  74446. * @param data defines the data to store
  74447. */
  74448. update(data: DataArray): void;
  74449. /**
  74450. * Updates the data directly.
  74451. * @param data the new data
  74452. * @param offset the new offset
  74453. * @param vertexCount the vertex count (optional)
  74454. * @param useBytes set to true if the offset is in bytes
  74455. */
  74456. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74457. /**
  74458. * Release all resources
  74459. */
  74460. dispose(): void;
  74461. }
  74462. /**
  74463. * Specialized buffer used to store vertex data
  74464. */
  74465. export class VertexBuffer {
  74466. /** @hidden */
  74467. _buffer: Buffer;
  74468. private _kind;
  74469. private _size;
  74470. private _ownsBuffer;
  74471. private _instanced;
  74472. private _instanceDivisor;
  74473. /**
  74474. * The byte type.
  74475. */
  74476. static readonly BYTE: number;
  74477. /**
  74478. * The unsigned byte type.
  74479. */
  74480. static readonly UNSIGNED_BYTE: number;
  74481. /**
  74482. * The short type.
  74483. */
  74484. static readonly SHORT: number;
  74485. /**
  74486. * The unsigned short type.
  74487. */
  74488. static readonly UNSIGNED_SHORT: number;
  74489. /**
  74490. * The integer type.
  74491. */
  74492. static readonly INT: number;
  74493. /**
  74494. * The unsigned integer type.
  74495. */
  74496. static readonly UNSIGNED_INT: number;
  74497. /**
  74498. * The float type.
  74499. */
  74500. static readonly FLOAT: number;
  74501. /**
  74502. * Gets or sets the instance divisor when in instanced mode
  74503. */
  74504. instanceDivisor: number;
  74505. /**
  74506. * Gets the byte stride.
  74507. */
  74508. readonly byteStride: number;
  74509. /**
  74510. * Gets the byte offset.
  74511. */
  74512. readonly byteOffset: number;
  74513. /**
  74514. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74515. */
  74516. readonly normalized: boolean;
  74517. /**
  74518. * Gets the data type of each component in the array.
  74519. */
  74520. readonly type: number;
  74521. /**
  74522. * Constructor
  74523. * @param engine the engine
  74524. * @param data the data to use for this vertex buffer
  74525. * @param kind the vertex buffer kind
  74526. * @param updatable whether the data is updatable
  74527. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74528. * @param stride the stride (optional)
  74529. * @param instanced whether the buffer is instanced (optional)
  74530. * @param offset the offset of the data (optional)
  74531. * @param size the number of components (optional)
  74532. * @param type the type of the component (optional)
  74533. * @param normalized whether the data contains normalized data (optional)
  74534. * @param useBytes set to true if stride and offset are in bytes (optional)
  74535. * @param divisor defines the instance divisor to use (1 by default)
  74536. */
  74537. 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);
  74538. /** @hidden */
  74539. _rebuild(): void;
  74540. /**
  74541. * Returns the kind of the VertexBuffer (string)
  74542. * @returns a string
  74543. */
  74544. getKind(): string;
  74545. /**
  74546. * Gets a boolean indicating if the VertexBuffer is updatable?
  74547. * @returns true if the buffer is updatable
  74548. */
  74549. isUpdatable(): boolean;
  74550. /**
  74551. * Gets current buffer's data
  74552. * @returns a DataArray or null
  74553. */
  74554. getData(): Nullable<DataArray>;
  74555. /**
  74556. * Gets underlying native buffer
  74557. * @returns underlying native buffer
  74558. */
  74559. getBuffer(): Nullable<DataBuffer>;
  74560. /**
  74561. * Gets the stride in float32 units (i.e. byte stride / 4).
  74562. * May not be an integer if the byte stride is not divisible by 4.
  74563. * DEPRECATED. Use byteStride instead.
  74564. * @returns the stride in float32 units
  74565. */
  74566. getStrideSize(): number;
  74567. /**
  74568. * Returns the offset as a multiple of the type byte length.
  74569. * DEPRECATED. Use byteOffset instead.
  74570. * @returns the offset in bytes
  74571. */
  74572. getOffset(): number;
  74573. /**
  74574. * Returns the number of components per vertex attribute (integer)
  74575. * @returns the size in float
  74576. */
  74577. getSize(): number;
  74578. /**
  74579. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74580. * @returns true if this buffer is instanced
  74581. */
  74582. getIsInstanced(): boolean;
  74583. /**
  74584. * Returns the instancing divisor, zero for non-instanced (integer).
  74585. * @returns a number
  74586. */
  74587. getInstanceDivisor(): number;
  74588. /**
  74589. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74590. * @param data defines the data to store
  74591. */
  74592. create(data?: DataArray): void;
  74593. /**
  74594. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74595. * This function will create a new buffer if the current one is not updatable
  74596. * @param data defines the data to store
  74597. */
  74598. update(data: DataArray): void;
  74599. /**
  74600. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74601. * Returns the directly updated WebGLBuffer.
  74602. * @param data the new data
  74603. * @param offset the new offset
  74604. * @param useBytes set to true if the offset is in bytes
  74605. */
  74606. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74607. /**
  74608. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74609. */
  74610. dispose(): void;
  74611. /**
  74612. * Enumerates each value of this vertex buffer as numbers.
  74613. * @param count the number of values to enumerate
  74614. * @param callback the callback function called for each value
  74615. */
  74616. forEach(count: number, callback: (value: number, index: number) => void): void;
  74617. /**
  74618. * Positions
  74619. */
  74620. static readonly PositionKind: string;
  74621. /**
  74622. * Normals
  74623. */
  74624. static readonly NormalKind: string;
  74625. /**
  74626. * Tangents
  74627. */
  74628. static readonly TangentKind: string;
  74629. /**
  74630. * Texture coordinates
  74631. */
  74632. static readonly UVKind: string;
  74633. /**
  74634. * Texture coordinates 2
  74635. */
  74636. static readonly UV2Kind: string;
  74637. /**
  74638. * Texture coordinates 3
  74639. */
  74640. static readonly UV3Kind: string;
  74641. /**
  74642. * Texture coordinates 4
  74643. */
  74644. static readonly UV4Kind: string;
  74645. /**
  74646. * Texture coordinates 5
  74647. */
  74648. static readonly UV5Kind: string;
  74649. /**
  74650. * Texture coordinates 6
  74651. */
  74652. static readonly UV6Kind: string;
  74653. /**
  74654. * Colors
  74655. */
  74656. static readonly ColorKind: string;
  74657. /**
  74658. * Matrix indices (for bones)
  74659. */
  74660. static readonly MatricesIndicesKind: string;
  74661. /**
  74662. * Matrix weights (for bones)
  74663. */
  74664. static readonly MatricesWeightsKind: string;
  74665. /**
  74666. * Additional matrix indices (for bones)
  74667. */
  74668. static readonly MatricesIndicesExtraKind: string;
  74669. /**
  74670. * Additional matrix weights (for bones)
  74671. */
  74672. static readonly MatricesWeightsExtraKind: string;
  74673. /**
  74674. * Deduces the stride given a kind.
  74675. * @param kind The kind string to deduce
  74676. * @returns The deduced stride
  74677. */
  74678. static DeduceStride(kind: string): number;
  74679. /**
  74680. * Gets the byte length of the given type.
  74681. * @param type the type
  74682. * @returns the number of bytes
  74683. */
  74684. static GetTypeByteLength(type: number): number;
  74685. /**
  74686. * Enumerates each value of the given parameters as numbers.
  74687. * @param data the data to enumerate
  74688. * @param byteOffset the byte offset of the data
  74689. * @param byteStride the byte stride of the data
  74690. * @param componentCount the number of components per element
  74691. * @param componentType the type of the component
  74692. * @param count the number of values to enumerate
  74693. * @param normalized whether the data is normalized
  74694. * @param callback the callback function called for each value
  74695. */
  74696. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74697. private static _GetFloatValue;
  74698. }
  74699. }
  74700. declare module BABYLON {
  74701. /**
  74702. * @hidden
  74703. */
  74704. export class IntersectionInfo {
  74705. bu: Nullable<number>;
  74706. bv: Nullable<number>;
  74707. distance: number;
  74708. faceId: number;
  74709. subMeshId: number;
  74710. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74711. }
  74712. }
  74713. declare module BABYLON {
  74714. /**
  74715. * Represens a plane by the equation ax + by + cz + d = 0
  74716. */
  74717. export class Plane {
  74718. private static _TmpMatrix;
  74719. /**
  74720. * Normal of the plane (a,b,c)
  74721. */
  74722. normal: Vector3;
  74723. /**
  74724. * d component of the plane
  74725. */
  74726. d: number;
  74727. /**
  74728. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74729. * @param a a component of the plane
  74730. * @param b b component of the plane
  74731. * @param c c component of the plane
  74732. * @param d d component of the plane
  74733. */
  74734. constructor(a: number, b: number, c: number, d: number);
  74735. /**
  74736. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74737. */
  74738. asArray(): number[];
  74739. /**
  74740. * @returns a new plane copied from the current Plane.
  74741. */
  74742. clone(): Plane;
  74743. /**
  74744. * @returns the string "Plane".
  74745. */
  74746. getClassName(): string;
  74747. /**
  74748. * @returns the Plane hash code.
  74749. */
  74750. getHashCode(): number;
  74751. /**
  74752. * Normalize the current Plane in place.
  74753. * @returns the updated Plane.
  74754. */
  74755. normalize(): Plane;
  74756. /**
  74757. * Applies a transformation the plane and returns the result
  74758. * @param transformation the transformation matrix to be applied to the plane
  74759. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74760. */
  74761. transform(transformation: DeepImmutable<Matrix>): Plane;
  74762. /**
  74763. * Calcualtte the dot product between the point and the plane normal
  74764. * @param point point to calculate the dot product with
  74765. * @returns the dot product (float) of the point coordinates and the plane normal.
  74766. */
  74767. dotCoordinate(point: DeepImmutable<Vector3>): number;
  74768. /**
  74769. * Updates the current Plane from the plane defined by the three given points.
  74770. * @param point1 one of the points used to contruct the plane
  74771. * @param point2 one of the points used to contruct the plane
  74772. * @param point3 one of the points used to contruct the plane
  74773. * @returns the updated Plane.
  74774. */
  74775. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74776. /**
  74777. * Checks if the plane is facing a given direction
  74778. * @param direction the direction to check if the plane is facing
  74779. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74780. * @returns True is the vector "direction" is the same side than the plane normal.
  74781. */
  74782. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  74783. /**
  74784. * Calculates the distance to a point
  74785. * @param point point to calculate distance to
  74786. * @returns the signed distance (float) from the given point to the Plane.
  74787. */
  74788. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  74789. /**
  74790. * Creates a plane from an array
  74791. * @param array the array to create a plane from
  74792. * @returns a new Plane from the given array.
  74793. */
  74794. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  74795. /**
  74796. * Creates a plane from three points
  74797. * @param point1 point used to create the plane
  74798. * @param point2 point used to create the plane
  74799. * @param point3 point used to create the plane
  74800. * @returns a new Plane defined by the three given points.
  74801. */
  74802. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74803. /**
  74804. * Creates a plane from an origin point and a normal
  74805. * @param origin origin of the plane to be constructed
  74806. * @param normal normal of the plane to be constructed
  74807. * @returns a new Plane the normal vector to this plane at the given origin point.
  74808. * Note : the vector "normal" is updated because normalized.
  74809. */
  74810. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74811. /**
  74812. * Calculates the distance from a plane and a point
  74813. * @param origin origin of the plane to be constructed
  74814. * @param normal normal of the plane to be constructed
  74815. * @param point point to calculate distance to
  74816. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74817. */
  74818. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74819. }
  74820. }
  74821. declare module BABYLON {
  74822. /**
  74823. * Class used to store bounding sphere information
  74824. */
  74825. export class BoundingSphere {
  74826. /**
  74827. * Gets the center of the bounding sphere in local space
  74828. */
  74829. readonly center: Vector3;
  74830. /**
  74831. * Radius of the bounding sphere in local space
  74832. */
  74833. radius: number;
  74834. /**
  74835. * Gets the center of the bounding sphere in world space
  74836. */
  74837. readonly centerWorld: Vector3;
  74838. /**
  74839. * Radius of the bounding sphere in world space
  74840. */
  74841. radiusWorld: number;
  74842. /**
  74843. * Gets the minimum vector in local space
  74844. */
  74845. readonly minimum: Vector3;
  74846. /**
  74847. * Gets the maximum vector in local space
  74848. */
  74849. readonly maximum: Vector3;
  74850. private _worldMatrix;
  74851. private static readonly TmpVector3;
  74852. /**
  74853. * Creates a new bounding sphere
  74854. * @param min defines the minimum vector (in local space)
  74855. * @param max defines the maximum vector (in local space)
  74856. * @param worldMatrix defines the new world matrix
  74857. */
  74858. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74859. /**
  74860. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74861. * @param min defines the new minimum vector (in local space)
  74862. * @param max defines the new maximum vector (in local space)
  74863. * @param worldMatrix defines the new world matrix
  74864. */
  74865. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74866. /**
  74867. * Scale the current bounding sphere by applying a scale factor
  74868. * @param factor defines the scale factor to apply
  74869. * @returns the current bounding box
  74870. */
  74871. scale(factor: number): BoundingSphere;
  74872. /**
  74873. * Gets the world matrix of the bounding box
  74874. * @returns a matrix
  74875. */
  74876. getWorldMatrix(): DeepImmutable<Matrix>;
  74877. /** @hidden */
  74878. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74879. /**
  74880. * Tests if the bounding sphere is intersecting the frustum planes
  74881. * @param frustumPlanes defines the frustum planes to test
  74882. * @returns true if there is an intersection
  74883. */
  74884. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74885. /**
  74886. * Tests if the bounding sphere center is in between the frustum planes.
  74887. * Used for optimistic fast inclusion.
  74888. * @param frustumPlanes defines the frustum planes to test
  74889. * @returns true if the sphere center is in between the frustum planes
  74890. */
  74891. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74892. /**
  74893. * Tests if a point is inside the bounding sphere
  74894. * @param point defines the point to test
  74895. * @returns true if the point is inside the bounding sphere
  74896. */
  74897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74898. /**
  74899. * Checks if two sphere intersct
  74900. * @param sphere0 sphere 0
  74901. * @param sphere1 sphere 1
  74902. * @returns true if the speres intersect
  74903. */
  74904. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74905. }
  74906. }
  74907. declare module BABYLON {
  74908. /**
  74909. * Class used to store bounding box information
  74910. */
  74911. export class BoundingBox implements ICullable {
  74912. /**
  74913. * Gets the 8 vectors representing the bounding box in local space
  74914. */
  74915. readonly vectors: Vector3[];
  74916. /**
  74917. * Gets the center of the bounding box in local space
  74918. */
  74919. readonly center: Vector3;
  74920. /**
  74921. * Gets the center of the bounding box in world space
  74922. */
  74923. readonly centerWorld: Vector3;
  74924. /**
  74925. * Gets the extend size in local space
  74926. */
  74927. readonly extendSize: Vector3;
  74928. /**
  74929. * Gets the extend size in world space
  74930. */
  74931. readonly extendSizeWorld: Vector3;
  74932. /**
  74933. * Gets the OBB (object bounding box) directions
  74934. */
  74935. readonly directions: Vector3[];
  74936. /**
  74937. * Gets the 8 vectors representing the bounding box in world space
  74938. */
  74939. readonly vectorsWorld: Vector3[];
  74940. /**
  74941. * Gets the minimum vector in world space
  74942. */
  74943. readonly minimumWorld: Vector3;
  74944. /**
  74945. * Gets the maximum vector in world space
  74946. */
  74947. readonly maximumWorld: Vector3;
  74948. /**
  74949. * Gets the minimum vector in local space
  74950. */
  74951. readonly minimum: Vector3;
  74952. /**
  74953. * Gets the maximum vector in local space
  74954. */
  74955. readonly maximum: Vector3;
  74956. private _worldMatrix;
  74957. private static readonly TmpVector3;
  74958. /**
  74959. * @hidden
  74960. */
  74961. _tag: number;
  74962. /**
  74963. * Creates a new bounding box
  74964. * @param min defines the minimum vector (in local space)
  74965. * @param max defines the maximum vector (in local space)
  74966. * @param worldMatrix defines the new world matrix
  74967. */
  74968. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74969. /**
  74970. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74971. * @param min defines the new minimum vector (in local space)
  74972. * @param max defines the new maximum vector (in local space)
  74973. * @param worldMatrix defines the new world matrix
  74974. */
  74975. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74976. /**
  74977. * Scale the current bounding box by applying a scale factor
  74978. * @param factor defines the scale factor to apply
  74979. * @returns the current bounding box
  74980. */
  74981. scale(factor: number): BoundingBox;
  74982. /**
  74983. * Gets the world matrix of the bounding box
  74984. * @returns a matrix
  74985. */
  74986. getWorldMatrix(): DeepImmutable<Matrix>;
  74987. /** @hidden */
  74988. _update(world: DeepImmutable<Matrix>): void;
  74989. /**
  74990. * Tests if the bounding box is intersecting the frustum planes
  74991. * @param frustumPlanes defines the frustum planes to test
  74992. * @returns true if there is an intersection
  74993. */
  74994. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74995. /**
  74996. * Tests if the bounding box is entirely inside the frustum planes
  74997. * @param frustumPlanes defines the frustum planes to test
  74998. * @returns true if there is an inclusion
  74999. */
  75000. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75001. /**
  75002. * Tests if a point is inside the bounding box
  75003. * @param point defines the point to test
  75004. * @returns true if the point is inside the bounding box
  75005. */
  75006. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75007. /**
  75008. * Tests if the bounding box intersects with a bounding sphere
  75009. * @param sphere defines the sphere to test
  75010. * @returns true if there is an intersection
  75011. */
  75012. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  75013. /**
  75014. * Tests if the bounding box intersects with a box defined by a min and max vectors
  75015. * @param min defines the min vector to use
  75016. * @param max defines the max vector to use
  75017. * @returns true if there is an intersection
  75018. */
  75019. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  75020. /**
  75021. * Tests if two bounding boxes are intersections
  75022. * @param box0 defines the first box to test
  75023. * @param box1 defines the second box to test
  75024. * @returns true if there is an intersection
  75025. */
  75026. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  75027. /**
  75028. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  75029. * @param minPoint defines the minimum vector of the bounding box
  75030. * @param maxPoint defines the maximum vector of the bounding box
  75031. * @param sphereCenter defines the sphere center
  75032. * @param sphereRadius defines the sphere radius
  75033. * @returns true if there is an intersection
  75034. */
  75035. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  75036. /**
  75037. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75038. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75039. * @param frustumPlanes defines the frustum planes to test
  75040. * @return true if there is an inclusion
  75041. */
  75042. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75043. /**
  75044. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75045. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75046. * @param frustumPlanes defines the frustum planes to test
  75047. * @return true if there is an intersection
  75048. */
  75049. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75050. }
  75051. }
  75052. declare module BABYLON {
  75053. /** @hidden */
  75054. export class Collider {
  75055. /** Define if a collision was found */
  75056. collisionFound: boolean;
  75057. /**
  75058. * Define last intersection point in local space
  75059. */
  75060. intersectionPoint: Vector3;
  75061. /**
  75062. * Define last collided mesh
  75063. */
  75064. collidedMesh: Nullable<AbstractMesh>;
  75065. private _collisionPoint;
  75066. private _planeIntersectionPoint;
  75067. private _tempVector;
  75068. private _tempVector2;
  75069. private _tempVector3;
  75070. private _tempVector4;
  75071. private _edge;
  75072. private _baseToVertex;
  75073. private _destinationPoint;
  75074. private _slidePlaneNormal;
  75075. private _displacementVector;
  75076. /** @hidden */
  75077. _radius: Vector3;
  75078. /** @hidden */
  75079. _retry: number;
  75080. private _velocity;
  75081. private _basePoint;
  75082. private _epsilon;
  75083. /** @hidden */
  75084. _velocityWorldLength: number;
  75085. /** @hidden */
  75086. _basePointWorld: Vector3;
  75087. private _velocityWorld;
  75088. private _normalizedVelocity;
  75089. /** @hidden */
  75090. _initialVelocity: Vector3;
  75091. /** @hidden */
  75092. _initialPosition: Vector3;
  75093. private _nearestDistance;
  75094. private _collisionMask;
  75095. collisionMask: number;
  75096. /**
  75097. * Gets the plane normal used to compute the sliding response (in local space)
  75098. */
  75099. readonly slidePlaneNormal: Vector3;
  75100. /** @hidden */
  75101. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75102. /** @hidden */
  75103. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75104. /** @hidden */
  75105. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75106. /** @hidden */
  75107. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75108. /** @hidden */
  75109. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75110. /** @hidden */
  75111. _getResponse(pos: Vector3, vel: Vector3): void;
  75112. }
  75113. }
  75114. declare module BABYLON {
  75115. /**
  75116. * Interface for cullable objects
  75117. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75118. */
  75119. export interface ICullable {
  75120. /**
  75121. * Checks if the object or part of the object is in the frustum
  75122. * @param frustumPlanes Camera near/planes
  75123. * @returns true if the object is in frustum otherwise false
  75124. */
  75125. isInFrustum(frustumPlanes: Plane[]): boolean;
  75126. /**
  75127. * Checks if a cullable object (mesh...) is in the camera frustum
  75128. * Unlike isInFrustum this cheks the full bounding box
  75129. * @param frustumPlanes Camera near/planes
  75130. * @returns true if the object is in frustum otherwise false
  75131. */
  75132. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75133. }
  75134. /**
  75135. * Info for a bounding data of a mesh
  75136. */
  75137. export class BoundingInfo implements ICullable {
  75138. /**
  75139. * Bounding box for the mesh
  75140. */
  75141. readonly boundingBox: BoundingBox;
  75142. /**
  75143. * Bounding sphere for the mesh
  75144. */
  75145. readonly boundingSphere: BoundingSphere;
  75146. private _isLocked;
  75147. private static readonly TmpVector3;
  75148. /**
  75149. * Constructs bounding info
  75150. * @param minimum min vector of the bounding box/sphere
  75151. * @param maximum max vector of the bounding box/sphere
  75152. * @param worldMatrix defines the new world matrix
  75153. */
  75154. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75155. /**
  75156. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75157. * @param min defines the new minimum vector (in local space)
  75158. * @param max defines the new maximum vector (in local space)
  75159. * @param worldMatrix defines the new world matrix
  75160. */
  75161. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75162. /**
  75163. * min vector of the bounding box/sphere
  75164. */
  75165. readonly minimum: Vector3;
  75166. /**
  75167. * max vector of the bounding box/sphere
  75168. */
  75169. readonly maximum: Vector3;
  75170. /**
  75171. * If the info is locked and won't be updated to avoid perf overhead
  75172. */
  75173. isLocked: boolean;
  75174. /**
  75175. * Updates the bounding sphere and box
  75176. * @param world world matrix to be used to update
  75177. */
  75178. update(world: DeepImmutable<Matrix>): void;
  75179. /**
  75180. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75181. * @param center New center of the bounding info
  75182. * @param extend New extend of the bounding info
  75183. * @returns the current bounding info
  75184. */
  75185. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75186. /**
  75187. * Scale the current bounding info by applying a scale factor
  75188. * @param factor defines the scale factor to apply
  75189. * @returns the current bounding info
  75190. */
  75191. scale(factor: number): BoundingInfo;
  75192. /**
  75193. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75194. * @param frustumPlanes defines the frustum to test
  75195. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  75196. * @returns true if the bounding info is in the frustum planes
  75197. */
  75198. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  75199. /**
  75200. * Gets the world distance between the min and max points of the bounding box
  75201. */
  75202. readonly diagonalLength: number;
  75203. /**
  75204. * Checks if a cullable object (mesh...) is in the camera frustum
  75205. * Unlike isInFrustum this cheks the full bounding box
  75206. * @param frustumPlanes Camera near/planes
  75207. * @returns true if the object is in frustum otherwise false
  75208. */
  75209. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75210. /** @hidden */
  75211. _checkCollision(collider: Collider): boolean;
  75212. /**
  75213. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  75214. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75215. * @param point the point to check intersection with
  75216. * @returns if the point intersects
  75217. */
  75218. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75219. /**
  75220. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  75221. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75222. * @param boundingInfo the bounding info to check intersection with
  75223. * @param precise if the intersection should be done using OBB
  75224. * @returns if the bounding info intersects
  75225. */
  75226. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75227. }
  75228. }
  75229. declare module BABYLON {
  75230. /**
  75231. * Extracts minimum and maximum values from a list of indexed positions
  75232. * @param positions defines the positions to use
  75233. * @param indices defines the indices to the positions
  75234. * @param indexStart defines the start index
  75235. * @param indexCount defines the end index
  75236. * @param bias defines bias value to add to the result
  75237. * @return minimum and maximum values
  75238. */
  75239. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  75240. minimum: Vector3;
  75241. maximum: Vector3;
  75242. };
  75243. /**
  75244. * Extracts minimum and maximum values from a list of positions
  75245. * @param positions defines the positions to use
  75246. * @param start defines the start index in the positions array
  75247. * @param count defines the number of positions to handle
  75248. * @param bias defines bias value to add to the result
  75249. * @param stride defines the stride size to use (distance between two positions in the positions array)
  75250. * @return minimum and maximum values
  75251. */
  75252. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75253. minimum: Vector3;
  75254. maximum: Vector3;
  75255. };
  75256. }
  75257. declare module BABYLON {
  75258. /** @hidden */
  75259. export class WebGLDataBuffer extends DataBuffer {
  75260. private _buffer;
  75261. constructor(resource: WebGLBuffer);
  75262. readonly underlyingResource: any;
  75263. }
  75264. }
  75265. declare module BABYLON {
  75266. /** @hidden */
  75267. export class WebGLPipelineContext implements IPipelineContext {
  75268. engine: ThinEngine;
  75269. program: Nullable<WebGLProgram>;
  75270. context?: WebGLRenderingContext;
  75271. vertexShader?: WebGLShader;
  75272. fragmentShader?: WebGLShader;
  75273. isParallelCompiled: boolean;
  75274. onCompiled?: () => void;
  75275. transformFeedback?: WebGLTransformFeedback | null;
  75276. readonly isAsync: boolean;
  75277. readonly isReady: boolean;
  75278. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75279. }
  75280. }
  75281. declare module BABYLON {
  75282. interface ThinEngine {
  75283. /**
  75284. * Create an uniform buffer
  75285. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75286. * @param elements defines the content of the uniform buffer
  75287. * @returns the webGL uniform buffer
  75288. */
  75289. createUniformBuffer(elements: FloatArray): DataBuffer;
  75290. /**
  75291. * Create a dynamic uniform buffer
  75292. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75293. * @param elements defines the content of the uniform buffer
  75294. * @returns the webGL uniform buffer
  75295. */
  75296. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  75297. /**
  75298. * Update an existing uniform buffer
  75299. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75300. * @param uniformBuffer defines the target uniform buffer
  75301. * @param elements defines the content to update
  75302. * @param offset defines the offset in the uniform buffer where update should start
  75303. * @param count defines the size of the data to update
  75304. */
  75305. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  75306. /**
  75307. * Bind an uniform buffer to the current webGL context
  75308. * @param buffer defines the buffer to bind
  75309. */
  75310. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  75311. /**
  75312. * Bind a buffer to the current webGL context at a given location
  75313. * @param buffer defines the buffer to bind
  75314. * @param location defines the index where to bind the buffer
  75315. */
  75316. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  75317. /**
  75318. * Bind a specific block at a given index in a specific shader program
  75319. * @param pipelineContext defines the pipeline context to use
  75320. * @param blockName defines the block name
  75321. * @param index defines the index where to bind the block
  75322. */
  75323. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  75324. }
  75325. }
  75326. declare module BABYLON {
  75327. /**
  75328. * Uniform buffer objects.
  75329. *
  75330. * Handles blocks of uniform on the GPU.
  75331. *
  75332. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75333. *
  75334. * For more information, please refer to :
  75335. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75336. */
  75337. export class UniformBuffer {
  75338. private _engine;
  75339. private _buffer;
  75340. private _data;
  75341. private _bufferData;
  75342. private _dynamic?;
  75343. private _uniformLocations;
  75344. private _uniformSizes;
  75345. private _uniformLocationPointer;
  75346. private _needSync;
  75347. private _noUBO;
  75348. private _currentEffect;
  75349. /** @hidden */
  75350. _alreadyBound: boolean;
  75351. private static _MAX_UNIFORM_SIZE;
  75352. private static _tempBuffer;
  75353. /**
  75354. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  75355. * This is dynamic to allow compat with webgl 1 and 2.
  75356. * You will need to pass the name of the uniform as well as the value.
  75357. */
  75358. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  75359. /**
  75360. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  75361. * This is dynamic to allow compat with webgl 1 and 2.
  75362. * You will need to pass the name of the uniform as well as the value.
  75363. */
  75364. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  75365. /**
  75366. * Lambda to Update a single float in a uniform buffer.
  75367. * This is dynamic to allow compat with webgl 1 and 2.
  75368. * You will need to pass the name of the uniform as well as the value.
  75369. */
  75370. updateFloat: (name: string, x: number) => void;
  75371. /**
  75372. * Lambda to Update a vec2 of float in a uniform buffer.
  75373. * This is dynamic to allow compat with webgl 1 and 2.
  75374. * You will need to pass the name of the uniform as well as the value.
  75375. */
  75376. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75377. /**
  75378. * Lambda to Update a vec3 of float in a uniform buffer.
  75379. * This is dynamic to allow compat with webgl 1 and 2.
  75380. * You will need to pass the name of the uniform as well as the value.
  75381. */
  75382. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75383. /**
  75384. * Lambda to Update a vec4 of float in a uniform buffer.
  75385. * This is dynamic to allow compat with webgl 1 and 2.
  75386. * You will need to pass the name of the uniform as well as the value.
  75387. */
  75388. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75389. /**
  75390. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  75391. * This is dynamic to allow compat with webgl 1 and 2.
  75392. * You will need to pass the name of the uniform as well as the value.
  75393. */
  75394. updateMatrix: (name: string, mat: Matrix) => void;
  75395. /**
  75396. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75397. * This is dynamic to allow compat with webgl 1 and 2.
  75398. * You will need to pass the name of the uniform as well as the value.
  75399. */
  75400. updateVector3: (name: string, vector: Vector3) => void;
  75401. /**
  75402. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75403. * This is dynamic to allow compat with webgl 1 and 2.
  75404. * You will need to pass the name of the uniform as well as the value.
  75405. */
  75406. updateVector4: (name: string, vector: Vector4) => void;
  75407. /**
  75408. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75409. * This is dynamic to allow compat with webgl 1 and 2.
  75410. * You will need to pass the name of the uniform as well as the value.
  75411. */
  75412. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75413. /**
  75414. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75415. * This is dynamic to allow compat with webgl 1 and 2.
  75416. * You will need to pass the name of the uniform as well as the value.
  75417. */
  75418. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75419. /**
  75420. * Instantiates a new Uniform buffer objects.
  75421. *
  75422. * Handles blocks of uniform on the GPU.
  75423. *
  75424. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75425. *
  75426. * For more information, please refer to :
  75427. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75428. * @param engine Define the engine the buffer is associated with
  75429. * @param data Define the data contained in the buffer
  75430. * @param dynamic Define if the buffer is updatable
  75431. */
  75432. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75433. /**
  75434. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75435. * or just falling back on setUniformXXX calls.
  75436. */
  75437. readonly useUbo: boolean;
  75438. /**
  75439. * Indicates if the WebGL underlying uniform buffer is in sync
  75440. * with the javascript cache data.
  75441. */
  75442. readonly isSync: boolean;
  75443. /**
  75444. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75445. * Also, a dynamic UniformBuffer will disable cache verification and always
  75446. * update the underlying WebGL uniform buffer to the GPU.
  75447. * @returns if Dynamic, otherwise false
  75448. */
  75449. isDynamic(): boolean;
  75450. /**
  75451. * The data cache on JS side.
  75452. * @returns the underlying data as a float array
  75453. */
  75454. getData(): Float32Array;
  75455. /**
  75456. * The underlying WebGL Uniform buffer.
  75457. * @returns the webgl buffer
  75458. */
  75459. getBuffer(): Nullable<DataBuffer>;
  75460. /**
  75461. * std140 layout specifies how to align data within an UBO structure.
  75462. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75463. * for specs.
  75464. */
  75465. private _fillAlignment;
  75466. /**
  75467. * Adds an uniform in the buffer.
  75468. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75469. * for the layout to be correct !
  75470. * @param name Name of the uniform, as used in the uniform block in the shader.
  75471. * @param size Data size, or data directly.
  75472. */
  75473. addUniform(name: string, size: number | number[]): void;
  75474. /**
  75475. * Adds a Matrix 4x4 to the uniform buffer.
  75476. * @param name Name of the uniform, as used in the uniform block in the shader.
  75477. * @param mat A 4x4 matrix.
  75478. */
  75479. addMatrix(name: string, mat: Matrix): void;
  75480. /**
  75481. * Adds a vec2 to the uniform buffer.
  75482. * @param name Name of the uniform, as used in the uniform block in the shader.
  75483. * @param x Define the x component value of the vec2
  75484. * @param y Define the y component value of the vec2
  75485. */
  75486. addFloat2(name: string, x: number, y: number): void;
  75487. /**
  75488. * Adds a vec3 to the uniform buffer.
  75489. * @param name Name of the uniform, as used in the uniform block in the shader.
  75490. * @param x Define the x component value of the vec3
  75491. * @param y Define the y component value of the vec3
  75492. * @param z Define the z component value of the vec3
  75493. */
  75494. addFloat3(name: string, x: number, y: number, z: number): void;
  75495. /**
  75496. * Adds a vec3 to the uniform buffer.
  75497. * @param name Name of the uniform, as used in the uniform block in the shader.
  75498. * @param color Define the vec3 from a Color
  75499. */
  75500. addColor3(name: string, color: Color3): void;
  75501. /**
  75502. * Adds a vec4 to the uniform buffer.
  75503. * @param name Name of the uniform, as used in the uniform block in the shader.
  75504. * @param color Define the rgb components from a Color
  75505. * @param alpha Define the a component of the vec4
  75506. */
  75507. addColor4(name: string, color: Color3, alpha: number): void;
  75508. /**
  75509. * Adds a vec3 to the uniform buffer.
  75510. * @param name Name of the uniform, as used in the uniform block in the shader.
  75511. * @param vector Define the vec3 components from a Vector
  75512. */
  75513. addVector3(name: string, vector: Vector3): void;
  75514. /**
  75515. * Adds a Matrix 3x3 to the uniform buffer.
  75516. * @param name Name of the uniform, as used in the uniform block in the shader.
  75517. */
  75518. addMatrix3x3(name: string): void;
  75519. /**
  75520. * Adds a Matrix 2x2 to the uniform buffer.
  75521. * @param name Name of the uniform, as used in the uniform block in the shader.
  75522. */
  75523. addMatrix2x2(name: string): void;
  75524. /**
  75525. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75526. */
  75527. create(): void;
  75528. /** @hidden */
  75529. _rebuild(): void;
  75530. /**
  75531. * Updates the WebGL Uniform Buffer on the GPU.
  75532. * If the `dynamic` flag is set to true, no cache comparison is done.
  75533. * Otherwise, the buffer will be updated only if the cache differs.
  75534. */
  75535. update(): void;
  75536. /**
  75537. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75538. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75539. * @param data Define the flattened data
  75540. * @param size Define the size of the data.
  75541. */
  75542. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75543. private _valueCache;
  75544. private _cacheMatrix;
  75545. private _updateMatrix3x3ForUniform;
  75546. private _updateMatrix3x3ForEffect;
  75547. private _updateMatrix2x2ForEffect;
  75548. private _updateMatrix2x2ForUniform;
  75549. private _updateFloatForEffect;
  75550. private _updateFloatForUniform;
  75551. private _updateFloat2ForEffect;
  75552. private _updateFloat2ForUniform;
  75553. private _updateFloat3ForEffect;
  75554. private _updateFloat3ForUniform;
  75555. private _updateFloat4ForEffect;
  75556. private _updateFloat4ForUniform;
  75557. private _updateMatrixForEffect;
  75558. private _updateMatrixForUniform;
  75559. private _updateVector3ForEffect;
  75560. private _updateVector3ForUniform;
  75561. private _updateVector4ForEffect;
  75562. private _updateVector4ForUniform;
  75563. private _updateColor3ForEffect;
  75564. private _updateColor3ForUniform;
  75565. private _updateColor4ForEffect;
  75566. private _updateColor4ForUniform;
  75567. /**
  75568. * Sets a sampler uniform on the effect.
  75569. * @param name Define the name of the sampler.
  75570. * @param texture Define the texture to set in the sampler
  75571. */
  75572. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75573. /**
  75574. * Directly updates the value of the uniform in the cache AND on the GPU.
  75575. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75576. * @param data Define the flattened data
  75577. */
  75578. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75579. /**
  75580. * Binds this uniform buffer to an effect.
  75581. * @param effect Define the effect to bind the buffer to
  75582. * @param name Name of the uniform block in the shader.
  75583. */
  75584. bindToEffect(effect: Effect, name: string): void;
  75585. /**
  75586. * Disposes the uniform buffer.
  75587. */
  75588. dispose(): void;
  75589. }
  75590. }
  75591. declare module BABYLON {
  75592. /**
  75593. * Enum that determines the text-wrapping mode to use.
  75594. */
  75595. export enum InspectableType {
  75596. /**
  75597. * Checkbox for booleans
  75598. */
  75599. Checkbox = 0,
  75600. /**
  75601. * Sliders for numbers
  75602. */
  75603. Slider = 1,
  75604. /**
  75605. * Vector3
  75606. */
  75607. Vector3 = 2,
  75608. /**
  75609. * Quaternions
  75610. */
  75611. Quaternion = 3,
  75612. /**
  75613. * Color3
  75614. */
  75615. Color3 = 4,
  75616. /**
  75617. * String
  75618. */
  75619. String = 5
  75620. }
  75621. /**
  75622. * Interface used to define custom inspectable properties.
  75623. * This interface is used by the inspector to display custom property grids
  75624. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75625. */
  75626. export interface IInspectable {
  75627. /**
  75628. * Gets the label to display
  75629. */
  75630. label: string;
  75631. /**
  75632. * Gets the name of the property to edit
  75633. */
  75634. propertyName: string;
  75635. /**
  75636. * Gets the type of the editor to use
  75637. */
  75638. type: InspectableType;
  75639. /**
  75640. * Gets the minimum value of the property when using in "slider" mode
  75641. */
  75642. min?: number;
  75643. /**
  75644. * Gets the maximum value of the property when using in "slider" mode
  75645. */
  75646. max?: number;
  75647. /**
  75648. * Gets the setp to use when using in "slider" mode
  75649. */
  75650. step?: number;
  75651. }
  75652. }
  75653. declare module BABYLON {
  75654. /**
  75655. * Class used to provide helper for timing
  75656. */
  75657. export class TimingTools {
  75658. /**
  75659. * Polyfill for setImmediate
  75660. * @param action defines the action to execute after the current execution block
  75661. */
  75662. static SetImmediate(action: () => void): void;
  75663. }
  75664. }
  75665. declare module BABYLON {
  75666. /**
  75667. * Class used to enable instatition of objects by class name
  75668. */
  75669. export class InstantiationTools {
  75670. /**
  75671. * Use this object to register external classes like custom textures or material
  75672. * to allow the laoders to instantiate them
  75673. */
  75674. static RegisteredExternalClasses: {
  75675. [key: string]: Object;
  75676. };
  75677. /**
  75678. * Tries to instantiate a new object from a given class name
  75679. * @param className defines the class name to instantiate
  75680. * @returns the new object or null if the system was not able to do the instantiation
  75681. */
  75682. static Instantiate(className: string): any;
  75683. }
  75684. }
  75685. declare module BABYLON {
  75686. /**
  75687. * Define options used to create a depth texture
  75688. */
  75689. export class DepthTextureCreationOptions {
  75690. /** Specifies whether or not a stencil should be allocated in the texture */
  75691. generateStencil?: boolean;
  75692. /** Specifies whether or not bilinear filtering is enable on the texture */
  75693. bilinearFiltering?: boolean;
  75694. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75695. comparisonFunction?: number;
  75696. /** Specifies if the created texture is a cube texture */
  75697. isCube?: boolean;
  75698. }
  75699. }
  75700. declare module BABYLON {
  75701. interface ThinEngine {
  75702. /**
  75703. * Creates a depth stencil cube texture.
  75704. * This is only available in WebGL 2.
  75705. * @param size The size of face edge in the cube texture.
  75706. * @param options The options defining the cube texture.
  75707. * @returns The cube texture
  75708. */
  75709. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75710. /**
  75711. * Creates a cube texture
  75712. * @param rootUrl defines the url where the files to load is located
  75713. * @param scene defines the current scene
  75714. * @param files defines the list of files to load (1 per face)
  75715. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75716. * @param onLoad defines an optional callback raised when the texture is loaded
  75717. * @param onError defines an optional callback raised if there is an issue to load the texture
  75718. * @param format defines the format of the data
  75719. * @param forcedExtension defines the extension to use to pick the right loader
  75720. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75721. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75722. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75723. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75724. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75725. * @returns the cube texture as an InternalTexture
  75726. */
  75727. 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;
  75728. /**
  75729. * Creates a cube texture
  75730. * @param rootUrl defines the url where the files to load is located
  75731. * @param scene defines the current scene
  75732. * @param files defines the list of files to load (1 per face)
  75733. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75734. * @param onLoad defines an optional callback raised when the texture is loaded
  75735. * @param onError defines an optional callback raised if there is an issue to load the texture
  75736. * @param format defines the format of the data
  75737. * @param forcedExtension defines the extension to use to pick the right loader
  75738. * @returns the cube texture as an InternalTexture
  75739. */
  75740. 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;
  75741. /**
  75742. * Creates a cube texture
  75743. * @param rootUrl defines the url where the files to load is located
  75744. * @param scene defines the current scene
  75745. * @param files defines the list of files to load (1 per face)
  75746. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75747. * @param onLoad defines an optional callback raised when the texture is loaded
  75748. * @param onError defines an optional callback raised if there is an issue to load the texture
  75749. * @param format defines the format of the data
  75750. * @param forcedExtension defines the extension to use to pick the right loader
  75751. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75752. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75753. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75754. * @returns the cube texture as an InternalTexture
  75755. */
  75756. 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;
  75757. /** @hidden */
  75758. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75759. /** @hidden */
  75760. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75761. /** @hidden */
  75762. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75763. /** @hidden */
  75764. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75765. /**
  75766. * @hidden
  75767. */
  75768. _setCubeMapTextureParams(loadMipmap: boolean): void;
  75769. }
  75770. }
  75771. declare module BABYLON {
  75772. /**
  75773. * Class for creating a cube texture
  75774. */
  75775. export class CubeTexture extends BaseTexture {
  75776. private _delayedOnLoad;
  75777. /**
  75778. * The url of the texture
  75779. */
  75780. url: string;
  75781. /**
  75782. * Gets or sets the center of the bounding box associated with the cube texture.
  75783. * It must define where the camera used to render the texture was set
  75784. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75785. */
  75786. boundingBoxPosition: Vector3;
  75787. private _boundingBoxSize;
  75788. /**
  75789. * Gets or sets the size of the bounding box associated with the cube texture
  75790. * When defined, the cubemap will switch to local mode
  75791. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75792. * @example https://www.babylonjs-playground.com/#RNASML
  75793. */
  75794. /**
  75795. * Returns the bounding box size
  75796. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75797. */
  75798. boundingBoxSize: Vector3;
  75799. protected _rotationY: number;
  75800. /**
  75801. * Sets texture matrix rotation angle around Y axis in radians.
  75802. */
  75803. /**
  75804. * Gets texture matrix rotation angle around Y axis radians.
  75805. */
  75806. rotationY: number;
  75807. /**
  75808. * Are mip maps generated for this texture or not.
  75809. */
  75810. readonly noMipmap: boolean;
  75811. private _noMipmap;
  75812. private _files;
  75813. protected _forcedExtension: Nullable<string>;
  75814. private _extensions;
  75815. private _textureMatrix;
  75816. private _format;
  75817. private _createPolynomials;
  75818. /** @hidden */
  75819. _prefiltered: boolean;
  75820. /**
  75821. * Creates a cube texture from an array of image urls
  75822. * @param files defines an array of image urls
  75823. * @param scene defines the hosting scene
  75824. * @param noMipmap specifies if mip maps are not used
  75825. * @returns a cube texture
  75826. */
  75827. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75828. /**
  75829. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75830. * @param url defines the url of the prefiltered texture
  75831. * @param scene defines the scene the texture is attached to
  75832. * @param forcedExtension defines the extension of the file if different from the url
  75833. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75834. * @return the prefiltered texture
  75835. */
  75836. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75837. /**
  75838. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75839. * as prefiltered data.
  75840. * @param rootUrl defines the url of the texture or the root name of the six images
  75841. * @param scene defines the scene the texture is attached to
  75842. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75843. * @param noMipmap defines if mipmaps should be created or not
  75844. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75845. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75846. * @param onError defines a callback triggered in case of error during load
  75847. * @param format defines the internal format to use for the texture once loaded
  75848. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75849. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75850. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75851. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75852. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75853. * @return the cube texture
  75854. */
  75855. 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);
  75856. /**
  75857. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75858. */
  75859. readonly isPrefiltered: boolean;
  75860. /**
  75861. * Get the current class name of the texture useful for serialization or dynamic coding.
  75862. * @returns "CubeTexture"
  75863. */
  75864. getClassName(): string;
  75865. /**
  75866. * Update the url (and optional buffer) of this texture if url was null during construction.
  75867. * @param url the url of the texture
  75868. * @param forcedExtension defines the extension to use
  75869. * @param onLoad callback called when the texture is loaded (defaults to null)
  75870. */
  75871. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75872. /**
  75873. * Delays loading of the cube texture
  75874. * @param forcedExtension defines the extension to use
  75875. */
  75876. delayLoad(forcedExtension?: string): void;
  75877. /**
  75878. * Returns the reflection texture matrix
  75879. * @returns the reflection texture matrix
  75880. */
  75881. getReflectionTextureMatrix(): Matrix;
  75882. /**
  75883. * Sets the reflection texture matrix
  75884. * @param value Reflection texture matrix
  75885. */
  75886. setReflectionTextureMatrix(value: Matrix): void;
  75887. /**
  75888. * Parses text to create a cube texture
  75889. * @param parsedTexture define the serialized text to read from
  75890. * @param scene defines the hosting scene
  75891. * @param rootUrl defines the root url of the cube texture
  75892. * @returns a cube texture
  75893. */
  75894. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75895. /**
  75896. * Makes a clone, or deep copy, of the cube texture
  75897. * @returns a new cube texture
  75898. */
  75899. clone(): CubeTexture;
  75900. }
  75901. }
  75902. declare module BABYLON {
  75903. /**
  75904. * Manages the defines for the Material
  75905. */
  75906. export class MaterialDefines {
  75907. /** @hidden */
  75908. protected _keys: string[];
  75909. private _isDirty;
  75910. /** @hidden */
  75911. _renderId: number;
  75912. /** @hidden */
  75913. _areLightsDirty: boolean;
  75914. /** @hidden */
  75915. _areLightsDisposed: boolean;
  75916. /** @hidden */
  75917. _areAttributesDirty: boolean;
  75918. /** @hidden */
  75919. _areTexturesDirty: boolean;
  75920. /** @hidden */
  75921. _areFresnelDirty: boolean;
  75922. /** @hidden */
  75923. _areMiscDirty: boolean;
  75924. /** @hidden */
  75925. _areImageProcessingDirty: boolean;
  75926. /** @hidden */
  75927. _normals: boolean;
  75928. /** @hidden */
  75929. _uvs: boolean;
  75930. /** @hidden */
  75931. _needNormals: boolean;
  75932. /** @hidden */
  75933. _needUVs: boolean;
  75934. [id: string]: any;
  75935. /**
  75936. * Specifies if the material needs to be re-calculated
  75937. */
  75938. readonly isDirty: boolean;
  75939. /**
  75940. * Marks the material to indicate that it has been re-calculated
  75941. */
  75942. markAsProcessed(): void;
  75943. /**
  75944. * Marks the material to indicate that it needs to be re-calculated
  75945. */
  75946. markAsUnprocessed(): void;
  75947. /**
  75948. * Marks the material to indicate all of its defines need to be re-calculated
  75949. */
  75950. markAllAsDirty(): void;
  75951. /**
  75952. * Marks the material to indicate that image processing needs to be re-calculated
  75953. */
  75954. markAsImageProcessingDirty(): void;
  75955. /**
  75956. * Marks the material to indicate the lights need to be re-calculated
  75957. * @param disposed Defines whether the light is dirty due to dispose or not
  75958. */
  75959. markAsLightDirty(disposed?: boolean): void;
  75960. /**
  75961. * Marks the attribute state as changed
  75962. */
  75963. markAsAttributesDirty(): void;
  75964. /**
  75965. * Marks the texture state as changed
  75966. */
  75967. markAsTexturesDirty(): void;
  75968. /**
  75969. * Marks the fresnel state as changed
  75970. */
  75971. markAsFresnelDirty(): void;
  75972. /**
  75973. * Marks the misc state as changed
  75974. */
  75975. markAsMiscDirty(): void;
  75976. /**
  75977. * Rebuilds the material defines
  75978. */
  75979. rebuild(): void;
  75980. /**
  75981. * Specifies if two material defines are equal
  75982. * @param other - A material define instance to compare to
  75983. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75984. */
  75985. isEqual(other: MaterialDefines): boolean;
  75986. /**
  75987. * Clones this instance's defines to another instance
  75988. * @param other - material defines to clone values to
  75989. */
  75990. cloneTo(other: MaterialDefines): void;
  75991. /**
  75992. * Resets the material define values
  75993. */
  75994. reset(): void;
  75995. /**
  75996. * Converts the material define values to a string
  75997. * @returns - String of material define information
  75998. */
  75999. toString(): string;
  76000. }
  76001. }
  76002. declare module BABYLON {
  76003. /**
  76004. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  76005. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  76006. * 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;
  76007. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  76008. */
  76009. export class ColorCurves {
  76010. private _dirty;
  76011. private _tempColor;
  76012. private _globalCurve;
  76013. private _highlightsCurve;
  76014. private _midtonesCurve;
  76015. private _shadowsCurve;
  76016. private _positiveCurve;
  76017. private _negativeCurve;
  76018. private _globalHue;
  76019. private _globalDensity;
  76020. private _globalSaturation;
  76021. private _globalExposure;
  76022. /**
  76023. * Gets the global Hue value.
  76024. * 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).
  76025. */
  76026. /**
  76027. * Sets the global Hue value.
  76028. * 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).
  76029. */
  76030. globalHue: number;
  76031. /**
  76032. * Gets the global Density value.
  76033. * 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.
  76034. * Values less than zero provide a filter of opposite hue.
  76035. */
  76036. /**
  76037. * Sets the global Density value.
  76038. * 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.
  76039. * Values less than zero provide a filter of opposite hue.
  76040. */
  76041. globalDensity: number;
  76042. /**
  76043. * Gets the global Saturation value.
  76044. * 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.
  76045. */
  76046. /**
  76047. * Sets the global Saturation value.
  76048. * 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.
  76049. */
  76050. globalSaturation: number;
  76051. /**
  76052. * Gets the global Exposure value.
  76053. * 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.
  76054. */
  76055. /**
  76056. * Sets the global Exposure value.
  76057. * 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.
  76058. */
  76059. globalExposure: number;
  76060. private _highlightsHue;
  76061. private _highlightsDensity;
  76062. private _highlightsSaturation;
  76063. private _highlightsExposure;
  76064. /**
  76065. * Gets the highlights Hue value.
  76066. * 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).
  76067. */
  76068. /**
  76069. * Sets the highlights Hue value.
  76070. * 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).
  76071. */
  76072. highlightsHue: number;
  76073. /**
  76074. * Gets the highlights Density value.
  76075. * 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.
  76076. * Values less than zero provide a filter of opposite hue.
  76077. */
  76078. /**
  76079. * Sets the highlights Density value.
  76080. * 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.
  76081. * Values less than zero provide a filter of opposite hue.
  76082. */
  76083. highlightsDensity: number;
  76084. /**
  76085. * Gets the highlights Saturation value.
  76086. * 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.
  76087. */
  76088. /**
  76089. * Sets the highlights Saturation value.
  76090. * 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.
  76091. */
  76092. highlightsSaturation: number;
  76093. /**
  76094. * Gets the highlights Exposure value.
  76095. * 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.
  76096. */
  76097. /**
  76098. * Sets the highlights Exposure value.
  76099. * 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.
  76100. */
  76101. highlightsExposure: number;
  76102. private _midtonesHue;
  76103. private _midtonesDensity;
  76104. private _midtonesSaturation;
  76105. private _midtonesExposure;
  76106. /**
  76107. * Gets the midtones Hue value.
  76108. * 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).
  76109. */
  76110. /**
  76111. * Sets the midtones Hue value.
  76112. * 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).
  76113. */
  76114. midtonesHue: number;
  76115. /**
  76116. * Gets the midtones Density value.
  76117. * 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.
  76118. * Values less than zero provide a filter of opposite hue.
  76119. */
  76120. /**
  76121. * Sets the midtones Density value.
  76122. * 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.
  76123. * Values less than zero provide a filter of opposite hue.
  76124. */
  76125. midtonesDensity: number;
  76126. /**
  76127. * Gets the midtones Saturation value.
  76128. * 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.
  76129. */
  76130. /**
  76131. * Sets the midtones Saturation value.
  76132. * 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.
  76133. */
  76134. midtonesSaturation: number;
  76135. /**
  76136. * Gets the midtones Exposure value.
  76137. * 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.
  76138. */
  76139. /**
  76140. * Sets the midtones Exposure value.
  76141. * 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.
  76142. */
  76143. midtonesExposure: number;
  76144. private _shadowsHue;
  76145. private _shadowsDensity;
  76146. private _shadowsSaturation;
  76147. private _shadowsExposure;
  76148. /**
  76149. * Gets the shadows Hue value.
  76150. * 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).
  76151. */
  76152. /**
  76153. * Sets the shadows Hue value.
  76154. * 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).
  76155. */
  76156. shadowsHue: number;
  76157. /**
  76158. * Gets the shadows Density value.
  76159. * 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.
  76160. * Values less than zero provide a filter of opposite hue.
  76161. */
  76162. /**
  76163. * Sets the shadows Density value.
  76164. * 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.
  76165. * Values less than zero provide a filter of opposite hue.
  76166. */
  76167. shadowsDensity: number;
  76168. /**
  76169. * Gets the shadows Saturation value.
  76170. * 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.
  76171. */
  76172. /**
  76173. * Sets the shadows Saturation value.
  76174. * 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.
  76175. */
  76176. shadowsSaturation: number;
  76177. /**
  76178. * Gets the shadows Exposure value.
  76179. * 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.
  76180. */
  76181. /**
  76182. * Sets the shadows Exposure value.
  76183. * 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.
  76184. */
  76185. shadowsExposure: number;
  76186. /**
  76187. * Returns the class name
  76188. * @returns The class name
  76189. */
  76190. getClassName(): string;
  76191. /**
  76192. * Binds the color curves to the shader.
  76193. * @param colorCurves The color curve to bind
  76194. * @param effect The effect to bind to
  76195. * @param positiveUniform The positive uniform shader parameter
  76196. * @param neutralUniform The neutral uniform shader parameter
  76197. * @param negativeUniform The negative uniform shader parameter
  76198. */
  76199. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  76200. /**
  76201. * Prepare the list of uniforms associated with the ColorCurves effects.
  76202. * @param uniformsList The list of uniforms used in the effect
  76203. */
  76204. static PrepareUniforms(uniformsList: string[]): void;
  76205. /**
  76206. * Returns color grading data based on a hue, density, saturation and exposure value.
  76207. * @param filterHue The hue of the color filter.
  76208. * @param filterDensity The density of the color filter.
  76209. * @param saturation The saturation.
  76210. * @param exposure The exposure.
  76211. * @param result The result data container.
  76212. */
  76213. private getColorGradingDataToRef;
  76214. /**
  76215. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  76216. * @param value The input slider value in range [-100,100].
  76217. * @returns Adjusted value.
  76218. */
  76219. private static applyColorGradingSliderNonlinear;
  76220. /**
  76221. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  76222. * @param hue The hue (H) input.
  76223. * @param saturation The saturation (S) input.
  76224. * @param brightness The brightness (B) input.
  76225. * @result An RGBA color represented as Vector4.
  76226. */
  76227. private static fromHSBToRef;
  76228. /**
  76229. * Returns a value clamped between min and max
  76230. * @param value The value to clamp
  76231. * @param min The minimum of value
  76232. * @param max The maximum of value
  76233. * @returns The clamped value.
  76234. */
  76235. private static clamp;
  76236. /**
  76237. * Clones the current color curve instance.
  76238. * @return The cloned curves
  76239. */
  76240. clone(): ColorCurves;
  76241. /**
  76242. * Serializes the current color curve instance to a json representation.
  76243. * @return a JSON representation
  76244. */
  76245. serialize(): any;
  76246. /**
  76247. * Parses the color curve from a json representation.
  76248. * @param source the JSON source to parse
  76249. * @return The parsed curves
  76250. */
  76251. static Parse(source: any): ColorCurves;
  76252. }
  76253. }
  76254. declare module BABYLON {
  76255. /**
  76256. * Interface to follow in your material defines to integrate easily the
  76257. * Image proccessing functions.
  76258. * @hidden
  76259. */
  76260. export interface IImageProcessingConfigurationDefines {
  76261. IMAGEPROCESSING: boolean;
  76262. VIGNETTE: boolean;
  76263. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76264. VIGNETTEBLENDMODEOPAQUE: boolean;
  76265. TONEMAPPING: boolean;
  76266. TONEMAPPING_ACES: boolean;
  76267. CONTRAST: boolean;
  76268. EXPOSURE: boolean;
  76269. COLORCURVES: boolean;
  76270. COLORGRADING: boolean;
  76271. COLORGRADING3D: boolean;
  76272. SAMPLER3DGREENDEPTH: boolean;
  76273. SAMPLER3DBGRMAP: boolean;
  76274. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76275. }
  76276. /**
  76277. * @hidden
  76278. */
  76279. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76280. IMAGEPROCESSING: boolean;
  76281. VIGNETTE: boolean;
  76282. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76283. VIGNETTEBLENDMODEOPAQUE: boolean;
  76284. TONEMAPPING: boolean;
  76285. TONEMAPPING_ACES: boolean;
  76286. CONTRAST: boolean;
  76287. COLORCURVES: boolean;
  76288. COLORGRADING: boolean;
  76289. COLORGRADING3D: boolean;
  76290. SAMPLER3DGREENDEPTH: boolean;
  76291. SAMPLER3DBGRMAP: boolean;
  76292. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76293. EXPOSURE: boolean;
  76294. constructor();
  76295. }
  76296. /**
  76297. * This groups together the common properties used for image processing either in direct forward pass
  76298. * or through post processing effect depending on the use of the image processing pipeline in your scene
  76299. * or not.
  76300. */
  76301. export class ImageProcessingConfiguration {
  76302. /**
  76303. * Default tone mapping applied in BabylonJS.
  76304. */
  76305. static readonly TONEMAPPING_STANDARD: number;
  76306. /**
  76307. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  76308. * to other engines rendering to increase portability.
  76309. */
  76310. static readonly TONEMAPPING_ACES: number;
  76311. /**
  76312. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  76313. */
  76314. colorCurves: Nullable<ColorCurves>;
  76315. private _colorCurvesEnabled;
  76316. /**
  76317. * Gets wether the color curves effect is enabled.
  76318. */
  76319. /**
  76320. * Sets wether the color curves effect is enabled.
  76321. */
  76322. colorCurvesEnabled: boolean;
  76323. private _colorGradingTexture;
  76324. /**
  76325. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76326. */
  76327. /**
  76328. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76329. */
  76330. colorGradingTexture: Nullable<BaseTexture>;
  76331. private _colorGradingEnabled;
  76332. /**
  76333. * Gets wether the color grading effect is enabled.
  76334. */
  76335. /**
  76336. * Sets wether the color grading effect is enabled.
  76337. */
  76338. colorGradingEnabled: boolean;
  76339. private _colorGradingWithGreenDepth;
  76340. /**
  76341. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  76342. */
  76343. /**
  76344. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  76345. */
  76346. colorGradingWithGreenDepth: boolean;
  76347. private _colorGradingBGR;
  76348. /**
  76349. * Gets wether the color grading texture contains BGR values.
  76350. */
  76351. /**
  76352. * Sets wether the color grading texture contains BGR values.
  76353. */
  76354. colorGradingBGR: boolean;
  76355. /** @hidden */
  76356. _exposure: number;
  76357. /**
  76358. * Gets the Exposure used in the effect.
  76359. */
  76360. /**
  76361. * Sets the Exposure used in the effect.
  76362. */
  76363. exposure: number;
  76364. private _toneMappingEnabled;
  76365. /**
  76366. * Gets wether the tone mapping effect is enabled.
  76367. */
  76368. /**
  76369. * Sets wether the tone mapping effect is enabled.
  76370. */
  76371. toneMappingEnabled: boolean;
  76372. private _toneMappingType;
  76373. /**
  76374. * Gets the type of tone mapping effect.
  76375. */
  76376. /**
  76377. * Sets the type of tone mapping effect used in BabylonJS.
  76378. */
  76379. toneMappingType: number;
  76380. protected _contrast: number;
  76381. /**
  76382. * Gets the contrast used in the effect.
  76383. */
  76384. /**
  76385. * Sets the contrast used in the effect.
  76386. */
  76387. contrast: number;
  76388. /**
  76389. * Vignette stretch size.
  76390. */
  76391. vignetteStretch: number;
  76392. /**
  76393. * Vignette centre X Offset.
  76394. */
  76395. vignetteCentreX: number;
  76396. /**
  76397. * Vignette centre Y Offset.
  76398. */
  76399. vignetteCentreY: number;
  76400. /**
  76401. * Vignette weight or intensity of the vignette effect.
  76402. */
  76403. vignetteWeight: number;
  76404. /**
  76405. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76406. * if vignetteEnabled is set to true.
  76407. */
  76408. vignetteColor: Color4;
  76409. /**
  76410. * Camera field of view used by the Vignette effect.
  76411. */
  76412. vignetteCameraFov: number;
  76413. private _vignetteBlendMode;
  76414. /**
  76415. * Gets the vignette blend mode allowing different kind of effect.
  76416. */
  76417. /**
  76418. * Sets the vignette blend mode allowing different kind of effect.
  76419. */
  76420. vignetteBlendMode: number;
  76421. private _vignetteEnabled;
  76422. /**
  76423. * Gets wether the vignette effect is enabled.
  76424. */
  76425. /**
  76426. * Sets wether the vignette effect is enabled.
  76427. */
  76428. vignetteEnabled: boolean;
  76429. private _applyByPostProcess;
  76430. /**
  76431. * Gets wether the image processing is applied through a post process or not.
  76432. */
  76433. /**
  76434. * Sets wether the image processing is applied through a post process or not.
  76435. */
  76436. applyByPostProcess: boolean;
  76437. private _isEnabled;
  76438. /**
  76439. * Gets wether the image processing is enabled or not.
  76440. */
  76441. /**
  76442. * Sets wether the image processing is enabled or not.
  76443. */
  76444. isEnabled: boolean;
  76445. /**
  76446. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76447. */
  76448. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76449. /**
  76450. * Method called each time the image processing information changes requires to recompile the effect.
  76451. */
  76452. protected _updateParameters(): void;
  76453. /**
  76454. * Gets the current class name.
  76455. * @return "ImageProcessingConfiguration"
  76456. */
  76457. getClassName(): string;
  76458. /**
  76459. * Prepare the list of uniforms associated with the Image Processing effects.
  76460. * @param uniforms The list of uniforms used in the effect
  76461. * @param defines the list of defines currently in use
  76462. */
  76463. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76464. /**
  76465. * Prepare the list of samplers associated with the Image Processing effects.
  76466. * @param samplersList The list of uniforms used in the effect
  76467. * @param defines the list of defines currently in use
  76468. */
  76469. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76470. /**
  76471. * Prepare the list of defines associated to the shader.
  76472. * @param defines the list of defines to complete
  76473. * @param forPostProcess Define if we are currently in post process mode or not
  76474. */
  76475. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76476. /**
  76477. * Returns true if all the image processing information are ready.
  76478. * @returns True if ready, otherwise, false
  76479. */
  76480. isReady(): boolean;
  76481. /**
  76482. * Binds the image processing to the shader.
  76483. * @param effect The effect to bind to
  76484. * @param overrideAspectRatio Override the aspect ratio of the effect
  76485. */
  76486. bind(effect: Effect, overrideAspectRatio?: number): void;
  76487. /**
  76488. * Clones the current image processing instance.
  76489. * @return The cloned image processing
  76490. */
  76491. clone(): ImageProcessingConfiguration;
  76492. /**
  76493. * Serializes the current image processing instance to a json representation.
  76494. * @return a JSON representation
  76495. */
  76496. serialize(): any;
  76497. /**
  76498. * Parses the image processing from a json representation.
  76499. * @param source the JSON source to parse
  76500. * @return The parsed image processing
  76501. */
  76502. static Parse(source: any): ImageProcessingConfiguration;
  76503. private static _VIGNETTEMODE_MULTIPLY;
  76504. private static _VIGNETTEMODE_OPAQUE;
  76505. /**
  76506. * Used to apply the vignette as a mix with the pixel color.
  76507. */
  76508. static readonly VIGNETTEMODE_MULTIPLY: number;
  76509. /**
  76510. * Used to apply the vignette as a replacement of the pixel color.
  76511. */
  76512. static readonly VIGNETTEMODE_OPAQUE: number;
  76513. }
  76514. }
  76515. declare module BABYLON {
  76516. /** @hidden */
  76517. export var postprocessVertexShader: {
  76518. name: string;
  76519. shader: string;
  76520. };
  76521. }
  76522. declare module BABYLON {
  76523. interface ThinEngine {
  76524. /**
  76525. * Creates a new render target texture
  76526. * @param size defines the size of the texture
  76527. * @param options defines the options used to create the texture
  76528. * @returns a new render target texture stored in an InternalTexture
  76529. */
  76530. createRenderTargetTexture(size: number | {
  76531. width: number;
  76532. height: number;
  76533. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76534. /**
  76535. * Creates a depth stencil texture.
  76536. * This is only available in WebGL 2 or with the depth texture extension available.
  76537. * @param size The size of face edge in the texture.
  76538. * @param options The options defining the texture.
  76539. * @returns The texture
  76540. */
  76541. createDepthStencilTexture(size: number | {
  76542. width: number;
  76543. height: number;
  76544. }, options: DepthTextureCreationOptions): InternalTexture;
  76545. /** @hidden */
  76546. _createDepthStencilTexture(size: number | {
  76547. width: number;
  76548. height: number;
  76549. }, options: DepthTextureCreationOptions): InternalTexture;
  76550. }
  76551. }
  76552. declare module BABYLON {
  76553. /** Defines supported spaces */
  76554. export enum Space {
  76555. /** Local (object) space */
  76556. LOCAL = 0,
  76557. /** World space */
  76558. WORLD = 1,
  76559. /** Bone space */
  76560. BONE = 2
  76561. }
  76562. /** Defines the 3 main axes */
  76563. export class Axis {
  76564. /** X axis */
  76565. static X: Vector3;
  76566. /** Y axis */
  76567. static Y: Vector3;
  76568. /** Z axis */
  76569. static Z: Vector3;
  76570. }
  76571. }
  76572. declare module BABYLON {
  76573. /**
  76574. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76575. * This is the base of the follow, arc rotate cameras and Free camera
  76576. * @see http://doc.babylonjs.com/features/cameras
  76577. */
  76578. export class TargetCamera extends Camera {
  76579. private static _RigCamTransformMatrix;
  76580. private static _TargetTransformMatrix;
  76581. private static _TargetFocalPoint;
  76582. /**
  76583. * Define the current direction the camera is moving to
  76584. */
  76585. cameraDirection: Vector3;
  76586. /**
  76587. * Define the current rotation the camera is rotating to
  76588. */
  76589. cameraRotation: Vector2;
  76590. /**
  76591. * When set, the up vector of the camera will be updated by the rotation of the camera
  76592. */
  76593. updateUpVectorFromRotation: boolean;
  76594. private _tmpQuaternion;
  76595. /**
  76596. * Define the current rotation of the camera
  76597. */
  76598. rotation: Vector3;
  76599. /**
  76600. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76601. */
  76602. rotationQuaternion: Quaternion;
  76603. /**
  76604. * Define the current speed of the camera
  76605. */
  76606. speed: number;
  76607. /**
  76608. * Add cconstraint to the camera to prevent it to move freely in all directions and
  76609. * around all axis.
  76610. */
  76611. noRotationConstraint: boolean;
  76612. /**
  76613. * Define the current target of the camera as an object or a position.
  76614. */
  76615. lockedTarget: any;
  76616. /** @hidden */
  76617. _currentTarget: Vector3;
  76618. /** @hidden */
  76619. _initialFocalDistance: number;
  76620. /** @hidden */
  76621. _viewMatrix: Matrix;
  76622. /** @hidden */
  76623. _camMatrix: Matrix;
  76624. /** @hidden */
  76625. _cameraTransformMatrix: Matrix;
  76626. /** @hidden */
  76627. _cameraRotationMatrix: Matrix;
  76628. /** @hidden */
  76629. _referencePoint: Vector3;
  76630. /** @hidden */
  76631. _transformedReferencePoint: Vector3;
  76632. protected _globalCurrentTarget: Vector3;
  76633. protected _globalCurrentUpVector: Vector3;
  76634. /** @hidden */
  76635. _reset: () => void;
  76636. private _defaultUp;
  76637. /**
  76638. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76639. * This is the base of the follow, arc rotate cameras and Free camera
  76640. * @see http://doc.babylonjs.com/features/cameras
  76641. * @param name Defines the name of the camera in the scene
  76642. * @param position Defines the start position of the camera in the scene
  76643. * @param scene Defines the scene the camera belongs to
  76644. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76645. */
  76646. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76647. /**
  76648. * Gets the position in front of the camera at a given distance.
  76649. * @param distance The distance from the camera we want the position to be
  76650. * @returns the position
  76651. */
  76652. getFrontPosition(distance: number): Vector3;
  76653. /** @hidden */
  76654. _getLockedTargetPosition(): Nullable<Vector3>;
  76655. private _storedPosition;
  76656. private _storedRotation;
  76657. private _storedRotationQuaternion;
  76658. /**
  76659. * Store current camera state of the camera (fov, position, rotation, etc..)
  76660. * @returns the camera
  76661. */
  76662. storeState(): Camera;
  76663. /**
  76664. * Restored camera state. You must call storeState() first
  76665. * @returns whether it was successful or not
  76666. * @hidden
  76667. */
  76668. _restoreStateValues(): boolean;
  76669. /** @hidden */
  76670. _initCache(): void;
  76671. /** @hidden */
  76672. _updateCache(ignoreParentClass?: boolean): void;
  76673. /** @hidden */
  76674. _isSynchronizedViewMatrix(): boolean;
  76675. /** @hidden */
  76676. _computeLocalCameraSpeed(): number;
  76677. /**
  76678. * Defines the target the camera should look at.
  76679. * @param target Defines the new target as a Vector or a mesh
  76680. */
  76681. setTarget(target: Vector3): void;
  76682. /**
  76683. * Return the current target position of the camera. This value is expressed in local space.
  76684. * @returns the target position
  76685. */
  76686. getTarget(): Vector3;
  76687. /** @hidden */
  76688. _decideIfNeedsToMove(): boolean;
  76689. /** @hidden */
  76690. _updatePosition(): void;
  76691. /** @hidden */
  76692. _checkInputs(): void;
  76693. protected _updateCameraRotationMatrix(): void;
  76694. /**
  76695. * 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)
  76696. * @returns the current camera
  76697. */
  76698. private _rotateUpVectorWithCameraRotationMatrix;
  76699. private _cachedRotationZ;
  76700. private _cachedQuaternionRotationZ;
  76701. /** @hidden */
  76702. _getViewMatrix(): Matrix;
  76703. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76704. /**
  76705. * @hidden
  76706. */
  76707. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76708. /**
  76709. * @hidden
  76710. */
  76711. _updateRigCameras(): void;
  76712. private _getRigCamPositionAndTarget;
  76713. /**
  76714. * Gets the current object class name.
  76715. * @return the class name
  76716. */
  76717. getClassName(): string;
  76718. }
  76719. }
  76720. declare module BABYLON {
  76721. /**
  76722. * Gather the list of keyboard event types as constants.
  76723. */
  76724. export class KeyboardEventTypes {
  76725. /**
  76726. * The keydown event is fired when a key becomes active (pressed).
  76727. */
  76728. static readonly KEYDOWN: number;
  76729. /**
  76730. * The keyup event is fired when a key has been released.
  76731. */
  76732. static readonly KEYUP: number;
  76733. }
  76734. /**
  76735. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76736. */
  76737. export class KeyboardInfo {
  76738. /**
  76739. * Defines the type of event (KeyboardEventTypes)
  76740. */
  76741. type: number;
  76742. /**
  76743. * Defines the related dom event
  76744. */
  76745. event: KeyboardEvent;
  76746. /**
  76747. * Instantiates a new keyboard info.
  76748. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76749. * @param type Defines the type of event (KeyboardEventTypes)
  76750. * @param event Defines the related dom event
  76751. */
  76752. constructor(
  76753. /**
  76754. * Defines the type of event (KeyboardEventTypes)
  76755. */
  76756. type: number,
  76757. /**
  76758. * Defines the related dom event
  76759. */
  76760. event: KeyboardEvent);
  76761. }
  76762. /**
  76763. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76764. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  76765. */
  76766. export class KeyboardInfoPre extends KeyboardInfo {
  76767. /**
  76768. * Defines the type of event (KeyboardEventTypes)
  76769. */
  76770. type: number;
  76771. /**
  76772. * Defines the related dom event
  76773. */
  76774. event: KeyboardEvent;
  76775. /**
  76776. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  76777. */
  76778. skipOnPointerObservable: boolean;
  76779. /**
  76780. * Instantiates a new keyboard pre info.
  76781. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76782. * @param type Defines the type of event (KeyboardEventTypes)
  76783. * @param event Defines the related dom event
  76784. */
  76785. constructor(
  76786. /**
  76787. * Defines the type of event (KeyboardEventTypes)
  76788. */
  76789. type: number,
  76790. /**
  76791. * Defines the related dom event
  76792. */
  76793. event: KeyboardEvent);
  76794. }
  76795. }
  76796. declare module BABYLON {
  76797. /**
  76798. * Manage the keyboard inputs to control the movement of a free camera.
  76799. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76800. */
  76801. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  76802. /**
  76803. * Defines the camera the input is attached to.
  76804. */
  76805. camera: FreeCamera;
  76806. /**
  76807. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76808. */
  76809. keysUp: number[];
  76810. /**
  76811. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76812. */
  76813. keysDown: number[];
  76814. /**
  76815. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76816. */
  76817. keysLeft: number[];
  76818. /**
  76819. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76820. */
  76821. keysRight: number[];
  76822. private _keys;
  76823. private _onCanvasBlurObserver;
  76824. private _onKeyboardObserver;
  76825. private _engine;
  76826. private _scene;
  76827. /**
  76828. * Attach the input controls to a specific dom element to get the input from.
  76829. * @param element Defines the element the controls should be listened from
  76830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76831. */
  76832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76833. /**
  76834. * Detach the current controls from the specified dom element.
  76835. * @param element Defines the element to stop listening the inputs from
  76836. */
  76837. detachControl(element: Nullable<HTMLElement>): void;
  76838. /**
  76839. * Update the current camera state depending on the inputs that have been used this frame.
  76840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76841. */
  76842. checkInputs(): void;
  76843. /**
  76844. * Gets the class name of the current intput.
  76845. * @returns the class name
  76846. */
  76847. getClassName(): string;
  76848. /** @hidden */
  76849. _onLostFocus(): void;
  76850. /**
  76851. * Get the friendly name associated with the input class.
  76852. * @returns the input friendly name
  76853. */
  76854. getSimpleName(): string;
  76855. }
  76856. }
  76857. declare module BABYLON {
  76858. /**
  76859. * Interface describing all the common properties and methods a shadow light needs to implement.
  76860. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76861. * as well as binding the different shadow properties to the effects.
  76862. */
  76863. export interface IShadowLight extends Light {
  76864. /**
  76865. * The light id in the scene (used in scene.findLighById for instance)
  76866. */
  76867. id: string;
  76868. /**
  76869. * The position the shdow will be casted from.
  76870. */
  76871. position: Vector3;
  76872. /**
  76873. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76874. */
  76875. direction: Vector3;
  76876. /**
  76877. * The transformed position. Position of the light in world space taking parenting in account.
  76878. */
  76879. transformedPosition: Vector3;
  76880. /**
  76881. * The transformed direction. Direction of the light in world space taking parenting in account.
  76882. */
  76883. transformedDirection: Vector3;
  76884. /**
  76885. * The friendly name of the light in the scene.
  76886. */
  76887. name: string;
  76888. /**
  76889. * Defines the shadow projection clipping minimum z value.
  76890. */
  76891. shadowMinZ: number;
  76892. /**
  76893. * Defines the shadow projection clipping maximum z value.
  76894. */
  76895. shadowMaxZ: number;
  76896. /**
  76897. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76898. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76899. */
  76900. computeTransformedInformation(): boolean;
  76901. /**
  76902. * Gets the scene the light belongs to.
  76903. * @returns The scene
  76904. */
  76905. getScene(): Scene;
  76906. /**
  76907. * Callback defining a custom Projection Matrix Builder.
  76908. * This can be used to override the default projection matrix computation.
  76909. */
  76910. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76911. /**
  76912. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76913. * @param matrix The materix to updated with the projection information
  76914. * @param viewMatrix The transform matrix of the light
  76915. * @param renderList The list of mesh to render in the map
  76916. * @returns The current light
  76917. */
  76918. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76919. /**
  76920. * Gets the current depth scale used in ESM.
  76921. * @returns The scale
  76922. */
  76923. getDepthScale(): number;
  76924. /**
  76925. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76926. * @returns true if a cube texture needs to be use
  76927. */
  76928. needCube(): boolean;
  76929. /**
  76930. * Detects if the projection matrix requires to be recomputed this frame.
  76931. * @returns true if it requires to be recomputed otherwise, false.
  76932. */
  76933. needProjectionMatrixCompute(): boolean;
  76934. /**
  76935. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76936. */
  76937. forceProjectionMatrixCompute(): void;
  76938. /**
  76939. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76940. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76941. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76942. */
  76943. getShadowDirection(faceIndex?: number): Vector3;
  76944. /**
  76945. * Gets the minZ used for shadow according to both the scene and the light.
  76946. * @param activeCamera The camera we are returning the min for
  76947. * @returns the depth min z
  76948. */
  76949. getDepthMinZ(activeCamera: Camera): number;
  76950. /**
  76951. * Gets the maxZ used for shadow according to both the scene and the light.
  76952. * @param activeCamera The camera we are returning the max for
  76953. * @returns the depth max z
  76954. */
  76955. getDepthMaxZ(activeCamera: Camera): number;
  76956. }
  76957. /**
  76958. * Base implementation IShadowLight
  76959. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76960. */
  76961. export abstract class ShadowLight extends Light implements IShadowLight {
  76962. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76963. protected _position: Vector3;
  76964. protected _setPosition(value: Vector3): void;
  76965. /**
  76966. * Sets the position the shadow will be casted from. Also use as the light position for both
  76967. * point and spot lights.
  76968. */
  76969. /**
  76970. * Sets the position the shadow will be casted from. Also use as the light position for both
  76971. * point and spot lights.
  76972. */
  76973. position: Vector3;
  76974. protected _direction: Vector3;
  76975. protected _setDirection(value: Vector3): void;
  76976. /**
  76977. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76978. * Also use as the light direction on spot and directional lights.
  76979. */
  76980. /**
  76981. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76982. * Also use as the light direction on spot and directional lights.
  76983. */
  76984. direction: Vector3;
  76985. private _shadowMinZ;
  76986. /**
  76987. * Gets the shadow projection clipping minimum z value.
  76988. */
  76989. /**
  76990. * Sets the shadow projection clipping minimum z value.
  76991. */
  76992. shadowMinZ: number;
  76993. private _shadowMaxZ;
  76994. /**
  76995. * Sets the shadow projection clipping maximum z value.
  76996. */
  76997. /**
  76998. * Gets the shadow projection clipping maximum z value.
  76999. */
  77000. shadowMaxZ: number;
  77001. /**
  77002. * Callback defining a custom Projection Matrix Builder.
  77003. * This can be used to override the default projection matrix computation.
  77004. */
  77005. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77006. /**
  77007. * The transformed position. Position of the light in world space taking parenting in account.
  77008. */
  77009. transformedPosition: Vector3;
  77010. /**
  77011. * The transformed direction. Direction of the light in world space taking parenting in account.
  77012. */
  77013. transformedDirection: Vector3;
  77014. private _needProjectionMatrixCompute;
  77015. /**
  77016. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77017. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77018. */
  77019. computeTransformedInformation(): boolean;
  77020. /**
  77021. * Return the depth scale used for the shadow map.
  77022. * @returns the depth scale.
  77023. */
  77024. getDepthScale(): number;
  77025. /**
  77026. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77027. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77028. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77029. */
  77030. getShadowDirection(faceIndex?: number): Vector3;
  77031. /**
  77032. * Returns the ShadowLight absolute position in the World.
  77033. * @returns the position vector in world space
  77034. */
  77035. getAbsolutePosition(): Vector3;
  77036. /**
  77037. * Sets the ShadowLight direction toward the passed target.
  77038. * @param target The point to target in local space
  77039. * @returns the updated ShadowLight direction
  77040. */
  77041. setDirectionToTarget(target: Vector3): Vector3;
  77042. /**
  77043. * Returns the light rotation in euler definition.
  77044. * @returns the x y z rotation in local space.
  77045. */
  77046. getRotation(): Vector3;
  77047. /**
  77048. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77049. * @returns true if a cube texture needs to be use
  77050. */
  77051. needCube(): boolean;
  77052. /**
  77053. * Detects if the projection matrix requires to be recomputed this frame.
  77054. * @returns true if it requires to be recomputed otherwise, false.
  77055. */
  77056. needProjectionMatrixCompute(): boolean;
  77057. /**
  77058. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77059. */
  77060. forceProjectionMatrixCompute(): void;
  77061. /** @hidden */
  77062. _initCache(): void;
  77063. /** @hidden */
  77064. _isSynchronized(): boolean;
  77065. /**
  77066. * Computes the world matrix of the node
  77067. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77068. * @returns the world matrix
  77069. */
  77070. computeWorldMatrix(force?: boolean): Matrix;
  77071. /**
  77072. * Gets the minZ used for shadow according to both the scene and the light.
  77073. * @param activeCamera The camera we are returning the min for
  77074. * @returns the depth min z
  77075. */
  77076. getDepthMinZ(activeCamera: Camera): number;
  77077. /**
  77078. * Gets the maxZ used for shadow according to both the scene and the light.
  77079. * @param activeCamera The camera we are returning the max for
  77080. * @returns the depth max z
  77081. */
  77082. getDepthMaxZ(activeCamera: Camera): number;
  77083. /**
  77084. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77085. * @param matrix The materix to updated with the projection information
  77086. * @param viewMatrix The transform matrix of the light
  77087. * @param renderList The list of mesh to render in the map
  77088. * @returns The current light
  77089. */
  77090. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77091. }
  77092. }
  77093. declare module BABYLON {
  77094. /**
  77095. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77096. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77097. */
  77098. export class EffectFallbacks implements IEffectFallbacks {
  77099. private _defines;
  77100. private _currentRank;
  77101. private _maxRank;
  77102. private _mesh;
  77103. /**
  77104. * Removes the fallback from the bound mesh.
  77105. */
  77106. unBindMesh(): void;
  77107. /**
  77108. * Adds a fallback on the specified property.
  77109. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77110. * @param define The name of the define in the shader
  77111. */
  77112. addFallback(rank: number, define: string): void;
  77113. /**
  77114. * Sets the mesh to use CPU skinning when needing to fallback.
  77115. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77116. * @param mesh The mesh to use the fallbacks.
  77117. */
  77118. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77119. /**
  77120. * Checks to see if more fallbacks are still availible.
  77121. */
  77122. readonly hasMoreFallbacks: boolean;
  77123. /**
  77124. * Removes the defines that should be removed when falling back.
  77125. * @param currentDefines defines the current define statements for the shader.
  77126. * @param effect defines the current effect we try to compile
  77127. * @returns The resulting defines with defines of the current rank removed.
  77128. */
  77129. reduce(currentDefines: string, effect: Effect): string;
  77130. }
  77131. }
  77132. declare module BABYLON {
  77133. /**
  77134. * "Static Class" containing the most commonly used helper while dealing with material for
  77135. * rendering purpose.
  77136. *
  77137. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77138. *
  77139. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77140. */
  77141. export class MaterialHelper {
  77142. /**
  77143. * Bind the current view position to an effect.
  77144. * @param effect The effect to be bound
  77145. * @param scene The scene the eyes position is used from
  77146. */
  77147. static BindEyePosition(effect: Effect, scene: Scene): void;
  77148. /**
  77149. * Helps preparing the defines values about the UVs in used in the effect.
  77150. * UVs are shared as much as we can accross channels in the shaders.
  77151. * @param texture The texture we are preparing the UVs for
  77152. * @param defines The defines to update
  77153. * @param key The channel key "diffuse", "specular"... used in the shader
  77154. */
  77155. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77156. /**
  77157. * Binds a texture matrix value to its corrsponding uniform
  77158. * @param texture The texture to bind the matrix for
  77159. * @param uniformBuffer The uniform buffer receivin the data
  77160. * @param key The channel key "diffuse", "specular"... used in the shader
  77161. */
  77162. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77163. /**
  77164. * Gets the current status of the fog (should it be enabled?)
  77165. * @param mesh defines the mesh to evaluate for fog support
  77166. * @param scene defines the hosting scene
  77167. * @returns true if fog must be enabled
  77168. */
  77169. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77170. /**
  77171. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77172. * @param mesh defines the current mesh
  77173. * @param scene defines the current scene
  77174. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77175. * @param pointsCloud defines if point cloud rendering has to be turned on
  77176. * @param fogEnabled defines if fog has to be turned on
  77177. * @param alphaTest defines if alpha testing has to be turned on
  77178. * @param defines defines the current list of defines
  77179. */
  77180. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77181. /**
  77182. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77183. * @param scene defines the current scene
  77184. * @param engine defines the current engine
  77185. * @param defines specifies the list of active defines
  77186. * @param useInstances defines if instances have to be turned on
  77187. * @param useClipPlane defines if clip plane have to be turned on
  77188. */
  77189. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77190. /**
  77191. * Prepares the defines for bones
  77192. * @param mesh The mesh containing the geometry data we will draw
  77193. * @param defines The defines to update
  77194. */
  77195. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  77196. /**
  77197. * Prepares the defines for morph targets
  77198. * @param mesh The mesh containing the geometry data we will draw
  77199. * @param defines The defines to update
  77200. */
  77201. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  77202. /**
  77203. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  77204. * @param mesh The mesh containing the geometry data we will draw
  77205. * @param defines The defines to update
  77206. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  77207. * @param useBones Precise whether bones should be used or not (override mesh info)
  77208. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  77209. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  77210. * @returns false if defines are considered not dirty and have not been checked
  77211. */
  77212. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  77213. /**
  77214. * Prepares the defines related to multiview
  77215. * @param scene The scene we are intending to draw
  77216. * @param defines The defines to update
  77217. */
  77218. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  77219. /**
  77220. * Prepares the defines related to the light information passed in parameter
  77221. * @param scene The scene we are intending to draw
  77222. * @param mesh The mesh the effect is compiling for
  77223. * @param light The light the effect is compiling for
  77224. * @param lightIndex The index of the light
  77225. * @param defines The defines to update
  77226. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77227. * @param state Defines the current state regarding what is needed (normals, etc...)
  77228. */
  77229. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  77230. needNormals: boolean;
  77231. needRebuild: boolean;
  77232. shadowEnabled: boolean;
  77233. specularEnabled: boolean;
  77234. lightmapMode: boolean;
  77235. }): void;
  77236. /**
  77237. * Prepares the defines related to the light information passed in parameter
  77238. * @param scene The scene we are intending to draw
  77239. * @param mesh The mesh the effect is compiling for
  77240. * @param defines The defines to update
  77241. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77242. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  77243. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  77244. * @returns true if normals will be required for the rest of the effect
  77245. */
  77246. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  77247. /**
  77248. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  77249. * @param lightIndex defines the light index
  77250. * @param uniformsList The uniform list
  77251. * @param samplersList The sampler list
  77252. * @param projectedLightTexture defines if projected texture must be used
  77253. * @param uniformBuffersList defines an optional list of uniform buffers
  77254. */
  77255. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77256. /**
  77257. * Prepares the uniforms and samplers list to be used in the effect
  77258. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77259. * @param samplersList The sampler list
  77260. * @param defines The defines helping in the list generation
  77261. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77262. */
  77263. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77264. /**
  77265. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77266. * @param defines The defines to update while falling back
  77267. * @param fallbacks The authorized effect fallbacks
  77268. * @param maxSimultaneousLights The maximum number of lights allowed
  77269. * @param rank the current rank of the Effect
  77270. * @returns The newly affected rank
  77271. */
  77272. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77273. private static _TmpMorphInfluencers;
  77274. /**
  77275. * Prepares the list of attributes required for morph targets according to the effect defines.
  77276. * @param attribs The current list of supported attribs
  77277. * @param mesh The mesh to prepare the morph targets attributes for
  77278. * @param influencers The number of influencers
  77279. */
  77280. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77281. /**
  77282. * Prepares the list of attributes required for morph targets according to the effect defines.
  77283. * @param attribs The current list of supported attribs
  77284. * @param mesh The mesh to prepare the morph targets attributes for
  77285. * @param defines The current Defines of the effect
  77286. */
  77287. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  77288. /**
  77289. * Prepares the list of attributes required for bones according to the effect defines.
  77290. * @param attribs The current list of supported attribs
  77291. * @param mesh The mesh to prepare the bones attributes for
  77292. * @param defines The current Defines of the effect
  77293. * @param fallbacks The current efffect fallback strategy
  77294. */
  77295. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  77296. /**
  77297. * Check and prepare the list of attributes required for instances according to the effect defines.
  77298. * @param attribs The current list of supported attribs
  77299. * @param defines The current MaterialDefines of the effect
  77300. */
  77301. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  77302. /**
  77303. * Add the list of attributes required for instances to the attribs array.
  77304. * @param attribs The current list of supported attribs
  77305. */
  77306. static PushAttributesForInstances(attribs: string[]): void;
  77307. /**
  77308. * Binds the light information to the effect.
  77309. * @param light The light containing the generator
  77310. * @param effect The effect we are binding the data to
  77311. * @param lightIndex The light index in the effect used to render
  77312. */
  77313. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  77314. /**
  77315. * Binds the lights information from the scene to the effect for the given mesh.
  77316. * @param light Light to bind
  77317. * @param lightIndex Light index
  77318. * @param scene The scene where the light belongs to
  77319. * @param effect The effect we are binding the data to
  77320. * @param useSpecular Defines if specular is supported
  77321. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77322. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77323. */
  77324. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77325. /**
  77326. * Binds the lights information from the scene to the effect for the given mesh.
  77327. * @param scene The scene the lights belongs to
  77328. * @param mesh The mesh we are binding the information to render
  77329. * @param effect The effect we are binding the data to
  77330. * @param defines The generated defines for the effect
  77331. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  77332. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77333. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77334. */
  77335. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77336. private static _tempFogColor;
  77337. /**
  77338. * Binds the fog information from the scene to the effect for the given mesh.
  77339. * @param scene The scene the lights belongs to
  77340. * @param mesh The mesh we are binding the information to render
  77341. * @param effect The effect we are binding the data to
  77342. * @param linearSpace Defines if the fog effect is applied in linear space
  77343. */
  77344. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  77345. /**
  77346. * Binds the bones information from the mesh to the effect.
  77347. * @param mesh The mesh we are binding the information to render
  77348. * @param effect The effect we are binding the data to
  77349. */
  77350. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  77351. /**
  77352. * Binds the morph targets information from the mesh to the effect.
  77353. * @param abstractMesh The mesh we are binding the information to render
  77354. * @param effect The effect we are binding the data to
  77355. */
  77356. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  77357. /**
  77358. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  77359. * @param defines The generated defines used in the effect
  77360. * @param effect The effect we are binding the data to
  77361. * @param scene The scene we are willing to render with logarithmic scale for
  77362. */
  77363. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  77364. /**
  77365. * Binds the clip plane information from the scene to the effect.
  77366. * @param scene The scene the clip plane information are extracted from
  77367. * @param effect The effect we are binding the data to
  77368. */
  77369. static BindClipPlane(effect: Effect, scene: Scene): void;
  77370. }
  77371. }
  77372. declare module BABYLON {
  77373. /** @hidden */
  77374. export var packingFunctions: {
  77375. name: string;
  77376. shader: string;
  77377. };
  77378. }
  77379. declare module BABYLON {
  77380. /** @hidden */
  77381. export var shadowMapPixelShader: {
  77382. name: string;
  77383. shader: string;
  77384. };
  77385. }
  77386. declare module BABYLON {
  77387. /** @hidden */
  77388. export var bonesDeclaration: {
  77389. name: string;
  77390. shader: string;
  77391. };
  77392. }
  77393. declare module BABYLON {
  77394. /** @hidden */
  77395. export var morphTargetsVertexGlobalDeclaration: {
  77396. name: string;
  77397. shader: string;
  77398. };
  77399. }
  77400. declare module BABYLON {
  77401. /** @hidden */
  77402. export var morphTargetsVertexDeclaration: {
  77403. name: string;
  77404. shader: string;
  77405. };
  77406. }
  77407. declare module BABYLON {
  77408. /** @hidden */
  77409. export var instancesDeclaration: {
  77410. name: string;
  77411. shader: string;
  77412. };
  77413. }
  77414. declare module BABYLON {
  77415. /** @hidden */
  77416. export var helperFunctions: {
  77417. name: string;
  77418. shader: string;
  77419. };
  77420. }
  77421. declare module BABYLON {
  77422. /** @hidden */
  77423. export var morphTargetsVertex: {
  77424. name: string;
  77425. shader: string;
  77426. };
  77427. }
  77428. declare module BABYLON {
  77429. /** @hidden */
  77430. export var instancesVertex: {
  77431. name: string;
  77432. shader: string;
  77433. };
  77434. }
  77435. declare module BABYLON {
  77436. /** @hidden */
  77437. export var bonesVertex: {
  77438. name: string;
  77439. shader: string;
  77440. };
  77441. }
  77442. declare module BABYLON {
  77443. /** @hidden */
  77444. export var shadowMapVertexShader: {
  77445. name: string;
  77446. shader: string;
  77447. };
  77448. }
  77449. declare module BABYLON {
  77450. /** @hidden */
  77451. export var depthBoxBlurPixelShader: {
  77452. name: string;
  77453. shader: string;
  77454. };
  77455. }
  77456. declare module BABYLON {
  77457. /**
  77458. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77459. */
  77460. export interface ICustomShaderOptions {
  77461. /**
  77462. * Gets or sets the custom shader name to use
  77463. */
  77464. shaderName: string;
  77465. /**
  77466. * The list of attribute names used in the shader
  77467. */
  77468. attributes?: string[];
  77469. /**
  77470. * The list of unifrom names used in the shader
  77471. */
  77472. uniforms?: string[];
  77473. /**
  77474. * The list of sampler names used in the shader
  77475. */
  77476. samplers?: string[];
  77477. /**
  77478. * The list of defines used in the shader
  77479. */
  77480. defines?: string[];
  77481. }
  77482. /**
  77483. * Interface to implement to create a shadow generator compatible with BJS.
  77484. */
  77485. export interface IShadowGenerator {
  77486. /**
  77487. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77488. * @returns The render target texture if present otherwise, null
  77489. */
  77490. getShadowMap(): Nullable<RenderTargetTexture>;
  77491. /**
  77492. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77493. * @returns The render target texture if the shadow map is present otherwise, null
  77494. */
  77495. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77496. /**
  77497. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77498. * @param subMesh The submesh we want to render in the shadow map
  77499. * @param useInstances Defines wether will draw in the map using instances
  77500. * @returns true if ready otherwise, false
  77501. */
  77502. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77503. /**
  77504. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77505. * @param defines Defines of the material we want to update
  77506. * @param lightIndex Index of the light in the enabled light list of the material
  77507. */
  77508. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77509. /**
  77510. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77511. * defined in the generator but impacting the effect).
  77512. * It implies the unifroms available on the materials are the standard BJS ones.
  77513. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77514. * @param effect The effect we are binfing the information for
  77515. */
  77516. bindShadowLight(lightIndex: string, effect: Effect): void;
  77517. /**
  77518. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77519. * (eq to shadow prjection matrix * light transform matrix)
  77520. * @returns The transform matrix used to create the shadow map
  77521. */
  77522. getTransformMatrix(): Matrix;
  77523. /**
  77524. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77525. * Cube and 2D textures for instance.
  77526. */
  77527. recreateShadowMap(): void;
  77528. /**
  77529. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77530. * @param onCompiled Callback triggered at the and of the effects compilation
  77531. * @param options Sets of optional options forcing the compilation with different modes
  77532. */
  77533. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77534. useInstances: boolean;
  77535. }>): void;
  77536. /**
  77537. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77538. * @param options Sets of optional options forcing the compilation with different modes
  77539. * @returns A promise that resolves when the compilation completes
  77540. */
  77541. forceCompilationAsync(options?: Partial<{
  77542. useInstances: boolean;
  77543. }>): Promise<void>;
  77544. /**
  77545. * Serializes the shadow generator setup to a json object.
  77546. * @returns The serialized JSON object
  77547. */
  77548. serialize(): any;
  77549. /**
  77550. * Disposes the Shadow map and related Textures and effects.
  77551. */
  77552. dispose(): void;
  77553. }
  77554. /**
  77555. * Default implementation IShadowGenerator.
  77556. * This is the main object responsible of generating shadows in the framework.
  77557. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77558. */
  77559. export class ShadowGenerator implements IShadowGenerator {
  77560. /**
  77561. * Shadow generator mode None: no filtering applied.
  77562. */
  77563. static readonly FILTER_NONE: number;
  77564. /**
  77565. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77566. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77567. */
  77568. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77569. /**
  77570. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77571. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77572. */
  77573. static readonly FILTER_POISSONSAMPLING: number;
  77574. /**
  77575. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77576. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77577. */
  77578. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77579. /**
  77580. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77581. * edge artifacts on steep falloff.
  77582. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77583. */
  77584. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77585. /**
  77586. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77587. * edge artifacts on steep falloff.
  77588. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77589. */
  77590. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77591. /**
  77592. * Shadow generator mode PCF: Percentage Closer Filtering
  77593. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77594. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77595. */
  77596. static readonly FILTER_PCF: number;
  77597. /**
  77598. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77599. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77600. * Contact Hardening
  77601. */
  77602. static readonly FILTER_PCSS: number;
  77603. /**
  77604. * Reserved for PCF and PCSS
  77605. * Highest Quality.
  77606. *
  77607. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77608. *
  77609. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77610. */
  77611. static readonly QUALITY_HIGH: number;
  77612. /**
  77613. * Reserved for PCF and PCSS
  77614. * Good tradeoff for quality/perf cross devices
  77615. *
  77616. * Execute PCF on a 3*3 kernel.
  77617. *
  77618. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77619. */
  77620. static readonly QUALITY_MEDIUM: number;
  77621. /**
  77622. * Reserved for PCF and PCSS
  77623. * The lowest quality but the fastest.
  77624. *
  77625. * Execute PCF on a 1*1 kernel.
  77626. *
  77627. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77628. */
  77629. static readonly QUALITY_LOW: number;
  77630. /** Gets or sets the custom shader name to use */
  77631. customShaderOptions: ICustomShaderOptions;
  77632. /**
  77633. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77634. */
  77635. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77636. /**
  77637. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77638. */
  77639. onAfterShadowMapRenderObservable: Observable<Effect>;
  77640. /**
  77641. * Observable triggered before a mesh is rendered in the shadow map.
  77642. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77643. */
  77644. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77645. /**
  77646. * Observable triggered after a mesh is rendered in the shadow map.
  77647. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77648. */
  77649. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77650. private _bias;
  77651. /**
  77652. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77653. */
  77654. /**
  77655. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77656. */
  77657. bias: number;
  77658. private _normalBias;
  77659. /**
  77660. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77661. */
  77662. /**
  77663. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77664. */
  77665. normalBias: number;
  77666. private _blurBoxOffset;
  77667. /**
  77668. * Gets the blur box offset: offset applied during the blur pass.
  77669. * Only useful if useKernelBlur = false
  77670. */
  77671. /**
  77672. * Sets the blur box offset: offset applied during the blur pass.
  77673. * Only useful if useKernelBlur = false
  77674. */
  77675. blurBoxOffset: number;
  77676. private _blurScale;
  77677. /**
  77678. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77679. * 2 means half of the size.
  77680. */
  77681. /**
  77682. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77683. * 2 means half of the size.
  77684. */
  77685. blurScale: number;
  77686. private _blurKernel;
  77687. /**
  77688. * Gets the blur kernel: kernel size of the blur pass.
  77689. * Only useful if useKernelBlur = true
  77690. */
  77691. /**
  77692. * Sets the blur kernel: kernel size of the blur pass.
  77693. * Only useful if useKernelBlur = true
  77694. */
  77695. blurKernel: number;
  77696. private _useKernelBlur;
  77697. /**
  77698. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77699. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77700. */
  77701. /**
  77702. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77703. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77704. */
  77705. useKernelBlur: boolean;
  77706. private _depthScale;
  77707. /**
  77708. * Gets the depth scale used in ESM mode.
  77709. */
  77710. /**
  77711. * Sets the depth scale used in ESM mode.
  77712. * This can override the scale stored on the light.
  77713. */
  77714. depthScale: number;
  77715. private _filter;
  77716. /**
  77717. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77718. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77719. */
  77720. /**
  77721. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77722. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77723. */
  77724. filter: number;
  77725. /**
  77726. * Gets if the current filter is set to Poisson Sampling.
  77727. */
  77728. /**
  77729. * Sets the current filter to Poisson Sampling.
  77730. */
  77731. usePoissonSampling: boolean;
  77732. /**
  77733. * Gets if the current filter is set to ESM.
  77734. */
  77735. /**
  77736. * Sets the current filter is to ESM.
  77737. */
  77738. useExponentialShadowMap: boolean;
  77739. /**
  77740. * Gets if the current filter is set to filtered ESM.
  77741. */
  77742. /**
  77743. * Gets if the current filter is set to filtered ESM.
  77744. */
  77745. useBlurExponentialShadowMap: boolean;
  77746. /**
  77747. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77748. * exponential to prevent steep falloff artifacts).
  77749. */
  77750. /**
  77751. * Sets the current filter to "close ESM" (using the inverse of the
  77752. * exponential to prevent steep falloff artifacts).
  77753. */
  77754. useCloseExponentialShadowMap: boolean;
  77755. /**
  77756. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77757. * exponential to prevent steep falloff artifacts).
  77758. */
  77759. /**
  77760. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77761. * exponential to prevent steep falloff artifacts).
  77762. */
  77763. useBlurCloseExponentialShadowMap: boolean;
  77764. /**
  77765. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  77766. */
  77767. /**
  77768. * Sets the current filter to "PCF" (percentage closer filtering).
  77769. */
  77770. usePercentageCloserFiltering: boolean;
  77771. private _filteringQuality;
  77772. /**
  77773. * Gets the PCF or PCSS Quality.
  77774. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77775. */
  77776. /**
  77777. * Sets the PCF or PCSS Quality.
  77778. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77779. */
  77780. filteringQuality: number;
  77781. /**
  77782. * Gets if the current filter is set to "PCSS" (contact hardening).
  77783. */
  77784. /**
  77785. * Sets the current filter to "PCSS" (contact hardening).
  77786. */
  77787. useContactHardeningShadow: boolean;
  77788. private _contactHardeningLightSizeUVRatio;
  77789. /**
  77790. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77791. * Using a ratio helps keeping shape stability independently of the map size.
  77792. *
  77793. * It does not account for the light projection as it was having too much
  77794. * instability during the light setup or during light position changes.
  77795. *
  77796. * Only valid if useContactHardeningShadow is true.
  77797. */
  77798. /**
  77799. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77800. * Using a ratio helps keeping shape stability independently of the map size.
  77801. *
  77802. * It does not account for the light projection as it was having too much
  77803. * instability during the light setup or during light position changes.
  77804. *
  77805. * Only valid if useContactHardeningShadow is true.
  77806. */
  77807. contactHardeningLightSizeUVRatio: number;
  77808. private _darkness;
  77809. /** Gets or sets the actual darkness of a shadow */
  77810. darkness: number;
  77811. /**
  77812. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77813. * 0 means strongest and 1 would means no shadow.
  77814. * @returns the darkness.
  77815. */
  77816. getDarkness(): number;
  77817. /**
  77818. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77819. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77820. * @returns the shadow generator allowing fluent coding.
  77821. */
  77822. setDarkness(darkness: number): ShadowGenerator;
  77823. private _transparencyShadow;
  77824. /** Gets or sets the ability to have transparent shadow */
  77825. transparencyShadow: boolean;
  77826. /**
  77827. * Sets the ability to have transparent shadow (boolean).
  77828. * @param transparent True if transparent else False
  77829. * @returns the shadow generator allowing fluent coding
  77830. */
  77831. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77832. private _shadowMap;
  77833. private _shadowMap2;
  77834. /**
  77835. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77836. * @returns The render target texture if present otherwise, null
  77837. */
  77838. getShadowMap(): Nullable<RenderTargetTexture>;
  77839. /**
  77840. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77841. * @returns The render target texture if the shadow map is present otherwise, null
  77842. */
  77843. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77844. /**
  77845. * Gets the class name of that object
  77846. * @returns "ShadowGenerator"
  77847. */
  77848. getClassName(): string;
  77849. /**
  77850. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77851. * @param mesh Mesh to add
  77852. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77853. * @returns the Shadow Generator itself
  77854. */
  77855. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77856. /**
  77857. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77858. * @param mesh Mesh to remove
  77859. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77860. * @returns the Shadow Generator itself
  77861. */
  77862. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77863. /**
  77864. * Controls the extent to which the shadows fade out at the edge of the frustum
  77865. * Used only by directionals and spots
  77866. */
  77867. frustumEdgeFalloff: number;
  77868. private _light;
  77869. /**
  77870. * Returns the associated light object.
  77871. * @returns the light generating the shadow
  77872. */
  77873. getLight(): IShadowLight;
  77874. /**
  77875. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77876. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77877. * It might on the other hand introduce peter panning.
  77878. */
  77879. forceBackFacesOnly: boolean;
  77880. private _scene;
  77881. private _lightDirection;
  77882. private _effect;
  77883. private _viewMatrix;
  77884. private _projectionMatrix;
  77885. private _transformMatrix;
  77886. private _cachedPosition;
  77887. private _cachedDirection;
  77888. private _cachedDefines;
  77889. private _currentRenderID;
  77890. private _boxBlurPostprocess;
  77891. private _kernelBlurXPostprocess;
  77892. private _kernelBlurYPostprocess;
  77893. private _blurPostProcesses;
  77894. private _mapSize;
  77895. private _currentFaceIndex;
  77896. private _currentFaceIndexCache;
  77897. private _textureType;
  77898. private _defaultTextureMatrix;
  77899. private _storedUniqueId;
  77900. /** @hidden */
  77901. static _SceneComponentInitialization: (scene: Scene) => void;
  77902. /**
  77903. * Creates a ShadowGenerator object.
  77904. * A ShadowGenerator is the required tool to use the shadows.
  77905. * Each light casting shadows needs to use its own ShadowGenerator.
  77906. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77907. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77908. * @param light The light object generating the shadows.
  77909. * @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.
  77910. */
  77911. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77912. private _initializeGenerator;
  77913. private _initializeShadowMap;
  77914. private _initializeBlurRTTAndPostProcesses;
  77915. private _renderForShadowMap;
  77916. private _renderSubMeshForShadowMap;
  77917. private _applyFilterValues;
  77918. /**
  77919. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77920. * @param onCompiled Callback triggered at the and of the effects compilation
  77921. * @param options Sets of optional options forcing the compilation with different modes
  77922. */
  77923. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77924. useInstances: boolean;
  77925. }>): void;
  77926. /**
  77927. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77928. * @param options Sets of optional options forcing the compilation with different modes
  77929. * @returns A promise that resolves when the compilation completes
  77930. */
  77931. forceCompilationAsync(options?: Partial<{
  77932. useInstances: boolean;
  77933. }>): Promise<void>;
  77934. /**
  77935. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77936. * @param subMesh The submesh we want to render in the shadow map
  77937. * @param useInstances Defines wether will draw in the map using instances
  77938. * @returns true if ready otherwise, false
  77939. */
  77940. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77941. /**
  77942. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77943. * @param defines Defines of the material we want to update
  77944. * @param lightIndex Index of the light in the enabled light list of the material
  77945. */
  77946. prepareDefines(defines: any, lightIndex: number): void;
  77947. /**
  77948. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77949. * defined in the generator but impacting the effect).
  77950. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77951. * @param effect The effect we are binfing the information for
  77952. */
  77953. bindShadowLight(lightIndex: string, effect: Effect): void;
  77954. /**
  77955. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77956. * (eq to shadow prjection matrix * light transform matrix)
  77957. * @returns The transform matrix used to create the shadow map
  77958. */
  77959. getTransformMatrix(): Matrix;
  77960. /**
  77961. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77962. * Cube and 2D textures for instance.
  77963. */
  77964. recreateShadowMap(): void;
  77965. private _disposeBlurPostProcesses;
  77966. private _disposeRTTandPostProcesses;
  77967. /**
  77968. * Disposes the ShadowGenerator.
  77969. * Returns nothing.
  77970. */
  77971. dispose(): void;
  77972. /**
  77973. * Serializes the shadow generator setup to a json object.
  77974. * @returns The serialized JSON object
  77975. */
  77976. serialize(): any;
  77977. /**
  77978. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77979. * @param parsedShadowGenerator The JSON object to parse
  77980. * @param scene The scene to create the shadow map for
  77981. * @returns The parsed shadow generator
  77982. */
  77983. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77984. }
  77985. }
  77986. declare module BABYLON {
  77987. /**
  77988. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77989. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77990. * 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.
  77991. */
  77992. export abstract class Light extends Node {
  77993. /**
  77994. * Falloff Default: light is falling off following the material specification:
  77995. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77996. */
  77997. static readonly FALLOFF_DEFAULT: number;
  77998. /**
  77999. * Falloff Physical: light is falling off following the inverse squared distance law.
  78000. */
  78001. static readonly FALLOFF_PHYSICAL: number;
  78002. /**
  78003. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  78004. * to enhance interoperability with other engines.
  78005. */
  78006. static readonly FALLOFF_GLTF: number;
  78007. /**
  78008. * Falloff Standard: light is falling off like in the standard material
  78009. * to enhance interoperability with other materials.
  78010. */
  78011. static readonly FALLOFF_STANDARD: number;
  78012. /**
  78013. * If every light affecting the material is in this lightmapMode,
  78014. * material.lightmapTexture adds or multiplies
  78015. * (depends on material.useLightmapAsShadowmap)
  78016. * after every other light calculations.
  78017. */
  78018. static readonly LIGHTMAP_DEFAULT: number;
  78019. /**
  78020. * material.lightmapTexture as only diffuse lighting from this light
  78021. * adds only specular lighting from this light
  78022. * adds dynamic shadows
  78023. */
  78024. static readonly LIGHTMAP_SPECULAR: number;
  78025. /**
  78026. * material.lightmapTexture as only lighting
  78027. * no light calculation from this light
  78028. * only adds dynamic shadows from this light
  78029. */
  78030. static readonly LIGHTMAP_SHADOWSONLY: number;
  78031. /**
  78032. * Each light type uses the default quantity according to its type:
  78033. * point/spot lights use luminous intensity
  78034. * directional lights use illuminance
  78035. */
  78036. static readonly INTENSITYMODE_AUTOMATIC: number;
  78037. /**
  78038. * lumen (lm)
  78039. */
  78040. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78041. /**
  78042. * candela (lm/sr)
  78043. */
  78044. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78045. /**
  78046. * lux (lm/m^2)
  78047. */
  78048. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78049. /**
  78050. * nit (cd/m^2)
  78051. */
  78052. static readonly INTENSITYMODE_LUMINANCE: number;
  78053. /**
  78054. * Light type const id of the point light.
  78055. */
  78056. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78057. /**
  78058. * Light type const id of the directional light.
  78059. */
  78060. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78061. /**
  78062. * Light type const id of the spot light.
  78063. */
  78064. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78065. /**
  78066. * Light type const id of the hemispheric light.
  78067. */
  78068. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78069. /**
  78070. * Diffuse gives the basic color to an object.
  78071. */
  78072. diffuse: Color3;
  78073. /**
  78074. * Specular produces a highlight color on an object.
  78075. * Note: This is note affecting PBR materials.
  78076. */
  78077. specular: Color3;
  78078. /**
  78079. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78080. * falling off base on range or angle.
  78081. * This can be set to any values in Light.FALLOFF_x.
  78082. *
  78083. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78084. * other types of materials.
  78085. */
  78086. falloffType: number;
  78087. /**
  78088. * Strength of the light.
  78089. * Note: By default it is define in the framework own unit.
  78090. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78091. */
  78092. intensity: number;
  78093. private _range;
  78094. protected _inverseSquaredRange: number;
  78095. /**
  78096. * Defines how far from the source the light is impacting in scene units.
  78097. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78098. */
  78099. /**
  78100. * Defines how far from the source the light is impacting in scene units.
  78101. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78102. */
  78103. range: number;
  78104. /**
  78105. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78106. * of light.
  78107. */
  78108. private _photometricScale;
  78109. private _intensityMode;
  78110. /**
  78111. * Gets the photometric scale used to interpret the intensity.
  78112. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78113. */
  78114. /**
  78115. * Sets the photometric scale used to interpret the intensity.
  78116. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78117. */
  78118. intensityMode: number;
  78119. private _radius;
  78120. /**
  78121. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78122. */
  78123. /**
  78124. * sets the light radius used by PBR Materials to simulate soft area lights.
  78125. */
  78126. radius: number;
  78127. private _renderPriority;
  78128. /**
  78129. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78130. * exceeding the number allowed of the materials.
  78131. */
  78132. renderPriority: number;
  78133. private _shadowEnabled;
  78134. /**
  78135. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78136. * the current shadow generator.
  78137. */
  78138. /**
  78139. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78140. * the current shadow generator.
  78141. */
  78142. shadowEnabled: boolean;
  78143. private _includedOnlyMeshes;
  78144. /**
  78145. * Gets the only meshes impacted by this light.
  78146. */
  78147. /**
  78148. * Sets the only meshes impacted by this light.
  78149. */
  78150. includedOnlyMeshes: AbstractMesh[];
  78151. private _excludedMeshes;
  78152. /**
  78153. * Gets the meshes not impacted by this light.
  78154. */
  78155. /**
  78156. * Sets the meshes not impacted by this light.
  78157. */
  78158. excludedMeshes: AbstractMesh[];
  78159. private _excludeWithLayerMask;
  78160. /**
  78161. * Gets the layer id use to find what meshes are not impacted by the light.
  78162. * Inactive if 0
  78163. */
  78164. /**
  78165. * Sets the layer id use to find what meshes are not impacted by the light.
  78166. * Inactive if 0
  78167. */
  78168. excludeWithLayerMask: number;
  78169. private _includeOnlyWithLayerMask;
  78170. /**
  78171. * Gets the layer id use to find what meshes are impacted by the light.
  78172. * Inactive if 0
  78173. */
  78174. /**
  78175. * Sets the layer id use to find what meshes are impacted by the light.
  78176. * Inactive if 0
  78177. */
  78178. includeOnlyWithLayerMask: number;
  78179. private _lightmapMode;
  78180. /**
  78181. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78182. */
  78183. /**
  78184. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78185. */
  78186. lightmapMode: number;
  78187. /**
  78188. * Shadow generator associted to the light.
  78189. * @hidden Internal use only.
  78190. */
  78191. _shadowGenerator: Nullable<IShadowGenerator>;
  78192. /**
  78193. * @hidden Internal use only.
  78194. */
  78195. _excludedMeshesIds: string[];
  78196. /**
  78197. * @hidden Internal use only.
  78198. */
  78199. _includedOnlyMeshesIds: string[];
  78200. /**
  78201. * The current light unifom buffer.
  78202. * @hidden Internal use only.
  78203. */
  78204. _uniformBuffer: UniformBuffer;
  78205. /** @hidden */
  78206. _renderId: number;
  78207. /**
  78208. * Creates a Light object in the scene.
  78209. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78210. * @param name The firendly name of the light
  78211. * @param scene The scene the light belongs too
  78212. */
  78213. constructor(name: string, scene: Scene);
  78214. protected abstract _buildUniformLayout(): void;
  78215. /**
  78216. * Sets the passed Effect "effect" with the Light information.
  78217. * @param effect The effect to update
  78218. * @param lightIndex The index of the light in the effect to update
  78219. * @returns The light
  78220. */
  78221. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  78222. /**
  78223. * Sets the passed Effect "effect" with the Light information.
  78224. * @param effect The effect to update
  78225. * @param lightDataUniformName The uniform used to store light data (position or direction)
  78226. * @returns The light
  78227. */
  78228. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  78229. /**
  78230. * Returns the string "Light".
  78231. * @returns the class name
  78232. */
  78233. getClassName(): string;
  78234. /** @hidden */
  78235. readonly _isLight: boolean;
  78236. /**
  78237. * Converts the light information to a readable string for debug purpose.
  78238. * @param fullDetails Supports for multiple levels of logging within scene loading
  78239. * @returns the human readable light info
  78240. */
  78241. toString(fullDetails?: boolean): string;
  78242. /** @hidden */
  78243. protected _syncParentEnabledState(): void;
  78244. /**
  78245. * Set the enabled state of this node.
  78246. * @param value - the new enabled state
  78247. */
  78248. setEnabled(value: boolean): void;
  78249. /**
  78250. * Returns the Light associated shadow generator if any.
  78251. * @return the associated shadow generator.
  78252. */
  78253. getShadowGenerator(): Nullable<IShadowGenerator>;
  78254. /**
  78255. * Returns a Vector3, the absolute light position in the World.
  78256. * @returns the world space position of the light
  78257. */
  78258. getAbsolutePosition(): Vector3;
  78259. /**
  78260. * Specifies if the light will affect the passed mesh.
  78261. * @param mesh The mesh to test against the light
  78262. * @return true the mesh is affected otherwise, false.
  78263. */
  78264. canAffectMesh(mesh: AbstractMesh): boolean;
  78265. /**
  78266. * Sort function to order lights for rendering.
  78267. * @param a First Light object to compare to second.
  78268. * @param b Second Light object to compare first.
  78269. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78270. */
  78271. static CompareLightsPriority(a: Light, b: Light): number;
  78272. /**
  78273. * Releases resources associated with this node.
  78274. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78275. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78276. */
  78277. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78278. /**
  78279. * Returns the light type ID (integer).
  78280. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78281. */
  78282. getTypeID(): number;
  78283. /**
  78284. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  78285. * @returns the scaled intensity in intensity mode unit
  78286. */
  78287. getScaledIntensity(): number;
  78288. /**
  78289. * Returns a new Light object, named "name", from the current one.
  78290. * @param name The name of the cloned light
  78291. * @returns the new created light
  78292. */
  78293. clone(name: string): Nullable<Light>;
  78294. /**
  78295. * Serializes the current light into a Serialization object.
  78296. * @returns the serialized object.
  78297. */
  78298. serialize(): any;
  78299. /**
  78300. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  78301. * This new light is named "name" and added to the passed scene.
  78302. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  78303. * @param name The friendly name of the light
  78304. * @param scene The scene the new light will belong to
  78305. * @returns the constructor function
  78306. */
  78307. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  78308. /**
  78309. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  78310. * @param parsedLight The JSON representation of the light
  78311. * @param scene The scene to create the parsed light in
  78312. * @returns the created light after parsing
  78313. */
  78314. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  78315. private _hookArrayForExcluded;
  78316. private _hookArrayForIncludedOnly;
  78317. private _resyncMeshes;
  78318. /**
  78319. * Forces the meshes to update their light related information in their rendering used effects
  78320. * @hidden Internal Use Only
  78321. */
  78322. _markMeshesAsLightDirty(): void;
  78323. /**
  78324. * Recomputes the cached photometric scale if needed.
  78325. */
  78326. private _computePhotometricScale;
  78327. /**
  78328. * Returns the Photometric Scale according to the light type and intensity mode.
  78329. */
  78330. private _getPhotometricScale;
  78331. /**
  78332. * Reorder the light in the scene according to their defined priority.
  78333. * @hidden Internal Use Only
  78334. */
  78335. _reorderLightsInScene(): void;
  78336. /**
  78337. * Prepares the list of defines specific to the light type.
  78338. * @param defines the list of defines
  78339. * @param lightIndex defines the index of the light for the effect
  78340. */
  78341. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78342. }
  78343. }
  78344. declare module BABYLON {
  78345. /**
  78346. * Interface used to define Action
  78347. */
  78348. export interface IAction {
  78349. /**
  78350. * Trigger for the action
  78351. */
  78352. trigger: number;
  78353. /** Options of the trigger */
  78354. triggerOptions: any;
  78355. /**
  78356. * Gets the trigger parameters
  78357. * @returns the trigger parameters
  78358. */
  78359. getTriggerParameter(): any;
  78360. /**
  78361. * Internal only - executes current action event
  78362. * @hidden
  78363. */
  78364. _executeCurrent(evt?: ActionEvent): void;
  78365. /**
  78366. * Serialize placeholder for child classes
  78367. * @param parent of child
  78368. * @returns the serialized object
  78369. */
  78370. serialize(parent: any): any;
  78371. /**
  78372. * Internal only
  78373. * @hidden
  78374. */
  78375. _prepare(): void;
  78376. /**
  78377. * Internal only - manager for action
  78378. * @hidden
  78379. */
  78380. _actionManager: AbstractActionManager;
  78381. /**
  78382. * Adds action to chain of actions, may be a DoNothingAction
  78383. * @param action defines the next action to execute
  78384. * @returns The action passed in
  78385. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78386. */
  78387. then(action: IAction): IAction;
  78388. }
  78389. /**
  78390. * The action to be carried out following a trigger
  78391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78392. */
  78393. export class Action implements IAction {
  78394. /** the trigger, with or without parameters, for the action */
  78395. triggerOptions: any;
  78396. /**
  78397. * Trigger for the action
  78398. */
  78399. trigger: number;
  78400. /**
  78401. * Internal only - manager for action
  78402. * @hidden
  78403. */
  78404. _actionManager: ActionManager;
  78405. private _nextActiveAction;
  78406. private _child;
  78407. private _condition?;
  78408. private _triggerParameter;
  78409. /**
  78410. * An event triggered prior to action being executed.
  78411. */
  78412. onBeforeExecuteObservable: Observable<Action>;
  78413. /**
  78414. * Creates a new Action
  78415. * @param triggerOptions the trigger, with or without parameters, for the action
  78416. * @param condition an optional determinant of action
  78417. */
  78418. constructor(
  78419. /** the trigger, with or without parameters, for the action */
  78420. triggerOptions: any, condition?: Condition);
  78421. /**
  78422. * Internal only
  78423. * @hidden
  78424. */
  78425. _prepare(): void;
  78426. /**
  78427. * Gets the trigger parameters
  78428. * @returns the trigger parameters
  78429. */
  78430. getTriggerParameter(): any;
  78431. /**
  78432. * Internal only - executes current action event
  78433. * @hidden
  78434. */
  78435. _executeCurrent(evt?: ActionEvent): void;
  78436. /**
  78437. * Execute placeholder for child classes
  78438. * @param evt optional action event
  78439. */
  78440. execute(evt?: ActionEvent): void;
  78441. /**
  78442. * Skips to next active action
  78443. */
  78444. skipToNextActiveAction(): void;
  78445. /**
  78446. * Adds action to chain of actions, may be a DoNothingAction
  78447. * @param action defines the next action to execute
  78448. * @returns The action passed in
  78449. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78450. */
  78451. then(action: Action): Action;
  78452. /**
  78453. * Internal only
  78454. * @hidden
  78455. */
  78456. _getProperty(propertyPath: string): string;
  78457. /**
  78458. * Internal only
  78459. * @hidden
  78460. */
  78461. _getEffectiveTarget(target: any, propertyPath: string): any;
  78462. /**
  78463. * Serialize placeholder for child classes
  78464. * @param parent of child
  78465. * @returns the serialized object
  78466. */
  78467. serialize(parent: any): any;
  78468. /**
  78469. * Internal only called by serialize
  78470. * @hidden
  78471. */
  78472. protected _serialize(serializedAction: any, parent?: any): any;
  78473. /**
  78474. * Internal only
  78475. * @hidden
  78476. */
  78477. static _SerializeValueAsString: (value: any) => string;
  78478. /**
  78479. * Internal only
  78480. * @hidden
  78481. */
  78482. static _GetTargetProperty: (target: Node | Scene) => {
  78483. name: string;
  78484. targetType: string;
  78485. value: string;
  78486. };
  78487. }
  78488. }
  78489. declare module BABYLON {
  78490. /**
  78491. * A Condition applied to an Action
  78492. */
  78493. export class Condition {
  78494. /**
  78495. * Internal only - manager for action
  78496. * @hidden
  78497. */
  78498. _actionManager: ActionManager;
  78499. /**
  78500. * Internal only
  78501. * @hidden
  78502. */
  78503. _evaluationId: number;
  78504. /**
  78505. * Internal only
  78506. * @hidden
  78507. */
  78508. _currentResult: boolean;
  78509. /**
  78510. * Creates a new Condition
  78511. * @param actionManager the manager of the action the condition is applied to
  78512. */
  78513. constructor(actionManager: ActionManager);
  78514. /**
  78515. * Check if the current condition is valid
  78516. * @returns a boolean
  78517. */
  78518. isValid(): boolean;
  78519. /**
  78520. * Internal only
  78521. * @hidden
  78522. */
  78523. _getProperty(propertyPath: string): string;
  78524. /**
  78525. * Internal only
  78526. * @hidden
  78527. */
  78528. _getEffectiveTarget(target: any, propertyPath: string): any;
  78529. /**
  78530. * Serialize placeholder for child classes
  78531. * @returns the serialized object
  78532. */
  78533. serialize(): any;
  78534. /**
  78535. * Internal only
  78536. * @hidden
  78537. */
  78538. protected _serialize(serializedCondition: any): any;
  78539. }
  78540. /**
  78541. * Defines specific conditional operators as extensions of Condition
  78542. */
  78543. export class ValueCondition extends Condition {
  78544. /** path to specify the property of the target the conditional operator uses */
  78545. propertyPath: string;
  78546. /** the value compared by the conditional operator against the current value of the property */
  78547. value: any;
  78548. /** the conditional operator, default ValueCondition.IsEqual */
  78549. operator: number;
  78550. /**
  78551. * Internal only
  78552. * @hidden
  78553. */
  78554. private static _IsEqual;
  78555. /**
  78556. * Internal only
  78557. * @hidden
  78558. */
  78559. private static _IsDifferent;
  78560. /**
  78561. * Internal only
  78562. * @hidden
  78563. */
  78564. private static _IsGreater;
  78565. /**
  78566. * Internal only
  78567. * @hidden
  78568. */
  78569. private static _IsLesser;
  78570. /**
  78571. * returns the number for IsEqual
  78572. */
  78573. static readonly IsEqual: number;
  78574. /**
  78575. * Returns the number for IsDifferent
  78576. */
  78577. static readonly IsDifferent: number;
  78578. /**
  78579. * Returns the number for IsGreater
  78580. */
  78581. static readonly IsGreater: number;
  78582. /**
  78583. * Returns the number for IsLesser
  78584. */
  78585. static readonly IsLesser: number;
  78586. /**
  78587. * Internal only The action manager for the condition
  78588. * @hidden
  78589. */
  78590. _actionManager: ActionManager;
  78591. /**
  78592. * Internal only
  78593. * @hidden
  78594. */
  78595. private _target;
  78596. /**
  78597. * Internal only
  78598. * @hidden
  78599. */
  78600. private _effectiveTarget;
  78601. /**
  78602. * Internal only
  78603. * @hidden
  78604. */
  78605. private _property;
  78606. /**
  78607. * Creates a new ValueCondition
  78608. * @param actionManager manager for the action the condition applies to
  78609. * @param target for the action
  78610. * @param propertyPath path to specify the property of the target the conditional operator uses
  78611. * @param value the value compared by the conditional operator against the current value of the property
  78612. * @param operator the conditional operator, default ValueCondition.IsEqual
  78613. */
  78614. constructor(actionManager: ActionManager, target: any,
  78615. /** path to specify the property of the target the conditional operator uses */
  78616. propertyPath: string,
  78617. /** the value compared by the conditional operator against the current value of the property */
  78618. value: any,
  78619. /** the conditional operator, default ValueCondition.IsEqual */
  78620. operator?: number);
  78621. /**
  78622. * Compares the given value with the property value for the specified conditional operator
  78623. * @returns the result of the comparison
  78624. */
  78625. isValid(): boolean;
  78626. /**
  78627. * Serialize the ValueCondition into a JSON compatible object
  78628. * @returns serialization object
  78629. */
  78630. serialize(): any;
  78631. /**
  78632. * Gets the name of the conditional operator for the ValueCondition
  78633. * @param operator the conditional operator
  78634. * @returns the name
  78635. */
  78636. static GetOperatorName(operator: number): string;
  78637. }
  78638. /**
  78639. * Defines a predicate condition as an extension of Condition
  78640. */
  78641. export class PredicateCondition extends Condition {
  78642. /** defines the predicate function used to validate the condition */
  78643. predicate: () => boolean;
  78644. /**
  78645. * Internal only - manager for action
  78646. * @hidden
  78647. */
  78648. _actionManager: ActionManager;
  78649. /**
  78650. * Creates a new PredicateCondition
  78651. * @param actionManager manager for the action the condition applies to
  78652. * @param predicate defines the predicate function used to validate the condition
  78653. */
  78654. constructor(actionManager: ActionManager,
  78655. /** defines the predicate function used to validate the condition */
  78656. predicate: () => boolean);
  78657. /**
  78658. * @returns the validity of the predicate condition
  78659. */
  78660. isValid(): boolean;
  78661. }
  78662. /**
  78663. * Defines a state condition as an extension of Condition
  78664. */
  78665. export class StateCondition extends Condition {
  78666. /** Value to compare with target state */
  78667. value: string;
  78668. /**
  78669. * Internal only - manager for action
  78670. * @hidden
  78671. */
  78672. _actionManager: ActionManager;
  78673. /**
  78674. * Internal only
  78675. * @hidden
  78676. */
  78677. private _target;
  78678. /**
  78679. * Creates a new StateCondition
  78680. * @param actionManager manager for the action the condition applies to
  78681. * @param target of the condition
  78682. * @param value to compare with target state
  78683. */
  78684. constructor(actionManager: ActionManager, target: any,
  78685. /** Value to compare with target state */
  78686. value: string);
  78687. /**
  78688. * Gets a boolean indicating if the current condition is met
  78689. * @returns the validity of the state
  78690. */
  78691. isValid(): boolean;
  78692. /**
  78693. * Serialize the StateCondition into a JSON compatible object
  78694. * @returns serialization object
  78695. */
  78696. serialize(): any;
  78697. }
  78698. }
  78699. declare module BABYLON {
  78700. /**
  78701. * This defines an action responsible to toggle a boolean once triggered.
  78702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78703. */
  78704. export class SwitchBooleanAction extends Action {
  78705. /**
  78706. * The path to the boolean property in the target object
  78707. */
  78708. propertyPath: string;
  78709. private _target;
  78710. private _effectiveTarget;
  78711. private _property;
  78712. /**
  78713. * Instantiate the action
  78714. * @param triggerOptions defines the trigger options
  78715. * @param target defines the object containing the boolean
  78716. * @param propertyPath defines the path to the boolean property in the target object
  78717. * @param condition defines the trigger related conditions
  78718. */
  78719. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78720. /** @hidden */
  78721. _prepare(): void;
  78722. /**
  78723. * Execute the action toggle the boolean value.
  78724. */
  78725. execute(): void;
  78726. /**
  78727. * Serializes the actions and its related information.
  78728. * @param parent defines the object to serialize in
  78729. * @returns the serialized object
  78730. */
  78731. serialize(parent: any): any;
  78732. }
  78733. /**
  78734. * This defines an action responsible to set a the state field of the target
  78735. * to a desired value once triggered.
  78736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78737. */
  78738. export class SetStateAction extends Action {
  78739. /**
  78740. * The value to store in the state field.
  78741. */
  78742. value: string;
  78743. private _target;
  78744. /**
  78745. * Instantiate the action
  78746. * @param triggerOptions defines the trigger options
  78747. * @param target defines the object containing the state property
  78748. * @param value defines the value to store in the state field
  78749. * @param condition defines the trigger related conditions
  78750. */
  78751. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78752. /**
  78753. * Execute the action and store the value on the target state property.
  78754. */
  78755. execute(): void;
  78756. /**
  78757. * Serializes the actions and its related information.
  78758. * @param parent defines the object to serialize in
  78759. * @returns the serialized object
  78760. */
  78761. serialize(parent: any): any;
  78762. }
  78763. /**
  78764. * This defines an action responsible to set a property of the target
  78765. * to a desired value once triggered.
  78766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78767. */
  78768. export class SetValueAction extends Action {
  78769. /**
  78770. * The path of the property to set in the target.
  78771. */
  78772. propertyPath: string;
  78773. /**
  78774. * The value to set in the property
  78775. */
  78776. value: any;
  78777. private _target;
  78778. private _effectiveTarget;
  78779. private _property;
  78780. /**
  78781. * Instantiate the action
  78782. * @param triggerOptions defines the trigger options
  78783. * @param target defines the object containing the property
  78784. * @param propertyPath defines the path of the property to set in the target
  78785. * @param value defines the value to set in the property
  78786. * @param condition defines the trigger related conditions
  78787. */
  78788. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78789. /** @hidden */
  78790. _prepare(): void;
  78791. /**
  78792. * Execute the action and set the targetted property to the desired value.
  78793. */
  78794. execute(): void;
  78795. /**
  78796. * Serializes the actions and its related information.
  78797. * @param parent defines the object to serialize in
  78798. * @returns the serialized object
  78799. */
  78800. serialize(parent: any): any;
  78801. }
  78802. /**
  78803. * This defines an action responsible to increment the target value
  78804. * to a desired value once triggered.
  78805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78806. */
  78807. export class IncrementValueAction extends Action {
  78808. /**
  78809. * The path of the property to increment in the target.
  78810. */
  78811. propertyPath: string;
  78812. /**
  78813. * The value we should increment the property by.
  78814. */
  78815. value: any;
  78816. private _target;
  78817. private _effectiveTarget;
  78818. private _property;
  78819. /**
  78820. * Instantiate the action
  78821. * @param triggerOptions defines the trigger options
  78822. * @param target defines the object containing the property
  78823. * @param propertyPath defines the path of the property to increment in the target
  78824. * @param value defines the value value we should increment the property by
  78825. * @param condition defines the trigger related conditions
  78826. */
  78827. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78828. /** @hidden */
  78829. _prepare(): void;
  78830. /**
  78831. * Execute the action and increment the target of the value amount.
  78832. */
  78833. execute(): void;
  78834. /**
  78835. * Serializes the actions and its related information.
  78836. * @param parent defines the object to serialize in
  78837. * @returns the serialized object
  78838. */
  78839. serialize(parent: any): any;
  78840. }
  78841. /**
  78842. * This defines an action responsible to start an animation once triggered.
  78843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78844. */
  78845. export class PlayAnimationAction extends Action {
  78846. /**
  78847. * Where the animation should start (animation frame)
  78848. */
  78849. from: number;
  78850. /**
  78851. * Where the animation should stop (animation frame)
  78852. */
  78853. to: number;
  78854. /**
  78855. * Define if the animation should loop or stop after the first play.
  78856. */
  78857. loop?: boolean;
  78858. private _target;
  78859. /**
  78860. * Instantiate the action
  78861. * @param triggerOptions defines the trigger options
  78862. * @param target defines the target animation or animation name
  78863. * @param from defines from where the animation should start (animation frame)
  78864. * @param end defines where the animation should stop (animation frame)
  78865. * @param loop defines if the animation should loop or stop after the first play
  78866. * @param condition defines the trigger related conditions
  78867. */
  78868. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78869. /** @hidden */
  78870. _prepare(): void;
  78871. /**
  78872. * Execute the action and play the animation.
  78873. */
  78874. execute(): void;
  78875. /**
  78876. * Serializes the actions and its related information.
  78877. * @param parent defines the object to serialize in
  78878. * @returns the serialized object
  78879. */
  78880. serialize(parent: any): any;
  78881. }
  78882. /**
  78883. * This defines an action responsible to stop an animation once triggered.
  78884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78885. */
  78886. export class StopAnimationAction extends Action {
  78887. private _target;
  78888. /**
  78889. * Instantiate the action
  78890. * @param triggerOptions defines the trigger options
  78891. * @param target defines the target animation or animation name
  78892. * @param condition defines the trigger related conditions
  78893. */
  78894. constructor(triggerOptions: any, target: any, condition?: Condition);
  78895. /** @hidden */
  78896. _prepare(): void;
  78897. /**
  78898. * Execute the action and stop the animation.
  78899. */
  78900. execute(): void;
  78901. /**
  78902. * Serializes the actions and its related information.
  78903. * @param parent defines the object to serialize in
  78904. * @returns the serialized object
  78905. */
  78906. serialize(parent: any): any;
  78907. }
  78908. /**
  78909. * This defines an action responsible that does nothing once triggered.
  78910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78911. */
  78912. export class DoNothingAction extends Action {
  78913. /**
  78914. * Instantiate the action
  78915. * @param triggerOptions defines the trigger options
  78916. * @param condition defines the trigger related conditions
  78917. */
  78918. constructor(triggerOptions?: any, condition?: Condition);
  78919. /**
  78920. * Execute the action and do nothing.
  78921. */
  78922. execute(): void;
  78923. /**
  78924. * Serializes the actions and its related information.
  78925. * @param parent defines the object to serialize in
  78926. * @returns the serialized object
  78927. */
  78928. serialize(parent: any): any;
  78929. }
  78930. /**
  78931. * This defines an action responsible to trigger several actions once triggered.
  78932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78933. */
  78934. export class CombineAction extends Action {
  78935. /**
  78936. * The list of aggregated animations to run.
  78937. */
  78938. children: Action[];
  78939. /**
  78940. * Instantiate the action
  78941. * @param triggerOptions defines the trigger options
  78942. * @param children defines the list of aggregated animations to run
  78943. * @param condition defines the trigger related conditions
  78944. */
  78945. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78946. /** @hidden */
  78947. _prepare(): void;
  78948. /**
  78949. * Execute the action and executes all the aggregated actions.
  78950. */
  78951. execute(evt: ActionEvent): void;
  78952. /**
  78953. * Serializes the actions and its related information.
  78954. * @param parent defines the object to serialize in
  78955. * @returns the serialized object
  78956. */
  78957. serialize(parent: any): any;
  78958. }
  78959. /**
  78960. * This defines an action responsible to run code (external event) once triggered.
  78961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78962. */
  78963. export class ExecuteCodeAction extends Action {
  78964. /**
  78965. * The callback function to run.
  78966. */
  78967. func: (evt: ActionEvent) => void;
  78968. /**
  78969. * Instantiate the action
  78970. * @param triggerOptions defines the trigger options
  78971. * @param func defines the callback function to run
  78972. * @param condition defines the trigger related conditions
  78973. */
  78974. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78975. /**
  78976. * Execute the action and run the attached code.
  78977. */
  78978. execute(evt: ActionEvent): void;
  78979. }
  78980. /**
  78981. * This defines an action responsible to set the parent property of the target once triggered.
  78982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78983. */
  78984. export class SetParentAction extends Action {
  78985. private _parent;
  78986. private _target;
  78987. /**
  78988. * Instantiate the action
  78989. * @param triggerOptions defines the trigger options
  78990. * @param target defines the target containing the parent property
  78991. * @param parent defines from where the animation should start (animation frame)
  78992. * @param condition defines the trigger related conditions
  78993. */
  78994. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78995. /** @hidden */
  78996. _prepare(): void;
  78997. /**
  78998. * Execute the action and set the parent property.
  78999. */
  79000. execute(): void;
  79001. /**
  79002. * Serializes the actions and its related information.
  79003. * @param parent defines the object to serialize in
  79004. * @returns the serialized object
  79005. */
  79006. serialize(parent: any): any;
  79007. }
  79008. }
  79009. declare module BABYLON {
  79010. /**
  79011. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  79012. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  79013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79014. */
  79015. export class ActionManager extends AbstractActionManager {
  79016. /**
  79017. * Nothing
  79018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79019. */
  79020. static readonly NothingTrigger: number;
  79021. /**
  79022. * On pick
  79023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79024. */
  79025. static readonly OnPickTrigger: number;
  79026. /**
  79027. * On left pick
  79028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79029. */
  79030. static readonly OnLeftPickTrigger: number;
  79031. /**
  79032. * On right pick
  79033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79034. */
  79035. static readonly OnRightPickTrigger: number;
  79036. /**
  79037. * On center pick
  79038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79039. */
  79040. static readonly OnCenterPickTrigger: number;
  79041. /**
  79042. * On pick down
  79043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79044. */
  79045. static readonly OnPickDownTrigger: number;
  79046. /**
  79047. * On double pick
  79048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79049. */
  79050. static readonly OnDoublePickTrigger: number;
  79051. /**
  79052. * On pick up
  79053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79054. */
  79055. static readonly OnPickUpTrigger: number;
  79056. /**
  79057. * On pick out.
  79058. * This trigger will only be raised if you also declared a OnPickDown
  79059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79060. */
  79061. static readonly OnPickOutTrigger: number;
  79062. /**
  79063. * On long press
  79064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79065. */
  79066. static readonly OnLongPressTrigger: number;
  79067. /**
  79068. * On pointer over
  79069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79070. */
  79071. static readonly OnPointerOverTrigger: number;
  79072. /**
  79073. * On pointer out
  79074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79075. */
  79076. static readonly OnPointerOutTrigger: number;
  79077. /**
  79078. * On every frame
  79079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79080. */
  79081. static readonly OnEveryFrameTrigger: number;
  79082. /**
  79083. * On intersection enter
  79084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79085. */
  79086. static readonly OnIntersectionEnterTrigger: number;
  79087. /**
  79088. * On intersection exit
  79089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79090. */
  79091. static readonly OnIntersectionExitTrigger: number;
  79092. /**
  79093. * On key down
  79094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79095. */
  79096. static readonly OnKeyDownTrigger: number;
  79097. /**
  79098. * On key up
  79099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79100. */
  79101. static readonly OnKeyUpTrigger: number;
  79102. private _scene;
  79103. /**
  79104. * Creates a new action manager
  79105. * @param scene defines the hosting scene
  79106. */
  79107. constructor(scene: Scene);
  79108. /**
  79109. * Releases all associated resources
  79110. */
  79111. dispose(): void;
  79112. /**
  79113. * Gets hosting scene
  79114. * @returns the hosting scene
  79115. */
  79116. getScene(): Scene;
  79117. /**
  79118. * Does this action manager handles actions of any of the given triggers
  79119. * @param triggers defines the triggers to be tested
  79120. * @return a boolean indicating whether one (or more) of the triggers is handled
  79121. */
  79122. hasSpecificTriggers(triggers: number[]): boolean;
  79123. /**
  79124. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79125. * speed.
  79126. * @param triggerA defines the trigger to be tested
  79127. * @param triggerB defines the trigger to be tested
  79128. * @return a boolean indicating whether one (or more) of the triggers is handled
  79129. */
  79130. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79131. /**
  79132. * Does this action manager handles actions of a given trigger
  79133. * @param trigger defines the trigger to be tested
  79134. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79135. * @return whether the trigger is handled
  79136. */
  79137. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79138. /**
  79139. * Does this action manager has pointer triggers
  79140. */
  79141. readonly hasPointerTriggers: boolean;
  79142. /**
  79143. * Does this action manager has pick triggers
  79144. */
  79145. readonly hasPickTriggers: boolean;
  79146. /**
  79147. * Registers an action to this action manager
  79148. * @param action defines the action to be registered
  79149. * @return the action amended (prepared) after registration
  79150. */
  79151. registerAction(action: IAction): Nullable<IAction>;
  79152. /**
  79153. * Unregisters an action to this action manager
  79154. * @param action defines the action to be unregistered
  79155. * @return a boolean indicating whether the action has been unregistered
  79156. */
  79157. unregisterAction(action: IAction): Boolean;
  79158. /**
  79159. * Process a specific trigger
  79160. * @param trigger defines the trigger to process
  79161. * @param evt defines the event details to be processed
  79162. */
  79163. processTrigger(trigger: number, evt?: IActionEvent): void;
  79164. /** @hidden */
  79165. _getEffectiveTarget(target: any, propertyPath: string): any;
  79166. /** @hidden */
  79167. _getProperty(propertyPath: string): string;
  79168. /**
  79169. * Serialize this manager to a JSON object
  79170. * @param name defines the property name to store this manager
  79171. * @returns a JSON representation of this manager
  79172. */
  79173. serialize(name: string): any;
  79174. /**
  79175. * Creates a new ActionManager from a JSON data
  79176. * @param parsedActions defines the JSON data to read from
  79177. * @param object defines the hosting mesh
  79178. * @param scene defines the hosting scene
  79179. */
  79180. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  79181. /**
  79182. * Get a trigger name by index
  79183. * @param trigger defines the trigger index
  79184. * @returns a trigger name
  79185. */
  79186. static GetTriggerName(trigger: number): string;
  79187. }
  79188. }
  79189. declare module BABYLON {
  79190. /**
  79191. * Class representing a ray with position and direction
  79192. */
  79193. export class Ray {
  79194. /** origin point */
  79195. origin: Vector3;
  79196. /** direction */
  79197. direction: Vector3;
  79198. /** length of the ray */
  79199. length: number;
  79200. private static readonly TmpVector3;
  79201. private _tmpRay;
  79202. /**
  79203. * Creates a new ray
  79204. * @param origin origin point
  79205. * @param direction direction
  79206. * @param length length of the ray
  79207. */
  79208. constructor(
  79209. /** origin point */
  79210. origin: Vector3,
  79211. /** direction */
  79212. direction: Vector3,
  79213. /** length of the ray */
  79214. length?: number);
  79215. /**
  79216. * Checks if the ray intersects a box
  79217. * @param minimum bound of the box
  79218. * @param maximum bound of the box
  79219. * @param intersectionTreshold extra extend to be added to the box in all direction
  79220. * @returns if the box was hit
  79221. */
  79222. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  79223. /**
  79224. * Checks if the ray intersects a box
  79225. * @param box the bounding box to check
  79226. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  79227. * @returns if the box was hit
  79228. */
  79229. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  79230. /**
  79231. * If the ray hits a sphere
  79232. * @param sphere the bounding sphere to check
  79233. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  79234. * @returns true if it hits the sphere
  79235. */
  79236. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  79237. /**
  79238. * If the ray hits a triange
  79239. * @param vertex0 triangle vertex
  79240. * @param vertex1 triangle vertex
  79241. * @param vertex2 triangle vertex
  79242. * @returns intersection information if hit
  79243. */
  79244. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  79245. /**
  79246. * Checks if ray intersects a plane
  79247. * @param plane the plane to check
  79248. * @returns the distance away it was hit
  79249. */
  79250. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  79251. /**
  79252. * Calculate the intercept of a ray on a given axis
  79253. * @param axis to check 'x' | 'y' | 'z'
  79254. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79255. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79256. */
  79257. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79258. /**
  79259. * Checks if ray intersects a mesh
  79260. * @param mesh the mesh to check
  79261. * @param fastCheck if only the bounding box should checked
  79262. * @returns picking info of the intersecton
  79263. */
  79264. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79265. /**
  79266. * Checks if ray intersects a mesh
  79267. * @param meshes the meshes to check
  79268. * @param fastCheck if only the bounding box should checked
  79269. * @param results array to store result in
  79270. * @returns Array of picking infos
  79271. */
  79272. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79273. private _comparePickingInfo;
  79274. private static smallnum;
  79275. private static rayl;
  79276. /**
  79277. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79278. * @param sega the first point of the segment to test the intersection against
  79279. * @param segb the second point of the segment to test the intersection against
  79280. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79281. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79282. */
  79283. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79284. /**
  79285. * Update the ray from viewport position
  79286. * @param x position
  79287. * @param y y position
  79288. * @param viewportWidth viewport width
  79289. * @param viewportHeight viewport height
  79290. * @param world world matrix
  79291. * @param view view matrix
  79292. * @param projection projection matrix
  79293. * @returns this ray updated
  79294. */
  79295. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79296. /**
  79297. * Creates a ray with origin and direction of 0,0,0
  79298. * @returns the new ray
  79299. */
  79300. static Zero(): Ray;
  79301. /**
  79302. * Creates a new ray from screen space and viewport
  79303. * @param x position
  79304. * @param y y position
  79305. * @param viewportWidth viewport width
  79306. * @param viewportHeight viewport height
  79307. * @param world world matrix
  79308. * @param view view matrix
  79309. * @param projection projection matrix
  79310. * @returns new ray
  79311. */
  79312. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79313. /**
  79314. * 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
  79315. * transformed to the given world matrix.
  79316. * @param origin The origin point
  79317. * @param end The end point
  79318. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79319. * @returns the new ray
  79320. */
  79321. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79322. /**
  79323. * Transforms a ray by a matrix
  79324. * @param ray ray to transform
  79325. * @param matrix matrix to apply
  79326. * @returns the resulting new ray
  79327. */
  79328. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79329. /**
  79330. * Transforms a ray by a matrix
  79331. * @param ray ray to transform
  79332. * @param matrix matrix to apply
  79333. * @param result ray to store result in
  79334. */
  79335. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79336. /**
  79337. * Unproject a ray from screen space to object space
  79338. * @param sourceX defines the screen space x coordinate to use
  79339. * @param sourceY defines the screen space y coordinate to use
  79340. * @param viewportWidth defines the current width of the viewport
  79341. * @param viewportHeight defines the current height of the viewport
  79342. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79343. * @param view defines the view matrix to use
  79344. * @param projection defines the projection matrix to use
  79345. */
  79346. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79347. }
  79348. /**
  79349. * Type used to define predicate used to select faces when a mesh intersection is detected
  79350. */
  79351. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79352. interface Scene {
  79353. /** @hidden */
  79354. _tempPickingRay: Nullable<Ray>;
  79355. /** @hidden */
  79356. _cachedRayForTransform: Ray;
  79357. /** @hidden */
  79358. _pickWithRayInverseMatrix: Matrix;
  79359. /** @hidden */
  79360. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79361. /** @hidden */
  79362. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79363. }
  79364. }
  79365. declare module BABYLON {
  79366. /**
  79367. * Groups all the scene component constants in one place to ease maintenance.
  79368. * @hidden
  79369. */
  79370. export class SceneComponentConstants {
  79371. static readonly NAME_EFFECTLAYER: string;
  79372. static readonly NAME_LAYER: string;
  79373. static readonly NAME_LENSFLARESYSTEM: string;
  79374. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79375. static readonly NAME_PARTICLESYSTEM: string;
  79376. static readonly NAME_GAMEPAD: string;
  79377. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79378. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79379. static readonly NAME_DEPTHRENDERER: string;
  79380. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79381. static readonly NAME_SPRITE: string;
  79382. static readonly NAME_OUTLINERENDERER: string;
  79383. static readonly NAME_PROCEDURALTEXTURE: string;
  79384. static readonly NAME_SHADOWGENERATOR: string;
  79385. static readonly NAME_OCTREE: string;
  79386. static readonly NAME_PHYSICSENGINE: string;
  79387. static readonly NAME_AUDIO: string;
  79388. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79389. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79390. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79391. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79392. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79393. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79394. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79395. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79396. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79397. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79398. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79399. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79400. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79401. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79402. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79403. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79404. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79405. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79406. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79407. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79408. static readonly STEP_AFTERRENDER_AUDIO: number;
  79409. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79410. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79411. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79412. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79413. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79414. static readonly STEP_POINTERMOVE_SPRITE: number;
  79415. static readonly STEP_POINTERDOWN_SPRITE: number;
  79416. static readonly STEP_POINTERUP_SPRITE: number;
  79417. }
  79418. /**
  79419. * This represents a scene component.
  79420. *
  79421. * This is used to decouple the dependency the scene is having on the different workloads like
  79422. * layers, post processes...
  79423. */
  79424. export interface ISceneComponent {
  79425. /**
  79426. * The name of the component. Each component must have a unique name.
  79427. */
  79428. name: string;
  79429. /**
  79430. * The scene the component belongs to.
  79431. */
  79432. scene: Scene;
  79433. /**
  79434. * Register the component to one instance of a scene.
  79435. */
  79436. register(): void;
  79437. /**
  79438. * Rebuilds the elements related to this component in case of
  79439. * context lost for instance.
  79440. */
  79441. rebuild(): void;
  79442. /**
  79443. * Disposes the component and the associated ressources.
  79444. */
  79445. dispose(): void;
  79446. }
  79447. /**
  79448. * This represents a SERIALIZABLE scene component.
  79449. *
  79450. * This extends Scene Component to add Serialization methods on top.
  79451. */
  79452. export interface ISceneSerializableComponent extends ISceneComponent {
  79453. /**
  79454. * Adds all the elements from the container to the scene
  79455. * @param container the container holding the elements
  79456. */
  79457. addFromContainer(container: AbstractScene): void;
  79458. /**
  79459. * Removes all the elements in the container from the scene
  79460. * @param container contains the elements to remove
  79461. * @param dispose if the removed element should be disposed (default: false)
  79462. */
  79463. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79464. /**
  79465. * Serializes the component data to the specified json object
  79466. * @param serializationObject The object to serialize to
  79467. */
  79468. serialize(serializationObject: any): void;
  79469. }
  79470. /**
  79471. * Strong typing of a Mesh related stage step action
  79472. */
  79473. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79474. /**
  79475. * Strong typing of a Evaluate Sub Mesh related stage step action
  79476. */
  79477. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79478. /**
  79479. * Strong typing of a Active Mesh related stage step action
  79480. */
  79481. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79482. /**
  79483. * Strong typing of a Camera related stage step action
  79484. */
  79485. export type CameraStageAction = (camera: Camera) => void;
  79486. /**
  79487. * Strong typing of a Camera Frame buffer related stage step action
  79488. */
  79489. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79490. /**
  79491. * Strong typing of a Render Target related stage step action
  79492. */
  79493. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79494. /**
  79495. * Strong typing of a RenderingGroup related stage step action
  79496. */
  79497. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79498. /**
  79499. * Strong typing of a Mesh Render related stage step action
  79500. */
  79501. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79502. /**
  79503. * Strong typing of a simple stage step action
  79504. */
  79505. export type SimpleStageAction = () => void;
  79506. /**
  79507. * Strong typing of a render target action.
  79508. */
  79509. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79510. /**
  79511. * Strong typing of a pointer move action.
  79512. */
  79513. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79514. /**
  79515. * Strong typing of a pointer up/down action.
  79516. */
  79517. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79518. /**
  79519. * Representation of a stage in the scene (Basically a list of ordered steps)
  79520. * @hidden
  79521. */
  79522. export class Stage<T extends Function> extends Array<{
  79523. index: number;
  79524. component: ISceneComponent;
  79525. action: T;
  79526. }> {
  79527. /**
  79528. * Hide ctor from the rest of the world.
  79529. * @param items The items to add.
  79530. */
  79531. private constructor();
  79532. /**
  79533. * Creates a new Stage.
  79534. * @returns A new instance of a Stage
  79535. */
  79536. static Create<T extends Function>(): Stage<T>;
  79537. /**
  79538. * Registers a step in an ordered way in the targeted stage.
  79539. * @param index Defines the position to register the step in
  79540. * @param component Defines the component attached to the step
  79541. * @param action Defines the action to launch during the step
  79542. */
  79543. registerStep(index: number, component: ISceneComponent, action: T): void;
  79544. /**
  79545. * Clears all the steps from the stage.
  79546. */
  79547. clear(): void;
  79548. }
  79549. }
  79550. declare module BABYLON {
  79551. interface Scene {
  79552. /** @hidden */
  79553. _pointerOverSprite: Nullable<Sprite>;
  79554. /** @hidden */
  79555. _pickedDownSprite: Nullable<Sprite>;
  79556. /** @hidden */
  79557. _tempSpritePickingRay: Nullable<Ray>;
  79558. /**
  79559. * All of the sprite managers added to this scene
  79560. * @see http://doc.babylonjs.com/babylon101/sprites
  79561. */
  79562. spriteManagers: Array<ISpriteManager>;
  79563. /**
  79564. * An event triggered when sprites rendering is about to start
  79565. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79566. */
  79567. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79568. /**
  79569. * An event triggered when sprites rendering is done
  79570. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79571. */
  79572. onAfterSpritesRenderingObservable: Observable<Scene>;
  79573. /** @hidden */
  79574. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79575. /** Launch a ray to try to pick a sprite in the scene
  79576. * @param x position on screen
  79577. * @param y position on screen
  79578. * @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
  79579. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79580. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79581. * @returns a PickingInfo
  79582. */
  79583. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79584. /** Use the given ray to pick a sprite in the scene
  79585. * @param ray The ray (in world space) to use to pick meshes
  79586. * @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
  79587. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79588. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79589. * @returns a PickingInfo
  79590. */
  79591. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79592. /** @hidden */
  79593. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79594. /** Launch a ray to try to pick sprites in the scene
  79595. * @param x position on screen
  79596. * @param y position on screen
  79597. * @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
  79598. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79599. * @returns a PickingInfo array
  79600. */
  79601. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79602. /** Use the given ray to pick sprites in the scene
  79603. * @param ray The ray (in world space) to use to pick meshes
  79604. * @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
  79605. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79606. * @returns a PickingInfo array
  79607. */
  79608. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79609. /**
  79610. * Force the sprite under the pointer
  79611. * @param sprite defines the sprite to use
  79612. */
  79613. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79614. /**
  79615. * Gets the sprite under the pointer
  79616. * @returns a Sprite or null if no sprite is under the pointer
  79617. */
  79618. getPointerOverSprite(): Nullable<Sprite>;
  79619. }
  79620. /**
  79621. * Defines the sprite scene component responsible to manage sprites
  79622. * in a given scene.
  79623. */
  79624. export class SpriteSceneComponent implements ISceneComponent {
  79625. /**
  79626. * The component name helpfull to identify the component in the list of scene components.
  79627. */
  79628. readonly name: string;
  79629. /**
  79630. * The scene the component belongs to.
  79631. */
  79632. scene: Scene;
  79633. /** @hidden */
  79634. private _spritePredicate;
  79635. /**
  79636. * Creates a new instance of the component for the given scene
  79637. * @param scene Defines the scene to register the component in
  79638. */
  79639. constructor(scene: Scene);
  79640. /**
  79641. * Registers the component in a given scene
  79642. */
  79643. register(): void;
  79644. /**
  79645. * Rebuilds the elements related to this component in case of
  79646. * context lost for instance.
  79647. */
  79648. rebuild(): void;
  79649. /**
  79650. * Disposes the component and the associated ressources.
  79651. */
  79652. dispose(): void;
  79653. private _pickSpriteButKeepRay;
  79654. private _pointerMove;
  79655. private _pointerDown;
  79656. private _pointerUp;
  79657. }
  79658. }
  79659. declare module BABYLON {
  79660. /** @hidden */
  79661. export var fogFragmentDeclaration: {
  79662. name: string;
  79663. shader: string;
  79664. };
  79665. }
  79666. declare module BABYLON {
  79667. /** @hidden */
  79668. export var fogFragment: {
  79669. name: string;
  79670. shader: string;
  79671. };
  79672. }
  79673. declare module BABYLON {
  79674. /** @hidden */
  79675. export var spritesPixelShader: {
  79676. name: string;
  79677. shader: string;
  79678. };
  79679. }
  79680. declare module BABYLON {
  79681. /** @hidden */
  79682. export var fogVertexDeclaration: {
  79683. name: string;
  79684. shader: string;
  79685. };
  79686. }
  79687. declare module BABYLON {
  79688. /** @hidden */
  79689. export var spritesVertexShader: {
  79690. name: string;
  79691. shader: string;
  79692. };
  79693. }
  79694. declare module BABYLON {
  79695. /**
  79696. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79697. */
  79698. export interface ISpriteManager extends IDisposable {
  79699. /**
  79700. * Restricts the camera to viewing objects with the same layerMask.
  79701. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79702. */
  79703. layerMask: number;
  79704. /**
  79705. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79706. */
  79707. isPickable: boolean;
  79708. /**
  79709. * Specifies the rendering group id for this mesh (0 by default)
  79710. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79711. */
  79712. renderingGroupId: number;
  79713. /**
  79714. * Defines the list of sprites managed by the manager.
  79715. */
  79716. sprites: Array<Sprite>;
  79717. /**
  79718. * Tests the intersection of a sprite with a specific ray.
  79719. * @param ray The ray we are sending to test the collision
  79720. * @param camera The camera space we are sending rays in
  79721. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79722. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79723. * @returns picking info or null.
  79724. */
  79725. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79726. /**
  79727. * Intersects the sprites with a ray
  79728. * @param ray defines the ray to intersect with
  79729. * @param camera defines the current active camera
  79730. * @param predicate defines a predicate used to select candidate sprites
  79731. * @returns null if no hit or a PickingInfo array
  79732. */
  79733. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79734. /**
  79735. * Renders the list of sprites on screen.
  79736. */
  79737. render(): void;
  79738. }
  79739. /**
  79740. * Class used to manage multiple sprites on the same spritesheet
  79741. * @see http://doc.babylonjs.com/babylon101/sprites
  79742. */
  79743. export class SpriteManager implements ISpriteManager {
  79744. /** defines the manager's name */
  79745. name: string;
  79746. /** Gets the list of sprites */
  79747. sprites: Sprite[];
  79748. /** Gets or sets the rendering group id (0 by default) */
  79749. renderingGroupId: number;
  79750. /** Gets or sets camera layer mask */
  79751. layerMask: number;
  79752. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79753. fogEnabled: boolean;
  79754. /** Gets or sets a boolean indicating if the sprites are pickable */
  79755. isPickable: boolean;
  79756. /** Defines the default width of a cell in the spritesheet */
  79757. cellWidth: number;
  79758. /** Defines the default height of a cell in the spritesheet */
  79759. cellHeight: number;
  79760. /** Associative array from JSON sprite data file */
  79761. private _cellData;
  79762. /** Array of sprite names from JSON sprite data file */
  79763. private _spriteMap;
  79764. /** True when packed cell data from JSON file is ready*/
  79765. private _packedAndReady;
  79766. /**
  79767. * An event triggered when the manager is disposed.
  79768. */
  79769. onDisposeObservable: Observable<SpriteManager>;
  79770. private _onDisposeObserver;
  79771. /**
  79772. * Callback called when the manager is disposed
  79773. */
  79774. onDispose: () => void;
  79775. private _capacity;
  79776. private _fromPacked;
  79777. private _spriteTexture;
  79778. private _epsilon;
  79779. private _scene;
  79780. private _vertexData;
  79781. private _buffer;
  79782. private _vertexBuffers;
  79783. private _indexBuffer;
  79784. private _effectBase;
  79785. private _effectFog;
  79786. /**
  79787. * Gets or sets the spritesheet texture
  79788. */
  79789. texture: Texture;
  79790. /**
  79791. * Creates a new sprite manager
  79792. * @param name defines the manager's name
  79793. * @param imgUrl defines the sprite sheet url
  79794. * @param capacity defines the maximum allowed number of sprites
  79795. * @param cellSize defines the size of a sprite cell
  79796. * @param scene defines the hosting scene
  79797. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79798. * @param samplingMode defines the smapling mode to use with spritesheet
  79799. * @param fromPacked set to false; do not alter
  79800. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  79801. */
  79802. constructor(
  79803. /** defines the manager's name */
  79804. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79805. private _makePacked;
  79806. private _appendSpriteVertex;
  79807. /**
  79808. * Intersects the sprites with a ray
  79809. * @param ray defines the ray to intersect with
  79810. * @param camera defines the current active camera
  79811. * @param predicate defines a predicate used to select candidate sprites
  79812. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79813. * @returns null if no hit or a PickingInfo
  79814. */
  79815. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79816. /**
  79817. * Intersects the sprites with a ray
  79818. * @param ray defines the ray to intersect with
  79819. * @param camera defines the current active camera
  79820. * @param predicate defines a predicate used to select candidate sprites
  79821. * @returns null if no hit or a PickingInfo array
  79822. */
  79823. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79824. /**
  79825. * Render all child sprites
  79826. */
  79827. render(): void;
  79828. /**
  79829. * Release associated resources
  79830. */
  79831. dispose(): void;
  79832. }
  79833. }
  79834. declare module BABYLON {
  79835. /**
  79836. * Class used to represent a sprite
  79837. * @see http://doc.babylonjs.com/babylon101/sprites
  79838. */
  79839. export class Sprite {
  79840. /** defines the name */
  79841. name: string;
  79842. /** Gets or sets the current world position */
  79843. position: Vector3;
  79844. /** Gets or sets the main color */
  79845. color: Color4;
  79846. /** Gets or sets the width */
  79847. width: number;
  79848. /** Gets or sets the height */
  79849. height: number;
  79850. /** Gets or sets rotation angle */
  79851. angle: number;
  79852. /** Gets or sets the cell index in the sprite sheet */
  79853. cellIndex: number;
  79854. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79855. cellRef: string;
  79856. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79857. invertU: number;
  79858. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79859. invertV: number;
  79860. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79861. disposeWhenFinishedAnimating: boolean;
  79862. /** Gets the list of attached animations */
  79863. animations: Animation[];
  79864. /** Gets or sets a boolean indicating if the sprite can be picked */
  79865. isPickable: boolean;
  79866. /**
  79867. * Gets or sets the associated action manager
  79868. */
  79869. actionManager: Nullable<ActionManager>;
  79870. private _animationStarted;
  79871. private _loopAnimation;
  79872. private _fromIndex;
  79873. private _toIndex;
  79874. private _delay;
  79875. private _direction;
  79876. private _manager;
  79877. private _time;
  79878. private _onAnimationEnd;
  79879. /**
  79880. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79881. */
  79882. isVisible: boolean;
  79883. /**
  79884. * Gets or sets the sprite size
  79885. */
  79886. size: number;
  79887. /**
  79888. * Creates a new Sprite
  79889. * @param name defines the name
  79890. * @param manager defines the manager
  79891. */
  79892. constructor(
  79893. /** defines the name */
  79894. name: string, manager: ISpriteManager);
  79895. /**
  79896. * Starts an animation
  79897. * @param from defines the initial key
  79898. * @param to defines the end key
  79899. * @param loop defines if the animation must loop
  79900. * @param delay defines the start delay (in ms)
  79901. * @param onAnimationEnd defines a callback to call when animation ends
  79902. */
  79903. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79904. /** Stops current animation (if any) */
  79905. stopAnimation(): void;
  79906. /** @hidden */
  79907. _animate(deltaTime: number): void;
  79908. /** Release associated resources */
  79909. dispose(): void;
  79910. }
  79911. }
  79912. declare module BABYLON {
  79913. /**
  79914. * Information about the result of picking within a scene
  79915. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79916. */
  79917. export class PickingInfo {
  79918. /** @hidden */
  79919. _pickingUnavailable: boolean;
  79920. /**
  79921. * If the pick collided with an object
  79922. */
  79923. hit: boolean;
  79924. /**
  79925. * Distance away where the pick collided
  79926. */
  79927. distance: number;
  79928. /**
  79929. * The location of pick collision
  79930. */
  79931. pickedPoint: Nullable<Vector3>;
  79932. /**
  79933. * The mesh corresponding the the pick collision
  79934. */
  79935. pickedMesh: Nullable<AbstractMesh>;
  79936. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79937. bu: number;
  79938. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79939. bv: number;
  79940. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79941. faceId: number;
  79942. /** Id of the the submesh that was picked */
  79943. subMeshId: number;
  79944. /** If a sprite was picked, this will be the sprite the pick collided with */
  79945. pickedSprite: Nullable<Sprite>;
  79946. /**
  79947. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79948. */
  79949. originMesh: Nullable<AbstractMesh>;
  79950. /**
  79951. * The ray that was used to perform the picking.
  79952. */
  79953. ray: Nullable<Ray>;
  79954. /**
  79955. * Gets the normal correspodning to the face the pick collided with
  79956. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79957. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79958. * @returns The normal correspodning to the face the pick collided with
  79959. */
  79960. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79961. /**
  79962. * Gets the texture coordinates of where the pick occured
  79963. * @returns the vector containing the coordnates of the texture
  79964. */
  79965. getTextureCoordinates(): Nullable<Vector2>;
  79966. }
  79967. }
  79968. declare module BABYLON {
  79969. /**
  79970. * Gather the list of pointer event types as constants.
  79971. */
  79972. export class PointerEventTypes {
  79973. /**
  79974. * 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.
  79975. */
  79976. static readonly POINTERDOWN: number;
  79977. /**
  79978. * The pointerup event is fired when a pointer is no longer active.
  79979. */
  79980. static readonly POINTERUP: number;
  79981. /**
  79982. * The pointermove event is fired when a pointer changes coordinates.
  79983. */
  79984. static readonly POINTERMOVE: number;
  79985. /**
  79986. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79987. */
  79988. static readonly POINTERWHEEL: number;
  79989. /**
  79990. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79991. */
  79992. static readonly POINTERPICK: number;
  79993. /**
  79994. * The pointertap event is fired when a the object has been touched and released without drag.
  79995. */
  79996. static readonly POINTERTAP: number;
  79997. /**
  79998. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79999. */
  80000. static readonly POINTERDOUBLETAP: number;
  80001. }
  80002. /**
  80003. * Base class of pointer info types.
  80004. */
  80005. export class PointerInfoBase {
  80006. /**
  80007. * Defines the type of event (PointerEventTypes)
  80008. */
  80009. type: number;
  80010. /**
  80011. * Defines the related dom event
  80012. */
  80013. event: PointerEvent | MouseWheelEvent;
  80014. /**
  80015. * Instantiates the base class of pointers info.
  80016. * @param type Defines the type of event (PointerEventTypes)
  80017. * @param event Defines the related dom event
  80018. */
  80019. constructor(
  80020. /**
  80021. * Defines the type of event (PointerEventTypes)
  80022. */
  80023. type: number,
  80024. /**
  80025. * Defines the related dom event
  80026. */
  80027. event: PointerEvent | MouseWheelEvent);
  80028. }
  80029. /**
  80030. * This class is used to store pointer related info for the onPrePointerObservable event.
  80031. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  80032. */
  80033. export class PointerInfoPre extends PointerInfoBase {
  80034. /**
  80035. * Ray from a pointer if availible (eg. 6dof controller)
  80036. */
  80037. ray: Nullable<Ray>;
  80038. /**
  80039. * Defines the local position of the pointer on the canvas.
  80040. */
  80041. localPosition: Vector2;
  80042. /**
  80043. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80044. */
  80045. skipOnPointerObservable: boolean;
  80046. /**
  80047. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80048. * @param type Defines the type of event (PointerEventTypes)
  80049. * @param event Defines the related dom event
  80050. * @param localX Defines the local x coordinates of the pointer when the event occured
  80051. * @param localY Defines the local y coordinates of the pointer when the event occured
  80052. */
  80053. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80054. }
  80055. /**
  80056. * This type contains all the data related to a pointer event in Babylon.js.
  80057. * 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.
  80058. */
  80059. export class PointerInfo extends PointerInfoBase {
  80060. /**
  80061. * Defines the picking info associated to the info (if any)\
  80062. */
  80063. pickInfo: Nullable<PickingInfo>;
  80064. /**
  80065. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80066. * @param type Defines the type of event (PointerEventTypes)
  80067. * @param event Defines the related dom event
  80068. * @param pickInfo Defines the picking info associated to the info (if any)\
  80069. */
  80070. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80071. /**
  80072. * Defines the picking info associated to the info (if any)\
  80073. */
  80074. pickInfo: Nullable<PickingInfo>);
  80075. }
  80076. /**
  80077. * Data relating to a touch event on the screen.
  80078. */
  80079. export interface PointerTouch {
  80080. /**
  80081. * X coordinate of touch.
  80082. */
  80083. x: number;
  80084. /**
  80085. * Y coordinate of touch.
  80086. */
  80087. y: number;
  80088. /**
  80089. * Id of touch. Unique for each finger.
  80090. */
  80091. pointerId: number;
  80092. /**
  80093. * Event type passed from DOM.
  80094. */
  80095. type: any;
  80096. }
  80097. }
  80098. declare module BABYLON {
  80099. /**
  80100. * Manage the mouse inputs to control the movement of a free camera.
  80101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80102. */
  80103. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80104. /**
  80105. * Define if touch is enabled in the mouse input
  80106. */
  80107. touchEnabled: boolean;
  80108. /**
  80109. * Defines the camera the input is attached to.
  80110. */
  80111. camera: FreeCamera;
  80112. /**
  80113. * Defines the buttons associated with the input to handle camera move.
  80114. */
  80115. buttons: number[];
  80116. /**
  80117. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80118. */
  80119. angularSensibility: number;
  80120. private _pointerInput;
  80121. private _onMouseMove;
  80122. private _observer;
  80123. private previousPosition;
  80124. /**
  80125. * Observable for when a pointer move event occurs containing the move offset
  80126. */
  80127. onPointerMovedObservable: Observable<{
  80128. offsetX: number;
  80129. offsetY: number;
  80130. }>;
  80131. /**
  80132. * @hidden
  80133. * If the camera should be rotated automatically based on pointer movement
  80134. */
  80135. _allowCameraRotation: boolean;
  80136. /**
  80137. * Manage the mouse inputs to control the movement of a free camera.
  80138. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80139. * @param touchEnabled Defines if touch is enabled or not
  80140. */
  80141. constructor(
  80142. /**
  80143. * Define if touch is enabled in the mouse input
  80144. */
  80145. touchEnabled?: boolean);
  80146. /**
  80147. * Attach the input controls to a specific dom element to get the input from.
  80148. * @param element Defines the element the controls should be listened from
  80149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80150. */
  80151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80152. /**
  80153. * Called on JS contextmenu event.
  80154. * Override this method to provide functionality.
  80155. */
  80156. protected onContextMenu(evt: PointerEvent): void;
  80157. /**
  80158. * Detach the current controls from the specified dom element.
  80159. * @param element Defines the element to stop listening the inputs from
  80160. */
  80161. detachControl(element: Nullable<HTMLElement>): void;
  80162. /**
  80163. * Gets the class name of the current intput.
  80164. * @returns the class name
  80165. */
  80166. getClassName(): string;
  80167. /**
  80168. * Get the friendly name associated with the input class.
  80169. * @returns the input friendly name
  80170. */
  80171. getSimpleName(): string;
  80172. }
  80173. }
  80174. declare module BABYLON {
  80175. /**
  80176. * Manage the touch inputs to control the movement of a free camera.
  80177. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80178. */
  80179. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  80180. /**
  80181. * Defines the camera the input is attached to.
  80182. */
  80183. camera: FreeCamera;
  80184. /**
  80185. * Defines the touch sensibility for rotation.
  80186. * The higher the faster.
  80187. */
  80188. touchAngularSensibility: number;
  80189. /**
  80190. * Defines the touch sensibility for move.
  80191. * The higher the faster.
  80192. */
  80193. touchMoveSensibility: number;
  80194. private _offsetX;
  80195. private _offsetY;
  80196. private _pointerPressed;
  80197. private _pointerInput;
  80198. private _observer;
  80199. private _onLostFocus;
  80200. /**
  80201. * Attach the input controls to a specific dom element to get the input from.
  80202. * @param element Defines the element the controls should be listened from
  80203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80204. */
  80205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80206. /**
  80207. * Detach the current controls from the specified dom element.
  80208. * @param element Defines the element to stop listening the inputs from
  80209. */
  80210. detachControl(element: Nullable<HTMLElement>): void;
  80211. /**
  80212. * Update the current camera state depending on the inputs that have been used this frame.
  80213. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80214. */
  80215. checkInputs(): void;
  80216. /**
  80217. * Gets the class name of the current intput.
  80218. * @returns the class name
  80219. */
  80220. getClassName(): string;
  80221. /**
  80222. * Get the friendly name associated with the input class.
  80223. * @returns the input friendly name
  80224. */
  80225. getSimpleName(): string;
  80226. }
  80227. }
  80228. declare module BABYLON {
  80229. /**
  80230. * Default Inputs manager for the FreeCamera.
  80231. * It groups all the default supported inputs for ease of use.
  80232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80233. */
  80234. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  80235. /**
  80236. * @hidden
  80237. */
  80238. _mouseInput: Nullable<FreeCameraMouseInput>;
  80239. /**
  80240. * Instantiates a new FreeCameraInputsManager.
  80241. * @param camera Defines the camera the inputs belong to
  80242. */
  80243. constructor(camera: FreeCamera);
  80244. /**
  80245. * Add keyboard input support to the input manager.
  80246. * @returns the current input manager
  80247. */
  80248. addKeyboard(): FreeCameraInputsManager;
  80249. /**
  80250. * Add mouse input support to the input manager.
  80251. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  80252. * @returns the current input manager
  80253. */
  80254. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80255. /**
  80256. * Removes the mouse input support from the manager
  80257. * @returns the current input manager
  80258. */
  80259. removeMouse(): FreeCameraInputsManager;
  80260. /**
  80261. * Add touch input support to the input manager.
  80262. * @returns the current input manager
  80263. */
  80264. addTouch(): FreeCameraInputsManager;
  80265. /**
  80266. * Remove all attached input methods from a camera
  80267. */
  80268. clear(): void;
  80269. }
  80270. }
  80271. declare module BABYLON {
  80272. /**
  80273. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80274. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80275. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80276. */
  80277. export class FreeCamera extends TargetCamera {
  80278. /**
  80279. * Define the collision ellipsoid of the camera.
  80280. * This is helpful to simulate a camera body like the player body around the camera
  80281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80282. */
  80283. ellipsoid: Vector3;
  80284. /**
  80285. * Define an offset for the position of the ellipsoid around the camera.
  80286. * This can be helpful to determine the center of the body near the gravity center of the body
  80287. * instead of its head.
  80288. */
  80289. ellipsoidOffset: Vector3;
  80290. /**
  80291. * Enable or disable collisions of the camera with the rest of the scene objects.
  80292. */
  80293. checkCollisions: boolean;
  80294. /**
  80295. * Enable or disable gravity on the camera.
  80296. */
  80297. applyGravity: boolean;
  80298. /**
  80299. * Define the input manager associated to the camera.
  80300. */
  80301. inputs: FreeCameraInputsManager;
  80302. /**
  80303. * Gets the input sensibility for a mouse input. (default is 2000.0)
  80304. * Higher values reduce sensitivity.
  80305. */
  80306. /**
  80307. * Sets the input sensibility for a mouse input. (default is 2000.0)
  80308. * Higher values reduce sensitivity.
  80309. */
  80310. angularSensibility: number;
  80311. /**
  80312. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80313. */
  80314. keysUp: number[];
  80315. /**
  80316. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80317. */
  80318. keysDown: number[];
  80319. /**
  80320. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80321. */
  80322. keysLeft: number[];
  80323. /**
  80324. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80325. */
  80326. keysRight: number[];
  80327. /**
  80328. * Event raised when the camera collide with a mesh in the scene.
  80329. */
  80330. onCollide: (collidedMesh: AbstractMesh) => void;
  80331. private _collider;
  80332. private _needMoveForGravity;
  80333. private _oldPosition;
  80334. private _diffPosition;
  80335. private _newPosition;
  80336. /** @hidden */
  80337. _localDirection: Vector3;
  80338. /** @hidden */
  80339. _transformedDirection: Vector3;
  80340. /**
  80341. * Instantiates a Free Camera.
  80342. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80343. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  80344. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80345. * @param name Define the name of the camera in the scene
  80346. * @param position Define the start position of the camera in the scene
  80347. * @param scene Define the scene the camera belongs to
  80348. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  80349. */
  80350. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  80351. /**
  80352. * Attached controls to the current camera.
  80353. * @param element Defines the element the controls should be listened from
  80354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80355. */
  80356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80357. /**
  80358. * Detach the current controls from the camera.
  80359. * The camera will stop reacting to inputs.
  80360. * @param element Defines the element to stop listening the inputs from
  80361. */
  80362. detachControl(element: HTMLElement): void;
  80363. private _collisionMask;
  80364. /**
  80365. * Define a collision mask to limit the list of object the camera can collide with
  80366. */
  80367. collisionMask: number;
  80368. /** @hidden */
  80369. _collideWithWorld(displacement: Vector3): void;
  80370. private _onCollisionPositionChange;
  80371. /** @hidden */
  80372. _checkInputs(): void;
  80373. /** @hidden */
  80374. _decideIfNeedsToMove(): boolean;
  80375. /** @hidden */
  80376. _updatePosition(): void;
  80377. /**
  80378. * Destroy the camera and release the current resources hold by it.
  80379. */
  80380. dispose(): void;
  80381. /**
  80382. * Gets the current object class name.
  80383. * @return the class name
  80384. */
  80385. getClassName(): string;
  80386. }
  80387. }
  80388. declare module BABYLON {
  80389. /**
  80390. * Represents a gamepad control stick position
  80391. */
  80392. export class StickValues {
  80393. /**
  80394. * The x component of the control stick
  80395. */
  80396. x: number;
  80397. /**
  80398. * The y component of the control stick
  80399. */
  80400. y: number;
  80401. /**
  80402. * Initializes the gamepad x and y control stick values
  80403. * @param x The x component of the gamepad control stick value
  80404. * @param y The y component of the gamepad control stick value
  80405. */
  80406. constructor(
  80407. /**
  80408. * The x component of the control stick
  80409. */
  80410. x: number,
  80411. /**
  80412. * The y component of the control stick
  80413. */
  80414. y: number);
  80415. }
  80416. /**
  80417. * An interface which manages callbacks for gamepad button changes
  80418. */
  80419. export interface GamepadButtonChanges {
  80420. /**
  80421. * Called when a gamepad has been changed
  80422. */
  80423. changed: boolean;
  80424. /**
  80425. * Called when a gamepad press event has been triggered
  80426. */
  80427. pressChanged: boolean;
  80428. /**
  80429. * Called when a touch event has been triggered
  80430. */
  80431. touchChanged: boolean;
  80432. /**
  80433. * Called when a value has changed
  80434. */
  80435. valueChanged: boolean;
  80436. }
  80437. /**
  80438. * Represents a gamepad
  80439. */
  80440. export class Gamepad {
  80441. /**
  80442. * The id of the gamepad
  80443. */
  80444. id: string;
  80445. /**
  80446. * The index of the gamepad
  80447. */
  80448. index: number;
  80449. /**
  80450. * The browser gamepad
  80451. */
  80452. browserGamepad: any;
  80453. /**
  80454. * Specifies what type of gamepad this represents
  80455. */
  80456. type: number;
  80457. private _leftStick;
  80458. private _rightStick;
  80459. /** @hidden */
  80460. _isConnected: boolean;
  80461. private _leftStickAxisX;
  80462. private _leftStickAxisY;
  80463. private _rightStickAxisX;
  80464. private _rightStickAxisY;
  80465. /**
  80466. * Triggered when the left control stick has been changed
  80467. */
  80468. private _onleftstickchanged;
  80469. /**
  80470. * Triggered when the right control stick has been changed
  80471. */
  80472. private _onrightstickchanged;
  80473. /**
  80474. * Represents a gamepad controller
  80475. */
  80476. static GAMEPAD: number;
  80477. /**
  80478. * Represents a generic controller
  80479. */
  80480. static GENERIC: number;
  80481. /**
  80482. * Represents an XBox controller
  80483. */
  80484. static XBOX: number;
  80485. /**
  80486. * Represents a pose-enabled controller
  80487. */
  80488. static POSE_ENABLED: number;
  80489. /**
  80490. * Represents an Dual Shock controller
  80491. */
  80492. static DUALSHOCK: number;
  80493. /**
  80494. * Specifies whether the left control stick should be Y-inverted
  80495. */
  80496. protected _invertLeftStickY: boolean;
  80497. /**
  80498. * Specifies if the gamepad has been connected
  80499. */
  80500. readonly isConnected: boolean;
  80501. /**
  80502. * Initializes the gamepad
  80503. * @param id The id of the gamepad
  80504. * @param index The index of the gamepad
  80505. * @param browserGamepad The browser gamepad
  80506. * @param leftStickX The x component of the left joystick
  80507. * @param leftStickY The y component of the left joystick
  80508. * @param rightStickX The x component of the right joystick
  80509. * @param rightStickY The y component of the right joystick
  80510. */
  80511. constructor(
  80512. /**
  80513. * The id of the gamepad
  80514. */
  80515. id: string,
  80516. /**
  80517. * The index of the gamepad
  80518. */
  80519. index: number,
  80520. /**
  80521. * The browser gamepad
  80522. */
  80523. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80524. /**
  80525. * Callback triggered when the left joystick has changed
  80526. * @param callback
  80527. */
  80528. onleftstickchanged(callback: (values: StickValues) => void): void;
  80529. /**
  80530. * Callback triggered when the right joystick has changed
  80531. * @param callback
  80532. */
  80533. onrightstickchanged(callback: (values: StickValues) => void): void;
  80534. /**
  80535. * Gets the left joystick
  80536. */
  80537. /**
  80538. * Sets the left joystick values
  80539. */
  80540. leftStick: StickValues;
  80541. /**
  80542. * Gets the right joystick
  80543. */
  80544. /**
  80545. * Sets the right joystick value
  80546. */
  80547. rightStick: StickValues;
  80548. /**
  80549. * Updates the gamepad joystick positions
  80550. */
  80551. update(): void;
  80552. /**
  80553. * Disposes the gamepad
  80554. */
  80555. dispose(): void;
  80556. }
  80557. /**
  80558. * Represents a generic gamepad
  80559. */
  80560. export class GenericPad extends Gamepad {
  80561. private _buttons;
  80562. private _onbuttondown;
  80563. private _onbuttonup;
  80564. /**
  80565. * Observable triggered when a button has been pressed
  80566. */
  80567. onButtonDownObservable: Observable<number>;
  80568. /**
  80569. * Observable triggered when a button has been released
  80570. */
  80571. onButtonUpObservable: Observable<number>;
  80572. /**
  80573. * Callback triggered when a button has been pressed
  80574. * @param callback Called when a button has been pressed
  80575. */
  80576. onbuttondown(callback: (buttonPressed: number) => void): void;
  80577. /**
  80578. * Callback triggered when a button has been released
  80579. * @param callback Called when a button has been released
  80580. */
  80581. onbuttonup(callback: (buttonReleased: number) => void): void;
  80582. /**
  80583. * Initializes the generic gamepad
  80584. * @param id The id of the generic gamepad
  80585. * @param index The index of the generic gamepad
  80586. * @param browserGamepad The browser gamepad
  80587. */
  80588. constructor(id: string, index: number, browserGamepad: any);
  80589. private _setButtonValue;
  80590. /**
  80591. * Updates the generic gamepad
  80592. */
  80593. update(): void;
  80594. /**
  80595. * Disposes the generic gamepad
  80596. */
  80597. dispose(): void;
  80598. }
  80599. }
  80600. declare module BABYLON {
  80601. interface Engine {
  80602. /**
  80603. * Creates a raw texture
  80604. * @param data defines the data to store in the texture
  80605. * @param width defines the width of the texture
  80606. * @param height defines the height of the texture
  80607. * @param format defines the format of the data
  80608. * @param generateMipMaps defines if the engine should generate the mip levels
  80609. * @param invertY defines if data must be stored with Y axis inverted
  80610. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80611. * @param compression defines the compression used (null by default)
  80612. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80613. * @returns the raw texture inside an InternalTexture
  80614. */
  80615. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80616. /**
  80617. * Update a raw texture
  80618. * @param texture defines the texture to update
  80619. * @param data defines the data to store in the texture
  80620. * @param format defines the format of the data
  80621. * @param invertY defines if data must be stored with Y axis inverted
  80622. */
  80623. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80624. /**
  80625. * Update a raw texture
  80626. * @param texture defines the texture to update
  80627. * @param data defines the data to store in the texture
  80628. * @param format defines the format of the data
  80629. * @param invertY defines if data must be stored with Y axis inverted
  80630. * @param compression defines the compression used (null by default)
  80631. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80632. */
  80633. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80634. /**
  80635. * Creates a new raw cube texture
  80636. * @param data defines the array of data to use to create each face
  80637. * @param size defines the size of the textures
  80638. * @param format defines the format of the data
  80639. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80640. * @param generateMipMaps defines if the engine should generate the mip levels
  80641. * @param invertY defines if data must be stored with Y axis inverted
  80642. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80643. * @param compression defines the compression used (null by default)
  80644. * @returns the cube texture as an InternalTexture
  80645. */
  80646. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80647. /**
  80648. * Update a raw cube texture
  80649. * @param texture defines the texture to udpdate
  80650. * @param data defines the data to store
  80651. * @param format defines the data format
  80652. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80653. * @param invertY defines if data must be stored with Y axis inverted
  80654. */
  80655. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80656. /**
  80657. * Update a raw cube texture
  80658. * @param texture defines the texture to udpdate
  80659. * @param data defines the data to store
  80660. * @param format defines the data format
  80661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80662. * @param invertY defines if data must be stored with Y axis inverted
  80663. * @param compression defines the compression used (null by default)
  80664. */
  80665. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80666. /**
  80667. * Update a raw cube texture
  80668. * @param texture defines the texture to udpdate
  80669. * @param data defines the data to store
  80670. * @param format defines the data format
  80671. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80672. * @param invertY defines if data must be stored with Y axis inverted
  80673. * @param compression defines the compression used (null by default)
  80674. * @param level defines which level of the texture to update
  80675. */
  80676. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80677. /**
  80678. * Creates a new raw cube texture from a specified url
  80679. * @param url defines the url where the data is located
  80680. * @param scene defines the current scene
  80681. * @param size defines the size of the textures
  80682. * @param format defines the format of the data
  80683. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80684. * @param noMipmap defines if the engine should avoid generating the mip levels
  80685. * @param callback defines a callback used to extract texture data from loaded data
  80686. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80687. * @param onLoad defines a callback called when texture is loaded
  80688. * @param onError defines a callback called if there is an error
  80689. * @returns the cube texture as an InternalTexture
  80690. */
  80691. 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;
  80692. /**
  80693. * Creates a new raw cube texture from a specified url
  80694. * @param url defines the url where the data is located
  80695. * @param scene defines the current scene
  80696. * @param size defines the size of the textures
  80697. * @param format defines the format of the data
  80698. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80699. * @param noMipmap defines if the engine should avoid generating the mip levels
  80700. * @param callback defines a callback used to extract texture data from loaded data
  80701. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80702. * @param onLoad defines a callback called when texture is loaded
  80703. * @param onError defines a callback called if there is an error
  80704. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80705. * @param invertY defines if data must be stored with Y axis inverted
  80706. * @returns the cube texture as an InternalTexture
  80707. */
  80708. 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;
  80709. /**
  80710. * Creates a new raw 3D texture
  80711. * @param data defines the data used to create the texture
  80712. * @param width defines the width of the texture
  80713. * @param height defines the height of the texture
  80714. * @param depth defines the depth of the texture
  80715. * @param format defines the format of the texture
  80716. * @param generateMipMaps defines if the engine must generate mip levels
  80717. * @param invertY defines if data must be stored with Y axis inverted
  80718. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80719. * @param compression defines the compressed used (can be null)
  80720. * @param textureType defines the compressed used (can be null)
  80721. * @returns a new raw 3D texture (stored in an InternalTexture)
  80722. */
  80723. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80724. /**
  80725. * Update a raw 3D texture
  80726. * @param texture defines the texture to update
  80727. * @param data defines the data to store
  80728. * @param format defines the data format
  80729. * @param invertY defines if data must be stored with Y axis inverted
  80730. */
  80731. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80732. /**
  80733. * Update a raw 3D texture
  80734. * @param texture defines the texture to update
  80735. * @param data defines the data to store
  80736. * @param format defines the data format
  80737. * @param invertY defines if data must be stored with Y axis inverted
  80738. * @param compression defines the used compression (can be null)
  80739. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80740. */
  80741. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80742. /**
  80743. * Creates a new raw 2D array texture
  80744. * @param data defines the data used to create the texture
  80745. * @param width defines the width of the texture
  80746. * @param height defines the height of the texture
  80747. * @param depth defines the number of layers of the texture
  80748. * @param format defines the format of the texture
  80749. * @param generateMipMaps defines if the engine must generate mip levels
  80750. * @param invertY defines if data must be stored with Y axis inverted
  80751. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80752. * @param compression defines the compressed used (can be null)
  80753. * @param textureType defines the compressed used (can be null)
  80754. * @returns a new raw 2D array texture (stored in an InternalTexture)
  80755. */
  80756. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80757. /**
  80758. * Update a raw 2D array texture
  80759. * @param texture defines the texture to update
  80760. * @param data defines the data to store
  80761. * @param format defines the data format
  80762. * @param invertY defines if data must be stored with Y axis inverted
  80763. */
  80764. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80765. /**
  80766. * Update a raw 2D array texture
  80767. * @param texture defines the texture to update
  80768. * @param data defines the data to store
  80769. * @param format defines the data format
  80770. * @param invertY defines if data must be stored with Y axis inverted
  80771. * @param compression defines the used compression (can be null)
  80772. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80773. */
  80774. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80775. }
  80776. }
  80777. declare module BABYLON {
  80778. /**
  80779. * Raw texture can help creating a texture directly from an array of data.
  80780. * This can be super useful if you either get the data from an uncompressed source or
  80781. * if you wish to create your texture pixel by pixel.
  80782. */
  80783. export class RawTexture extends Texture {
  80784. /**
  80785. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80786. */
  80787. format: number;
  80788. private _engine;
  80789. /**
  80790. * Instantiates a new RawTexture.
  80791. * Raw texture can help creating a texture directly from an array of data.
  80792. * This can be super useful if you either get the data from an uncompressed source or
  80793. * if you wish to create your texture pixel by pixel.
  80794. * @param data define the array of data to use to create the texture
  80795. * @param width define the width of the texture
  80796. * @param height define the height of the texture
  80797. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80798. * @param scene define the scene the texture belongs to
  80799. * @param generateMipMaps define whether mip maps should be generated or not
  80800. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80801. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80802. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80803. */
  80804. constructor(data: ArrayBufferView, width: number, height: number,
  80805. /**
  80806. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80807. */
  80808. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80809. /**
  80810. * Updates the texture underlying data.
  80811. * @param data Define the new data of the texture
  80812. */
  80813. update(data: ArrayBufferView): void;
  80814. /**
  80815. * Creates a luminance texture from some data.
  80816. * @param data Define the texture data
  80817. * @param width Define the width of the texture
  80818. * @param height Define the height of the texture
  80819. * @param scene Define the scene the texture belongs to
  80820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80823. * @returns the luminance texture
  80824. */
  80825. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80826. /**
  80827. * Creates a luminance alpha texture from some data.
  80828. * @param data Define the texture data
  80829. * @param width Define the width of the texture
  80830. * @param height Define the height of the texture
  80831. * @param scene Define the scene the texture belongs to
  80832. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80833. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80834. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80835. * @returns the luminance alpha texture
  80836. */
  80837. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80838. /**
  80839. * Creates an alpha texture from some data.
  80840. * @param data Define the texture data
  80841. * @param width Define the width of the texture
  80842. * @param height Define the height of the texture
  80843. * @param scene Define the scene the texture belongs to
  80844. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80845. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80846. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80847. * @returns the alpha texture
  80848. */
  80849. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80850. /**
  80851. * Creates a RGB texture from some data.
  80852. * @param data Define the texture data
  80853. * @param width Define the width of the texture
  80854. * @param height Define the height of the texture
  80855. * @param scene Define the scene the texture belongs to
  80856. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80857. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80858. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80859. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80860. * @returns the RGB alpha texture
  80861. */
  80862. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80863. /**
  80864. * Creates a RGBA texture from some data.
  80865. * @param data Define the texture data
  80866. * @param width Define the width of the texture
  80867. * @param height Define the height of the texture
  80868. * @param scene Define the scene the texture belongs to
  80869. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80870. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80871. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80872. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80873. * @returns the RGBA texture
  80874. */
  80875. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80876. /**
  80877. * Creates a R texture from some data.
  80878. * @param data Define the texture data
  80879. * @param width Define the width of the texture
  80880. * @param height Define the height of the texture
  80881. * @param scene Define the scene the texture belongs to
  80882. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80883. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80884. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80885. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80886. * @returns the R texture
  80887. */
  80888. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80889. }
  80890. }
  80891. declare module BABYLON {
  80892. /**
  80893. * Interface for the size containing width and height
  80894. */
  80895. export interface ISize {
  80896. /**
  80897. * Width
  80898. */
  80899. width: number;
  80900. /**
  80901. * Heighht
  80902. */
  80903. height: number;
  80904. }
  80905. /**
  80906. * Size containing widht and height
  80907. */
  80908. export class Size implements ISize {
  80909. /**
  80910. * Width
  80911. */
  80912. width: number;
  80913. /**
  80914. * Height
  80915. */
  80916. height: number;
  80917. /**
  80918. * Creates a Size object from the given width and height (floats).
  80919. * @param width width of the new size
  80920. * @param height height of the new size
  80921. */
  80922. constructor(width: number, height: number);
  80923. /**
  80924. * Returns a string with the Size width and height
  80925. * @returns a string with the Size width and height
  80926. */
  80927. toString(): string;
  80928. /**
  80929. * "Size"
  80930. * @returns the string "Size"
  80931. */
  80932. getClassName(): string;
  80933. /**
  80934. * Returns the Size hash code.
  80935. * @returns a hash code for a unique width and height
  80936. */
  80937. getHashCode(): number;
  80938. /**
  80939. * Updates the current size from the given one.
  80940. * @param src the given size
  80941. */
  80942. copyFrom(src: Size): void;
  80943. /**
  80944. * Updates in place the current Size from the given floats.
  80945. * @param width width of the new size
  80946. * @param height height of the new size
  80947. * @returns the updated Size.
  80948. */
  80949. copyFromFloats(width: number, height: number): Size;
  80950. /**
  80951. * Updates in place the current Size from the given floats.
  80952. * @param width width to set
  80953. * @param height height to set
  80954. * @returns the updated Size.
  80955. */
  80956. set(width: number, height: number): Size;
  80957. /**
  80958. * Multiplies the width and height by numbers
  80959. * @param w factor to multiple the width by
  80960. * @param h factor to multiple the height by
  80961. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80962. */
  80963. multiplyByFloats(w: number, h: number): Size;
  80964. /**
  80965. * Clones the size
  80966. * @returns a new Size copied from the given one.
  80967. */
  80968. clone(): Size;
  80969. /**
  80970. * True if the current Size and the given one width and height are strictly equal.
  80971. * @param other the other size to compare against
  80972. * @returns True if the current Size and the given one width and height are strictly equal.
  80973. */
  80974. equals(other: Size): boolean;
  80975. /**
  80976. * The surface of the Size : width * height (float).
  80977. */
  80978. readonly surface: number;
  80979. /**
  80980. * Create a new size of zero
  80981. * @returns a new Size set to (0.0, 0.0)
  80982. */
  80983. static Zero(): Size;
  80984. /**
  80985. * Sums the width and height of two sizes
  80986. * @param otherSize size to add to this size
  80987. * @returns a new Size set as the addition result of the current Size and the given one.
  80988. */
  80989. add(otherSize: Size): Size;
  80990. /**
  80991. * Subtracts the width and height of two
  80992. * @param otherSize size to subtract to this size
  80993. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80994. */
  80995. subtract(otherSize: Size): Size;
  80996. /**
  80997. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80998. * @param start starting size to lerp between
  80999. * @param end end size to lerp between
  81000. * @param amount amount to lerp between the start and end values
  81001. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  81002. */
  81003. static Lerp(start: Size, end: Size, amount: number): Size;
  81004. }
  81005. }
  81006. declare module BABYLON {
  81007. /**
  81008. * Defines a runtime animation
  81009. */
  81010. export class RuntimeAnimation {
  81011. private _events;
  81012. /**
  81013. * The current frame of the runtime animation
  81014. */
  81015. private _currentFrame;
  81016. /**
  81017. * The animation used by the runtime animation
  81018. */
  81019. private _animation;
  81020. /**
  81021. * The target of the runtime animation
  81022. */
  81023. private _target;
  81024. /**
  81025. * The initiating animatable
  81026. */
  81027. private _host;
  81028. /**
  81029. * The original value of the runtime animation
  81030. */
  81031. private _originalValue;
  81032. /**
  81033. * The original blend value of the runtime animation
  81034. */
  81035. private _originalBlendValue;
  81036. /**
  81037. * The offsets cache of the runtime animation
  81038. */
  81039. private _offsetsCache;
  81040. /**
  81041. * The high limits cache of the runtime animation
  81042. */
  81043. private _highLimitsCache;
  81044. /**
  81045. * Specifies if the runtime animation has been stopped
  81046. */
  81047. private _stopped;
  81048. /**
  81049. * The blending factor of the runtime animation
  81050. */
  81051. private _blendingFactor;
  81052. /**
  81053. * The BabylonJS scene
  81054. */
  81055. private _scene;
  81056. /**
  81057. * The current value of the runtime animation
  81058. */
  81059. private _currentValue;
  81060. /** @hidden */
  81061. _animationState: _IAnimationState;
  81062. /**
  81063. * The active target of the runtime animation
  81064. */
  81065. private _activeTargets;
  81066. private _currentActiveTarget;
  81067. private _directTarget;
  81068. /**
  81069. * The target path of the runtime animation
  81070. */
  81071. private _targetPath;
  81072. /**
  81073. * The weight of the runtime animation
  81074. */
  81075. private _weight;
  81076. /**
  81077. * The ratio offset of the runtime animation
  81078. */
  81079. private _ratioOffset;
  81080. /**
  81081. * The previous delay of the runtime animation
  81082. */
  81083. private _previousDelay;
  81084. /**
  81085. * The previous ratio of the runtime animation
  81086. */
  81087. private _previousRatio;
  81088. private _enableBlending;
  81089. private _keys;
  81090. private _minFrame;
  81091. private _maxFrame;
  81092. private _minValue;
  81093. private _maxValue;
  81094. private _targetIsArray;
  81095. /**
  81096. * Gets the current frame of the runtime animation
  81097. */
  81098. readonly currentFrame: number;
  81099. /**
  81100. * Gets the weight of the runtime animation
  81101. */
  81102. readonly weight: number;
  81103. /**
  81104. * Gets the current value of the runtime animation
  81105. */
  81106. readonly currentValue: any;
  81107. /**
  81108. * Gets the target path of the runtime animation
  81109. */
  81110. readonly targetPath: string;
  81111. /**
  81112. * Gets the actual target of the runtime animation
  81113. */
  81114. readonly target: any;
  81115. /** @hidden */
  81116. _onLoop: () => void;
  81117. /**
  81118. * Create a new RuntimeAnimation object
  81119. * @param target defines the target of the animation
  81120. * @param animation defines the source animation object
  81121. * @param scene defines the hosting scene
  81122. * @param host defines the initiating Animatable
  81123. */
  81124. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81125. private _preparePath;
  81126. /**
  81127. * Gets the animation from the runtime animation
  81128. */
  81129. readonly animation: Animation;
  81130. /**
  81131. * Resets the runtime animation to the beginning
  81132. * @param restoreOriginal defines whether to restore the target property to the original value
  81133. */
  81134. reset(restoreOriginal?: boolean): void;
  81135. /**
  81136. * Specifies if the runtime animation is stopped
  81137. * @returns Boolean specifying if the runtime animation is stopped
  81138. */
  81139. isStopped(): boolean;
  81140. /**
  81141. * Disposes of the runtime animation
  81142. */
  81143. dispose(): void;
  81144. /**
  81145. * Apply the interpolated value to the target
  81146. * @param currentValue defines the value computed by the animation
  81147. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81148. */
  81149. setValue(currentValue: any, weight: number): void;
  81150. private _getOriginalValues;
  81151. private _setValue;
  81152. /**
  81153. * Gets the loop pmode of the runtime animation
  81154. * @returns Loop Mode
  81155. */
  81156. private _getCorrectLoopMode;
  81157. /**
  81158. * Move the current animation to a given frame
  81159. * @param frame defines the frame to move to
  81160. */
  81161. goToFrame(frame: number): void;
  81162. /**
  81163. * @hidden Internal use only
  81164. */
  81165. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81166. /**
  81167. * Execute the current animation
  81168. * @param delay defines the delay to add to the current frame
  81169. * @param from defines the lower bound of the animation range
  81170. * @param to defines the upper bound of the animation range
  81171. * @param loop defines if the current animation must loop
  81172. * @param speedRatio defines the current speed ratio
  81173. * @param weight defines the weight of the animation (default is -1 so no weight)
  81174. * @param onLoop optional callback called when animation loops
  81175. * @returns a boolean indicating if the animation is running
  81176. */
  81177. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81178. }
  81179. }
  81180. declare module BABYLON {
  81181. /**
  81182. * Class used to store an actual running animation
  81183. */
  81184. export class Animatable {
  81185. /** defines the target object */
  81186. target: any;
  81187. /** defines the starting frame number (default is 0) */
  81188. fromFrame: number;
  81189. /** defines the ending frame number (default is 100) */
  81190. toFrame: number;
  81191. /** defines if the animation must loop (default is false) */
  81192. loopAnimation: boolean;
  81193. /** defines a callback to call when animation ends if it is not looping */
  81194. onAnimationEnd?: (() => void) | null | undefined;
  81195. /** defines a callback to call when animation loops */
  81196. onAnimationLoop?: (() => void) | null | undefined;
  81197. private _localDelayOffset;
  81198. private _pausedDelay;
  81199. private _runtimeAnimations;
  81200. private _paused;
  81201. private _scene;
  81202. private _speedRatio;
  81203. private _weight;
  81204. private _syncRoot;
  81205. /**
  81206. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81207. * This will only apply for non looping animation (default is true)
  81208. */
  81209. disposeOnEnd: boolean;
  81210. /**
  81211. * Gets a boolean indicating if the animation has started
  81212. */
  81213. animationStarted: boolean;
  81214. /**
  81215. * Observer raised when the animation ends
  81216. */
  81217. onAnimationEndObservable: Observable<Animatable>;
  81218. /**
  81219. * Observer raised when the animation loops
  81220. */
  81221. onAnimationLoopObservable: Observable<Animatable>;
  81222. /**
  81223. * Gets the root Animatable used to synchronize and normalize animations
  81224. */
  81225. readonly syncRoot: Nullable<Animatable>;
  81226. /**
  81227. * Gets the current frame of the first RuntimeAnimation
  81228. * Used to synchronize Animatables
  81229. */
  81230. readonly masterFrame: number;
  81231. /**
  81232. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81233. */
  81234. weight: number;
  81235. /**
  81236. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81237. */
  81238. speedRatio: number;
  81239. /**
  81240. * Creates a new Animatable
  81241. * @param scene defines the hosting scene
  81242. * @param target defines the target object
  81243. * @param fromFrame defines the starting frame number (default is 0)
  81244. * @param toFrame defines the ending frame number (default is 100)
  81245. * @param loopAnimation defines if the animation must loop (default is false)
  81246. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81247. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81248. * @param animations defines a group of animation to add to the new Animatable
  81249. * @param onAnimationLoop defines a callback to call when animation loops
  81250. */
  81251. constructor(scene: Scene,
  81252. /** defines the target object */
  81253. target: any,
  81254. /** defines the starting frame number (default is 0) */
  81255. fromFrame?: number,
  81256. /** defines the ending frame number (default is 100) */
  81257. toFrame?: number,
  81258. /** defines if the animation must loop (default is false) */
  81259. loopAnimation?: boolean, speedRatio?: number,
  81260. /** defines a callback to call when animation ends if it is not looping */
  81261. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81262. /** defines a callback to call when animation loops */
  81263. onAnimationLoop?: (() => void) | null | undefined);
  81264. /**
  81265. * Synchronize and normalize current Animatable with a source Animatable
  81266. * This is useful when using animation weights and when animations are not of the same length
  81267. * @param root defines the root Animatable to synchronize with
  81268. * @returns the current Animatable
  81269. */
  81270. syncWith(root: Animatable): Animatable;
  81271. /**
  81272. * Gets the list of runtime animations
  81273. * @returns an array of RuntimeAnimation
  81274. */
  81275. getAnimations(): RuntimeAnimation[];
  81276. /**
  81277. * Adds more animations to the current animatable
  81278. * @param target defines the target of the animations
  81279. * @param animations defines the new animations to add
  81280. */
  81281. appendAnimations(target: any, animations: Animation[]): void;
  81282. /**
  81283. * Gets the source animation for a specific property
  81284. * @param property defines the propertyu to look for
  81285. * @returns null or the source animation for the given property
  81286. */
  81287. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81288. /**
  81289. * Gets the runtime animation for a specific property
  81290. * @param property defines the propertyu to look for
  81291. * @returns null or the runtime animation for the given property
  81292. */
  81293. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81294. /**
  81295. * Resets the animatable to its original state
  81296. */
  81297. reset(): void;
  81298. /**
  81299. * Allows the animatable to blend with current running animations
  81300. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81301. * @param blendingSpeed defines the blending speed to use
  81302. */
  81303. enableBlending(blendingSpeed: number): void;
  81304. /**
  81305. * Disable animation blending
  81306. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81307. */
  81308. disableBlending(): void;
  81309. /**
  81310. * Jump directly to a given frame
  81311. * @param frame defines the frame to jump to
  81312. */
  81313. goToFrame(frame: number): void;
  81314. /**
  81315. * Pause the animation
  81316. */
  81317. pause(): void;
  81318. /**
  81319. * Restart the animation
  81320. */
  81321. restart(): void;
  81322. private _raiseOnAnimationEnd;
  81323. /**
  81324. * Stop and delete the current animation
  81325. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81326. * @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)
  81327. */
  81328. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81329. /**
  81330. * Wait asynchronously for the animation to end
  81331. * @returns a promise which will be fullfilled when the animation ends
  81332. */
  81333. waitAsync(): Promise<Animatable>;
  81334. /** @hidden */
  81335. _animate(delay: number): boolean;
  81336. }
  81337. interface Scene {
  81338. /** @hidden */
  81339. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81340. /** @hidden */
  81341. _processLateAnimationBindingsForMatrices(holder: {
  81342. totalWeight: number;
  81343. animations: RuntimeAnimation[];
  81344. originalValue: Matrix;
  81345. }): any;
  81346. /** @hidden */
  81347. _processLateAnimationBindingsForQuaternions(holder: {
  81348. totalWeight: number;
  81349. animations: RuntimeAnimation[];
  81350. originalValue: Quaternion;
  81351. }, refQuaternion: Quaternion): Quaternion;
  81352. /** @hidden */
  81353. _processLateAnimationBindings(): void;
  81354. /**
  81355. * Will start the animation sequence of a given target
  81356. * @param target defines the target
  81357. * @param from defines from which frame should animation start
  81358. * @param to defines until which frame should animation run.
  81359. * @param weight defines the weight to apply to the animation (1.0 by default)
  81360. * @param loop defines if the animation loops
  81361. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81362. * @param onAnimationEnd defines the function to be executed when the animation ends
  81363. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81364. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81365. * @param onAnimationLoop defines the callback to call when an animation loops
  81366. * @returns the animatable object created for this animation
  81367. */
  81368. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81369. /**
  81370. * Will start the animation sequence of a given target
  81371. * @param target defines the target
  81372. * @param from defines from which frame should animation start
  81373. * @param to defines until which frame should animation run.
  81374. * @param loop defines if the animation loops
  81375. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81376. * @param onAnimationEnd defines the function to be executed when the animation ends
  81377. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81378. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81379. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81380. * @param onAnimationLoop defines the callback to call when an animation loops
  81381. * @returns the animatable object created for this animation
  81382. */
  81383. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81384. /**
  81385. * Will start the animation sequence of a given target and its hierarchy
  81386. * @param target defines the target
  81387. * @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.
  81388. * @param from defines from which frame should animation start
  81389. * @param to defines until which frame should animation run.
  81390. * @param loop defines if the animation loops
  81391. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81392. * @param onAnimationEnd defines the function to be executed when the animation ends
  81393. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81394. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81395. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81396. * @param onAnimationLoop defines the callback to call when an animation loops
  81397. * @returns the list of created animatables
  81398. */
  81399. 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[];
  81400. /**
  81401. * Begin a new animation on a given node
  81402. * @param target defines the target where the animation will take place
  81403. * @param animations defines the list of animations to start
  81404. * @param from defines the initial value
  81405. * @param to defines the final value
  81406. * @param loop defines if you want animation to loop (off by default)
  81407. * @param speedRatio defines the speed ratio to apply to all animations
  81408. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81409. * @param onAnimationLoop defines the callback to call when an animation loops
  81410. * @returns the list of created animatables
  81411. */
  81412. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81413. /**
  81414. * Begin a new animation on a given node and its hierarchy
  81415. * @param target defines the root node where the animation will take place
  81416. * @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.
  81417. * @param animations defines the list of animations to start
  81418. * @param from defines the initial value
  81419. * @param to defines the final value
  81420. * @param loop defines if you want animation to loop (off by default)
  81421. * @param speedRatio defines the speed ratio to apply to all animations
  81422. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81423. * @param onAnimationLoop defines the callback to call when an animation loops
  81424. * @returns the list of animatables created for all nodes
  81425. */
  81426. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81427. /**
  81428. * Gets the animatable associated with a specific target
  81429. * @param target defines the target of the animatable
  81430. * @returns the required animatable if found
  81431. */
  81432. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81433. /**
  81434. * Gets all animatables associated with a given target
  81435. * @param target defines the target to look animatables for
  81436. * @returns an array of Animatables
  81437. */
  81438. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81439. /**
  81440. * Stops and removes all animations that have been applied to the scene
  81441. */
  81442. stopAllAnimations(): void;
  81443. /**
  81444. * Gets the current delta time used by animation engine
  81445. */
  81446. deltaTime: number;
  81447. }
  81448. interface Bone {
  81449. /**
  81450. * Copy an animation range from another bone
  81451. * @param source defines the source bone
  81452. * @param rangeName defines the range name to copy
  81453. * @param frameOffset defines the frame offset
  81454. * @param rescaleAsRequired defines if rescaling must be applied if required
  81455. * @param skelDimensionsRatio defines the scaling ratio
  81456. * @returns true if operation was successful
  81457. */
  81458. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81459. }
  81460. }
  81461. declare module BABYLON {
  81462. /**
  81463. * Class used to override all child animations of a given target
  81464. */
  81465. export class AnimationPropertiesOverride {
  81466. /**
  81467. * Gets or sets a value indicating if animation blending must be used
  81468. */
  81469. enableBlending: boolean;
  81470. /**
  81471. * Gets or sets the blending speed to use when enableBlending is true
  81472. */
  81473. blendingSpeed: number;
  81474. /**
  81475. * Gets or sets the default loop mode to use
  81476. */
  81477. loopMode: number;
  81478. }
  81479. }
  81480. declare module BABYLON {
  81481. /**
  81482. * Class used to handle skinning animations
  81483. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81484. */
  81485. export class Skeleton implements IAnimatable {
  81486. /** defines the skeleton name */
  81487. name: string;
  81488. /** defines the skeleton Id */
  81489. id: string;
  81490. /**
  81491. * Defines the list of child bones
  81492. */
  81493. bones: Bone[];
  81494. /**
  81495. * Defines an estimate of the dimension of the skeleton at rest
  81496. */
  81497. dimensionsAtRest: Vector3;
  81498. /**
  81499. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81500. */
  81501. needInitialSkinMatrix: boolean;
  81502. /**
  81503. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81504. */
  81505. overrideMesh: Nullable<AbstractMesh>;
  81506. /**
  81507. * Gets the list of animations attached to this skeleton
  81508. */
  81509. animations: Array<Animation>;
  81510. private _scene;
  81511. private _isDirty;
  81512. private _transformMatrices;
  81513. private _transformMatrixTexture;
  81514. private _meshesWithPoseMatrix;
  81515. private _animatables;
  81516. private _identity;
  81517. private _synchronizedWithMesh;
  81518. private _ranges;
  81519. private _lastAbsoluteTransformsUpdateId;
  81520. private _canUseTextureForBones;
  81521. private _uniqueId;
  81522. /** @hidden */
  81523. _numBonesWithLinkedTransformNode: number;
  81524. /** @hidden */
  81525. _hasWaitingData: Nullable<boolean>;
  81526. /**
  81527. * Specifies if the skeleton should be serialized
  81528. */
  81529. doNotSerialize: boolean;
  81530. private _useTextureToStoreBoneMatrices;
  81531. /**
  81532. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81533. * Please note that this option is not available if the hardware does not support it
  81534. */
  81535. useTextureToStoreBoneMatrices: boolean;
  81536. private _animationPropertiesOverride;
  81537. /**
  81538. * Gets or sets the animation properties override
  81539. */
  81540. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81541. /**
  81542. * List of inspectable custom properties (used by the Inspector)
  81543. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81544. */
  81545. inspectableCustomProperties: IInspectable[];
  81546. /**
  81547. * An observable triggered before computing the skeleton's matrices
  81548. */
  81549. onBeforeComputeObservable: Observable<Skeleton>;
  81550. /**
  81551. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81552. */
  81553. readonly isUsingTextureForMatrices: boolean;
  81554. /**
  81555. * Gets the unique ID of this skeleton
  81556. */
  81557. readonly uniqueId: number;
  81558. /**
  81559. * Creates a new skeleton
  81560. * @param name defines the skeleton name
  81561. * @param id defines the skeleton Id
  81562. * @param scene defines the hosting scene
  81563. */
  81564. constructor(
  81565. /** defines the skeleton name */
  81566. name: string,
  81567. /** defines the skeleton Id */
  81568. id: string, scene: Scene);
  81569. /**
  81570. * Gets the current object class name.
  81571. * @return the class name
  81572. */
  81573. getClassName(): string;
  81574. /**
  81575. * Returns an array containing the root bones
  81576. * @returns an array containing the root bones
  81577. */
  81578. getChildren(): Array<Bone>;
  81579. /**
  81580. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81581. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81582. * @returns a Float32Array containing matrices data
  81583. */
  81584. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81585. /**
  81586. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81587. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81588. * @returns a raw texture containing the data
  81589. */
  81590. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81591. /**
  81592. * Gets the current hosting scene
  81593. * @returns a scene object
  81594. */
  81595. getScene(): Scene;
  81596. /**
  81597. * Gets a string representing the current skeleton data
  81598. * @param fullDetails defines a boolean indicating if we want a verbose version
  81599. * @returns a string representing the current skeleton data
  81600. */
  81601. toString(fullDetails?: boolean): string;
  81602. /**
  81603. * Get bone's index searching by name
  81604. * @param name defines bone's name to search for
  81605. * @return the indice of the bone. Returns -1 if not found
  81606. */
  81607. getBoneIndexByName(name: string): number;
  81608. /**
  81609. * Creater a new animation range
  81610. * @param name defines the name of the range
  81611. * @param from defines the start key
  81612. * @param to defines the end key
  81613. */
  81614. createAnimationRange(name: string, from: number, to: number): void;
  81615. /**
  81616. * Delete a specific animation range
  81617. * @param name defines the name of the range
  81618. * @param deleteFrames defines if frames must be removed as well
  81619. */
  81620. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81621. /**
  81622. * Gets a specific animation range
  81623. * @param name defines the name of the range to look for
  81624. * @returns the requested animation range or null if not found
  81625. */
  81626. getAnimationRange(name: string): Nullable<AnimationRange>;
  81627. /**
  81628. * Gets the list of all animation ranges defined on this skeleton
  81629. * @returns an array
  81630. */
  81631. getAnimationRanges(): Nullable<AnimationRange>[];
  81632. /**
  81633. * Copy animation range from a source skeleton.
  81634. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81635. * @param source defines the source skeleton
  81636. * @param name defines the name of the range to copy
  81637. * @param rescaleAsRequired defines if rescaling must be applied if required
  81638. * @returns true if operation was successful
  81639. */
  81640. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81641. /**
  81642. * Forces the skeleton to go to rest pose
  81643. */
  81644. returnToRest(): void;
  81645. private _getHighestAnimationFrame;
  81646. /**
  81647. * Begin a specific animation range
  81648. * @param name defines the name of the range to start
  81649. * @param loop defines if looping must be turned on (false by default)
  81650. * @param speedRatio defines the speed ratio to apply (1 by default)
  81651. * @param onAnimationEnd defines a callback which will be called when animation will end
  81652. * @returns a new animatable
  81653. */
  81654. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81655. /** @hidden */
  81656. _markAsDirty(): void;
  81657. /** @hidden */
  81658. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81659. /** @hidden */
  81660. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81661. private _computeTransformMatrices;
  81662. /**
  81663. * Build all resources required to render a skeleton
  81664. */
  81665. prepare(): void;
  81666. /**
  81667. * Gets the list of animatables currently running for this skeleton
  81668. * @returns an array of animatables
  81669. */
  81670. getAnimatables(): IAnimatable[];
  81671. /**
  81672. * Clone the current skeleton
  81673. * @param name defines the name of the new skeleton
  81674. * @param id defines the id of the new skeleton
  81675. * @returns the new skeleton
  81676. */
  81677. clone(name: string, id?: string): Skeleton;
  81678. /**
  81679. * Enable animation blending for this skeleton
  81680. * @param blendingSpeed defines the blending speed to apply
  81681. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81682. */
  81683. enableBlending(blendingSpeed?: number): void;
  81684. /**
  81685. * Releases all resources associated with the current skeleton
  81686. */
  81687. dispose(): void;
  81688. /**
  81689. * Serialize the skeleton in a JSON object
  81690. * @returns a JSON object
  81691. */
  81692. serialize(): any;
  81693. /**
  81694. * Creates a new skeleton from serialized data
  81695. * @param parsedSkeleton defines the serialized data
  81696. * @param scene defines the hosting scene
  81697. * @returns a new skeleton
  81698. */
  81699. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81700. /**
  81701. * Compute all node absolute transforms
  81702. * @param forceUpdate defines if computation must be done even if cache is up to date
  81703. */
  81704. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81705. /**
  81706. * Gets the root pose matrix
  81707. * @returns a matrix
  81708. */
  81709. getPoseMatrix(): Nullable<Matrix>;
  81710. /**
  81711. * Sorts bones per internal index
  81712. */
  81713. sortBones(): void;
  81714. private _sortBones;
  81715. }
  81716. }
  81717. declare module BABYLON {
  81718. /**
  81719. * Class used to store bone information
  81720. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81721. */
  81722. export class Bone extends Node {
  81723. /**
  81724. * defines the bone name
  81725. */
  81726. name: string;
  81727. private static _tmpVecs;
  81728. private static _tmpQuat;
  81729. private static _tmpMats;
  81730. /**
  81731. * Gets the list of child bones
  81732. */
  81733. children: Bone[];
  81734. /** Gets the animations associated with this bone */
  81735. animations: Animation[];
  81736. /**
  81737. * Gets or sets bone length
  81738. */
  81739. length: number;
  81740. /**
  81741. * @hidden Internal only
  81742. * Set this value to map this bone to a different index in the transform matrices
  81743. * Set this value to -1 to exclude the bone from the transform matrices
  81744. */
  81745. _index: Nullable<number>;
  81746. private _skeleton;
  81747. private _localMatrix;
  81748. private _restPose;
  81749. private _baseMatrix;
  81750. private _absoluteTransform;
  81751. private _invertedAbsoluteTransform;
  81752. private _parent;
  81753. private _scalingDeterminant;
  81754. private _worldTransform;
  81755. private _localScaling;
  81756. private _localRotation;
  81757. private _localPosition;
  81758. private _needToDecompose;
  81759. private _needToCompose;
  81760. /** @hidden */
  81761. _linkedTransformNode: Nullable<TransformNode>;
  81762. /** @hidden */
  81763. _waitingTransformNodeId: Nullable<string>;
  81764. /** @hidden */
  81765. /** @hidden */
  81766. _matrix: Matrix;
  81767. /**
  81768. * Create a new bone
  81769. * @param name defines the bone name
  81770. * @param skeleton defines the parent skeleton
  81771. * @param parentBone defines the parent (can be null if the bone is the root)
  81772. * @param localMatrix defines the local matrix
  81773. * @param restPose defines the rest pose matrix
  81774. * @param baseMatrix defines the base matrix
  81775. * @param index defines index of the bone in the hiearchy
  81776. */
  81777. constructor(
  81778. /**
  81779. * defines the bone name
  81780. */
  81781. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  81782. /**
  81783. * Gets the current object class name.
  81784. * @return the class name
  81785. */
  81786. getClassName(): string;
  81787. /**
  81788. * Gets the parent skeleton
  81789. * @returns a skeleton
  81790. */
  81791. getSkeleton(): Skeleton;
  81792. /**
  81793. * Gets parent bone
  81794. * @returns a bone or null if the bone is the root of the bone hierarchy
  81795. */
  81796. getParent(): Nullable<Bone>;
  81797. /**
  81798. * Returns an array containing the root bones
  81799. * @returns an array containing the root bones
  81800. */
  81801. getChildren(): Array<Bone>;
  81802. /**
  81803. * Gets the node index in matrix array generated for rendering
  81804. * @returns the node index
  81805. */
  81806. getIndex(): number;
  81807. /**
  81808. * Sets the parent bone
  81809. * @param parent defines the parent (can be null if the bone is the root)
  81810. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81811. */
  81812. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  81813. /**
  81814. * Gets the local matrix
  81815. * @returns a matrix
  81816. */
  81817. getLocalMatrix(): Matrix;
  81818. /**
  81819. * Gets the base matrix (initial matrix which remains unchanged)
  81820. * @returns a matrix
  81821. */
  81822. getBaseMatrix(): Matrix;
  81823. /**
  81824. * Gets the rest pose matrix
  81825. * @returns a matrix
  81826. */
  81827. getRestPose(): Matrix;
  81828. /**
  81829. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  81830. */
  81831. getWorldMatrix(): Matrix;
  81832. /**
  81833. * Sets the local matrix to rest pose matrix
  81834. */
  81835. returnToRest(): void;
  81836. /**
  81837. * Gets the inverse of the absolute transform matrix.
  81838. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  81839. * @returns a matrix
  81840. */
  81841. getInvertedAbsoluteTransform(): Matrix;
  81842. /**
  81843. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81844. * @returns a matrix
  81845. */
  81846. getAbsoluteTransform(): Matrix;
  81847. /**
  81848. * Links with the given transform node.
  81849. * The local matrix of this bone is copied from the transform node every frame.
  81850. * @param transformNode defines the transform node to link to
  81851. */
  81852. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81853. /**
  81854. * Gets the node used to drive the bone's transformation
  81855. * @returns a transform node or null
  81856. */
  81857. getTransformNode(): Nullable<TransformNode>;
  81858. /** Gets or sets current position (in local space) */
  81859. position: Vector3;
  81860. /** Gets or sets current rotation (in local space) */
  81861. rotation: Vector3;
  81862. /** Gets or sets current rotation quaternion (in local space) */
  81863. rotationQuaternion: Quaternion;
  81864. /** Gets or sets current scaling (in local space) */
  81865. scaling: Vector3;
  81866. /**
  81867. * Gets the animation properties override
  81868. */
  81869. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81870. private _decompose;
  81871. private _compose;
  81872. /**
  81873. * Update the base and local matrices
  81874. * @param matrix defines the new base or local matrix
  81875. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81876. * @param updateLocalMatrix defines if the local matrix should be updated
  81877. */
  81878. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  81879. /** @hidden */
  81880. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  81881. /**
  81882. * Flag the bone as dirty (Forcing it to update everything)
  81883. */
  81884. markAsDirty(): void;
  81885. /** @hidden */
  81886. _markAsDirtyAndCompose(): void;
  81887. private _markAsDirtyAndDecompose;
  81888. /**
  81889. * Translate the bone in local or world space
  81890. * @param vec The amount to translate the bone
  81891. * @param space The space that the translation is in
  81892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81893. */
  81894. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81895. /**
  81896. * Set the postion of the bone in local or world space
  81897. * @param position The position to set the bone
  81898. * @param space The space that the position is in
  81899. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81900. */
  81901. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81902. /**
  81903. * Set the absolute position of the bone (world space)
  81904. * @param position The position to set the bone
  81905. * @param mesh The mesh that this bone is attached to
  81906. */
  81907. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81908. /**
  81909. * Scale the bone on the x, y and z axes (in local space)
  81910. * @param x The amount to scale the bone on the x axis
  81911. * @param y The amount to scale the bone on the y axis
  81912. * @param z The amount to scale the bone on the z axis
  81913. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81914. */
  81915. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81916. /**
  81917. * Set the bone scaling in local space
  81918. * @param scale defines the scaling vector
  81919. */
  81920. setScale(scale: Vector3): void;
  81921. /**
  81922. * Gets the current scaling in local space
  81923. * @returns the current scaling vector
  81924. */
  81925. getScale(): Vector3;
  81926. /**
  81927. * Gets the current scaling in local space and stores it in a target vector
  81928. * @param result defines the target vector
  81929. */
  81930. getScaleToRef(result: Vector3): void;
  81931. /**
  81932. * Set the yaw, pitch, and roll of the bone in local or world space
  81933. * @param yaw The rotation of the bone on the y axis
  81934. * @param pitch The rotation of the bone on the x axis
  81935. * @param roll The rotation of the bone on the z axis
  81936. * @param space The space that the axes of rotation are in
  81937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81938. */
  81939. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81940. /**
  81941. * Add a rotation to the bone on an axis in local or world space
  81942. * @param axis The axis to rotate the bone on
  81943. * @param amount The amount to rotate the bone
  81944. * @param space The space that the axis is in
  81945. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81946. */
  81947. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81948. /**
  81949. * Set the rotation of the bone to a particular axis angle in local or world space
  81950. * @param axis The axis to rotate the bone on
  81951. * @param angle The angle that the bone should be rotated to
  81952. * @param space The space that the axis is in
  81953. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81954. */
  81955. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81956. /**
  81957. * Set the euler rotation of the bone in local of world space
  81958. * @param rotation The euler rotation that the bone should be set to
  81959. * @param space The space that the rotation is in
  81960. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81961. */
  81962. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81963. /**
  81964. * Set the quaternion rotation of the bone in local of world space
  81965. * @param quat The quaternion rotation that the bone should be set to
  81966. * @param space The space that the rotation is in
  81967. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81968. */
  81969. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81970. /**
  81971. * Set the rotation matrix of the bone in local of world space
  81972. * @param rotMat The rotation matrix that the bone should be set to
  81973. * @param space The space that the rotation is in
  81974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81975. */
  81976. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81977. private _rotateWithMatrix;
  81978. private _getNegativeRotationToRef;
  81979. /**
  81980. * Get the position of the bone in local or world space
  81981. * @param space The space that the returned position is in
  81982. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81983. * @returns The position of the bone
  81984. */
  81985. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81986. /**
  81987. * Copy the position of the bone to a vector3 in local or world space
  81988. * @param space The space that the returned position is in
  81989. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81990. * @param result The vector3 to copy the position to
  81991. */
  81992. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81993. /**
  81994. * Get the absolute position of the bone (world space)
  81995. * @param mesh The mesh that this bone is attached to
  81996. * @returns The absolute position of the bone
  81997. */
  81998. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81999. /**
  82000. * Copy the absolute position of the bone (world space) to the result param
  82001. * @param mesh The mesh that this bone is attached to
  82002. * @param result The vector3 to copy the absolute position to
  82003. */
  82004. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  82005. /**
  82006. * Compute the absolute transforms of this bone and its children
  82007. */
  82008. computeAbsoluteTransforms(): void;
  82009. /**
  82010. * Get the world direction from an axis that is in the local space of the bone
  82011. * @param localAxis The local direction that is used to compute the world direction
  82012. * @param mesh The mesh that this bone is attached to
  82013. * @returns The world direction
  82014. */
  82015. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82016. /**
  82017. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  82018. * @param localAxis The local direction that is used to compute the world direction
  82019. * @param mesh The mesh that this bone is attached to
  82020. * @param result The vector3 that the world direction will be copied to
  82021. */
  82022. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82023. /**
  82024. * Get the euler rotation of the bone in local or world space
  82025. * @param space The space that the rotation should be in
  82026. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82027. * @returns The euler rotation
  82028. */
  82029. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82030. /**
  82031. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  82032. * @param space The space that the rotation should be in
  82033. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82034. * @param result The vector3 that the rotation should be copied to
  82035. */
  82036. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82037. /**
  82038. * Get the quaternion rotation of the bone in either local or world space
  82039. * @param space The space that the rotation should be in
  82040. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82041. * @returns The quaternion rotation
  82042. */
  82043. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82044. /**
  82045. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82046. * @param space The space that the rotation should be in
  82047. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82048. * @param result The quaternion that the rotation should be copied to
  82049. */
  82050. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82051. /**
  82052. * Get the rotation matrix of the bone in local or world space
  82053. * @param space The space that the rotation should be in
  82054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82055. * @returns The rotation matrix
  82056. */
  82057. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82058. /**
  82059. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82060. * @param space The space that the rotation should be in
  82061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82062. * @param result The quaternion that the rotation should be copied to
  82063. */
  82064. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82065. /**
  82066. * Get the world position of a point that is in the local space of the bone
  82067. * @param position The local position
  82068. * @param mesh The mesh that this bone is attached to
  82069. * @returns The world position
  82070. */
  82071. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82072. /**
  82073. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82074. * @param position The local position
  82075. * @param mesh The mesh that this bone is attached to
  82076. * @param result The vector3 that the world position should be copied to
  82077. */
  82078. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82079. /**
  82080. * Get the local position of a point that is in world space
  82081. * @param position The world position
  82082. * @param mesh The mesh that this bone is attached to
  82083. * @returns The local position
  82084. */
  82085. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82086. /**
  82087. * Get the local position of a point that is in world space and copy it to the result param
  82088. * @param position The world position
  82089. * @param mesh The mesh that this bone is attached to
  82090. * @param result The vector3 that the local position should be copied to
  82091. */
  82092. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82093. }
  82094. }
  82095. declare module BABYLON {
  82096. /**
  82097. * 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.
  82098. * @see https://doc.babylonjs.com/how_to/transformnode
  82099. */
  82100. export class TransformNode extends Node {
  82101. /**
  82102. * Object will not rotate to face the camera
  82103. */
  82104. static BILLBOARDMODE_NONE: number;
  82105. /**
  82106. * Object will rotate to face the camera but only on the x axis
  82107. */
  82108. static BILLBOARDMODE_X: number;
  82109. /**
  82110. * Object will rotate to face the camera but only on the y axis
  82111. */
  82112. static BILLBOARDMODE_Y: number;
  82113. /**
  82114. * Object will rotate to face the camera but only on the z axis
  82115. */
  82116. static BILLBOARDMODE_Z: number;
  82117. /**
  82118. * Object will rotate to face the camera
  82119. */
  82120. static BILLBOARDMODE_ALL: number;
  82121. /**
  82122. * Object will rotate to face the camera's position instead of orientation
  82123. */
  82124. static BILLBOARDMODE_USE_POSITION: number;
  82125. private _forward;
  82126. private _forwardInverted;
  82127. private _up;
  82128. private _right;
  82129. private _rightInverted;
  82130. private _position;
  82131. private _rotation;
  82132. private _rotationQuaternion;
  82133. protected _scaling: Vector3;
  82134. protected _isDirty: boolean;
  82135. private _transformToBoneReferal;
  82136. private _isAbsoluteSynced;
  82137. private _billboardMode;
  82138. /**
  82139. * Gets or sets the billboard mode. Default is 0.
  82140. *
  82141. * | Value | Type | Description |
  82142. * | --- | --- | --- |
  82143. * | 0 | BILLBOARDMODE_NONE | |
  82144. * | 1 | BILLBOARDMODE_X | |
  82145. * | 2 | BILLBOARDMODE_Y | |
  82146. * | 4 | BILLBOARDMODE_Z | |
  82147. * | 7 | BILLBOARDMODE_ALL | |
  82148. *
  82149. */
  82150. billboardMode: number;
  82151. private _preserveParentRotationForBillboard;
  82152. /**
  82153. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82154. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82155. */
  82156. preserveParentRotationForBillboard: boolean;
  82157. /**
  82158. * 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
  82159. */
  82160. scalingDeterminant: number;
  82161. private _infiniteDistance;
  82162. /**
  82163. * Gets or sets the distance of the object to max, often used by skybox
  82164. */
  82165. infiniteDistance: boolean;
  82166. /**
  82167. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82168. * By default the system will update normals to compensate
  82169. */
  82170. ignoreNonUniformScaling: boolean;
  82171. /**
  82172. * 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
  82173. */
  82174. reIntegrateRotationIntoRotationQuaternion: boolean;
  82175. /** @hidden */
  82176. _poseMatrix: Nullable<Matrix>;
  82177. /** @hidden */
  82178. _localMatrix: Matrix;
  82179. private _usePivotMatrix;
  82180. private _absolutePosition;
  82181. private _absoluteScaling;
  82182. private _absoluteRotationQuaternion;
  82183. private _pivotMatrix;
  82184. private _pivotMatrixInverse;
  82185. protected _postMultiplyPivotMatrix: boolean;
  82186. protected _isWorldMatrixFrozen: boolean;
  82187. /** @hidden */
  82188. _indexInSceneTransformNodesArray: number;
  82189. /**
  82190. * An event triggered after the world matrix is updated
  82191. */
  82192. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  82193. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  82194. /**
  82195. * Gets a string identifying the name of the class
  82196. * @returns "TransformNode" string
  82197. */
  82198. getClassName(): string;
  82199. /**
  82200. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  82201. */
  82202. position: Vector3;
  82203. /**
  82204. * 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)).
  82205. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  82206. */
  82207. rotation: Vector3;
  82208. /**
  82209. * 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)).
  82210. */
  82211. scaling: Vector3;
  82212. /**
  82213. * 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).
  82214. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  82215. */
  82216. rotationQuaternion: Nullable<Quaternion>;
  82217. /**
  82218. * The forward direction of that transform in world space.
  82219. */
  82220. readonly forward: Vector3;
  82221. /**
  82222. * The up direction of that transform in world space.
  82223. */
  82224. readonly up: Vector3;
  82225. /**
  82226. * The right direction of that transform in world space.
  82227. */
  82228. readonly right: Vector3;
  82229. /**
  82230. * Copies the parameter passed Matrix into the mesh Pose matrix.
  82231. * @param matrix the matrix to copy the pose from
  82232. * @returns this TransformNode.
  82233. */
  82234. updatePoseMatrix(matrix: Matrix): TransformNode;
  82235. /**
  82236. * Returns the mesh Pose matrix.
  82237. * @returns the pose matrix
  82238. */
  82239. getPoseMatrix(): Matrix;
  82240. /** @hidden */
  82241. _isSynchronized(): boolean;
  82242. /** @hidden */
  82243. _initCache(): void;
  82244. /**
  82245. * Flag the transform node as dirty (Forcing it to update everything)
  82246. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  82247. * @returns this transform node
  82248. */
  82249. markAsDirty(property: string): TransformNode;
  82250. /**
  82251. * Returns the current mesh absolute position.
  82252. * Returns a Vector3.
  82253. */
  82254. readonly absolutePosition: Vector3;
  82255. /**
  82256. * Returns the current mesh absolute scaling.
  82257. * Returns a Vector3.
  82258. */
  82259. readonly absoluteScaling: Vector3;
  82260. /**
  82261. * Returns the current mesh absolute rotation.
  82262. * Returns a Quaternion.
  82263. */
  82264. readonly absoluteRotationQuaternion: Quaternion;
  82265. /**
  82266. * Sets a new matrix to apply before all other transformation
  82267. * @param matrix defines the transform matrix
  82268. * @returns the current TransformNode
  82269. */
  82270. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82271. /**
  82272. * Sets a new pivot matrix to the current node
  82273. * @param matrix defines the new pivot matrix to use
  82274. * @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
  82275. * @returns the current TransformNode
  82276. */
  82277. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82278. /**
  82279. * Returns the mesh pivot matrix.
  82280. * Default : Identity.
  82281. * @returns the matrix
  82282. */
  82283. getPivotMatrix(): Matrix;
  82284. /**
  82285. * Instantiate (when possible) or clone that node with its hierarchy
  82286. * @param newParent defines the new parent to use for the instance (or clone)
  82287. * @param options defines options to configure how copy is done
  82288. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  82289. * @returns an instance (or a clone) of the current node with its hiearchy
  82290. */
  82291. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  82292. doNotInstantiate: boolean;
  82293. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  82294. /**
  82295. * Prevents the World matrix to be computed any longer
  82296. * @param newWorldMatrix defines an optional matrix to use as world matrix
  82297. * @returns the TransformNode.
  82298. */
  82299. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  82300. /**
  82301. * Allows back the World matrix computation.
  82302. * @returns the TransformNode.
  82303. */
  82304. unfreezeWorldMatrix(): this;
  82305. /**
  82306. * True if the World matrix has been frozen.
  82307. */
  82308. readonly isWorldMatrixFrozen: boolean;
  82309. /**
  82310. * Retuns the mesh absolute position in the World.
  82311. * @returns a Vector3.
  82312. */
  82313. getAbsolutePosition(): Vector3;
  82314. /**
  82315. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  82316. * @param absolutePosition the absolute position to set
  82317. * @returns the TransformNode.
  82318. */
  82319. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82320. /**
  82321. * Sets the mesh position in its local space.
  82322. * @param vector3 the position to set in localspace
  82323. * @returns the TransformNode.
  82324. */
  82325. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  82326. /**
  82327. * Returns the mesh position in the local space from the current World matrix values.
  82328. * @returns a new Vector3.
  82329. */
  82330. getPositionExpressedInLocalSpace(): Vector3;
  82331. /**
  82332. * Translates the mesh along the passed Vector3 in its local space.
  82333. * @param vector3 the distance to translate in localspace
  82334. * @returns the TransformNode.
  82335. */
  82336. locallyTranslate(vector3: Vector3): TransformNode;
  82337. private static _lookAtVectorCache;
  82338. /**
  82339. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  82340. * @param targetPoint the position (must be in same space as current mesh) to look at
  82341. * @param yawCor optional yaw (y-axis) correction in radians
  82342. * @param pitchCor optional pitch (x-axis) correction in radians
  82343. * @param rollCor optional roll (z-axis) correction in radians
  82344. * @param space the choosen space of the target
  82345. * @returns the TransformNode.
  82346. */
  82347. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  82348. /**
  82349. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82350. * This Vector3 is expressed in the World space.
  82351. * @param localAxis axis to rotate
  82352. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82353. */
  82354. getDirection(localAxis: Vector3): Vector3;
  82355. /**
  82356. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  82357. * localAxis is expressed in the mesh local space.
  82358. * result is computed in the Wordl space from the mesh World matrix.
  82359. * @param localAxis axis to rotate
  82360. * @param result the resulting transformnode
  82361. * @returns this TransformNode.
  82362. */
  82363. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  82364. /**
  82365. * Sets this transform node rotation to the given local axis.
  82366. * @param localAxis the axis in local space
  82367. * @param yawCor optional yaw (y-axis) correction in radians
  82368. * @param pitchCor optional pitch (x-axis) correction in radians
  82369. * @param rollCor optional roll (z-axis) correction in radians
  82370. * @returns this TransformNode
  82371. */
  82372. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  82373. /**
  82374. * Sets a new pivot point to the current node
  82375. * @param point defines the new pivot point to use
  82376. * @param space defines if the point is in world or local space (local by default)
  82377. * @returns the current TransformNode
  82378. */
  82379. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82380. /**
  82381. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82382. * @returns the pivot point
  82383. */
  82384. getPivotPoint(): Vector3;
  82385. /**
  82386. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82387. * @param result the vector3 to store the result
  82388. * @returns this TransformNode.
  82389. */
  82390. getPivotPointToRef(result: Vector3): TransformNode;
  82391. /**
  82392. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82393. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82394. */
  82395. getAbsolutePivotPoint(): Vector3;
  82396. /**
  82397. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82398. * @param result vector3 to store the result
  82399. * @returns this TransformNode.
  82400. */
  82401. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82402. /**
  82403. * Defines the passed node as the parent of the current node.
  82404. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82405. * @see https://doc.babylonjs.com/how_to/parenting
  82406. * @param node the node ot set as the parent
  82407. * @returns this TransformNode.
  82408. */
  82409. setParent(node: Nullable<Node>): TransformNode;
  82410. private _nonUniformScaling;
  82411. /**
  82412. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82413. */
  82414. readonly nonUniformScaling: boolean;
  82415. /** @hidden */
  82416. _updateNonUniformScalingState(value: boolean): boolean;
  82417. /**
  82418. * Attach the current TransformNode to another TransformNode associated with a bone
  82419. * @param bone Bone affecting the TransformNode
  82420. * @param affectedTransformNode TransformNode associated with the bone
  82421. * @returns this object
  82422. */
  82423. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82424. /**
  82425. * Detach the transform node if its associated with a bone
  82426. * @returns this object
  82427. */
  82428. detachFromBone(): TransformNode;
  82429. private static _rotationAxisCache;
  82430. /**
  82431. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82432. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82433. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82434. * The passed axis is also normalized.
  82435. * @param axis the axis to rotate around
  82436. * @param amount the amount to rotate in radians
  82437. * @param space Space to rotate in (Default: local)
  82438. * @returns the TransformNode.
  82439. */
  82440. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82441. /**
  82442. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82443. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82444. * The passed axis is also normalized. .
  82445. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82446. * @param point the point to rotate around
  82447. * @param axis the axis to rotate around
  82448. * @param amount the amount to rotate in radians
  82449. * @returns the TransformNode
  82450. */
  82451. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82452. /**
  82453. * Translates the mesh along the axis vector for the passed distance in the given space.
  82454. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82455. * @param axis the axis to translate in
  82456. * @param distance the distance to translate
  82457. * @param space Space to rotate in (Default: local)
  82458. * @returns the TransformNode.
  82459. */
  82460. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82461. /**
  82462. * Adds a rotation step to the mesh current rotation.
  82463. * x, y, z are Euler angles expressed in radians.
  82464. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82465. * This means this rotation is made in the mesh local space only.
  82466. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82467. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82468. * ```javascript
  82469. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82470. * ```
  82471. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82472. * 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.
  82473. * @param x Rotation to add
  82474. * @param y Rotation to add
  82475. * @param z Rotation to add
  82476. * @returns the TransformNode.
  82477. */
  82478. addRotation(x: number, y: number, z: number): TransformNode;
  82479. /**
  82480. * @hidden
  82481. */
  82482. protected _getEffectiveParent(): Nullable<Node>;
  82483. /**
  82484. * Computes the world matrix of the node
  82485. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82486. * @returns the world matrix
  82487. */
  82488. computeWorldMatrix(force?: boolean): Matrix;
  82489. protected _afterComputeWorldMatrix(): void;
  82490. /**
  82491. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82492. * @param func callback function to add
  82493. *
  82494. * @returns the TransformNode.
  82495. */
  82496. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82497. /**
  82498. * Removes a registered callback function.
  82499. * @param func callback function to remove
  82500. * @returns the TransformNode.
  82501. */
  82502. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82503. /**
  82504. * Gets the position of the current mesh in camera space
  82505. * @param camera defines the camera to use
  82506. * @returns a position
  82507. */
  82508. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82509. /**
  82510. * Returns the distance from the mesh to the active camera
  82511. * @param camera defines the camera to use
  82512. * @returns the distance
  82513. */
  82514. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82515. /**
  82516. * Clone the current transform node
  82517. * @param name Name of the new clone
  82518. * @param newParent New parent for the clone
  82519. * @param doNotCloneChildren Do not clone children hierarchy
  82520. * @returns the new transform node
  82521. */
  82522. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82523. /**
  82524. * Serializes the objects information.
  82525. * @param currentSerializationObject defines the object to serialize in
  82526. * @returns the serialized object
  82527. */
  82528. serialize(currentSerializationObject?: any): any;
  82529. /**
  82530. * Returns a new TransformNode object parsed from the source provided.
  82531. * @param parsedTransformNode is the source.
  82532. * @param scene the scne the object belongs to
  82533. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82534. * @returns a new TransformNode object parsed from the source provided.
  82535. */
  82536. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82537. /**
  82538. * Get all child-transformNodes of this node
  82539. * @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
  82540. * @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
  82541. * @returns an array of TransformNode
  82542. */
  82543. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82544. /**
  82545. * Releases resources associated with this transform node.
  82546. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82547. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82548. */
  82549. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82550. /**
  82551. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82552. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82553. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82554. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82555. * @returns the current mesh
  82556. */
  82557. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82558. private _syncAbsoluteScalingAndRotation;
  82559. }
  82560. }
  82561. declare module BABYLON {
  82562. /**
  82563. * Defines the types of pose enabled controllers that are supported
  82564. */
  82565. export enum PoseEnabledControllerType {
  82566. /**
  82567. * HTC Vive
  82568. */
  82569. VIVE = 0,
  82570. /**
  82571. * Oculus Rift
  82572. */
  82573. OCULUS = 1,
  82574. /**
  82575. * Windows mixed reality
  82576. */
  82577. WINDOWS = 2,
  82578. /**
  82579. * Samsung gear VR
  82580. */
  82581. GEAR_VR = 3,
  82582. /**
  82583. * Google Daydream
  82584. */
  82585. DAYDREAM = 4,
  82586. /**
  82587. * Generic
  82588. */
  82589. GENERIC = 5
  82590. }
  82591. /**
  82592. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82593. */
  82594. export interface MutableGamepadButton {
  82595. /**
  82596. * Value of the button/trigger
  82597. */
  82598. value: number;
  82599. /**
  82600. * If the button/trigger is currently touched
  82601. */
  82602. touched: boolean;
  82603. /**
  82604. * If the button/trigger is currently pressed
  82605. */
  82606. pressed: boolean;
  82607. }
  82608. /**
  82609. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82610. * @hidden
  82611. */
  82612. export interface ExtendedGamepadButton extends GamepadButton {
  82613. /**
  82614. * If the button/trigger is currently pressed
  82615. */
  82616. readonly pressed: boolean;
  82617. /**
  82618. * If the button/trigger is currently touched
  82619. */
  82620. readonly touched: boolean;
  82621. /**
  82622. * Value of the button/trigger
  82623. */
  82624. readonly value: number;
  82625. }
  82626. /** @hidden */
  82627. export interface _GamePadFactory {
  82628. /**
  82629. * Returns wether or not the current gamepad can be created for this type of controller.
  82630. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82631. * @returns true if it can be created, otherwise false
  82632. */
  82633. canCreate(gamepadInfo: any): boolean;
  82634. /**
  82635. * Creates a new instance of the Gamepad.
  82636. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82637. * @returns the new gamepad instance
  82638. */
  82639. create(gamepadInfo: any): Gamepad;
  82640. }
  82641. /**
  82642. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82643. */
  82644. export class PoseEnabledControllerHelper {
  82645. /** @hidden */
  82646. static _ControllerFactories: _GamePadFactory[];
  82647. /** @hidden */
  82648. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82649. /**
  82650. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82651. * @param vrGamepad the gamepad to initialized
  82652. * @returns a vr controller of the type the gamepad identified as
  82653. */
  82654. static InitiateController(vrGamepad: any): Gamepad;
  82655. }
  82656. /**
  82657. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82658. */
  82659. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82660. /**
  82661. * If the controller is used in a webXR session
  82662. */
  82663. isXR: boolean;
  82664. private _deviceRoomPosition;
  82665. private _deviceRoomRotationQuaternion;
  82666. /**
  82667. * The device position in babylon space
  82668. */
  82669. devicePosition: Vector3;
  82670. /**
  82671. * The device rotation in babylon space
  82672. */
  82673. deviceRotationQuaternion: Quaternion;
  82674. /**
  82675. * The scale factor of the device in babylon space
  82676. */
  82677. deviceScaleFactor: number;
  82678. /**
  82679. * (Likely devicePosition should be used instead) The device position in its room space
  82680. */
  82681. position: Vector3;
  82682. /**
  82683. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82684. */
  82685. rotationQuaternion: Quaternion;
  82686. /**
  82687. * The type of controller (Eg. Windows mixed reality)
  82688. */
  82689. controllerType: PoseEnabledControllerType;
  82690. protected _calculatedPosition: Vector3;
  82691. private _calculatedRotation;
  82692. /**
  82693. * The raw pose from the device
  82694. */
  82695. rawPose: DevicePose;
  82696. private _trackPosition;
  82697. private _maxRotationDistFromHeadset;
  82698. private _draggedRoomRotation;
  82699. /**
  82700. * @hidden
  82701. */
  82702. _disableTrackPosition(fixedPosition: Vector3): void;
  82703. /**
  82704. * Internal, the mesh attached to the controller
  82705. * @hidden
  82706. */
  82707. _mesh: Nullable<AbstractMesh>;
  82708. private _poseControlledCamera;
  82709. private _leftHandSystemQuaternion;
  82710. /**
  82711. * Internal, matrix used to convert room space to babylon space
  82712. * @hidden
  82713. */
  82714. _deviceToWorld: Matrix;
  82715. /**
  82716. * Node to be used when casting a ray from the controller
  82717. * @hidden
  82718. */
  82719. _pointingPoseNode: Nullable<TransformNode>;
  82720. /**
  82721. * Name of the child mesh that can be used to cast a ray from the controller
  82722. */
  82723. static readonly POINTING_POSE: string;
  82724. /**
  82725. * Creates a new PoseEnabledController from a gamepad
  82726. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82727. */
  82728. constructor(browserGamepad: any);
  82729. private _workingMatrix;
  82730. /**
  82731. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82732. */
  82733. update(): void;
  82734. /**
  82735. * Updates only the pose device and mesh without doing any button event checking
  82736. */
  82737. protected _updatePoseAndMesh(): void;
  82738. /**
  82739. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82740. * @param poseData raw pose fromthe device
  82741. */
  82742. updateFromDevice(poseData: DevicePose): void;
  82743. /**
  82744. * @hidden
  82745. */
  82746. _meshAttachedObservable: Observable<AbstractMesh>;
  82747. /**
  82748. * Attaches a mesh to the controller
  82749. * @param mesh the mesh to be attached
  82750. */
  82751. attachToMesh(mesh: AbstractMesh): void;
  82752. /**
  82753. * Attaches the controllers mesh to a camera
  82754. * @param camera the camera the mesh should be attached to
  82755. */
  82756. attachToPoseControlledCamera(camera: TargetCamera): void;
  82757. /**
  82758. * Disposes of the controller
  82759. */
  82760. dispose(): void;
  82761. /**
  82762. * The mesh that is attached to the controller
  82763. */
  82764. readonly mesh: Nullable<AbstractMesh>;
  82765. /**
  82766. * Gets the ray of the controller in the direction the controller is pointing
  82767. * @param length the length the resulting ray should be
  82768. * @returns a ray in the direction the controller is pointing
  82769. */
  82770. getForwardRay(length?: number): Ray;
  82771. }
  82772. }
  82773. declare module BABYLON {
  82774. /**
  82775. * Defines the WebVRController object that represents controllers tracked in 3D space
  82776. */
  82777. export abstract class WebVRController extends PoseEnabledController {
  82778. /**
  82779. * Internal, the default controller model for the controller
  82780. */
  82781. protected _defaultModel: Nullable<AbstractMesh>;
  82782. /**
  82783. * Fired when the trigger state has changed
  82784. */
  82785. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  82786. /**
  82787. * Fired when the main button state has changed
  82788. */
  82789. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82790. /**
  82791. * Fired when the secondary button state has changed
  82792. */
  82793. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82794. /**
  82795. * Fired when the pad state has changed
  82796. */
  82797. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  82798. /**
  82799. * Fired when controllers stick values have changed
  82800. */
  82801. onPadValuesChangedObservable: Observable<StickValues>;
  82802. /**
  82803. * Array of button availible on the controller
  82804. */
  82805. protected _buttons: Array<MutableGamepadButton>;
  82806. private _onButtonStateChange;
  82807. /**
  82808. * Fired when a controller button's state has changed
  82809. * @param callback the callback containing the button that was modified
  82810. */
  82811. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  82812. /**
  82813. * X and Y axis corresponding to the controllers joystick
  82814. */
  82815. pad: StickValues;
  82816. /**
  82817. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  82818. */
  82819. hand: string;
  82820. /**
  82821. * The default controller model for the controller
  82822. */
  82823. readonly defaultModel: Nullable<AbstractMesh>;
  82824. /**
  82825. * Creates a new WebVRController from a gamepad
  82826. * @param vrGamepad the gamepad that the WebVRController should be created from
  82827. */
  82828. constructor(vrGamepad: any);
  82829. /**
  82830. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  82831. */
  82832. update(): void;
  82833. /**
  82834. * Function to be called when a button is modified
  82835. */
  82836. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  82837. /**
  82838. * Loads a mesh and attaches it to the controller
  82839. * @param scene the scene the mesh should be added to
  82840. * @param meshLoaded callback for when the mesh has been loaded
  82841. */
  82842. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  82843. private _setButtonValue;
  82844. private _changes;
  82845. private _checkChanges;
  82846. /**
  82847. * Disposes of th webVRCOntroller
  82848. */
  82849. dispose(): void;
  82850. }
  82851. }
  82852. declare module BABYLON {
  82853. /**
  82854. * The HemisphericLight simulates the ambient environment light,
  82855. * so the passed direction is the light reflection direction, not the incoming direction.
  82856. */
  82857. export class HemisphericLight extends Light {
  82858. /**
  82859. * The groundColor is the light in the opposite direction to the one specified during creation.
  82860. * 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.
  82861. */
  82862. groundColor: Color3;
  82863. /**
  82864. * The light reflection direction, not the incoming direction.
  82865. */
  82866. direction: Vector3;
  82867. /**
  82868. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  82869. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  82870. * The HemisphericLight can't cast shadows.
  82871. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82872. * @param name The friendly name of the light
  82873. * @param direction The direction of the light reflection
  82874. * @param scene The scene the light belongs to
  82875. */
  82876. constructor(name: string, direction: Vector3, scene: Scene);
  82877. protected _buildUniformLayout(): void;
  82878. /**
  82879. * Returns the string "HemisphericLight".
  82880. * @return The class name
  82881. */
  82882. getClassName(): string;
  82883. /**
  82884. * Sets the HemisphericLight direction towards the passed target (Vector3).
  82885. * Returns the updated direction.
  82886. * @param target The target the direction should point to
  82887. * @return The computed direction
  82888. */
  82889. setDirectionToTarget(target: Vector3): Vector3;
  82890. /**
  82891. * Returns the shadow generator associated to the light.
  82892. * @returns Always null for hemispheric lights because it does not support shadows.
  82893. */
  82894. getShadowGenerator(): Nullable<IShadowGenerator>;
  82895. /**
  82896. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82897. * @param effect The effect to update
  82898. * @param lightIndex The index of the light in the effect to update
  82899. * @returns The hemispheric light
  82900. */
  82901. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82902. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82903. /**
  82904. * Computes the world matrix of the node
  82905. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82906. * @param useWasUpdatedFlag defines a reserved property
  82907. * @returns the world matrix
  82908. */
  82909. computeWorldMatrix(): Matrix;
  82910. /**
  82911. * Returns the integer 3.
  82912. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82913. */
  82914. getTypeID(): number;
  82915. /**
  82916. * Prepares the list of defines specific to the light type.
  82917. * @param defines the list of defines
  82918. * @param lightIndex defines the index of the light for the effect
  82919. */
  82920. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82921. }
  82922. }
  82923. declare module BABYLON {
  82924. /** @hidden */
  82925. export var vrMultiviewToSingleviewPixelShader: {
  82926. name: string;
  82927. shader: string;
  82928. };
  82929. }
  82930. declare module BABYLON {
  82931. /**
  82932. * Renders to multiple views with a single draw call
  82933. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82934. */
  82935. export class MultiviewRenderTarget extends RenderTargetTexture {
  82936. /**
  82937. * Creates a multiview render target
  82938. * @param scene scene used with the render target
  82939. * @param size the size of the render target (used for each view)
  82940. */
  82941. constructor(scene: Scene, size?: number | {
  82942. width: number;
  82943. height: number;
  82944. } | {
  82945. ratio: number;
  82946. });
  82947. /**
  82948. * @hidden
  82949. * @param faceIndex the face index, if its a cube texture
  82950. */
  82951. _bindFrameBuffer(faceIndex?: number): void;
  82952. /**
  82953. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82954. * @returns the view count
  82955. */
  82956. getViewCount(): number;
  82957. }
  82958. }
  82959. declare module BABYLON {
  82960. /**
  82961. * Represents a camera frustum
  82962. */
  82963. export class Frustum {
  82964. /**
  82965. * Gets the planes representing the frustum
  82966. * @param transform matrix to be applied to the returned planes
  82967. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82968. */
  82969. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82970. /**
  82971. * Gets the near frustum plane transformed by the transform matrix
  82972. * @param transform transformation matrix to be applied to the resulting frustum plane
  82973. * @param frustumPlane the resuling frustum plane
  82974. */
  82975. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82976. /**
  82977. * Gets the far frustum plane transformed by the transform matrix
  82978. * @param transform transformation matrix to be applied to the resulting frustum plane
  82979. * @param frustumPlane the resuling frustum plane
  82980. */
  82981. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82982. /**
  82983. * Gets the left frustum plane transformed by the transform matrix
  82984. * @param transform transformation matrix to be applied to the resulting frustum plane
  82985. * @param frustumPlane the resuling frustum plane
  82986. */
  82987. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82988. /**
  82989. * Gets the right frustum plane transformed by the transform matrix
  82990. * @param transform transformation matrix to be applied to the resulting frustum plane
  82991. * @param frustumPlane the resuling frustum plane
  82992. */
  82993. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82994. /**
  82995. * Gets the top frustum plane transformed by the transform matrix
  82996. * @param transform transformation matrix to be applied to the resulting frustum plane
  82997. * @param frustumPlane the resuling frustum plane
  82998. */
  82999. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83000. /**
  83001. * Gets the bottom frustum plane transformed by the transform matrix
  83002. * @param transform transformation matrix to be applied to the resulting frustum plane
  83003. * @param frustumPlane the resuling frustum plane
  83004. */
  83005. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83006. /**
  83007. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  83008. * @param transform transformation matrix to be applied to the resulting frustum planes
  83009. * @param frustumPlanes the resuling frustum planes
  83010. */
  83011. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  83012. }
  83013. }
  83014. declare module BABYLON {
  83015. interface Engine {
  83016. /**
  83017. * Creates a new multiview render target
  83018. * @param width defines the width of the texture
  83019. * @param height defines the height of the texture
  83020. * @returns the created multiview texture
  83021. */
  83022. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  83023. /**
  83024. * Binds a multiview framebuffer to be drawn to
  83025. * @param multiviewTexture texture to bind
  83026. */
  83027. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  83028. }
  83029. interface Camera {
  83030. /**
  83031. * @hidden
  83032. * 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)
  83033. */
  83034. _useMultiviewToSingleView: boolean;
  83035. /**
  83036. * @hidden
  83037. * 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)
  83038. */
  83039. _multiviewTexture: Nullable<RenderTargetTexture>;
  83040. /**
  83041. * @hidden
  83042. * ensures the multiview texture of the camera exists and has the specified width/height
  83043. * @param width height to set on the multiview texture
  83044. * @param height width to set on the multiview texture
  83045. */
  83046. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83047. }
  83048. interface Scene {
  83049. /** @hidden */
  83050. _transformMatrixR: Matrix;
  83051. /** @hidden */
  83052. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83053. /** @hidden */
  83054. _createMultiviewUbo(): void;
  83055. /** @hidden */
  83056. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83057. /** @hidden */
  83058. _renderMultiviewToSingleView(camera: Camera): void;
  83059. }
  83060. }
  83061. declare module BABYLON {
  83062. /**
  83063. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83064. * This will not be used for webXR as it supports displaying texture arrays directly
  83065. */
  83066. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83067. /**
  83068. * Initializes a VRMultiviewToSingleview
  83069. * @param name name of the post process
  83070. * @param camera camera to be applied to
  83071. * @param scaleFactor scaling factor to the size of the output texture
  83072. */
  83073. constructor(name: string, camera: Camera, scaleFactor: number);
  83074. }
  83075. }
  83076. declare module BABYLON {
  83077. /**
  83078. * Interface used to define additional presentation attributes
  83079. */
  83080. export interface IVRPresentationAttributes {
  83081. /**
  83082. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83083. */
  83084. highRefreshRate: boolean;
  83085. /**
  83086. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83087. */
  83088. foveationLevel: number;
  83089. }
  83090. interface Engine {
  83091. /** @hidden */
  83092. _vrDisplay: any;
  83093. /** @hidden */
  83094. _vrSupported: boolean;
  83095. /** @hidden */
  83096. _oldSize: Size;
  83097. /** @hidden */
  83098. _oldHardwareScaleFactor: number;
  83099. /** @hidden */
  83100. _vrExclusivePointerMode: boolean;
  83101. /** @hidden */
  83102. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83103. /** @hidden */
  83104. _onVRDisplayPointerRestricted: () => void;
  83105. /** @hidden */
  83106. _onVRDisplayPointerUnrestricted: () => void;
  83107. /** @hidden */
  83108. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83109. /** @hidden */
  83110. _onVrDisplayDisconnect: Nullable<() => void>;
  83111. /** @hidden */
  83112. _onVrDisplayPresentChange: Nullable<() => void>;
  83113. /**
  83114. * Observable signaled when VR display mode changes
  83115. */
  83116. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83117. /**
  83118. * Observable signaled when VR request present is complete
  83119. */
  83120. onVRRequestPresentComplete: Observable<boolean>;
  83121. /**
  83122. * Observable signaled when VR request present starts
  83123. */
  83124. onVRRequestPresentStart: Observable<Engine>;
  83125. /**
  83126. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83127. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83128. */
  83129. isInVRExclusivePointerMode: boolean;
  83130. /**
  83131. * Gets a boolean indicating if a webVR device was detected
  83132. * @returns true if a webVR device was detected
  83133. */
  83134. isVRDevicePresent(): boolean;
  83135. /**
  83136. * Gets the current webVR device
  83137. * @returns the current webVR device (or null)
  83138. */
  83139. getVRDevice(): any;
  83140. /**
  83141. * Initializes a webVR display and starts listening to display change events
  83142. * The onVRDisplayChangedObservable will be notified upon these changes
  83143. * @returns A promise containing a VRDisplay and if vr is supported
  83144. */
  83145. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83146. /** @hidden */
  83147. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83148. /**
  83149. * Gets or sets the presentation attributes used to configure VR rendering
  83150. */
  83151. vrPresentationAttributes?: IVRPresentationAttributes;
  83152. /**
  83153. * Call this function to switch to webVR mode
  83154. * Will do nothing if webVR is not supported or if there is no webVR device
  83155. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83156. */
  83157. enableVR(): void;
  83158. /** @hidden */
  83159. _onVRFullScreenTriggered(): void;
  83160. }
  83161. }
  83162. declare module BABYLON {
  83163. /**
  83164. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83165. * IMPORTANT!! The data is right-hand data.
  83166. * @export
  83167. * @interface DevicePose
  83168. */
  83169. export interface DevicePose {
  83170. /**
  83171. * The position of the device, values in array are [x,y,z].
  83172. */
  83173. readonly position: Nullable<Float32Array>;
  83174. /**
  83175. * The linearVelocity of the device, values in array are [x,y,z].
  83176. */
  83177. readonly linearVelocity: Nullable<Float32Array>;
  83178. /**
  83179. * The linearAcceleration of the device, values in array are [x,y,z].
  83180. */
  83181. readonly linearAcceleration: Nullable<Float32Array>;
  83182. /**
  83183. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  83184. */
  83185. readonly orientation: Nullable<Float32Array>;
  83186. /**
  83187. * The angularVelocity of the device, values in array are [x,y,z].
  83188. */
  83189. readonly angularVelocity: Nullable<Float32Array>;
  83190. /**
  83191. * The angularAcceleration of the device, values in array are [x,y,z].
  83192. */
  83193. readonly angularAcceleration: Nullable<Float32Array>;
  83194. }
  83195. /**
  83196. * Interface representing a pose controlled object in Babylon.
  83197. * A pose controlled object has both regular pose values as well as pose values
  83198. * from an external device such as a VR head mounted display
  83199. */
  83200. export interface PoseControlled {
  83201. /**
  83202. * The position of the object in babylon space.
  83203. */
  83204. position: Vector3;
  83205. /**
  83206. * The rotation quaternion of the object in babylon space.
  83207. */
  83208. rotationQuaternion: Quaternion;
  83209. /**
  83210. * The position of the device in babylon space.
  83211. */
  83212. devicePosition?: Vector3;
  83213. /**
  83214. * The rotation quaternion of the device in babylon space.
  83215. */
  83216. deviceRotationQuaternion: Quaternion;
  83217. /**
  83218. * The raw pose coming from the device.
  83219. */
  83220. rawPose: Nullable<DevicePose>;
  83221. /**
  83222. * The scale of the device to be used when translating from device space to babylon space.
  83223. */
  83224. deviceScaleFactor: number;
  83225. /**
  83226. * Updates the poseControlled values based on the input device pose.
  83227. * @param poseData the pose data to update the object with
  83228. */
  83229. updateFromDevice(poseData: DevicePose): void;
  83230. }
  83231. /**
  83232. * Set of options to customize the webVRCamera
  83233. */
  83234. export interface WebVROptions {
  83235. /**
  83236. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  83237. */
  83238. trackPosition?: boolean;
  83239. /**
  83240. * Sets the scale of the vrDevice in babylon space. (default: 1)
  83241. */
  83242. positionScale?: number;
  83243. /**
  83244. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  83245. */
  83246. displayName?: string;
  83247. /**
  83248. * Should the native controller meshes be initialized. (default: true)
  83249. */
  83250. controllerMeshes?: boolean;
  83251. /**
  83252. * Creating a default HemiLight only on controllers. (default: true)
  83253. */
  83254. defaultLightingOnControllers?: boolean;
  83255. /**
  83256. * If you don't want to use the default VR button of the helper. (default: false)
  83257. */
  83258. useCustomVRButton?: boolean;
  83259. /**
  83260. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83261. */
  83262. customVRButton?: HTMLButtonElement;
  83263. /**
  83264. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83265. */
  83266. rayLength?: number;
  83267. /**
  83268. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83269. */
  83270. defaultHeight?: number;
  83271. /**
  83272. * If multiview should be used if availible (default: false)
  83273. */
  83274. useMultiview?: boolean;
  83275. }
  83276. /**
  83277. * This represents a WebVR camera.
  83278. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83279. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83280. */
  83281. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83282. private webVROptions;
  83283. /**
  83284. * @hidden
  83285. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  83286. */
  83287. _vrDevice: any;
  83288. /**
  83289. * The rawPose of the vrDevice.
  83290. */
  83291. rawPose: Nullable<DevicePose>;
  83292. private _onVREnabled;
  83293. private _specsVersion;
  83294. private _attached;
  83295. private _frameData;
  83296. protected _descendants: Array<Node>;
  83297. private _deviceRoomPosition;
  83298. /** @hidden */
  83299. _deviceRoomRotationQuaternion: Quaternion;
  83300. private _standingMatrix;
  83301. /**
  83302. * Represents device position in babylon space.
  83303. */
  83304. devicePosition: Vector3;
  83305. /**
  83306. * Represents device rotation in babylon space.
  83307. */
  83308. deviceRotationQuaternion: Quaternion;
  83309. /**
  83310. * The scale of the device to be used when translating from device space to babylon space.
  83311. */
  83312. deviceScaleFactor: number;
  83313. private _deviceToWorld;
  83314. private _worldToDevice;
  83315. /**
  83316. * References to the webVR controllers for the vrDevice.
  83317. */
  83318. controllers: Array<WebVRController>;
  83319. /**
  83320. * Emits an event when a controller is attached.
  83321. */
  83322. onControllersAttachedObservable: Observable<WebVRController[]>;
  83323. /**
  83324. * Emits an event when a controller's mesh has been loaded;
  83325. */
  83326. onControllerMeshLoadedObservable: Observable<WebVRController>;
  83327. /**
  83328. * Emits an event when the HMD's pose has been updated.
  83329. */
  83330. onPoseUpdatedFromDeviceObservable: Observable<any>;
  83331. private _poseSet;
  83332. /**
  83333. * If the rig cameras be used as parent instead of this camera.
  83334. */
  83335. rigParenting: boolean;
  83336. private _lightOnControllers;
  83337. private _defaultHeight?;
  83338. /**
  83339. * Instantiates a WebVRFreeCamera.
  83340. * @param name The name of the WebVRFreeCamera
  83341. * @param position The starting anchor position for the camera
  83342. * @param scene The scene the camera belongs to
  83343. * @param webVROptions a set of customizable options for the webVRCamera
  83344. */
  83345. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  83346. /**
  83347. * Gets the device distance from the ground in meters.
  83348. * @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.
  83349. */
  83350. deviceDistanceToRoomGround(): number;
  83351. /**
  83352. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83353. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  83354. */
  83355. useStandingMatrix(callback?: (bool: boolean) => void): void;
  83356. /**
  83357. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83358. * @returns A promise with a boolean set to if the standing matrix is supported.
  83359. */
  83360. useStandingMatrixAsync(): Promise<boolean>;
  83361. /**
  83362. * Disposes the camera
  83363. */
  83364. dispose(): void;
  83365. /**
  83366. * Gets a vrController by name.
  83367. * @param name The name of the controller to retreive
  83368. * @returns the controller matching the name specified or null if not found
  83369. */
  83370. getControllerByName(name: string): Nullable<WebVRController>;
  83371. private _leftController;
  83372. /**
  83373. * The controller corresponding to the users left hand.
  83374. */
  83375. readonly leftController: Nullable<WebVRController>;
  83376. private _rightController;
  83377. /**
  83378. * The controller corresponding to the users right hand.
  83379. */
  83380. readonly rightController: Nullable<WebVRController>;
  83381. /**
  83382. * Casts a ray forward from the vrCamera's gaze.
  83383. * @param length Length of the ray (default: 100)
  83384. * @returns the ray corresponding to the gaze
  83385. */
  83386. getForwardRay(length?: number): Ray;
  83387. /**
  83388. * @hidden
  83389. * Updates the camera based on device's frame data
  83390. */
  83391. _checkInputs(): void;
  83392. /**
  83393. * Updates the poseControlled values based on the input device pose.
  83394. * @param poseData Pose coming from the device
  83395. */
  83396. updateFromDevice(poseData: DevicePose): void;
  83397. private _htmlElementAttached;
  83398. private _detachIfAttached;
  83399. /**
  83400. * WebVR's attach control will start broadcasting frames to the device.
  83401. * Note that in certain browsers (chrome for example) this function must be called
  83402. * within a user-interaction callback. Example:
  83403. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83404. *
  83405. * @param element html element to attach the vrDevice to
  83406. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83407. */
  83408. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83409. /**
  83410. * Detaches the camera from the html element and disables VR
  83411. *
  83412. * @param element html element to detach from
  83413. */
  83414. detachControl(element: HTMLElement): void;
  83415. /**
  83416. * @returns the name of this class
  83417. */
  83418. getClassName(): string;
  83419. /**
  83420. * Calls resetPose on the vrDisplay
  83421. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83422. */
  83423. resetToCurrentRotation(): void;
  83424. /**
  83425. * @hidden
  83426. * Updates the rig cameras (left and right eye)
  83427. */
  83428. _updateRigCameras(): void;
  83429. private _workingVector;
  83430. private _oneVector;
  83431. private _workingMatrix;
  83432. private updateCacheCalled;
  83433. private _correctPositionIfNotTrackPosition;
  83434. /**
  83435. * @hidden
  83436. * Updates the cached values of the camera
  83437. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83438. */
  83439. _updateCache(ignoreParentClass?: boolean): void;
  83440. /**
  83441. * @hidden
  83442. * Get current device position in babylon world
  83443. */
  83444. _computeDevicePosition(): void;
  83445. /**
  83446. * Updates the current device position and rotation in the babylon world
  83447. */
  83448. update(): void;
  83449. /**
  83450. * @hidden
  83451. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83452. * @returns an identity matrix
  83453. */
  83454. _getViewMatrix(): Matrix;
  83455. private _tmpMatrix;
  83456. /**
  83457. * This function is called by the two RIG cameras.
  83458. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83459. * @hidden
  83460. */
  83461. _getWebVRViewMatrix(): Matrix;
  83462. /** @hidden */
  83463. _getWebVRProjectionMatrix(): Matrix;
  83464. private _onGamepadConnectedObserver;
  83465. private _onGamepadDisconnectedObserver;
  83466. private _updateCacheWhenTrackingDisabledObserver;
  83467. /**
  83468. * Initializes the controllers and their meshes
  83469. */
  83470. initControllers(): void;
  83471. }
  83472. }
  83473. declare module BABYLON {
  83474. /**
  83475. * Size options for a post process
  83476. */
  83477. export type PostProcessOptions = {
  83478. width: number;
  83479. height: number;
  83480. };
  83481. /**
  83482. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83483. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83484. */
  83485. export class PostProcess {
  83486. /** Name of the PostProcess. */
  83487. name: string;
  83488. /**
  83489. * Gets or sets the unique id of the post process
  83490. */
  83491. uniqueId: number;
  83492. /**
  83493. * Width of the texture to apply the post process on
  83494. */
  83495. width: number;
  83496. /**
  83497. * Height of the texture to apply the post process on
  83498. */
  83499. height: number;
  83500. /**
  83501. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  83502. * @hidden
  83503. */
  83504. _outputTexture: Nullable<InternalTexture>;
  83505. /**
  83506. * Sampling mode used by the shader
  83507. * See https://doc.babylonjs.com/classes/3.1/texture
  83508. */
  83509. renderTargetSamplingMode: number;
  83510. /**
  83511. * Clear color to use when screen clearing
  83512. */
  83513. clearColor: Color4;
  83514. /**
  83515. * If the buffer needs to be cleared before applying the post process. (default: true)
  83516. * Should be set to false if shader will overwrite all previous pixels.
  83517. */
  83518. autoClear: boolean;
  83519. /**
  83520. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83521. */
  83522. alphaMode: number;
  83523. /**
  83524. * Sets the setAlphaBlendConstants of the babylon engine
  83525. */
  83526. alphaConstants: Color4;
  83527. /**
  83528. * Animations to be used for the post processing
  83529. */
  83530. animations: Animation[];
  83531. /**
  83532. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83533. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83534. */
  83535. enablePixelPerfectMode: boolean;
  83536. /**
  83537. * Force the postprocess to be applied without taking in account viewport
  83538. */
  83539. forceFullscreenViewport: boolean;
  83540. /**
  83541. * List of inspectable custom properties (used by the Inspector)
  83542. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83543. */
  83544. inspectableCustomProperties: IInspectable[];
  83545. /**
  83546. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83547. *
  83548. * | Value | Type | Description |
  83549. * | ----- | ----------------------------------- | ----------- |
  83550. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83551. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83552. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83553. *
  83554. */
  83555. scaleMode: number;
  83556. /**
  83557. * Force textures to be a power of two (default: false)
  83558. */
  83559. alwaysForcePOT: boolean;
  83560. private _samples;
  83561. /**
  83562. * Number of sample textures (default: 1)
  83563. */
  83564. samples: number;
  83565. /**
  83566. * Modify the scale of the post process to be the same as the viewport (default: false)
  83567. */
  83568. adaptScaleToCurrentViewport: boolean;
  83569. private _camera;
  83570. private _scene;
  83571. private _engine;
  83572. private _options;
  83573. private _reusable;
  83574. private _textureType;
  83575. /**
  83576. * Smart array of input and output textures for the post process.
  83577. * @hidden
  83578. */
  83579. _textures: SmartArray<InternalTexture>;
  83580. /**
  83581. * The index in _textures that corresponds to the output texture.
  83582. * @hidden
  83583. */
  83584. _currentRenderTextureInd: number;
  83585. private _effect;
  83586. private _samplers;
  83587. private _fragmentUrl;
  83588. private _vertexUrl;
  83589. private _parameters;
  83590. private _scaleRatio;
  83591. protected _indexParameters: any;
  83592. private _shareOutputWithPostProcess;
  83593. private _texelSize;
  83594. private _forcedOutputTexture;
  83595. /**
  83596. * Returns the fragment url or shader name used in the post process.
  83597. * @returns the fragment url or name in the shader store.
  83598. */
  83599. getEffectName(): string;
  83600. /**
  83601. * An event triggered when the postprocess is activated.
  83602. */
  83603. onActivateObservable: Observable<Camera>;
  83604. private _onActivateObserver;
  83605. /**
  83606. * A function that is added to the onActivateObservable
  83607. */
  83608. onActivate: Nullable<(camera: Camera) => void>;
  83609. /**
  83610. * An event triggered when the postprocess changes its size.
  83611. */
  83612. onSizeChangedObservable: Observable<PostProcess>;
  83613. private _onSizeChangedObserver;
  83614. /**
  83615. * A function that is added to the onSizeChangedObservable
  83616. */
  83617. onSizeChanged: (postProcess: PostProcess) => void;
  83618. /**
  83619. * An event triggered when the postprocess applies its effect.
  83620. */
  83621. onApplyObservable: Observable<Effect>;
  83622. private _onApplyObserver;
  83623. /**
  83624. * A function that is added to the onApplyObservable
  83625. */
  83626. onApply: (effect: Effect) => void;
  83627. /**
  83628. * An event triggered before rendering the postprocess
  83629. */
  83630. onBeforeRenderObservable: Observable<Effect>;
  83631. private _onBeforeRenderObserver;
  83632. /**
  83633. * A function that is added to the onBeforeRenderObservable
  83634. */
  83635. onBeforeRender: (effect: Effect) => void;
  83636. /**
  83637. * An event triggered after rendering the postprocess
  83638. */
  83639. onAfterRenderObservable: Observable<Effect>;
  83640. private _onAfterRenderObserver;
  83641. /**
  83642. * A function that is added to the onAfterRenderObservable
  83643. */
  83644. onAfterRender: (efect: Effect) => void;
  83645. /**
  83646. * 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
  83647. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83648. */
  83649. inputTexture: InternalTexture;
  83650. /**
  83651. * Gets the camera which post process is applied to.
  83652. * @returns The camera the post process is applied to.
  83653. */
  83654. getCamera(): Camera;
  83655. /**
  83656. * Gets the texel size of the postprocess.
  83657. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83658. */
  83659. readonly texelSize: Vector2;
  83660. /**
  83661. * Creates a new instance PostProcess
  83662. * @param name The name of the PostProcess.
  83663. * @param fragmentUrl The url of the fragment shader to be used.
  83664. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83665. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83666. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83667. * @param camera The camera to apply the render pass to.
  83668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83669. * @param engine The engine which the post process will be applied. (default: current engine)
  83670. * @param reusable If the post process can be reused on the same frame. (default: false)
  83671. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83672. * @param textureType Type of textures used when performing the post process. (default: 0)
  83673. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83674. * @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
  83675. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83676. */
  83677. constructor(
  83678. /** Name of the PostProcess. */
  83679. 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);
  83680. /**
  83681. * Gets a string idenfifying the name of the class
  83682. * @returns "PostProcess" string
  83683. */
  83684. getClassName(): string;
  83685. /**
  83686. * Gets the engine which this post process belongs to.
  83687. * @returns The engine the post process was enabled with.
  83688. */
  83689. getEngine(): Engine;
  83690. /**
  83691. * The effect that is created when initializing the post process.
  83692. * @returns The created effect corresponding the the postprocess.
  83693. */
  83694. getEffect(): Effect;
  83695. /**
  83696. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83697. * @param postProcess The post process to share the output with.
  83698. * @returns This post process.
  83699. */
  83700. shareOutputWith(postProcess: PostProcess): PostProcess;
  83701. /**
  83702. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83703. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83704. */
  83705. useOwnOutput(): void;
  83706. /**
  83707. * Updates the effect with the current post process compile time values and recompiles the shader.
  83708. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83709. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83710. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83711. * @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
  83712. * @param onCompiled Called when the shader has been compiled.
  83713. * @param onError Called if there is an error when compiling a shader.
  83714. */
  83715. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83716. /**
  83717. * The post process is reusable if it can be used multiple times within one frame.
  83718. * @returns If the post process is reusable
  83719. */
  83720. isReusable(): boolean;
  83721. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83722. markTextureDirty(): void;
  83723. /**
  83724. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83725. * 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.
  83726. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83727. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83728. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83729. * @returns The target texture that was bound to be written to.
  83730. */
  83731. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83732. /**
  83733. * If the post process is supported.
  83734. */
  83735. readonly isSupported: boolean;
  83736. /**
  83737. * The aspect ratio of the output texture.
  83738. */
  83739. readonly aspectRatio: number;
  83740. /**
  83741. * Get a value indicating if the post-process is ready to be used
  83742. * @returns true if the post-process is ready (shader is compiled)
  83743. */
  83744. isReady(): boolean;
  83745. /**
  83746. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83747. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83748. */
  83749. apply(): Nullable<Effect>;
  83750. private _disposeTextures;
  83751. /**
  83752. * Disposes the post process.
  83753. * @param camera The camera to dispose the post process on.
  83754. */
  83755. dispose(camera?: Camera): void;
  83756. }
  83757. }
  83758. declare module BABYLON {
  83759. /** @hidden */
  83760. export var kernelBlurVaryingDeclaration: {
  83761. name: string;
  83762. shader: string;
  83763. };
  83764. }
  83765. declare module BABYLON {
  83766. /** @hidden */
  83767. export var kernelBlurFragment: {
  83768. name: string;
  83769. shader: string;
  83770. };
  83771. }
  83772. declare module BABYLON {
  83773. /** @hidden */
  83774. export var kernelBlurFragment2: {
  83775. name: string;
  83776. shader: string;
  83777. };
  83778. }
  83779. declare module BABYLON {
  83780. /** @hidden */
  83781. export var kernelBlurPixelShader: {
  83782. name: string;
  83783. shader: string;
  83784. };
  83785. }
  83786. declare module BABYLON {
  83787. /** @hidden */
  83788. export var kernelBlurVertex: {
  83789. name: string;
  83790. shader: string;
  83791. };
  83792. }
  83793. declare module BABYLON {
  83794. /** @hidden */
  83795. export var kernelBlurVertexShader: {
  83796. name: string;
  83797. shader: string;
  83798. };
  83799. }
  83800. declare module BABYLON {
  83801. /**
  83802. * The Blur Post Process which blurs an image based on a kernel and direction.
  83803. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  83804. */
  83805. export class BlurPostProcess extends PostProcess {
  83806. /** The direction in which to blur the image. */
  83807. direction: Vector2;
  83808. private blockCompilation;
  83809. protected _kernel: number;
  83810. protected _idealKernel: number;
  83811. protected _packedFloat: boolean;
  83812. private _staticDefines;
  83813. /**
  83814. * Sets the length in pixels of the blur sample region
  83815. */
  83816. /**
  83817. * Gets the length in pixels of the blur sample region
  83818. */
  83819. kernel: number;
  83820. /**
  83821. * Sets wether or not the blur needs to unpack/repack floats
  83822. */
  83823. /**
  83824. * Gets wether or not the blur is unpacking/repacking floats
  83825. */
  83826. packedFloat: boolean;
  83827. /**
  83828. * Creates a new instance BlurPostProcess
  83829. * @param name The name of the effect.
  83830. * @param direction The direction in which to blur the image.
  83831. * @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.
  83832. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83833. * @param camera The camera to apply the render pass to.
  83834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83835. * @param engine The engine which the post process will be applied. (default: current engine)
  83836. * @param reusable If the post process can be reused on the same frame. (default: false)
  83837. * @param textureType Type of textures used when performing the post process. (default: 0)
  83838. * @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)
  83839. */
  83840. constructor(name: string,
  83841. /** The direction in which to blur the image. */
  83842. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  83843. /**
  83844. * Updates the effect with the current post process compile time values and recompiles the shader.
  83845. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83846. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83847. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83848. * @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
  83849. * @param onCompiled Called when the shader has been compiled.
  83850. * @param onError Called if there is an error when compiling a shader.
  83851. */
  83852. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83853. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83854. /**
  83855. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  83856. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  83857. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  83858. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  83859. * The gaps between physical kernels are compensated for in the weighting of the samples
  83860. * @param idealKernel Ideal blur kernel.
  83861. * @return Nearest best kernel.
  83862. */
  83863. protected _nearestBestKernel(idealKernel: number): number;
  83864. /**
  83865. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83866. * @param x The point on the Gaussian distribution to sample.
  83867. * @return the value of the Gaussian function at x.
  83868. */
  83869. protected _gaussianWeight(x: number): number;
  83870. /**
  83871. * Generates a string that can be used as a floating point number in GLSL.
  83872. * @param x Value to print.
  83873. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  83874. * @return GLSL float string.
  83875. */
  83876. protected _glslFloat(x: number, decimalFigures?: number): string;
  83877. }
  83878. }
  83879. declare module BABYLON {
  83880. /**
  83881. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83882. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83883. * You can then easily use it as a reflectionTexture on a flat surface.
  83884. * In case the surface is not a plane, please consider relying on reflection probes.
  83885. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83886. */
  83887. export class MirrorTexture extends RenderTargetTexture {
  83888. private scene;
  83889. /**
  83890. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  83891. * 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.
  83892. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83893. */
  83894. mirrorPlane: Plane;
  83895. /**
  83896. * Define the blur ratio used to blur the reflection if needed.
  83897. */
  83898. blurRatio: number;
  83899. /**
  83900. * Define the adaptive blur kernel used to blur the reflection if needed.
  83901. * This will autocompute the closest best match for the `blurKernel`
  83902. */
  83903. adaptiveBlurKernel: number;
  83904. /**
  83905. * Define the blur kernel used to blur the reflection if needed.
  83906. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83907. */
  83908. blurKernel: number;
  83909. /**
  83910. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83911. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83912. */
  83913. blurKernelX: number;
  83914. /**
  83915. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  83916. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83917. */
  83918. blurKernelY: number;
  83919. private _autoComputeBlurKernel;
  83920. protected _onRatioRescale(): void;
  83921. private _updateGammaSpace;
  83922. private _imageProcessingConfigChangeObserver;
  83923. private _transformMatrix;
  83924. private _mirrorMatrix;
  83925. private _savedViewMatrix;
  83926. private _blurX;
  83927. private _blurY;
  83928. private _adaptiveBlurKernel;
  83929. private _blurKernelX;
  83930. private _blurKernelY;
  83931. private _blurRatio;
  83932. /**
  83933. * Instantiates a Mirror Texture.
  83934. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83935. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83936. * You can then easily use it as a reflectionTexture on a flat surface.
  83937. * In case the surface is not a plane, please consider relying on reflection probes.
  83938. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83939. * @param name
  83940. * @param size
  83941. * @param scene
  83942. * @param generateMipMaps
  83943. * @param type
  83944. * @param samplingMode
  83945. * @param generateDepthBuffer
  83946. */
  83947. constructor(name: string, size: number | {
  83948. width: number;
  83949. height: number;
  83950. } | {
  83951. ratio: number;
  83952. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83953. private _preparePostProcesses;
  83954. /**
  83955. * Clone the mirror texture.
  83956. * @returns the cloned texture
  83957. */
  83958. clone(): MirrorTexture;
  83959. /**
  83960. * Serialize the texture to a JSON representation you could use in Parse later on
  83961. * @returns the serialized JSON representation
  83962. */
  83963. serialize(): any;
  83964. /**
  83965. * Dispose the texture and release its associated resources.
  83966. */
  83967. dispose(): void;
  83968. }
  83969. }
  83970. declare module BABYLON {
  83971. /**
  83972. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83973. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83974. */
  83975. export class Texture extends BaseTexture {
  83976. /**
  83977. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83978. */
  83979. static SerializeBuffers: boolean;
  83980. /** @hidden */
  83981. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83982. /** @hidden */
  83983. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83984. /** @hidden */
  83985. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83986. /** nearest is mag = nearest and min = nearest and mip = linear */
  83987. static readonly NEAREST_SAMPLINGMODE: number;
  83988. /** nearest is mag = nearest and min = nearest and mip = linear */
  83989. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83990. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83991. static readonly BILINEAR_SAMPLINGMODE: number;
  83992. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83993. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83994. /** Trilinear is mag = linear and min = linear and mip = linear */
  83995. static readonly TRILINEAR_SAMPLINGMODE: number;
  83996. /** Trilinear is mag = linear and min = linear and mip = linear */
  83997. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83998. /** mag = nearest and min = nearest and mip = nearest */
  83999. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  84000. /** mag = nearest and min = linear and mip = nearest */
  84001. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  84002. /** mag = nearest and min = linear and mip = linear */
  84003. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  84004. /** mag = nearest and min = linear and mip = none */
  84005. static readonly NEAREST_LINEAR: number;
  84006. /** mag = nearest and min = nearest and mip = none */
  84007. static readonly NEAREST_NEAREST: number;
  84008. /** mag = linear and min = nearest and mip = nearest */
  84009. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  84010. /** mag = linear and min = nearest and mip = linear */
  84011. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  84012. /** mag = linear and min = linear and mip = none */
  84013. static readonly LINEAR_LINEAR: number;
  84014. /** mag = linear and min = nearest and mip = none */
  84015. static readonly LINEAR_NEAREST: number;
  84016. /** Explicit coordinates mode */
  84017. static readonly EXPLICIT_MODE: number;
  84018. /** Spherical coordinates mode */
  84019. static readonly SPHERICAL_MODE: number;
  84020. /** Planar coordinates mode */
  84021. static readonly PLANAR_MODE: number;
  84022. /** Cubic coordinates mode */
  84023. static readonly CUBIC_MODE: number;
  84024. /** Projection coordinates mode */
  84025. static readonly PROJECTION_MODE: number;
  84026. /** Inverse Cubic coordinates mode */
  84027. static readonly SKYBOX_MODE: number;
  84028. /** Inverse Cubic coordinates mode */
  84029. static readonly INVCUBIC_MODE: number;
  84030. /** Equirectangular coordinates mode */
  84031. static readonly EQUIRECTANGULAR_MODE: number;
  84032. /** Equirectangular Fixed coordinates mode */
  84033. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  84034. /** Equirectangular Fixed Mirrored coordinates mode */
  84035. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84036. /** Texture is not repeating outside of 0..1 UVs */
  84037. static readonly CLAMP_ADDRESSMODE: number;
  84038. /** Texture is repeating outside of 0..1 UVs */
  84039. static readonly WRAP_ADDRESSMODE: number;
  84040. /** Texture is repeating and mirrored */
  84041. static readonly MIRROR_ADDRESSMODE: number;
  84042. /**
  84043. * 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
  84044. */
  84045. static UseSerializedUrlIfAny: boolean;
  84046. /**
  84047. * Define the url of the texture.
  84048. */
  84049. url: Nullable<string>;
  84050. /**
  84051. * Define an offset on the texture to offset the u coordinates of the UVs
  84052. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84053. */
  84054. uOffset: number;
  84055. /**
  84056. * Define an offset on the texture to offset the v coordinates of the UVs
  84057. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84058. */
  84059. vOffset: number;
  84060. /**
  84061. * Define an offset on the texture to scale the u coordinates of the UVs
  84062. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84063. */
  84064. uScale: number;
  84065. /**
  84066. * Define an offset on the texture to scale the v coordinates of the UVs
  84067. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84068. */
  84069. vScale: number;
  84070. /**
  84071. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84072. * @see http://doc.babylonjs.com/how_to/more_materials
  84073. */
  84074. uAng: number;
  84075. /**
  84076. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84077. * @see http://doc.babylonjs.com/how_to/more_materials
  84078. */
  84079. vAng: number;
  84080. /**
  84081. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84082. * @see http://doc.babylonjs.com/how_to/more_materials
  84083. */
  84084. wAng: number;
  84085. /**
  84086. * Defines the center of rotation (U)
  84087. */
  84088. uRotationCenter: number;
  84089. /**
  84090. * Defines the center of rotation (V)
  84091. */
  84092. vRotationCenter: number;
  84093. /**
  84094. * Defines the center of rotation (W)
  84095. */
  84096. wRotationCenter: number;
  84097. /**
  84098. * Are mip maps generated for this texture or not.
  84099. */
  84100. readonly noMipmap: boolean;
  84101. /**
  84102. * List of inspectable custom properties (used by the Inspector)
  84103. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84104. */
  84105. inspectableCustomProperties: Nullable<IInspectable[]>;
  84106. private _noMipmap;
  84107. /** @hidden */
  84108. _invertY: boolean;
  84109. private _rowGenerationMatrix;
  84110. private _cachedTextureMatrix;
  84111. private _projectionModeMatrix;
  84112. private _t0;
  84113. private _t1;
  84114. private _t2;
  84115. private _cachedUOffset;
  84116. private _cachedVOffset;
  84117. private _cachedUScale;
  84118. private _cachedVScale;
  84119. private _cachedUAng;
  84120. private _cachedVAng;
  84121. private _cachedWAng;
  84122. private _cachedProjectionMatrixId;
  84123. private _cachedCoordinatesMode;
  84124. /** @hidden */
  84125. protected _initialSamplingMode: number;
  84126. /** @hidden */
  84127. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84128. private _deleteBuffer;
  84129. protected _format: Nullable<number>;
  84130. private _delayedOnLoad;
  84131. private _delayedOnError;
  84132. private _mimeType?;
  84133. /**
  84134. * Observable triggered once the texture has been loaded.
  84135. */
  84136. onLoadObservable: Observable<Texture>;
  84137. protected _isBlocking: boolean;
  84138. /**
  84139. * Is the texture preventing material to render while loading.
  84140. * If false, a default texture will be used instead of the loading one during the preparation step.
  84141. */
  84142. isBlocking: boolean;
  84143. /**
  84144. * Get the current sampling mode associated with the texture.
  84145. */
  84146. readonly samplingMode: number;
  84147. /**
  84148. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84149. */
  84150. readonly invertY: boolean;
  84151. /**
  84152. * Instantiates a new texture.
  84153. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84154. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84155. * @param url defines the url of the picture to load as a texture
  84156. * @param scene defines the scene or engine the texture will belong to
  84157. * @param noMipmap defines if the texture will require mip maps or not
  84158. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84159. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84160. * @param onLoad defines a callback triggered when the texture has been loaded
  84161. * @param onError defines a callback triggered when an error occurred during the loading session
  84162. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84163. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84164. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84165. * @param mimeType defines an optional mime type information
  84166. */
  84167. 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);
  84168. /**
  84169. * Update the url (and optional buffer) of this texture if url was null during construction.
  84170. * @param url the url of the texture
  84171. * @param buffer the buffer of the texture (defaults to null)
  84172. * @param onLoad callback called when the texture is loaded (defaults to null)
  84173. */
  84174. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84175. /**
  84176. * Finish the loading sequence of a texture flagged as delayed load.
  84177. * @hidden
  84178. */
  84179. delayLoad(): void;
  84180. private _prepareRowForTextureGeneration;
  84181. /**
  84182. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  84183. * @returns the transform matrix of the texture.
  84184. */
  84185. getTextureMatrix(): Matrix;
  84186. /**
  84187. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  84188. * @returns The reflection texture transform
  84189. */
  84190. getReflectionTextureMatrix(): Matrix;
  84191. /**
  84192. * Clones the texture.
  84193. * @returns the cloned texture
  84194. */
  84195. clone(): Texture;
  84196. /**
  84197. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84198. * @returns The JSON representation of the texture
  84199. */
  84200. serialize(): any;
  84201. /**
  84202. * Get the current class name of the texture useful for serialization or dynamic coding.
  84203. * @returns "Texture"
  84204. */
  84205. getClassName(): string;
  84206. /**
  84207. * Dispose the texture and release its associated resources.
  84208. */
  84209. dispose(): void;
  84210. /**
  84211. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  84212. * @param parsedTexture Define the JSON representation of the texture
  84213. * @param scene Define the scene the parsed texture should be instantiated in
  84214. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  84215. * @returns The parsed texture if successful
  84216. */
  84217. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  84218. /**
  84219. * Creates a texture from its base 64 representation.
  84220. * @param data Define the base64 payload without the data: prefix
  84221. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84222. * @param scene Define the scene the texture should belong to
  84223. * @param noMipmap Forces the texture to not create mip map information if true
  84224. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84225. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84226. * @param onLoad define a callback triggered when the texture has been loaded
  84227. * @param onError define a callback triggered when an error occurred during the loading session
  84228. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84229. * @returns the created texture
  84230. */
  84231. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  84232. /**
  84233. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  84234. * @param data Define the base64 payload without the data: prefix
  84235. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84236. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  84237. * @param scene Define the scene the texture should belong to
  84238. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  84239. * @param noMipmap Forces the texture to not create mip map information if true
  84240. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84241. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84242. * @param onLoad define a callback triggered when the texture has been loaded
  84243. * @param onError define a callback triggered when an error occurred during the loading session
  84244. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84245. * @returns the created texture
  84246. */
  84247. 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;
  84248. }
  84249. }
  84250. declare module BABYLON {
  84251. /**
  84252. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84253. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84254. */
  84255. export class PostProcessManager {
  84256. private _scene;
  84257. private _indexBuffer;
  84258. private _vertexBuffers;
  84259. /**
  84260. * Creates a new instance PostProcess
  84261. * @param scene The scene that the post process is associated with.
  84262. */
  84263. constructor(scene: Scene);
  84264. private _prepareBuffers;
  84265. private _buildIndexBuffer;
  84266. /**
  84267. * Rebuilds the vertex buffers of the manager.
  84268. * @hidden
  84269. */
  84270. _rebuild(): void;
  84271. /**
  84272. * Prepares a frame to be run through a post process.
  84273. * @param sourceTexture The input texture to the post procesess. (default: null)
  84274. * @param postProcesses An array of post processes to be run. (default: null)
  84275. * @returns True if the post processes were able to be run.
  84276. * @hidden
  84277. */
  84278. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84279. /**
  84280. * Manually render a set of post processes to a texture.
  84281. * @param postProcesses An array of post processes to be run.
  84282. * @param targetTexture The target texture to render to.
  84283. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  84284. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  84285. * @param lodLevel defines which lod of the texture to render to
  84286. */
  84287. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  84288. /**
  84289. * Finalize the result of the output of the postprocesses.
  84290. * @param doNotPresent If true the result will not be displayed to the screen.
  84291. * @param targetTexture The target texture to render to.
  84292. * @param faceIndex The index of the face to bind the target texture to.
  84293. * @param postProcesses The array of post processes to render.
  84294. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  84295. * @hidden
  84296. */
  84297. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  84298. /**
  84299. * Disposes of the post process manager.
  84300. */
  84301. dispose(): void;
  84302. }
  84303. }
  84304. declare module BABYLON {
  84305. /** Interface used by value gradients (color, factor, ...) */
  84306. export interface IValueGradient {
  84307. /**
  84308. * Gets or sets the gradient value (between 0 and 1)
  84309. */
  84310. gradient: number;
  84311. }
  84312. /** Class used to store color4 gradient */
  84313. export class ColorGradient implements IValueGradient {
  84314. /**
  84315. * Gets or sets the gradient value (between 0 and 1)
  84316. */
  84317. gradient: number;
  84318. /**
  84319. * Gets or sets first associated color
  84320. */
  84321. color1: Color4;
  84322. /**
  84323. * Gets or sets second associated color
  84324. */
  84325. color2?: Color4;
  84326. /**
  84327. * Will get a color picked randomly between color1 and color2.
  84328. * If color2 is undefined then color1 will be used
  84329. * @param result defines the target Color4 to store the result in
  84330. */
  84331. getColorToRef(result: Color4): void;
  84332. }
  84333. /** Class used to store color 3 gradient */
  84334. export class Color3Gradient implements IValueGradient {
  84335. /**
  84336. * Gets or sets the gradient value (between 0 and 1)
  84337. */
  84338. gradient: number;
  84339. /**
  84340. * Gets or sets the associated color
  84341. */
  84342. color: Color3;
  84343. }
  84344. /** Class used to store factor gradient */
  84345. export class FactorGradient implements IValueGradient {
  84346. /**
  84347. * Gets or sets the gradient value (between 0 and 1)
  84348. */
  84349. gradient: number;
  84350. /**
  84351. * Gets or sets first associated factor
  84352. */
  84353. factor1: number;
  84354. /**
  84355. * Gets or sets second associated factor
  84356. */
  84357. factor2?: number;
  84358. /**
  84359. * Will get a number picked randomly between factor1 and factor2.
  84360. * If factor2 is undefined then factor1 will be used
  84361. * @returns the picked number
  84362. */
  84363. getFactor(): number;
  84364. }
  84365. /**
  84366. * Helper used to simplify some generic gradient tasks
  84367. */
  84368. export class GradientHelper {
  84369. /**
  84370. * Gets the current gradient from an array of IValueGradient
  84371. * @param ratio defines the current ratio to get
  84372. * @param gradients defines the array of IValueGradient
  84373. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84374. */
  84375. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84376. }
  84377. }
  84378. declare module BABYLON {
  84379. interface ThinEngine {
  84380. /**
  84381. * Creates a dynamic texture
  84382. * @param width defines the width of the texture
  84383. * @param height defines the height of the texture
  84384. * @param generateMipMaps defines if the engine should generate the mip levels
  84385. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84386. * @returns the dynamic texture inside an InternalTexture
  84387. */
  84388. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84389. /**
  84390. * Update the content of a dynamic texture
  84391. * @param texture defines the texture to update
  84392. * @param canvas defines the canvas containing the source
  84393. * @param invertY defines if data must be stored with Y axis inverted
  84394. * @param premulAlpha defines if alpha is stored as premultiplied
  84395. * @param format defines the format of the data
  84396. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84397. */
  84398. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84399. }
  84400. }
  84401. declare module BABYLON {
  84402. /**
  84403. * Helper class used to generate a canvas to manipulate images
  84404. */
  84405. export class CanvasGenerator {
  84406. /**
  84407. * Create a new canvas (or offscreen canvas depending on the context)
  84408. * @param width defines the expected width
  84409. * @param height defines the expected height
  84410. * @return a new canvas or offscreen canvas
  84411. */
  84412. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84413. }
  84414. }
  84415. declare module BABYLON {
  84416. /**
  84417. * A class extending Texture allowing drawing on a texture
  84418. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84419. */
  84420. export class DynamicTexture extends Texture {
  84421. private _generateMipMaps;
  84422. private _canvas;
  84423. private _context;
  84424. private _engine;
  84425. /**
  84426. * Creates a DynamicTexture
  84427. * @param name defines the name of the texture
  84428. * @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
  84429. * @param scene defines the scene where you want the texture
  84430. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84431. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84432. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84433. */
  84434. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84435. /**
  84436. * Get the current class name of the texture useful for serialization or dynamic coding.
  84437. * @returns "DynamicTexture"
  84438. */
  84439. getClassName(): string;
  84440. /**
  84441. * Gets the current state of canRescale
  84442. */
  84443. readonly canRescale: boolean;
  84444. private _recreate;
  84445. /**
  84446. * Scales the texture
  84447. * @param ratio the scale factor to apply to both width and height
  84448. */
  84449. scale(ratio: number): void;
  84450. /**
  84451. * Resizes the texture
  84452. * @param width the new width
  84453. * @param height the new height
  84454. */
  84455. scaleTo(width: number, height: number): void;
  84456. /**
  84457. * Gets the context of the canvas used by the texture
  84458. * @returns the canvas context of the dynamic texture
  84459. */
  84460. getContext(): CanvasRenderingContext2D;
  84461. /**
  84462. * Clears the texture
  84463. */
  84464. clear(): void;
  84465. /**
  84466. * Updates the texture
  84467. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84468. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84469. */
  84470. update(invertY?: boolean, premulAlpha?: boolean): void;
  84471. /**
  84472. * Draws text onto the texture
  84473. * @param text defines the text to be drawn
  84474. * @param x defines the placement of the text from the left
  84475. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84476. * @param font defines the font to be used with font-style, font-size, font-name
  84477. * @param color defines the color used for the text
  84478. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84479. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84480. * @param update defines whether texture is immediately update (default is true)
  84481. */
  84482. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84483. /**
  84484. * Clones the texture
  84485. * @returns the clone of the texture.
  84486. */
  84487. clone(): DynamicTexture;
  84488. /**
  84489. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84490. * @returns a serialized dynamic texture object
  84491. */
  84492. serialize(): any;
  84493. /** @hidden */
  84494. _rebuild(): void;
  84495. }
  84496. }
  84497. declare module BABYLON {
  84498. interface AbstractScene {
  84499. /**
  84500. * The list of procedural textures added to the scene
  84501. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84502. */
  84503. proceduralTextures: Array<ProceduralTexture>;
  84504. }
  84505. /**
  84506. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84507. * in a given scene.
  84508. */
  84509. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84510. /**
  84511. * The component name helpfull to identify the component in the list of scene components.
  84512. */
  84513. readonly name: string;
  84514. /**
  84515. * The scene the component belongs to.
  84516. */
  84517. scene: Scene;
  84518. /**
  84519. * Creates a new instance of the component for the given scene
  84520. * @param scene Defines the scene to register the component in
  84521. */
  84522. constructor(scene: Scene);
  84523. /**
  84524. * Registers the component in a given scene
  84525. */
  84526. register(): void;
  84527. /**
  84528. * Rebuilds the elements related to this component in case of
  84529. * context lost for instance.
  84530. */
  84531. rebuild(): void;
  84532. /**
  84533. * Disposes the component and the associated ressources.
  84534. */
  84535. dispose(): void;
  84536. private _beforeClear;
  84537. }
  84538. }
  84539. declare module BABYLON {
  84540. interface ThinEngine {
  84541. /**
  84542. * Creates a new render target cube texture
  84543. * @param size defines the size of the texture
  84544. * @param options defines the options used to create the texture
  84545. * @returns a new render target cube texture stored in an InternalTexture
  84546. */
  84547. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84548. }
  84549. }
  84550. declare module BABYLON {
  84551. /** @hidden */
  84552. export var proceduralVertexShader: {
  84553. name: string;
  84554. shader: string;
  84555. };
  84556. }
  84557. declare module BABYLON {
  84558. /**
  84559. * 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.
  84560. * This is the base class of any Procedural texture and contains most of the shareable code.
  84561. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84562. */
  84563. export class ProceduralTexture extends Texture {
  84564. isCube: boolean;
  84565. /**
  84566. * Define if the texture is enabled or not (disabled texture will not render)
  84567. */
  84568. isEnabled: boolean;
  84569. /**
  84570. * Define if the texture must be cleared before rendering (default is true)
  84571. */
  84572. autoClear: boolean;
  84573. /**
  84574. * Callback called when the texture is generated
  84575. */
  84576. onGenerated: () => void;
  84577. /**
  84578. * Event raised when the texture is generated
  84579. */
  84580. onGeneratedObservable: Observable<ProceduralTexture>;
  84581. /** @hidden */
  84582. _generateMipMaps: boolean;
  84583. /** @hidden **/
  84584. _effect: Effect;
  84585. /** @hidden */
  84586. _textures: {
  84587. [key: string]: Texture;
  84588. };
  84589. private _size;
  84590. private _currentRefreshId;
  84591. private _refreshRate;
  84592. private _vertexBuffers;
  84593. private _indexBuffer;
  84594. private _uniforms;
  84595. private _samplers;
  84596. private _fragment;
  84597. private _floats;
  84598. private _ints;
  84599. private _floatsArrays;
  84600. private _colors3;
  84601. private _colors4;
  84602. private _vectors2;
  84603. private _vectors3;
  84604. private _matrices;
  84605. private _fallbackTexture;
  84606. private _fallbackTextureUsed;
  84607. private _engine;
  84608. private _cachedDefines;
  84609. private _contentUpdateId;
  84610. private _contentData;
  84611. /**
  84612. * Instantiates a new procedural texture.
  84613. * 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.
  84614. * This is the base class of any Procedural texture and contains most of the shareable code.
  84615. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84616. * @param name Define the name of the texture
  84617. * @param size Define the size of the texture to create
  84618. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84619. * @param scene Define the scene the texture belongs to
  84620. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84621. * @param generateMipMaps Define if the texture should creates mip maps or not
  84622. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84623. */
  84624. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84625. /**
  84626. * The effect that is created when initializing the post process.
  84627. * @returns The created effect corresponding the the postprocess.
  84628. */
  84629. getEffect(): Effect;
  84630. /**
  84631. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84632. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84633. */
  84634. getContent(): Nullable<ArrayBufferView>;
  84635. private _createIndexBuffer;
  84636. /** @hidden */
  84637. _rebuild(): void;
  84638. /**
  84639. * Resets the texture in order to recreate its associated resources.
  84640. * This can be called in case of context loss
  84641. */
  84642. reset(): void;
  84643. protected _getDefines(): string;
  84644. /**
  84645. * Is the texture ready to be used ? (rendered at least once)
  84646. * @returns true if ready, otherwise, false.
  84647. */
  84648. isReady(): boolean;
  84649. /**
  84650. * Resets the refresh counter of the texture and start bak from scratch.
  84651. * Could be useful to regenerate the texture if it is setup to render only once.
  84652. */
  84653. resetRefreshCounter(): void;
  84654. /**
  84655. * Set the fragment shader to use in order to render the texture.
  84656. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84657. */
  84658. setFragment(fragment: any): void;
  84659. /**
  84660. * Define the refresh rate of the texture or the rendering frequency.
  84661. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84662. */
  84663. refreshRate: number;
  84664. /** @hidden */
  84665. _shouldRender(): boolean;
  84666. /**
  84667. * Get the size the texture is rendering at.
  84668. * @returns the size (texture is always squared)
  84669. */
  84670. getRenderSize(): number;
  84671. /**
  84672. * Resize the texture to new value.
  84673. * @param size Define the new size the texture should have
  84674. * @param generateMipMaps Define whether the new texture should create mip maps
  84675. */
  84676. resize(size: number, generateMipMaps: boolean): void;
  84677. private _checkUniform;
  84678. /**
  84679. * Set a texture in the shader program used to render.
  84680. * @param name Define the name of the uniform samplers as defined in the shader
  84681. * @param texture Define the texture to bind to this sampler
  84682. * @return the texture itself allowing "fluent" like uniform updates
  84683. */
  84684. setTexture(name: string, texture: Texture): ProceduralTexture;
  84685. /**
  84686. * Set a float in the shader.
  84687. * @param name Define the name of the uniform as defined in the shader
  84688. * @param value Define the value to give to the uniform
  84689. * @return the texture itself allowing "fluent" like uniform updates
  84690. */
  84691. setFloat(name: string, value: number): ProceduralTexture;
  84692. /**
  84693. * Set a int in the shader.
  84694. * @param name Define the name of the uniform as defined in the shader
  84695. * @param value Define the value to give to the uniform
  84696. * @return the texture itself allowing "fluent" like uniform updates
  84697. */
  84698. setInt(name: string, value: number): ProceduralTexture;
  84699. /**
  84700. * Set an array of floats in the shader.
  84701. * @param name Define the name of the uniform as defined in the shader
  84702. * @param value Define the value to give to the uniform
  84703. * @return the texture itself allowing "fluent" like uniform updates
  84704. */
  84705. setFloats(name: string, value: number[]): ProceduralTexture;
  84706. /**
  84707. * Set a vec3 in the shader from a Color3.
  84708. * @param name Define the name of the uniform as defined in the shader
  84709. * @param value Define the value to give to the uniform
  84710. * @return the texture itself allowing "fluent" like uniform updates
  84711. */
  84712. setColor3(name: string, value: Color3): ProceduralTexture;
  84713. /**
  84714. * Set a vec4 in the shader from a Color4.
  84715. * @param name Define the name of the uniform as defined in the shader
  84716. * @param value Define the value to give to the uniform
  84717. * @return the texture itself allowing "fluent" like uniform updates
  84718. */
  84719. setColor4(name: string, value: Color4): ProceduralTexture;
  84720. /**
  84721. * Set a vec2 in the shader from a Vector2.
  84722. * @param name Define the name of the uniform as defined in the shader
  84723. * @param value Define the value to give to the uniform
  84724. * @return the texture itself allowing "fluent" like uniform updates
  84725. */
  84726. setVector2(name: string, value: Vector2): ProceduralTexture;
  84727. /**
  84728. * Set a vec3 in the shader from a Vector3.
  84729. * @param name Define the name of the uniform as defined in the shader
  84730. * @param value Define the value to give to the uniform
  84731. * @return the texture itself allowing "fluent" like uniform updates
  84732. */
  84733. setVector3(name: string, value: Vector3): ProceduralTexture;
  84734. /**
  84735. * Set a mat4 in the shader from a MAtrix.
  84736. * @param name Define the name of the uniform as defined in the shader
  84737. * @param value Define the value to give to the uniform
  84738. * @return the texture itself allowing "fluent" like uniform updates
  84739. */
  84740. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84741. /**
  84742. * Render the texture to its associated render target.
  84743. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84744. */
  84745. render(useCameraPostProcess?: boolean): void;
  84746. /**
  84747. * Clone the texture.
  84748. * @returns the cloned texture
  84749. */
  84750. clone(): ProceduralTexture;
  84751. /**
  84752. * Dispose the texture and release its asoociated resources.
  84753. */
  84754. dispose(): void;
  84755. }
  84756. }
  84757. declare module BABYLON {
  84758. /**
  84759. * This represents the base class for particle system in Babylon.
  84760. * 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.
  84761. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84762. * @example https://doc.babylonjs.com/babylon101/particles
  84763. */
  84764. export class BaseParticleSystem {
  84765. /**
  84766. * Source color is added to the destination color without alpha affecting the result
  84767. */
  84768. static BLENDMODE_ONEONE: number;
  84769. /**
  84770. * Blend current color and particle color using particle’s alpha
  84771. */
  84772. static BLENDMODE_STANDARD: number;
  84773. /**
  84774. * Add current color and particle color multiplied by particle’s alpha
  84775. */
  84776. static BLENDMODE_ADD: number;
  84777. /**
  84778. * Multiply current color with particle color
  84779. */
  84780. static BLENDMODE_MULTIPLY: number;
  84781. /**
  84782. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84783. */
  84784. static BLENDMODE_MULTIPLYADD: number;
  84785. /**
  84786. * List of animations used by the particle system.
  84787. */
  84788. animations: Animation[];
  84789. /**
  84790. * The id of the Particle system.
  84791. */
  84792. id: string;
  84793. /**
  84794. * The friendly name of the Particle system.
  84795. */
  84796. name: string;
  84797. /**
  84798. * The rendering group used by the Particle system to chose when to render.
  84799. */
  84800. renderingGroupId: number;
  84801. /**
  84802. * The emitter represents the Mesh or position we are attaching the particle system to.
  84803. */
  84804. emitter: Nullable<AbstractMesh | Vector3>;
  84805. /**
  84806. * The maximum number of particles to emit per frame
  84807. */
  84808. emitRate: number;
  84809. /**
  84810. * If you want to launch only a few particles at once, that can be done, as well.
  84811. */
  84812. manualEmitCount: number;
  84813. /**
  84814. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84815. */
  84816. updateSpeed: number;
  84817. /**
  84818. * The amount of time the particle system is running (depends of the overall update speed).
  84819. */
  84820. targetStopDuration: number;
  84821. /**
  84822. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84823. */
  84824. disposeOnStop: boolean;
  84825. /**
  84826. * Minimum power of emitting particles.
  84827. */
  84828. minEmitPower: number;
  84829. /**
  84830. * Maximum power of emitting particles.
  84831. */
  84832. maxEmitPower: number;
  84833. /**
  84834. * Minimum life time of emitting particles.
  84835. */
  84836. minLifeTime: number;
  84837. /**
  84838. * Maximum life time of emitting particles.
  84839. */
  84840. maxLifeTime: number;
  84841. /**
  84842. * Minimum Size of emitting particles.
  84843. */
  84844. minSize: number;
  84845. /**
  84846. * Maximum Size of emitting particles.
  84847. */
  84848. maxSize: number;
  84849. /**
  84850. * Minimum scale of emitting particles on X axis.
  84851. */
  84852. minScaleX: number;
  84853. /**
  84854. * Maximum scale of emitting particles on X axis.
  84855. */
  84856. maxScaleX: number;
  84857. /**
  84858. * Minimum scale of emitting particles on Y axis.
  84859. */
  84860. minScaleY: number;
  84861. /**
  84862. * Maximum scale of emitting particles on Y axis.
  84863. */
  84864. maxScaleY: number;
  84865. /**
  84866. * Gets or sets the minimal initial rotation in radians.
  84867. */
  84868. minInitialRotation: number;
  84869. /**
  84870. * Gets or sets the maximal initial rotation in radians.
  84871. */
  84872. maxInitialRotation: number;
  84873. /**
  84874. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84875. */
  84876. minAngularSpeed: number;
  84877. /**
  84878. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84879. */
  84880. maxAngularSpeed: number;
  84881. /**
  84882. * The texture used to render each particle. (this can be a spritesheet)
  84883. */
  84884. particleTexture: Nullable<Texture>;
  84885. /**
  84886. * The layer mask we are rendering the particles through.
  84887. */
  84888. layerMask: number;
  84889. /**
  84890. * This can help using your own shader to render the particle system.
  84891. * The according effect will be created
  84892. */
  84893. customShader: any;
  84894. /**
  84895. * By default particle system starts as soon as they are created. This prevents the
  84896. * automatic start to happen and let you decide when to start emitting particles.
  84897. */
  84898. preventAutoStart: boolean;
  84899. private _noiseTexture;
  84900. /**
  84901. * Gets or sets a texture used to add random noise to particle positions
  84902. */
  84903. noiseTexture: Nullable<ProceduralTexture>;
  84904. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84905. noiseStrength: Vector3;
  84906. /**
  84907. * Callback triggered when the particle animation is ending.
  84908. */
  84909. onAnimationEnd: Nullable<() => void>;
  84910. /**
  84911. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84912. */
  84913. blendMode: number;
  84914. /**
  84915. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84916. * to override the particles.
  84917. */
  84918. forceDepthWrite: boolean;
  84919. /** 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 */
  84920. preWarmCycles: number;
  84921. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84922. preWarmStepOffset: number;
  84923. /**
  84924. * 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)
  84925. */
  84926. spriteCellChangeSpeed: number;
  84927. /**
  84928. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84929. */
  84930. startSpriteCellID: number;
  84931. /**
  84932. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84933. */
  84934. endSpriteCellID: number;
  84935. /**
  84936. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84937. */
  84938. spriteCellWidth: number;
  84939. /**
  84940. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84941. */
  84942. spriteCellHeight: number;
  84943. /**
  84944. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84945. */
  84946. spriteRandomStartCell: boolean;
  84947. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84948. translationPivot: Vector2;
  84949. /** @hidden */
  84950. protected _isAnimationSheetEnabled: boolean;
  84951. /**
  84952. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84953. */
  84954. beginAnimationOnStart: boolean;
  84955. /**
  84956. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84957. */
  84958. beginAnimationFrom: number;
  84959. /**
  84960. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84961. */
  84962. beginAnimationTo: number;
  84963. /**
  84964. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84965. */
  84966. beginAnimationLoop: boolean;
  84967. /**
  84968. * Gets or sets a world offset applied to all particles
  84969. */
  84970. worldOffset: Vector3;
  84971. /**
  84972. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84973. */
  84974. isAnimationSheetEnabled: boolean;
  84975. /**
  84976. * Get hosting scene
  84977. * @returns the scene
  84978. */
  84979. getScene(): Scene;
  84980. /**
  84981. * You can use gravity if you want to give an orientation to your particles.
  84982. */
  84983. gravity: Vector3;
  84984. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84985. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84986. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84987. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84988. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84989. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84990. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84991. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84992. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84993. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84994. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84995. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84996. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84997. /**
  84998. * Defines the delay in milliseconds before starting the system (0 by default)
  84999. */
  85000. startDelay: number;
  85001. /**
  85002. * Gets the current list of drag gradients.
  85003. * You must use addDragGradient and removeDragGradient to udpate this list
  85004. * @returns the list of drag gradients
  85005. */
  85006. getDragGradients(): Nullable<Array<FactorGradient>>;
  85007. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85008. limitVelocityDamping: number;
  85009. /**
  85010. * Gets the current list of limit velocity gradients.
  85011. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85012. * @returns the list of limit velocity gradients
  85013. */
  85014. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85015. /**
  85016. * Gets the current list of color gradients.
  85017. * You must use addColorGradient and removeColorGradient to udpate this list
  85018. * @returns the list of color gradients
  85019. */
  85020. getColorGradients(): Nullable<Array<ColorGradient>>;
  85021. /**
  85022. * Gets the current list of size gradients.
  85023. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85024. * @returns the list of size gradients
  85025. */
  85026. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85027. /**
  85028. * Gets the current list of color remap gradients.
  85029. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85030. * @returns the list of color remap gradients
  85031. */
  85032. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85033. /**
  85034. * Gets the current list of alpha remap gradients.
  85035. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85036. * @returns the list of alpha remap gradients
  85037. */
  85038. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85039. /**
  85040. * Gets the current list of life time gradients.
  85041. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85042. * @returns the list of life time gradients
  85043. */
  85044. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85045. /**
  85046. * Gets the current list of angular speed gradients.
  85047. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85048. * @returns the list of angular speed gradients
  85049. */
  85050. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85051. /**
  85052. * Gets the current list of velocity gradients.
  85053. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85054. * @returns the list of velocity gradients
  85055. */
  85056. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85057. /**
  85058. * Gets the current list of start size gradients.
  85059. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85060. * @returns the list of start size gradients
  85061. */
  85062. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85063. /**
  85064. * Gets the current list of emit rate gradients.
  85065. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85066. * @returns the list of emit rate gradients
  85067. */
  85068. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85069. /**
  85070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85071. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85072. */
  85073. direction1: Vector3;
  85074. /**
  85075. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85076. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85077. */
  85078. direction2: Vector3;
  85079. /**
  85080. * 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.
  85081. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85082. */
  85083. minEmitBox: Vector3;
  85084. /**
  85085. * 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.
  85086. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85087. */
  85088. maxEmitBox: Vector3;
  85089. /**
  85090. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85091. */
  85092. color1: Color4;
  85093. /**
  85094. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85095. */
  85096. color2: Color4;
  85097. /**
  85098. * Color the particle will have at the end of its lifetime
  85099. */
  85100. colorDead: Color4;
  85101. /**
  85102. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85103. */
  85104. textureMask: Color4;
  85105. /**
  85106. * The particle emitter type defines the emitter used by the particle system.
  85107. * It can be for example box, sphere, or cone...
  85108. */
  85109. particleEmitterType: IParticleEmitterType;
  85110. /** @hidden */
  85111. _isSubEmitter: boolean;
  85112. /**
  85113. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85114. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85115. */
  85116. billboardMode: number;
  85117. protected _isBillboardBased: boolean;
  85118. /**
  85119. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85120. */
  85121. isBillboardBased: boolean;
  85122. /**
  85123. * The scene the particle system belongs to.
  85124. */
  85125. protected _scene: Scene;
  85126. /**
  85127. * Local cache of defines for image processing.
  85128. */
  85129. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85130. /**
  85131. * Default configuration related to image processing available in the standard Material.
  85132. */
  85133. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85134. /**
  85135. * Gets the image processing configuration used either in this material.
  85136. */
  85137. /**
  85138. * Sets the Default image processing configuration used either in the this material.
  85139. *
  85140. * If sets to null, the scene one is in use.
  85141. */
  85142. imageProcessingConfiguration: ImageProcessingConfiguration;
  85143. /**
  85144. * Attaches a new image processing configuration to the Standard Material.
  85145. * @param configuration
  85146. */
  85147. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85148. /** @hidden */
  85149. protected _reset(): void;
  85150. /** @hidden */
  85151. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85152. /**
  85153. * Instantiates a particle system.
  85154. * 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.
  85155. * @param name The name of the particle system
  85156. */
  85157. constructor(name: string);
  85158. /**
  85159. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85162. * @returns the emitter
  85163. */
  85164. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85165. /**
  85166. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85167. * @param radius The radius of the hemisphere to emit from
  85168. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85169. * @returns the emitter
  85170. */
  85171. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85172. /**
  85173. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85174. * @param radius The radius of the sphere to emit from
  85175. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85176. * @returns the emitter
  85177. */
  85178. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85179. /**
  85180. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85181. * @param radius The radius of the sphere to emit from
  85182. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85183. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85184. * @returns the emitter
  85185. */
  85186. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85187. /**
  85188. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85189. * @param radius The radius of the emission cylinder
  85190. * @param height The height of the emission cylinder
  85191. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85192. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85193. * @returns the emitter
  85194. */
  85195. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85196. /**
  85197. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85198. * @param radius The radius of the cylinder to emit from
  85199. * @param height The height of the emission cylinder
  85200. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85201. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85202. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85203. * @returns the emitter
  85204. */
  85205. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85206. /**
  85207. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85208. * @param radius The radius of the cone to emit from
  85209. * @param angle The base angle of the cone
  85210. * @returns the emitter
  85211. */
  85212. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85213. /**
  85214. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85215. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85216. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85217. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85218. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85219. * @returns the emitter
  85220. */
  85221. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85222. }
  85223. }
  85224. declare module BABYLON {
  85225. /**
  85226. * Type of sub emitter
  85227. */
  85228. export enum SubEmitterType {
  85229. /**
  85230. * Attached to the particle over it's lifetime
  85231. */
  85232. ATTACHED = 0,
  85233. /**
  85234. * Created when the particle dies
  85235. */
  85236. END = 1
  85237. }
  85238. /**
  85239. * Sub emitter class used to emit particles from an existing particle
  85240. */
  85241. export class SubEmitter {
  85242. /**
  85243. * the particle system to be used by the sub emitter
  85244. */
  85245. particleSystem: ParticleSystem;
  85246. /**
  85247. * Type of the submitter (Default: END)
  85248. */
  85249. type: SubEmitterType;
  85250. /**
  85251. * 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)
  85252. * Note: This only is supported when using an emitter of type Mesh
  85253. */
  85254. inheritDirection: boolean;
  85255. /**
  85256. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85257. */
  85258. inheritedVelocityAmount: number;
  85259. /**
  85260. * Creates a sub emitter
  85261. * @param particleSystem the particle system to be used by the sub emitter
  85262. */
  85263. constructor(
  85264. /**
  85265. * the particle system to be used by the sub emitter
  85266. */
  85267. particleSystem: ParticleSystem);
  85268. /**
  85269. * Clones the sub emitter
  85270. * @returns the cloned sub emitter
  85271. */
  85272. clone(): SubEmitter;
  85273. /**
  85274. * Serialize current object to a JSON object
  85275. * @returns the serialized object
  85276. */
  85277. serialize(): any;
  85278. /** @hidden */
  85279. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85280. /**
  85281. * Creates a new SubEmitter from a serialized JSON version
  85282. * @param serializationObject defines the JSON object to read from
  85283. * @param scene defines the hosting scene
  85284. * @param rootUrl defines the rootUrl for data loading
  85285. * @returns a new SubEmitter
  85286. */
  85287. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85288. /** Release associated resources */
  85289. dispose(): void;
  85290. }
  85291. }
  85292. declare module BABYLON {
  85293. /** @hidden */
  85294. export var clipPlaneFragmentDeclaration: {
  85295. name: string;
  85296. shader: string;
  85297. };
  85298. }
  85299. declare module BABYLON {
  85300. /** @hidden */
  85301. export var imageProcessingDeclaration: {
  85302. name: string;
  85303. shader: string;
  85304. };
  85305. }
  85306. declare module BABYLON {
  85307. /** @hidden */
  85308. export var imageProcessingFunctions: {
  85309. name: string;
  85310. shader: string;
  85311. };
  85312. }
  85313. declare module BABYLON {
  85314. /** @hidden */
  85315. export var clipPlaneFragment: {
  85316. name: string;
  85317. shader: string;
  85318. };
  85319. }
  85320. declare module BABYLON {
  85321. /** @hidden */
  85322. export var particlesPixelShader: {
  85323. name: string;
  85324. shader: string;
  85325. };
  85326. }
  85327. declare module BABYLON {
  85328. /** @hidden */
  85329. export var clipPlaneVertexDeclaration: {
  85330. name: string;
  85331. shader: string;
  85332. };
  85333. }
  85334. declare module BABYLON {
  85335. /** @hidden */
  85336. export var clipPlaneVertex: {
  85337. name: string;
  85338. shader: string;
  85339. };
  85340. }
  85341. declare module BABYLON {
  85342. /** @hidden */
  85343. export var particlesVertexShader: {
  85344. name: string;
  85345. shader: string;
  85346. };
  85347. }
  85348. declare module BABYLON {
  85349. /**
  85350. * This represents a particle system in Babylon.
  85351. * 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.
  85352. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85353. * @example https://doc.babylonjs.com/babylon101/particles
  85354. */
  85355. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85356. /**
  85357. * Billboard mode will only apply to Y axis
  85358. */
  85359. static readonly BILLBOARDMODE_Y: number;
  85360. /**
  85361. * Billboard mode will apply to all axes
  85362. */
  85363. static readonly BILLBOARDMODE_ALL: number;
  85364. /**
  85365. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85366. */
  85367. static readonly BILLBOARDMODE_STRETCHED: number;
  85368. /**
  85369. * This function can be defined to provide custom update for active particles.
  85370. * This function will be called instead of regular update (age, position, color, etc.).
  85371. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85372. */
  85373. updateFunction: (particles: Particle[]) => void;
  85374. private _emitterWorldMatrix;
  85375. /**
  85376. * This function can be defined to specify initial direction for every new particle.
  85377. * It by default use the emitterType defined function
  85378. */
  85379. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85380. /**
  85381. * This function can be defined to specify initial position for every new particle.
  85382. * It by default use the emitterType defined function
  85383. */
  85384. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85385. /**
  85386. * @hidden
  85387. */
  85388. _inheritedVelocityOffset: Vector3;
  85389. /**
  85390. * An event triggered when the system is disposed
  85391. */
  85392. onDisposeObservable: Observable<ParticleSystem>;
  85393. private _onDisposeObserver;
  85394. /**
  85395. * Sets a callback that will be triggered when the system is disposed
  85396. */
  85397. onDispose: () => void;
  85398. private _particles;
  85399. private _epsilon;
  85400. private _capacity;
  85401. private _stockParticles;
  85402. private _newPartsExcess;
  85403. private _vertexData;
  85404. private _vertexBuffer;
  85405. private _vertexBuffers;
  85406. private _spriteBuffer;
  85407. private _indexBuffer;
  85408. private _effect;
  85409. private _customEffect;
  85410. private _cachedDefines;
  85411. private _scaledColorStep;
  85412. private _colorDiff;
  85413. private _scaledDirection;
  85414. private _scaledGravity;
  85415. private _currentRenderId;
  85416. private _alive;
  85417. private _useInstancing;
  85418. private _started;
  85419. private _stopped;
  85420. private _actualFrame;
  85421. private _scaledUpdateSpeed;
  85422. private _vertexBufferSize;
  85423. /** @hidden */
  85424. _currentEmitRateGradient: Nullable<FactorGradient>;
  85425. /** @hidden */
  85426. _currentEmitRate1: number;
  85427. /** @hidden */
  85428. _currentEmitRate2: number;
  85429. /** @hidden */
  85430. _currentStartSizeGradient: Nullable<FactorGradient>;
  85431. /** @hidden */
  85432. _currentStartSize1: number;
  85433. /** @hidden */
  85434. _currentStartSize2: number;
  85435. private readonly _rawTextureWidth;
  85436. private _rampGradientsTexture;
  85437. private _useRampGradients;
  85438. /** Gets or sets a boolean indicating that ramp gradients must be used
  85439. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85440. */
  85441. useRampGradients: boolean;
  85442. /**
  85443. * 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.
  85444. * 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: [])
  85445. */
  85446. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85447. private _subEmitters;
  85448. /**
  85449. * @hidden
  85450. * If the particle systems emitter should be disposed when the particle system is disposed
  85451. */
  85452. _disposeEmitterOnDispose: boolean;
  85453. /**
  85454. * The current active Sub-systems, this property is used by the root particle system only.
  85455. */
  85456. activeSubSystems: Array<ParticleSystem>;
  85457. private _rootParticleSystem;
  85458. /**
  85459. * Gets the current list of active particles
  85460. */
  85461. readonly particles: Particle[];
  85462. /**
  85463. * Returns the string "ParticleSystem"
  85464. * @returns a string containing the class name
  85465. */
  85466. getClassName(): string;
  85467. /**
  85468. * Instantiates a particle system.
  85469. * 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.
  85470. * @param name The name of the particle system
  85471. * @param capacity The max number of particles alive at the same time
  85472. * @param scene The scene the particle system belongs to
  85473. * @param customEffect a custom effect used to change the way particles are rendered by default
  85474. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85475. * @param epsilon Offset used to render the particles
  85476. */
  85477. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85478. private _addFactorGradient;
  85479. private _removeFactorGradient;
  85480. /**
  85481. * Adds a new life time gradient
  85482. * @param gradient defines the gradient to use (between 0 and 1)
  85483. * @param factor defines the life time factor to affect to the specified gradient
  85484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85485. * @returns the current particle system
  85486. */
  85487. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85488. /**
  85489. * Remove a specific life time gradient
  85490. * @param gradient defines the gradient to remove
  85491. * @returns the current particle system
  85492. */
  85493. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85494. /**
  85495. * Adds a new size gradient
  85496. * @param gradient defines the gradient to use (between 0 and 1)
  85497. * @param factor defines the size factor to affect to the specified gradient
  85498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85499. * @returns the current particle system
  85500. */
  85501. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85502. /**
  85503. * Remove a specific size gradient
  85504. * @param gradient defines the gradient to remove
  85505. * @returns the current particle system
  85506. */
  85507. removeSizeGradient(gradient: number): IParticleSystem;
  85508. /**
  85509. * Adds a new color remap gradient
  85510. * @param gradient defines the gradient to use (between 0 and 1)
  85511. * @param min defines the color remap minimal range
  85512. * @param max defines the color remap maximal range
  85513. * @returns the current particle system
  85514. */
  85515. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85516. /**
  85517. * Remove a specific color remap gradient
  85518. * @param gradient defines the gradient to remove
  85519. * @returns the current particle system
  85520. */
  85521. removeColorRemapGradient(gradient: number): IParticleSystem;
  85522. /**
  85523. * Adds a new alpha remap gradient
  85524. * @param gradient defines the gradient to use (between 0 and 1)
  85525. * @param min defines the alpha remap minimal range
  85526. * @param max defines the alpha remap maximal range
  85527. * @returns the current particle system
  85528. */
  85529. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85530. /**
  85531. * Remove a specific alpha remap gradient
  85532. * @param gradient defines the gradient to remove
  85533. * @returns the current particle system
  85534. */
  85535. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85536. /**
  85537. * Adds a new angular speed gradient
  85538. * @param gradient defines the gradient to use (between 0 and 1)
  85539. * @param factor defines the angular speed to affect to the specified gradient
  85540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85541. * @returns the current particle system
  85542. */
  85543. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85544. /**
  85545. * Remove a specific angular speed gradient
  85546. * @param gradient defines the gradient to remove
  85547. * @returns the current particle system
  85548. */
  85549. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85550. /**
  85551. * Adds a new velocity gradient
  85552. * @param gradient defines the gradient to use (between 0 and 1)
  85553. * @param factor defines the velocity to affect to the specified gradient
  85554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85555. * @returns the current particle system
  85556. */
  85557. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85558. /**
  85559. * Remove a specific velocity gradient
  85560. * @param gradient defines the gradient to remove
  85561. * @returns the current particle system
  85562. */
  85563. removeVelocityGradient(gradient: number): IParticleSystem;
  85564. /**
  85565. * Adds a new limit velocity gradient
  85566. * @param gradient defines the gradient to use (between 0 and 1)
  85567. * @param factor defines the limit velocity value to affect to the specified gradient
  85568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85569. * @returns the current particle system
  85570. */
  85571. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85572. /**
  85573. * Remove a specific limit velocity gradient
  85574. * @param gradient defines the gradient to remove
  85575. * @returns the current particle system
  85576. */
  85577. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85578. /**
  85579. * Adds a new drag gradient
  85580. * @param gradient defines the gradient to use (between 0 and 1)
  85581. * @param factor defines the drag value to affect to the specified gradient
  85582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85583. * @returns the current particle system
  85584. */
  85585. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85586. /**
  85587. * Remove a specific drag gradient
  85588. * @param gradient defines the gradient to remove
  85589. * @returns the current particle system
  85590. */
  85591. removeDragGradient(gradient: number): IParticleSystem;
  85592. /**
  85593. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85594. * @param gradient defines the gradient to use (between 0 and 1)
  85595. * @param factor defines the emit rate value to affect to the specified gradient
  85596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85597. * @returns the current particle system
  85598. */
  85599. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85600. /**
  85601. * Remove a specific emit rate gradient
  85602. * @param gradient defines the gradient to remove
  85603. * @returns the current particle system
  85604. */
  85605. removeEmitRateGradient(gradient: number): IParticleSystem;
  85606. /**
  85607. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85608. * @param gradient defines the gradient to use (between 0 and 1)
  85609. * @param factor defines the start size value to affect to the specified gradient
  85610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85611. * @returns the current particle system
  85612. */
  85613. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85614. /**
  85615. * Remove a specific start size gradient
  85616. * @param gradient defines the gradient to remove
  85617. * @returns the current particle system
  85618. */
  85619. removeStartSizeGradient(gradient: number): IParticleSystem;
  85620. private _createRampGradientTexture;
  85621. /**
  85622. * Gets the current list of ramp gradients.
  85623. * You must use addRampGradient and removeRampGradient to udpate this list
  85624. * @returns the list of ramp gradients
  85625. */
  85626. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85627. /**
  85628. * Adds a new ramp gradient used to remap particle colors
  85629. * @param gradient defines the gradient to use (between 0 and 1)
  85630. * @param color defines the color to affect to the specified gradient
  85631. * @returns the current particle system
  85632. */
  85633. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85634. /**
  85635. * Remove a specific ramp gradient
  85636. * @param gradient defines the gradient to remove
  85637. * @returns the current particle system
  85638. */
  85639. removeRampGradient(gradient: number): ParticleSystem;
  85640. /**
  85641. * Adds a new color gradient
  85642. * @param gradient defines the gradient to use (between 0 and 1)
  85643. * @param color1 defines the color to affect to the specified gradient
  85644. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85645. * @returns this particle system
  85646. */
  85647. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85648. /**
  85649. * Remove a specific color gradient
  85650. * @param gradient defines the gradient to remove
  85651. * @returns this particle system
  85652. */
  85653. removeColorGradient(gradient: number): IParticleSystem;
  85654. private _fetchR;
  85655. protected _reset(): void;
  85656. private _resetEffect;
  85657. private _createVertexBuffers;
  85658. private _createIndexBuffer;
  85659. /**
  85660. * Gets the maximum number of particles active at the same time.
  85661. * @returns The max number of active particles.
  85662. */
  85663. getCapacity(): number;
  85664. /**
  85665. * Gets whether there are still active particles in the system.
  85666. * @returns True if it is alive, otherwise false.
  85667. */
  85668. isAlive(): boolean;
  85669. /**
  85670. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85671. * @returns True if it has been started, otherwise false.
  85672. */
  85673. isStarted(): boolean;
  85674. private _prepareSubEmitterInternalArray;
  85675. /**
  85676. * Starts the particle system and begins to emit
  85677. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85678. */
  85679. start(delay?: number): void;
  85680. /**
  85681. * Stops the particle system.
  85682. * @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.
  85683. */
  85684. stop(stopSubEmitters?: boolean): void;
  85685. /**
  85686. * Remove all active particles
  85687. */
  85688. reset(): void;
  85689. /**
  85690. * @hidden (for internal use only)
  85691. */
  85692. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85693. /**
  85694. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85695. * Its lifetime will start back at 0.
  85696. */
  85697. recycleParticle: (particle: Particle) => void;
  85698. private _stopSubEmitters;
  85699. private _createParticle;
  85700. private _removeFromRoot;
  85701. private _emitFromParticle;
  85702. private _update;
  85703. /** @hidden */
  85704. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85705. /** @hidden */
  85706. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85707. /** @hidden */
  85708. private _getEffect;
  85709. /**
  85710. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85711. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85712. */
  85713. animate(preWarmOnly?: boolean): void;
  85714. private _appendParticleVertices;
  85715. /**
  85716. * Rebuilds the particle system.
  85717. */
  85718. rebuild(): void;
  85719. /**
  85720. * Is this system ready to be used/rendered
  85721. * @return true if the system is ready
  85722. */
  85723. isReady(): boolean;
  85724. private _render;
  85725. /**
  85726. * Renders the particle system in its current state.
  85727. * @returns the current number of particles
  85728. */
  85729. render(): number;
  85730. /**
  85731. * Disposes the particle system and free the associated resources
  85732. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85733. */
  85734. dispose(disposeTexture?: boolean): void;
  85735. /**
  85736. * Clones the particle system.
  85737. * @param name The name of the cloned object
  85738. * @param newEmitter The new emitter to use
  85739. * @returns the cloned particle system
  85740. */
  85741. clone(name: string, newEmitter: any): ParticleSystem;
  85742. /**
  85743. * Serializes the particle system to a JSON object.
  85744. * @returns the JSON object
  85745. */
  85746. serialize(): any;
  85747. /** @hidden */
  85748. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85749. /** @hidden */
  85750. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85751. /**
  85752. * Parses a JSON object to create a particle system.
  85753. * @param parsedParticleSystem The JSON object to parse
  85754. * @param scene The scene to create the particle system in
  85755. * @param rootUrl The root url to use to load external dependencies like texture
  85756. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85757. * @returns the Parsed particle system
  85758. */
  85759. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85760. }
  85761. }
  85762. declare module BABYLON {
  85763. /**
  85764. * A particle represents one of the element emitted by a particle system.
  85765. * This is mainly define by its coordinates, direction, velocity and age.
  85766. */
  85767. export class Particle {
  85768. /**
  85769. * The particle system the particle belongs to.
  85770. */
  85771. particleSystem: ParticleSystem;
  85772. private static _Count;
  85773. /**
  85774. * Unique ID of the particle
  85775. */
  85776. id: number;
  85777. /**
  85778. * The world position of the particle in the scene.
  85779. */
  85780. position: Vector3;
  85781. /**
  85782. * The world direction of the particle in the scene.
  85783. */
  85784. direction: Vector3;
  85785. /**
  85786. * The color of the particle.
  85787. */
  85788. color: Color4;
  85789. /**
  85790. * The color change of the particle per step.
  85791. */
  85792. colorStep: Color4;
  85793. /**
  85794. * Defines how long will the life of the particle be.
  85795. */
  85796. lifeTime: number;
  85797. /**
  85798. * The current age of the particle.
  85799. */
  85800. age: number;
  85801. /**
  85802. * The current size of the particle.
  85803. */
  85804. size: number;
  85805. /**
  85806. * The current scale of the particle.
  85807. */
  85808. scale: Vector2;
  85809. /**
  85810. * The current angle of the particle.
  85811. */
  85812. angle: number;
  85813. /**
  85814. * Defines how fast is the angle changing.
  85815. */
  85816. angularSpeed: number;
  85817. /**
  85818. * Defines the cell index used by the particle to be rendered from a sprite.
  85819. */
  85820. cellIndex: number;
  85821. /**
  85822. * The information required to support color remapping
  85823. */
  85824. remapData: Vector4;
  85825. /** @hidden */
  85826. _randomCellOffset?: number;
  85827. /** @hidden */
  85828. _initialDirection: Nullable<Vector3>;
  85829. /** @hidden */
  85830. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85831. /** @hidden */
  85832. _initialStartSpriteCellID: number;
  85833. /** @hidden */
  85834. _initialEndSpriteCellID: number;
  85835. /** @hidden */
  85836. _currentColorGradient: Nullable<ColorGradient>;
  85837. /** @hidden */
  85838. _currentColor1: Color4;
  85839. /** @hidden */
  85840. _currentColor2: Color4;
  85841. /** @hidden */
  85842. _currentSizeGradient: Nullable<FactorGradient>;
  85843. /** @hidden */
  85844. _currentSize1: number;
  85845. /** @hidden */
  85846. _currentSize2: number;
  85847. /** @hidden */
  85848. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85849. /** @hidden */
  85850. _currentAngularSpeed1: number;
  85851. /** @hidden */
  85852. _currentAngularSpeed2: number;
  85853. /** @hidden */
  85854. _currentVelocityGradient: Nullable<FactorGradient>;
  85855. /** @hidden */
  85856. _currentVelocity1: number;
  85857. /** @hidden */
  85858. _currentVelocity2: number;
  85859. /** @hidden */
  85860. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85861. /** @hidden */
  85862. _currentLimitVelocity1: number;
  85863. /** @hidden */
  85864. _currentLimitVelocity2: number;
  85865. /** @hidden */
  85866. _currentDragGradient: Nullable<FactorGradient>;
  85867. /** @hidden */
  85868. _currentDrag1: number;
  85869. /** @hidden */
  85870. _currentDrag2: number;
  85871. /** @hidden */
  85872. _randomNoiseCoordinates1: Vector3;
  85873. /** @hidden */
  85874. _randomNoiseCoordinates2: Vector3;
  85875. /**
  85876. * Creates a new instance Particle
  85877. * @param particleSystem the particle system the particle belongs to
  85878. */
  85879. constructor(
  85880. /**
  85881. * The particle system the particle belongs to.
  85882. */
  85883. particleSystem: ParticleSystem);
  85884. private updateCellInfoFromSystem;
  85885. /**
  85886. * Defines how the sprite cell index is updated for the particle
  85887. */
  85888. updateCellIndex(): void;
  85889. /** @hidden */
  85890. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85891. /** @hidden */
  85892. _inheritParticleInfoToSubEmitters(): void;
  85893. /** @hidden */
  85894. _reset(): void;
  85895. /**
  85896. * Copy the properties of particle to another one.
  85897. * @param other the particle to copy the information to.
  85898. */
  85899. copyTo(other: Particle): void;
  85900. }
  85901. }
  85902. declare module BABYLON {
  85903. /**
  85904. * Particle emitter represents a volume emitting particles.
  85905. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85906. */
  85907. export interface IParticleEmitterType {
  85908. /**
  85909. * Called by the particle System when the direction is computed for the created particle.
  85910. * @param worldMatrix is the world matrix of the particle system
  85911. * @param directionToUpdate is the direction vector to update with the result
  85912. * @param particle is the particle we are computed the direction for
  85913. */
  85914. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85915. /**
  85916. * Called by the particle System when the position is computed for the created particle.
  85917. * @param worldMatrix is the world matrix of the particle system
  85918. * @param positionToUpdate is the position vector to update with the result
  85919. * @param particle is the particle we are computed the position for
  85920. */
  85921. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85922. /**
  85923. * Clones the current emitter and returns a copy of it
  85924. * @returns the new emitter
  85925. */
  85926. clone(): IParticleEmitterType;
  85927. /**
  85928. * Called by the GPUParticleSystem to setup the update shader
  85929. * @param effect defines the update shader
  85930. */
  85931. applyToShader(effect: Effect): void;
  85932. /**
  85933. * Returns a string to use to update the GPU particles update shader
  85934. * @returns the effect defines string
  85935. */
  85936. getEffectDefines(): string;
  85937. /**
  85938. * Returns a string representing the class name
  85939. * @returns a string containing the class name
  85940. */
  85941. getClassName(): string;
  85942. /**
  85943. * Serializes the particle system to a JSON object.
  85944. * @returns the JSON object
  85945. */
  85946. serialize(): any;
  85947. /**
  85948. * Parse properties from a JSON object
  85949. * @param serializationObject defines the JSON object
  85950. */
  85951. parse(serializationObject: any): void;
  85952. }
  85953. }
  85954. declare module BABYLON {
  85955. /**
  85956. * Particle emitter emitting particles from the inside of a box.
  85957. * It emits the particles randomly between 2 given directions.
  85958. */
  85959. export class BoxParticleEmitter implements IParticleEmitterType {
  85960. /**
  85961. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85962. */
  85963. direction1: Vector3;
  85964. /**
  85965. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85966. */
  85967. direction2: Vector3;
  85968. /**
  85969. * 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.
  85970. */
  85971. minEmitBox: Vector3;
  85972. /**
  85973. * 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.
  85974. */
  85975. maxEmitBox: Vector3;
  85976. /**
  85977. * Creates a new instance BoxParticleEmitter
  85978. */
  85979. constructor();
  85980. /**
  85981. * Called by the particle System when the direction is computed for the created particle.
  85982. * @param worldMatrix is the world matrix of the particle system
  85983. * @param directionToUpdate is the direction vector to update with the result
  85984. * @param particle is the particle we are computed the direction for
  85985. */
  85986. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85987. /**
  85988. * Called by the particle System when the position is computed for the created particle.
  85989. * @param worldMatrix is the world matrix of the particle system
  85990. * @param positionToUpdate is the position vector to update with the result
  85991. * @param particle is the particle we are computed the position for
  85992. */
  85993. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85994. /**
  85995. * Clones the current emitter and returns a copy of it
  85996. * @returns the new emitter
  85997. */
  85998. clone(): BoxParticleEmitter;
  85999. /**
  86000. * Called by the GPUParticleSystem to setup the update shader
  86001. * @param effect defines the update shader
  86002. */
  86003. applyToShader(effect: Effect): void;
  86004. /**
  86005. * Returns a string to use to update the GPU particles update shader
  86006. * @returns a string containng the defines string
  86007. */
  86008. getEffectDefines(): string;
  86009. /**
  86010. * Returns the string "BoxParticleEmitter"
  86011. * @returns a string containing the class name
  86012. */
  86013. getClassName(): string;
  86014. /**
  86015. * Serializes the particle system to a JSON object.
  86016. * @returns the JSON object
  86017. */
  86018. serialize(): any;
  86019. /**
  86020. * Parse properties from a JSON object
  86021. * @param serializationObject defines the JSON object
  86022. */
  86023. parse(serializationObject: any): void;
  86024. }
  86025. }
  86026. declare module BABYLON {
  86027. /**
  86028. * Particle emitter emitting particles from the inside of a cone.
  86029. * It emits the particles alongside the cone volume from the base to the particle.
  86030. * The emission direction might be randomized.
  86031. */
  86032. export class ConeParticleEmitter implements IParticleEmitterType {
  86033. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86034. directionRandomizer: number;
  86035. private _radius;
  86036. private _angle;
  86037. private _height;
  86038. /**
  86039. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86040. */
  86041. radiusRange: number;
  86042. /**
  86043. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86044. */
  86045. heightRange: number;
  86046. /**
  86047. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86048. */
  86049. emitFromSpawnPointOnly: boolean;
  86050. /**
  86051. * Gets or sets the radius of the emission cone
  86052. */
  86053. radius: number;
  86054. /**
  86055. * Gets or sets the angle of the emission cone
  86056. */
  86057. angle: number;
  86058. private _buildHeight;
  86059. /**
  86060. * Creates a new instance ConeParticleEmitter
  86061. * @param radius the radius of the emission cone (1 by default)
  86062. * @param angle the cone base angle (PI by default)
  86063. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86064. */
  86065. constructor(radius?: number, angle?: number,
  86066. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86067. directionRandomizer?: number);
  86068. /**
  86069. * Called by the particle System when the direction is computed for the created particle.
  86070. * @param worldMatrix is the world matrix of the particle system
  86071. * @param directionToUpdate is the direction vector to update with the result
  86072. * @param particle is the particle we are computed the direction for
  86073. */
  86074. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86075. /**
  86076. * Called by the particle System when the position is computed for the created particle.
  86077. * @param worldMatrix is the world matrix of the particle system
  86078. * @param positionToUpdate is the position vector to update with the result
  86079. * @param particle is the particle we are computed the position for
  86080. */
  86081. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86082. /**
  86083. * Clones the current emitter and returns a copy of it
  86084. * @returns the new emitter
  86085. */
  86086. clone(): ConeParticleEmitter;
  86087. /**
  86088. * Called by the GPUParticleSystem to setup the update shader
  86089. * @param effect defines the update shader
  86090. */
  86091. applyToShader(effect: Effect): void;
  86092. /**
  86093. * Returns a string to use to update the GPU particles update shader
  86094. * @returns a string containng the defines string
  86095. */
  86096. getEffectDefines(): string;
  86097. /**
  86098. * Returns the string "ConeParticleEmitter"
  86099. * @returns a string containing the class name
  86100. */
  86101. getClassName(): string;
  86102. /**
  86103. * Serializes the particle system to a JSON object.
  86104. * @returns the JSON object
  86105. */
  86106. serialize(): any;
  86107. /**
  86108. * Parse properties from a JSON object
  86109. * @param serializationObject defines the JSON object
  86110. */
  86111. parse(serializationObject: any): void;
  86112. }
  86113. }
  86114. declare module BABYLON {
  86115. /**
  86116. * Particle emitter emitting particles from the inside of a cylinder.
  86117. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86118. */
  86119. export class CylinderParticleEmitter implements IParticleEmitterType {
  86120. /**
  86121. * The radius of the emission cylinder.
  86122. */
  86123. radius: number;
  86124. /**
  86125. * The height of the emission cylinder.
  86126. */
  86127. height: number;
  86128. /**
  86129. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86130. */
  86131. radiusRange: number;
  86132. /**
  86133. * How much to randomize the particle direction [0-1].
  86134. */
  86135. directionRandomizer: number;
  86136. /**
  86137. * Creates a new instance CylinderParticleEmitter
  86138. * @param radius the radius of the emission cylinder (1 by default)
  86139. * @param height the height of the emission cylinder (1 by default)
  86140. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86141. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86142. */
  86143. constructor(
  86144. /**
  86145. * The radius of the emission cylinder.
  86146. */
  86147. radius?: number,
  86148. /**
  86149. * The height of the emission cylinder.
  86150. */
  86151. height?: number,
  86152. /**
  86153. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86154. */
  86155. radiusRange?: number,
  86156. /**
  86157. * How much to randomize the particle direction [0-1].
  86158. */
  86159. directionRandomizer?: number);
  86160. /**
  86161. * Called by the particle System when the direction is computed for the created particle.
  86162. * @param worldMatrix is the world matrix of the particle system
  86163. * @param directionToUpdate is the direction vector to update with the result
  86164. * @param particle is the particle we are computed the direction for
  86165. */
  86166. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86167. /**
  86168. * Called by the particle System when the position is computed for the created particle.
  86169. * @param worldMatrix is the world matrix of the particle system
  86170. * @param positionToUpdate is the position vector to update with the result
  86171. * @param particle is the particle we are computed the position for
  86172. */
  86173. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86174. /**
  86175. * Clones the current emitter and returns a copy of it
  86176. * @returns the new emitter
  86177. */
  86178. clone(): CylinderParticleEmitter;
  86179. /**
  86180. * Called by the GPUParticleSystem to setup the update shader
  86181. * @param effect defines the update shader
  86182. */
  86183. applyToShader(effect: Effect): void;
  86184. /**
  86185. * Returns a string to use to update the GPU particles update shader
  86186. * @returns a string containng the defines string
  86187. */
  86188. getEffectDefines(): string;
  86189. /**
  86190. * Returns the string "CylinderParticleEmitter"
  86191. * @returns a string containing the class name
  86192. */
  86193. getClassName(): string;
  86194. /**
  86195. * Serializes the particle system to a JSON object.
  86196. * @returns the JSON object
  86197. */
  86198. serialize(): any;
  86199. /**
  86200. * Parse properties from a JSON object
  86201. * @param serializationObject defines the JSON object
  86202. */
  86203. parse(serializationObject: any): void;
  86204. }
  86205. /**
  86206. * Particle emitter emitting particles from the inside of a cylinder.
  86207. * It emits the particles randomly between two vectors.
  86208. */
  86209. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86210. /**
  86211. * The min limit of the emission direction.
  86212. */
  86213. direction1: Vector3;
  86214. /**
  86215. * The max limit of the emission direction.
  86216. */
  86217. direction2: Vector3;
  86218. /**
  86219. * Creates a new instance CylinderDirectedParticleEmitter
  86220. * @param radius the radius of the emission cylinder (1 by default)
  86221. * @param height the height of the emission cylinder (1 by default)
  86222. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86223. * @param direction1 the min limit of the emission direction (up vector by default)
  86224. * @param direction2 the max limit of the emission direction (up vector by default)
  86225. */
  86226. constructor(radius?: number, height?: number, radiusRange?: number,
  86227. /**
  86228. * The min limit of the emission direction.
  86229. */
  86230. direction1?: Vector3,
  86231. /**
  86232. * The max limit of the emission direction.
  86233. */
  86234. direction2?: Vector3);
  86235. /**
  86236. * Called by the particle System when the direction is computed for the created particle.
  86237. * @param worldMatrix is the world matrix of the particle system
  86238. * @param directionToUpdate is the direction vector to update with the result
  86239. * @param particle is the particle we are computed the direction for
  86240. */
  86241. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86242. /**
  86243. * Clones the current emitter and returns a copy of it
  86244. * @returns the new emitter
  86245. */
  86246. clone(): CylinderDirectedParticleEmitter;
  86247. /**
  86248. * Called by the GPUParticleSystem to setup the update shader
  86249. * @param effect defines the update shader
  86250. */
  86251. applyToShader(effect: Effect): void;
  86252. /**
  86253. * Returns a string to use to update the GPU particles update shader
  86254. * @returns a string containng the defines string
  86255. */
  86256. getEffectDefines(): string;
  86257. /**
  86258. * Returns the string "CylinderDirectedParticleEmitter"
  86259. * @returns a string containing the class name
  86260. */
  86261. getClassName(): string;
  86262. /**
  86263. * Serializes the particle system to a JSON object.
  86264. * @returns the JSON object
  86265. */
  86266. serialize(): any;
  86267. /**
  86268. * Parse properties from a JSON object
  86269. * @param serializationObject defines the JSON object
  86270. */
  86271. parse(serializationObject: any): void;
  86272. }
  86273. }
  86274. declare module BABYLON {
  86275. /**
  86276. * Particle emitter emitting particles from the inside of a hemisphere.
  86277. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86278. */
  86279. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86280. /**
  86281. * The radius of the emission hemisphere.
  86282. */
  86283. radius: number;
  86284. /**
  86285. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86286. */
  86287. radiusRange: number;
  86288. /**
  86289. * How much to randomize the particle direction [0-1].
  86290. */
  86291. directionRandomizer: number;
  86292. /**
  86293. * Creates a new instance HemisphericParticleEmitter
  86294. * @param radius the radius of the emission hemisphere (1 by default)
  86295. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86296. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86297. */
  86298. constructor(
  86299. /**
  86300. * The radius of the emission hemisphere.
  86301. */
  86302. radius?: number,
  86303. /**
  86304. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86305. */
  86306. radiusRange?: number,
  86307. /**
  86308. * How much to randomize the particle direction [0-1].
  86309. */
  86310. directionRandomizer?: number);
  86311. /**
  86312. * Called by the particle System when the direction is computed for the created particle.
  86313. * @param worldMatrix is the world matrix of the particle system
  86314. * @param directionToUpdate is the direction vector to update with the result
  86315. * @param particle is the particle we are computed the direction for
  86316. */
  86317. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86318. /**
  86319. * Called by the particle System when the position is computed for the created particle.
  86320. * @param worldMatrix is the world matrix of the particle system
  86321. * @param positionToUpdate is the position vector to update with the result
  86322. * @param particle is the particle we are computed the position for
  86323. */
  86324. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86325. /**
  86326. * Clones the current emitter and returns a copy of it
  86327. * @returns the new emitter
  86328. */
  86329. clone(): HemisphericParticleEmitter;
  86330. /**
  86331. * Called by the GPUParticleSystem to setup the update shader
  86332. * @param effect defines the update shader
  86333. */
  86334. applyToShader(effect: Effect): void;
  86335. /**
  86336. * Returns a string to use to update the GPU particles update shader
  86337. * @returns a string containng the defines string
  86338. */
  86339. getEffectDefines(): string;
  86340. /**
  86341. * Returns the string "HemisphericParticleEmitter"
  86342. * @returns a string containing the class name
  86343. */
  86344. getClassName(): string;
  86345. /**
  86346. * Serializes the particle system to a JSON object.
  86347. * @returns the JSON object
  86348. */
  86349. serialize(): any;
  86350. /**
  86351. * Parse properties from a JSON object
  86352. * @param serializationObject defines the JSON object
  86353. */
  86354. parse(serializationObject: any): void;
  86355. }
  86356. }
  86357. declare module BABYLON {
  86358. /**
  86359. * Particle emitter emitting particles from a point.
  86360. * It emits the particles randomly between 2 given directions.
  86361. */
  86362. export class PointParticleEmitter implements IParticleEmitterType {
  86363. /**
  86364. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86365. */
  86366. direction1: Vector3;
  86367. /**
  86368. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86369. */
  86370. direction2: Vector3;
  86371. /**
  86372. * Creates a new instance PointParticleEmitter
  86373. */
  86374. constructor();
  86375. /**
  86376. * Called by the particle System when the direction is computed for the created particle.
  86377. * @param worldMatrix is the world matrix of the particle system
  86378. * @param directionToUpdate is the direction vector to update with the result
  86379. * @param particle is the particle we are computed the direction for
  86380. */
  86381. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86382. /**
  86383. * Called by the particle System when the position is computed for the created particle.
  86384. * @param worldMatrix is the world matrix of the particle system
  86385. * @param positionToUpdate is the position vector to update with the result
  86386. * @param particle is the particle we are computed the position for
  86387. */
  86388. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86389. /**
  86390. * Clones the current emitter and returns a copy of it
  86391. * @returns the new emitter
  86392. */
  86393. clone(): PointParticleEmitter;
  86394. /**
  86395. * Called by the GPUParticleSystem to setup the update shader
  86396. * @param effect defines the update shader
  86397. */
  86398. applyToShader(effect: Effect): void;
  86399. /**
  86400. * Returns a string to use to update the GPU particles update shader
  86401. * @returns a string containng the defines string
  86402. */
  86403. getEffectDefines(): string;
  86404. /**
  86405. * Returns the string "PointParticleEmitter"
  86406. * @returns a string containing the class name
  86407. */
  86408. getClassName(): string;
  86409. /**
  86410. * Serializes the particle system to a JSON object.
  86411. * @returns the JSON object
  86412. */
  86413. serialize(): any;
  86414. /**
  86415. * Parse properties from a JSON object
  86416. * @param serializationObject defines the JSON object
  86417. */
  86418. parse(serializationObject: any): void;
  86419. }
  86420. }
  86421. declare module BABYLON {
  86422. /**
  86423. * Particle emitter emitting particles from the inside of a sphere.
  86424. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86425. */
  86426. export class SphereParticleEmitter implements IParticleEmitterType {
  86427. /**
  86428. * The radius of the emission sphere.
  86429. */
  86430. radius: number;
  86431. /**
  86432. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86433. */
  86434. radiusRange: number;
  86435. /**
  86436. * How much to randomize the particle direction [0-1].
  86437. */
  86438. directionRandomizer: number;
  86439. /**
  86440. * Creates a new instance SphereParticleEmitter
  86441. * @param radius the radius of the emission sphere (1 by default)
  86442. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86443. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86444. */
  86445. constructor(
  86446. /**
  86447. * The radius of the emission sphere.
  86448. */
  86449. radius?: number,
  86450. /**
  86451. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86452. */
  86453. radiusRange?: number,
  86454. /**
  86455. * How much to randomize the particle direction [0-1].
  86456. */
  86457. directionRandomizer?: number);
  86458. /**
  86459. * Called by the particle System when the direction is computed for the created particle.
  86460. * @param worldMatrix is the world matrix of the particle system
  86461. * @param directionToUpdate is the direction vector to update with the result
  86462. * @param particle is the particle we are computed the direction for
  86463. */
  86464. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86465. /**
  86466. * Called by the particle System when the position is computed for the created particle.
  86467. * @param worldMatrix is the world matrix of the particle system
  86468. * @param positionToUpdate is the position vector to update with the result
  86469. * @param particle is the particle we are computed the position for
  86470. */
  86471. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86472. /**
  86473. * Clones the current emitter and returns a copy of it
  86474. * @returns the new emitter
  86475. */
  86476. clone(): SphereParticleEmitter;
  86477. /**
  86478. * Called by the GPUParticleSystem to setup the update shader
  86479. * @param effect defines the update shader
  86480. */
  86481. applyToShader(effect: Effect): void;
  86482. /**
  86483. * Returns a string to use to update the GPU particles update shader
  86484. * @returns a string containng the defines string
  86485. */
  86486. getEffectDefines(): string;
  86487. /**
  86488. * Returns the string "SphereParticleEmitter"
  86489. * @returns a string containing the class name
  86490. */
  86491. getClassName(): string;
  86492. /**
  86493. * Serializes the particle system to a JSON object.
  86494. * @returns the JSON object
  86495. */
  86496. serialize(): any;
  86497. /**
  86498. * Parse properties from a JSON object
  86499. * @param serializationObject defines the JSON object
  86500. */
  86501. parse(serializationObject: any): void;
  86502. }
  86503. /**
  86504. * Particle emitter emitting particles from the inside of a sphere.
  86505. * It emits the particles randomly between two vectors.
  86506. */
  86507. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86508. /**
  86509. * The min limit of the emission direction.
  86510. */
  86511. direction1: Vector3;
  86512. /**
  86513. * The max limit of the emission direction.
  86514. */
  86515. direction2: Vector3;
  86516. /**
  86517. * Creates a new instance SphereDirectedParticleEmitter
  86518. * @param radius the radius of the emission sphere (1 by default)
  86519. * @param direction1 the min limit of the emission direction (up vector by default)
  86520. * @param direction2 the max limit of the emission direction (up vector by default)
  86521. */
  86522. constructor(radius?: number,
  86523. /**
  86524. * The min limit of the emission direction.
  86525. */
  86526. direction1?: Vector3,
  86527. /**
  86528. * The max limit of the emission direction.
  86529. */
  86530. direction2?: Vector3);
  86531. /**
  86532. * Called by the particle System when the direction is computed for the created particle.
  86533. * @param worldMatrix is the world matrix of the particle system
  86534. * @param directionToUpdate is the direction vector to update with the result
  86535. * @param particle is the particle we are computed the direction for
  86536. */
  86537. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86538. /**
  86539. * Clones the current emitter and returns a copy of it
  86540. * @returns the new emitter
  86541. */
  86542. clone(): SphereDirectedParticleEmitter;
  86543. /**
  86544. * Called by the GPUParticleSystem to setup the update shader
  86545. * @param effect defines the update shader
  86546. */
  86547. applyToShader(effect: Effect): void;
  86548. /**
  86549. * Returns a string to use to update the GPU particles update shader
  86550. * @returns a string containng the defines string
  86551. */
  86552. getEffectDefines(): string;
  86553. /**
  86554. * Returns the string "SphereDirectedParticleEmitter"
  86555. * @returns a string containing the class name
  86556. */
  86557. getClassName(): string;
  86558. /**
  86559. * Serializes the particle system to a JSON object.
  86560. * @returns the JSON object
  86561. */
  86562. serialize(): any;
  86563. /**
  86564. * Parse properties from a JSON object
  86565. * @param serializationObject defines the JSON object
  86566. */
  86567. parse(serializationObject: any): void;
  86568. }
  86569. }
  86570. declare module BABYLON {
  86571. /**
  86572. * Interface representing a particle system in Babylon.js.
  86573. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86574. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86575. */
  86576. export interface IParticleSystem {
  86577. /**
  86578. * List of animations used by the particle system.
  86579. */
  86580. animations: Animation[];
  86581. /**
  86582. * The id of the Particle system.
  86583. */
  86584. id: string;
  86585. /**
  86586. * The name of the Particle system.
  86587. */
  86588. name: string;
  86589. /**
  86590. * The emitter represents the Mesh or position we are attaching the particle system to.
  86591. */
  86592. emitter: Nullable<AbstractMesh | Vector3>;
  86593. /**
  86594. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86595. */
  86596. isBillboardBased: boolean;
  86597. /**
  86598. * The rendering group used by the Particle system to chose when to render.
  86599. */
  86600. renderingGroupId: number;
  86601. /**
  86602. * The layer mask we are rendering the particles through.
  86603. */
  86604. layerMask: number;
  86605. /**
  86606. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86607. */
  86608. updateSpeed: number;
  86609. /**
  86610. * The amount of time the particle system is running (depends of the overall update speed).
  86611. */
  86612. targetStopDuration: number;
  86613. /**
  86614. * The texture used to render each particle. (this can be a spritesheet)
  86615. */
  86616. particleTexture: Nullable<Texture>;
  86617. /**
  86618. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86619. */
  86620. blendMode: number;
  86621. /**
  86622. * Minimum life time of emitting particles.
  86623. */
  86624. minLifeTime: number;
  86625. /**
  86626. * Maximum life time of emitting particles.
  86627. */
  86628. maxLifeTime: number;
  86629. /**
  86630. * Minimum Size of emitting particles.
  86631. */
  86632. minSize: number;
  86633. /**
  86634. * Maximum Size of emitting particles.
  86635. */
  86636. maxSize: number;
  86637. /**
  86638. * Minimum scale of emitting particles on X axis.
  86639. */
  86640. minScaleX: number;
  86641. /**
  86642. * Maximum scale of emitting particles on X axis.
  86643. */
  86644. maxScaleX: number;
  86645. /**
  86646. * Minimum scale of emitting particles on Y axis.
  86647. */
  86648. minScaleY: number;
  86649. /**
  86650. * Maximum scale of emitting particles on Y axis.
  86651. */
  86652. maxScaleY: number;
  86653. /**
  86654. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86655. */
  86656. color1: Color4;
  86657. /**
  86658. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86659. */
  86660. color2: Color4;
  86661. /**
  86662. * Color the particle will have at the end of its lifetime.
  86663. */
  86664. colorDead: Color4;
  86665. /**
  86666. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86667. */
  86668. emitRate: number;
  86669. /**
  86670. * You can use gravity if you want to give an orientation to your particles.
  86671. */
  86672. gravity: Vector3;
  86673. /**
  86674. * Minimum power of emitting particles.
  86675. */
  86676. minEmitPower: number;
  86677. /**
  86678. * Maximum power of emitting particles.
  86679. */
  86680. maxEmitPower: number;
  86681. /**
  86682. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86683. */
  86684. minAngularSpeed: number;
  86685. /**
  86686. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86687. */
  86688. maxAngularSpeed: number;
  86689. /**
  86690. * Gets or sets the minimal initial rotation in radians.
  86691. */
  86692. minInitialRotation: number;
  86693. /**
  86694. * Gets or sets the maximal initial rotation in radians.
  86695. */
  86696. maxInitialRotation: number;
  86697. /**
  86698. * The particle emitter type defines the emitter used by the particle system.
  86699. * It can be for example box, sphere, or cone...
  86700. */
  86701. particleEmitterType: Nullable<IParticleEmitterType>;
  86702. /**
  86703. * Defines the delay in milliseconds before starting the system (0 by default)
  86704. */
  86705. startDelay: number;
  86706. /**
  86707. * 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
  86708. */
  86709. preWarmCycles: number;
  86710. /**
  86711. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86712. */
  86713. preWarmStepOffset: number;
  86714. /**
  86715. * 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)
  86716. */
  86717. spriteCellChangeSpeed: number;
  86718. /**
  86719. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86720. */
  86721. startSpriteCellID: number;
  86722. /**
  86723. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86724. */
  86725. endSpriteCellID: number;
  86726. /**
  86727. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86728. */
  86729. spriteCellWidth: number;
  86730. /**
  86731. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86732. */
  86733. spriteCellHeight: number;
  86734. /**
  86735. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86736. */
  86737. spriteRandomStartCell: boolean;
  86738. /**
  86739. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86740. */
  86741. isAnimationSheetEnabled: boolean;
  86742. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86743. translationPivot: Vector2;
  86744. /**
  86745. * Gets or sets a texture used to add random noise to particle positions
  86746. */
  86747. noiseTexture: Nullable<BaseTexture>;
  86748. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86749. noiseStrength: Vector3;
  86750. /**
  86751. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86752. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86753. */
  86754. billboardMode: number;
  86755. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86756. limitVelocityDamping: number;
  86757. /**
  86758. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86759. */
  86760. beginAnimationOnStart: boolean;
  86761. /**
  86762. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86763. */
  86764. beginAnimationFrom: number;
  86765. /**
  86766. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86767. */
  86768. beginAnimationTo: number;
  86769. /**
  86770. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86771. */
  86772. beginAnimationLoop: boolean;
  86773. /**
  86774. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86775. */
  86776. disposeOnStop: boolean;
  86777. /**
  86778. * Gets the maximum number of particles active at the same time.
  86779. * @returns The max number of active particles.
  86780. */
  86781. getCapacity(): number;
  86782. /**
  86783. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86784. * @returns True if it has been started, otherwise false.
  86785. */
  86786. isStarted(): boolean;
  86787. /**
  86788. * Animates the particle system for this frame.
  86789. */
  86790. animate(): void;
  86791. /**
  86792. * Renders the particle system in its current state.
  86793. * @returns the current number of particles
  86794. */
  86795. render(): number;
  86796. /**
  86797. * Dispose the particle system and frees its associated resources.
  86798. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86799. */
  86800. dispose(disposeTexture?: boolean): void;
  86801. /**
  86802. * Clones the particle system.
  86803. * @param name The name of the cloned object
  86804. * @param newEmitter The new emitter to use
  86805. * @returns the cloned particle system
  86806. */
  86807. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86808. /**
  86809. * Serializes the particle system to a JSON object.
  86810. * @returns the JSON object
  86811. */
  86812. serialize(): any;
  86813. /**
  86814. * Rebuild the particle system
  86815. */
  86816. rebuild(): void;
  86817. /**
  86818. * Starts the particle system and begins to emit
  86819. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86820. */
  86821. start(delay?: number): void;
  86822. /**
  86823. * Stops the particle system.
  86824. */
  86825. stop(): void;
  86826. /**
  86827. * Remove all active particles
  86828. */
  86829. reset(): void;
  86830. /**
  86831. * Is this system ready to be used/rendered
  86832. * @return true if the system is ready
  86833. */
  86834. isReady(): boolean;
  86835. /**
  86836. * Adds a new color gradient
  86837. * @param gradient defines the gradient to use (between 0 and 1)
  86838. * @param color1 defines the color to affect to the specified gradient
  86839. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86840. * @returns the current particle system
  86841. */
  86842. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86843. /**
  86844. * Remove a specific color gradient
  86845. * @param gradient defines the gradient to remove
  86846. * @returns the current particle system
  86847. */
  86848. removeColorGradient(gradient: number): IParticleSystem;
  86849. /**
  86850. * Adds a new size gradient
  86851. * @param gradient defines the gradient to use (between 0 and 1)
  86852. * @param factor defines the size factor to affect to the specified gradient
  86853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86854. * @returns the current particle system
  86855. */
  86856. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86857. /**
  86858. * Remove a specific size gradient
  86859. * @param gradient defines the gradient to remove
  86860. * @returns the current particle system
  86861. */
  86862. removeSizeGradient(gradient: number): IParticleSystem;
  86863. /**
  86864. * Gets the current list of color gradients.
  86865. * You must use addColorGradient and removeColorGradient to udpate this list
  86866. * @returns the list of color gradients
  86867. */
  86868. getColorGradients(): Nullable<Array<ColorGradient>>;
  86869. /**
  86870. * Gets the current list of size gradients.
  86871. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86872. * @returns the list of size gradients
  86873. */
  86874. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86875. /**
  86876. * Gets the current list of angular speed gradients.
  86877. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86878. * @returns the list of angular speed gradients
  86879. */
  86880. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86881. /**
  86882. * Adds a new angular speed gradient
  86883. * @param gradient defines the gradient to use (between 0 and 1)
  86884. * @param factor defines the angular speed to affect to the specified gradient
  86885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86886. * @returns the current particle system
  86887. */
  86888. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86889. /**
  86890. * Remove a specific angular speed gradient
  86891. * @param gradient defines the gradient to remove
  86892. * @returns the current particle system
  86893. */
  86894. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86895. /**
  86896. * Gets the current list of velocity gradients.
  86897. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86898. * @returns the list of velocity gradients
  86899. */
  86900. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86901. /**
  86902. * Adds a new velocity gradient
  86903. * @param gradient defines the gradient to use (between 0 and 1)
  86904. * @param factor defines the velocity to affect to the specified gradient
  86905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86906. * @returns the current particle system
  86907. */
  86908. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86909. /**
  86910. * Remove a specific velocity gradient
  86911. * @param gradient defines the gradient to remove
  86912. * @returns the current particle system
  86913. */
  86914. removeVelocityGradient(gradient: number): IParticleSystem;
  86915. /**
  86916. * Gets the current list of limit velocity gradients.
  86917. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86918. * @returns the list of limit velocity gradients
  86919. */
  86920. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86921. /**
  86922. * Adds a new limit velocity gradient
  86923. * @param gradient defines the gradient to use (between 0 and 1)
  86924. * @param factor defines the limit velocity to affect to the specified gradient
  86925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86926. * @returns the current particle system
  86927. */
  86928. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86929. /**
  86930. * Remove a specific limit velocity gradient
  86931. * @param gradient defines the gradient to remove
  86932. * @returns the current particle system
  86933. */
  86934. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86935. /**
  86936. * Adds a new drag gradient
  86937. * @param gradient defines the gradient to use (between 0 and 1)
  86938. * @param factor defines the drag to affect to the specified gradient
  86939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86940. * @returns the current particle system
  86941. */
  86942. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86943. /**
  86944. * Remove a specific drag gradient
  86945. * @param gradient defines the gradient to remove
  86946. * @returns the current particle system
  86947. */
  86948. removeDragGradient(gradient: number): IParticleSystem;
  86949. /**
  86950. * Gets the current list of drag gradients.
  86951. * You must use addDragGradient and removeDragGradient to udpate this list
  86952. * @returns the list of drag gradients
  86953. */
  86954. getDragGradients(): Nullable<Array<FactorGradient>>;
  86955. /**
  86956. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86957. * @param gradient defines the gradient to use (between 0 and 1)
  86958. * @param factor defines the emit rate to affect to the specified gradient
  86959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86960. * @returns the current particle system
  86961. */
  86962. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86963. /**
  86964. * Remove a specific emit rate gradient
  86965. * @param gradient defines the gradient to remove
  86966. * @returns the current particle system
  86967. */
  86968. removeEmitRateGradient(gradient: number): IParticleSystem;
  86969. /**
  86970. * Gets the current list of emit rate gradients.
  86971. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86972. * @returns the list of emit rate gradients
  86973. */
  86974. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86975. /**
  86976. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86977. * @param gradient defines the gradient to use (between 0 and 1)
  86978. * @param factor defines the start size to affect to the specified gradient
  86979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86980. * @returns the current particle system
  86981. */
  86982. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86983. /**
  86984. * Remove a specific start size gradient
  86985. * @param gradient defines the gradient to remove
  86986. * @returns the current particle system
  86987. */
  86988. removeStartSizeGradient(gradient: number): IParticleSystem;
  86989. /**
  86990. * Gets the current list of start size gradients.
  86991. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86992. * @returns the list of start size gradients
  86993. */
  86994. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86995. /**
  86996. * Adds a new life time gradient
  86997. * @param gradient defines the gradient to use (between 0 and 1)
  86998. * @param factor defines the life time factor to affect to the specified gradient
  86999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87000. * @returns the current particle system
  87001. */
  87002. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87003. /**
  87004. * Remove a specific life time gradient
  87005. * @param gradient defines the gradient to remove
  87006. * @returns the current particle system
  87007. */
  87008. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87009. /**
  87010. * Gets the current list of life time gradients.
  87011. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87012. * @returns the list of life time gradients
  87013. */
  87014. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87015. /**
  87016. * Gets the current list of color gradients.
  87017. * You must use addColorGradient and removeColorGradient to udpate this list
  87018. * @returns the list of color gradients
  87019. */
  87020. getColorGradients(): Nullable<Array<ColorGradient>>;
  87021. /**
  87022. * Adds a new ramp gradient used to remap particle colors
  87023. * @param gradient defines the gradient to use (between 0 and 1)
  87024. * @param color defines the color to affect to the specified gradient
  87025. * @returns the current particle system
  87026. */
  87027. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87028. /**
  87029. * Gets the current list of ramp gradients.
  87030. * You must use addRampGradient and removeRampGradient to udpate this list
  87031. * @returns the list of ramp gradients
  87032. */
  87033. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87034. /** Gets or sets a boolean indicating that ramp gradients must be used
  87035. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87036. */
  87037. useRampGradients: boolean;
  87038. /**
  87039. * Adds a new color remap gradient
  87040. * @param gradient defines the gradient to use (between 0 and 1)
  87041. * @param min defines the color remap minimal range
  87042. * @param max defines the color remap maximal range
  87043. * @returns the current particle system
  87044. */
  87045. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87046. /**
  87047. * Gets the current list of color remap gradients.
  87048. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87049. * @returns the list of color remap gradients
  87050. */
  87051. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87052. /**
  87053. * Adds a new alpha remap gradient
  87054. * @param gradient defines the gradient to use (between 0 and 1)
  87055. * @param min defines the alpha remap minimal range
  87056. * @param max defines the alpha remap maximal range
  87057. * @returns the current particle system
  87058. */
  87059. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87060. /**
  87061. * Gets the current list of alpha remap gradients.
  87062. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87063. * @returns the list of alpha remap gradients
  87064. */
  87065. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87066. /**
  87067. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87068. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87069. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87070. * @returns the emitter
  87071. */
  87072. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87073. /**
  87074. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87075. * @param radius The radius of the hemisphere to emit from
  87076. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87077. * @returns the emitter
  87078. */
  87079. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87080. /**
  87081. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87082. * @param radius The radius of the sphere to emit from
  87083. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87084. * @returns the emitter
  87085. */
  87086. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87087. /**
  87088. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87089. * @param radius The radius of the sphere to emit from
  87090. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87091. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87092. * @returns the emitter
  87093. */
  87094. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87095. /**
  87096. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87097. * @param radius The radius of the emission cylinder
  87098. * @param height The height of the emission cylinder
  87099. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87100. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87101. * @returns the emitter
  87102. */
  87103. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87104. /**
  87105. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87106. * @param radius The radius of the cylinder to emit from
  87107. * @param height The height of the emission cylinder
  87108. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87109. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87110. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87111. * @returns the emitter
  87112. */
  87113. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87114. /**
  87115. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87116. * @param radius The radius of the cone to emit from
  87117. * @param angle The base angle of the cone
  87118. * @returns the emitter
  87119. */
  87120. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87121. /**
  87122. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87123. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87124. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87125. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87126. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87127. * @returns the emitter
  87128. */
  87129. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87130. /**
  87131. * Get hosting scene
  87132. * @returns the scene
  87133. */
  87134. getScene(): Scene;
  87135. }
  87136. }
  87137. declare module BABYLON {
  87138. /**
  87139. * Creates an instance based on a source mesh.
  87140. */
  87141. export class InstancedMesh extends AbstractMesh {
  87142. private _sourceMesh;
  87143. private _currentLOD;
  87144. /** @hidden */
  87145. _indexInSourceMeshInstanceArray: number;
  87146. constructor(name: string, source: Mesh);
  87147. /**
  87148. * Returns the string "InstancedMesh".
  87149. */
  87150. getClassName(): string;
  87151. /** Gets the list of lights affecting that mesh */
  87152. readonly lightSources: Light[];
  87153. _resyncLightSources(): void;
  87154. _resyncLighSource(light: Light): void;
  87155. _removeLightSource(light: Light, dispose: boolean): void;
  87156. /**
  87157. * If the source mesh receives shadows
  87158. */
  87159. readonly receiveShadows: boolean;
  87160. /**
  87161. * The material of the source mesh
  87162. */
  87163. readonly material: Nullable<Material>;
  87164. /**
  87165. * Visibility of the source mesh
  87166. */
  87167. readonly visibility: number;
  87168. /**
  87169. * Skeleton of the source mesh
  87170. */
  87171. readonly skeleton: Nullable<Skeleton>;
  87172. /**
  87173. * Rendering ground id of the source mesh
  87174. */
  87175. renderingGroupId: number;
  87176. /**
  87177. * Returns the total number of vertices (integer).
  87178. */
  87179. getTotalVertices(): number;
  87180. /**
  87181. * Returns a positive integer : the total number of indices in this mesh geometry.
  87182. * @returns the numner of indices or zero if the mesh has no geometry.
  87183. */
  87184. getTotalIndices(): number;
  87185. /**
  87186. * The source mesh of the instance
  87187. */
  87188. readonly sourceMesh: Mesh;
  87189. /**
  87190. * Is this node ready to be used/rendered
  87191. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87192. * @return {boolean} is it ready
  87193. */
  87194. isReady(completeCheck?: boolean): boolean;
  87195. /**
  87196. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87197. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87198. * @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.
  87199. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87200. */
  87201. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  87202. /**
  87203. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87204. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87205. * The `data` are either a numeric array either a Float32Array.
  87206. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87207. * 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).
  87208. * Note that a new underlying VertexBuffer object is created each call.
  87209. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87210. *
  87211. * Possible `kind` values :
  87212. * - VertexBuffer.PositionKind
  87213. * - VertexBuffer.UVKind
  87214. * - VertexBuffer.UV2Kind
  87215. * - VertexBuffer.UV3Kind
  87216. * - VertexBuffer.UV4Kind
  87217. * - VertexBuffer.UV5Kind
  87218. * - VertexBuffer.UV6Kind
  87219. * - VertexBuffer.ColorKind
  87220. * - VertexBuffer.MatricesIndicesKind
  87221. * - VertexBuffer.MatricesIndicesExtraKind
  87222. * - VertexBuffer.MatricesWeightsKind
  87223. * - VertexBuffer.MatricesWeightsExtraKind
  87224. *
  87225. * Returns the Mesh.
  87226. */
  87227. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87228. /**
  87229. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87230. * If the mesh has no geometry, it is simply returned as it is.
  87231. * The `data` are either a numeric array either a Float32Array.
  87232. * No new underlying VertexBuffer object is created.
  87233. * 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.
  87234. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87235. *
  87236. * Possible `kind` values :
  87237. * - VertexBuffer.PositionKind
  87238. * - VertexBuffer.UVKind
  87239. * - VertexBuffer.UV2Kind
  87240. * - VertexBuffer.UV3Kind
  87241. * - VertexBuffer.UV4Kind
  87242. * - VertexBuffer.UV5Kind
  87243. * - VertexBuffer.UV6Kind
  87244. * - VertexBuffer.ColorKind
  87245. * - VertexBuffer.MatricesIndicesKind
  87246. * - VertexBuffer.MatricesIndicesExtraKind
  87247. * - VertexBuffer.MatricesWeightsKind
  87248. * - VertexBuffer.MatricesWeightsExtraKind
  87249. *
  87250. * Returns the Mesh.
  87251. */
  87252. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87253. /**
  87254. * Sets the mesh indices.
  87255. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87256. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87257. * This method creates a new index buffer each call.
  87258. * Returns the Mesh.
  87259. */
  87260. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87261. /**
  87262. * Boolean : True if the mesh owns the requested kind of data.
  87263. */
  87264. isVerticesDataPresent(kind: string): boolean;
  87265. /**
  87266. * Returns an array of indices (IndicesArray).
  87267. */
  87268. getIndices(): Nullable<IndicesArray>;
  87269. readonly _positions: Nullable<Vector3[]>;
  87270. /**
  87271. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87272. * This means the mesh underlying bounding box and sphere are recomputed.
  87273. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87274. * @returns the current mesh
  87275. */
  87276. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87277. /** @hidden */
  87278. _preActivate(): InstancedMesh;
  87279. /** @hidden */
  87280. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87281. /** @hidden */
  87282. _postActivate(): void;
  87283. getWorldMatrix(): Matrix;
  87284. readonly isAnInstance: boolean;
  87285. /**
  87286. * Returns the current associated LOD AbstractMesh.
  87287. */
  87288. getLOD(camera: Camera): AbstractMesh;
  87289. /** @hidden */
  87290. _syncSubMeshes(): InstancedMesh;
  87291. /** @hidden */
  87292. _generatePointsArray(): boolean;
  87293. /**
  87294. * Creates a new InstancedMesh from the current mesh.
  87295. * - name (string) : the cloned mesh name
  87296. * - newParent (optional Node) : the optional Node to parent the clone to.
  87297. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87298. *
  87299. * Returns the clone.
  87300. */
  87301. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87302. /**
  87303. * Disposes the InstancedMesh.
  87304. * Returns nothing.
  87305. */
  87306. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87307. }
  87308. interface Mesh {
  87309. /**
  87310. * Register a custom buffer that will be instanced
  87311. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87312. * @param kind defines the buffer kind
  87313. * @param stride defines the stride in floats
  87314. */
  87315. registerInstancedBuffer(kind: string, stride: number): void;
  87316. /** @hidden */
  87317. _userInstancedBuffersStorage: {
  87318. data: {
  87319. [key: string]: Float32Array;
  87320. };
  87321. sizes: {
  87322. [key: string]: number;
  87323. };
  87324. vertexBuffers: {
  87325. [key: string]: Nullable<VertexBuffer>;
  87326. };
  87327. strides: {
  87328. [key: string]: number;
  87329. };
  87330. };
  87331. }
  87332. interface AbstractMesh {
  87333. /**
  87334. * Object used to store instanced buffers defined by user
  87335. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87336. */
  87337. instancedBuffers: {
  87338. [key: string]: any;
  87339. };
  87340. }
  87341. }
  87342. declare module BABYLON {
  87343. /**
  87344. * Defines the options associated with the creation of a shader material.
  87345. */
  87346. export interface IShaderMaterialOptions {
  87347. /**
  87348. * Does the material work in alpha blend mode
  87349. */
  87350. needAlphaBlending: boolean;
  87351. /**
  87352. * Does the material work in alpha test mode
  87353. */
  87354. needAlphaTesting: boolean;
  87355. /**
  87356. * The list of attribute names used in the shader
  87357. */
  87358. attributes: string[];
  87359. /**
  87360. * The list of unifrom names used in the shader
  87361. */
  87362. uniforms: string[];
  87363. /**
  87364. * The list of UBO names used in the shader
  87365. */
  87366. uniformBuffers: string[];
  87367. /**
  87368. * The list of sampler names used in the shader
  87369. */
  87370. samplers: string[];
  87371. /**
  87372. * The list of defines used in the shader
  87373. */
  87374. defines: string[];
  87375. }
  87376. /**
  87377. * 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.
  87378. *
  87379. * This returned material effects how the mesh will look based on the code in the shaders.
  87380. *
  87381. * @see http://doc.babylonjs.com/how_to/shader_material
  87382. */
  87383. export class ShaderMaterial extends Material {
  87384. private _shaderPath;
  87385. private _options;
  87386. private _textures;
  87387. private _textureArrays;
  87388. private _floats;
  87389. private _ints;
  87390. private _floatsArrays;
  87391. private _colors3;
  87392. private _colors3Arrays;
  87393. private _colors4;
  87394. private _colors4Arrays;
  87395. private _vectors2;
  87396. private _vectors3;
  87397. private _vectors4;
  87398. private _matrices;
  87399. private _matrixArrays;
  87400. private _matrices3x3;
  87401. private _matrices2x2;
  87402. private _vectors2Arrays;
  87403. private _vectors3Arrays;
  87404. private _vectors4Arrays;
  87405. private _cachedWorldViewMatrix;
  87406. private _cachedWorldViewProjectionMatrix;
  87407. private _renderId;
  87408. private _multiview;
  87409. /**
  87410. * Instantiate a new shader material.
  87411. * 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.
  87412. * This returned material effects how the mesh will look based on the code in the shaders.
  87413. * @see http://doc.babylonjs.com/how_to/shader_material
  87414. * @param name Define the name of the material in the scene
  87415. * @param scene Define the scene the material belongs to
  87416. * @param shaderPath Defines the route to the shader code in one of three ways:
  87417. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87418. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87419. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87420. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87421. * @param options Define the options used to create the shader
  87422. */
  87423. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87424. /**
  87425. * Gets the shader path used to define the shader code
  87426. * It can be modified to trigger a new compilation
  87427. */
  87428. /**
  87429. * Sets the shader path used to define the shader code
  87430. * It can be modified to trigger a new compilation
  87431. */
  87432. shaderPath: any;
  87433. /**
  87434. * Gets the options used to compile the shader.
  87435. * They can be modified to trigger a new compilation
  87436. */
  87437. readonly options: IShaderMaterialOptions;
  87438. /**
  87439. * Gets the current class name of the material e.g. "ShaderMaterial"
  87440. * Mainly use in serialization.
  87441. * @returns the class name
  87442. */
  87443. getClassName(): string;
  87444. /**
  87445. * Specifies if the material will require alpha blending
  87446. * @returns a boolean specifying if alpha blending is needed
  87447. */
  87448. needAlphaBlending(): boolean;
  87449. /**
  87450. * Specifies if this material should be rendered in alpha test mode
  87451. * @returns a boolean specifying if an alpha test is needed.
  87452. */
  87453. needAlphaTesting(): boolean;
  87454. private _checkUniform;
  87455. /**
  87456. * Set a texture in the shader.
  87457. * @param name Define the name of the uniform samplers as defined in the shader
  87458. * @param texture Define the texture to bind to this sampler
  87459. * @return the material itself allowing "fluent" like uniform updates
  87460. */
  87461. setTexture(name: string, texture: Texture): ShaderMaterial;
  87462. /**
  87463. * Set a texture array in the shader.
  87464. * @param name Define the name of the uniform sampler array as defined in the shader
  87465. * @param textures Define the list of textures to bind to this sampler
  87466. * @return the material itself allowing "fluent" like uniform updates
  87467. */
  87468. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87469. /**
  87470. * Set a float in the shader.
  87471. * @param name Define the name of the uniform as defined in the shader
  87472. * @param value Define the value to give to the uniform
  87473. * @return the material itself allowing "fluent" like uniform updates
  87474. */
  87475. setFloat(name: string, value: number): ShaderMaterial;
  87476. /**
  87477. * Set a int in the shader.
  87478. * @param name Define the name of the uniform as defined in the shader
  87479. * @param value Define the value to give to the uniform
  87480. * @return the material itself allowing "fluent" like uniform updates
  87481. */
  87482. setInt(name: string, value: number): ShaderMaterial;
  87483. /**
  87484. * Set an array of floats in the shader.
  87485. * @param name Define the name of the uniform as defined in the shader
  87486. * @param value Define the value to give to the uniform
  87487. * @return the material itself allowing "fluent" like uniform updates
  87488. */
  87489. setFloats(name: string, value: number[]): ShaderMaterial;
  87490. /**
  87491. * Set a vec3 in the shader from a Color3.
  87492. * @param name Define the name of the uniform as defined in the shader
  87493. * @param value Define the value to give to the uniform
  87494. * @return the material itself allowing "fluent" like uniform updates
  87495. */
  87496. setColor3(name: string, value: Color3): ShaderMaterial;
  87497. /**
  87498. * Set a vec3 array in the shader from a Color3 array.
  87499. * @param name Define the name of the uniform as defined in the shader
  87500. * @param value Define the value to give to the uniform
  87501. * @return the material itself allowing "fluent" like uniform updates
  87502. */
  87503. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  87504. /**
  87505. * Set a vec4 in the shader from a Color4.
  87506. * @param name Define the name of the uniform as defined in the shader
  87507. * @param value Define the value to give to the uniform
  87508. * @return the material itself allowing "fluent" like uniform updates
  87509. */
  87510. setColor4(name: string, value: Color4): ShaderMaterial;
  87511. /**
  87512. * Set a vec4 array in the shader from a Color4 array.
  87513. * @param name Define the name of the uniform as defined in the shader
  87514. * @param value Define the value to give to the uniform
  87515. * @return the material itself allowing "fluent" like uniform updates
  87516. */
  87517. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87518. /**
  87519. * Set a vec2 in the shader from a Vector2.
  87520. * @param name Define the name of the uniform as defined in the shader
  87521. * @param value Define the value to give to the uniform
  87522. * @return the material itself allowing "fluent" like uniform updates
  87523. */
  87524. setVector2(name: string, value: Vector2): ShaderMaterial;
  87525. /**
  87526. * Set a vec3 in the shader from a Vector3.
  87527. * @param name Define the name of the uniform as defined in the shader
  87528. * @param value Define the value to give to the uniform
  87529. * @return the material itself allowing "fluent" like uniform updates
  87530. */
  87531. setVector3(name: string, value: Vector3): ShaderMaterial;
  87532. /**
  87533. * Set a vec4 in the shader from a Vector4.
  87534. * @param name Define the name of the uniform as defined in the shader
  87535. * @param value Define the value to give to the uniform
  87536. * @return the material itself allowing "fluent" like uniform updates
  87537. */
  87538. setVector4(name: string, value: Vector4): ShaderMaterial;
  87539. /**
  87540. * Set a mat4 in the shader from a Matrix.
  87541. * @param name Define the name of the uniform as defined in the shader
  87542. * @param value Define the value to give to the uniform
  87543. * @return the material itself allowing "fluent" like uniform updates
  87544. */
  87545. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87546. /**
  87547. * Set a float32Array in the shader from a matrix array.
  87548. * @param name Define the name of the uniform as defined in the shader
  87549. * @param value Define the value to give to the uniform
  87550. * @return the material itself allowing "fluent" like uniform updates
  87551. */
  87552. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  87553. /**
  87554. * Set a mat3 in the shader from a Float32Array.
  87555. * @param name Define the name of the uniform as defined in the shader
  87556. * @param value Define the value to give to the uniform
  87557. * @return the material itself allowing "fluent" like uniform updates
  87558. */
  87559. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87560. /**
  87561. * Set a mat2 in the shader from a Float32Array.
  87562. * @param name Define the name of the uniform as defined in the shader
  87563. * @param value Define the value to give to the uniform
  87564. * @return the material itself allowing "fluent" like uniform updates
  87565. */
  87566. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87567. /**
  87568. * Set a vec2 array in the shader from a number array.
  87569. * @param name Define the name of the uniform as defined in the shader
  87570. * @param value Define the value to give to the uniform
  87571. * @return the material itself allowing "fluent" like uniform updates
  87572. */
  87573. setArray2(name: string, value: number[]): ShaderMaterial;
  87574. /**
  87575. * Set a vec3 array in the shader from a number array.
  87576. * @param name Define the name of the uniform as defined in the shader
  87577. * @param value Define the value to give to the uniform
  87578. * @return the material itself allowing "fluent" like uniform updates
  87579. */
  87580. setArray3(name: string, value: number[]): ShaderMaterial;
  87581. /**
  87582. * Set a vec4 array in the shader from a number array.
  87583. * @param name Define the name of the uniform as defined in the shader
  87584. * @param value Define the value to give to the uniform
  87585. * @return the material itself allowing "fluent" like uniform updates
  87586. */
  87587. setArray4(name: string, value: number[]): ShaderMaterial;
  87588. private _checkCache;
  87589. /**
  87590. * Specifies that the submesh is ready to be used
  87591. * @param mesh defines the mesh to check
  87592. * @param subMesh defines which submesh to check
  87593. * @param useInstances specifies that instances should be used
  87594. * @returns a boolean indicating that the submesh is ready or not
  87595. */
  87596. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87597. /**
  87598. * Checks if the material is ready to render the requested mesh
  87599. * @param mesh Define the mesh to render
  87600. * @param useInstances Define whether or not the material is used with instances
  87601. * @returns true if ready, otherwise false
  87602. */
  87603. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87604. /**
  87605. * Binds the world matrix to the material
  87606. * @param world defines the world transformation matrix
  87607. */
  87608. bindOnlyWorldMatrix(world: Matrix): void;
  87609. /**
  87610. * Binds the material to the mesh
  87611. * @param world defines the world transformation matrix
  87612. * @param mesh defines the mesh to bind the material to
  87613. */
  87614. bind(world: Matrix, mesh?: Mesh): void;
  87615. /**
  87616. * Gets the active textures from the material
  87617. * @returns an array of textures
  87618. */
  87619. getActiveTextures(): BaseTexture[];
  87620. /**
  87621. * Specifies if the material uses a texture
  87622. * @param texture defines the texture to check against the material
  87623. * @returns a boolean specifying if the material uses the texture
  87624. */
  87625. hasTexture(texture: BaseTexture): boolean;
  87626. /**
  87627. * Makes a duplicate of the material, and gives it a new name
  87628. * @param name defines the new name for the duplicated material
  87629. * @returns the cloned material
  87630. */
  87631. clone(name: string): ShaderMaterial;
  87632. /**
  87633. * Disposes the material
  87634. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87635. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87636. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87637. */
  87638. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87639. /**
  87640. * Serializes this material in a JSON representation
  87641. * @returns the serialized material object
  87642. */
  87643. serialize(): any;
  87644. /**
  87645. * Creates a shader material from parsed shader material data
  87646. * @param source defines the JSON represnetation of the material
  87647. * @param scene defines the hosting scene
  87648. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87649. * @returns a new material
  87650. */
  87651. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87652. }
  87653. }
  87654. declare module BABYLON {
  87655. /** @hidden */
  87656. export var colorPixelShader: {
  87657. name: string;
  87658. shader: string;
  87659. };
  87660. }
  87661. declare module BABYLON {
  87662. /** @hidden */
  87663. export var colorVertexShader: {
  87664. name: string;
  87665. shader: string;
  87666. };
  87667. }
  87668. declare module BABYLON {
  87669. /**
  87670. * Line mesh
  87671. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87672. */
  87673. export class LinesMesh extends Mesh {
  87674. /**
  87675. * If vertex color should be applied to the mesh
  87676. */
  87677. readonly useVertexColor?: boolean | undefined;
  87678. /**
  87679. * If vertex alpha should be applied to the mesh
  87680. */
  87681. readonly useVertexAlpha?: boolean | undefined;
  87682. /**
  87683. * Color of the line (Default: White)
  87684. */
  87685. color: Color3;
  87686. /**
  87687. * Alpha of the line (Default: 1)
  87688. */
  87689. alpha: number;
  87690. /**
  87691. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87692. * This margin is expressed in world space coordinates, so its value may vary.
  87693. * Default value is 0.1
  87694. */
  87695. intersectionThreshold: number;
  87696. private _colorShader;
  87697. private color4;
  87698. /**
  87699. * Creates a new LinesMesh
  87700. * @param name defines the name
  87701. * @param scene defines the hosting scene
  87702. * @param parent defines the parent mesh if any
  87703. * @param source defines the optional source LinesMesh used to clone data from
  87704. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87705. * When false, achieved by calling a clone(), also passing False.
  87706. * This will make creation of children, recursive.
  87707. * @param useVertexColor defines if this LinesMesh supports vertex color
  87708. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87709. */
  87710. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87711. /**
  87712. * If vertex color should be applied to the mesh
  87713. */
  87714. useVertexColor?: boolean | undefined,
  87715. /**
  87716. * If vertex alpha should be applied to the mesh
  87717. */
  87718. useVertexAlpha?: boolean | undefined);
  87719. private _addClipPlaneDefine;
  87720. private _removeClipPlaneDefine;
  87721. isReady(): boolean;
  87722. /**
  87723. * Returns the string "LineMesh"
  87724. */
  87725. getClassName(): string;
  87726. /**
  87727. * @hidden
  87728. */
  87729. /**
  87730. * @hidden
  87731. */
  87732. material: Material;
  87733. /**
  87734. * @hidden
  87735. */
  87736. readonly checkCollisions: boolean;
  87737. /** @hidden */
  87738. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87739. /** @hidden */
  87740. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87741. /**
  87742. * Disposes of the line mesh
  87743. * @param doNotRecurse If children should be disposed
  87744. */
  87745. dispose(doNotRecurse?: boolean): void;
  87746. /**
  87747. * Returns a new LineMesh object cloned from the current one.
  87748. */
  87749. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87750. /**
  87751. * Creates a new InstancedLinesMesh object from the mesh model.
  87752. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87753. * @param name defines the name of the new instance
  87754. * @returns a new InstancedLinesMesh
  87755. */
  87756. createInstance(name: string): InstancedLinesMesh;
  87757. }
  87758. /**
  87759. * Creates an instance based on a source LinesMesh
  87760. */
  87761. export class InstancedLinesMesh extends InstancedMesh {
  87762. /**
  87763. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87764. * This margin is expressed in world space coordinates, so its value may vary.
  87765. * Initilized with the intersectionThreshold value of the source LinesMesh
  87766. */
  87767. intersectionThreshold: number;
  87768. constructor(name: string, source: LinesMesh);
  87769. /**
  87770. * Returns the string "InstancedLinesMesh".
  87771. */
  87772. getClassName(): string;
  87773. }
  87774. }
  87775. declare module BABYLON {
  87776. /** @hidden */
  87777. export var linePixelShader: {
  87778. name: string;
  87779. shader: string;
  87780. };
  87781. }
  87782. declare module BABYLON {
  87783. /** @hidden */
  87784. export var lineVertexShader: {
  87785. name: string;
  87786. shader: string;
  87787. };
  87788. }
  87789. declare module BABYLON {
  87790. interface AbstractMesh {
  87791. /**
  87792. * Gets the edgesRenderer associated with the mesh
  87793. */
  87794. edgesRenderer: Nullable<EdgesRenderer>;
  87795. }
  87796. interface LinesMesh {
  87797. /**
  87798. * Enables the edge rendering mode on the mesh.
  87799. * This mode makes the mesh edges visible
  87800. * @param epsilon defines the maximal distance between two angles to detect a face
  87801. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87802. * @returns the currentAbstractMesh
  87803. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87804. */
  87805. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87806. }
  87807. interface InstancedLinesMesh {
  87808. /**
  87809. * Enables the edge rendering mode on the mesh.
  87810. * This mode makes the mesh edges visible
  87811. * @param epsilon defines the maximal distance between two angles to detect a face
  87812. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87813. * @returns the current InstancedLinesMesh
  87814. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87815. */
  87816. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  87817. }
  87818. /**
  87819. * Defines the minimum contract an Edges renderer should follow.
  87820. */
  87821. export interface IEdgesRenderer extends IDisposable {
  87822. /**
  87823. * Gets or sets a boolean indicating if the edgesRenderer is active
  87824. */
  87825. isEnabled: boolean;
  87826. /**
  87827. * Renders the edges of the attached mesh,
  87828. */
  87829. render(): void;
  87830. /**
  87831. * Checks wether or not the edges renderer is ready to render.
  87832. * @return true if ready, otherwise false.
  87833. */
  87834. isReady(): boolean;
  87835. }
  87836. /**
  87837. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  87838. */
  87839. export class EdgesRenderer implements IEdgesRenderer {
  87840. /**
  87841. * Define the size of the edges with an orthographic camera
  87842. */
  87843. edgesWidthScalerForOrthographic: number;
  87844. /**
  87845. * Define the size of the edges with a perspective camera
  87846. */
  87847. edgesWidthScalerForPerspective: number;
  87848. protected _source: AbstractMesh;
  87849. protected _linesPositions: number[];
  87850. protected _linesNormals: number[];
  87851. protected _linesIndices: number[];
  87852. protected _epsilon: number;
  87853. protected _indicesCount: number;
  87854. protected _lineShader: ShaderMaterial;
  87855. protected _ib: DataBuffer;
  87856. protected _buffers: {
  87857. [key: string]: Nullable<VertexBuffer>;
  87858. };
  87859. protected _checkVerticesInsteadOfIndices: boolean;
  87860. private _meshRebuildObserver;
  87861. private _meshDisposeObserver;
  87862. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  87863. isEnabled: boolean;
  87864. /**
  87865. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  87866. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  87867. * @param source Mesh used to create edges
  87868. * @param epsilon sum of angles in adjacency to check for edge
  87869. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  87870. * @param generateEdgesLines - should generate Lines or only prepare resources.
  87871. */
  87872. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  87873. protected _prepareRessources(): void;
  87874. /** @hidden */
  87875. _rebuild(): void;
  87876. /**
  87877. * Releases the required resources for the edges renderer
  87878. */
  87879. dispose(): void;
  87880. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  87881. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  87882. /**
  87883. * Checks if the pair of p0 and p1 is en edge
  87884. * @param faceIndex
  87885. * @param edge
  87886. * @param faceNormals
  87887. * @param p0
  87888. * @param p1
  87889. * @private
  87890. */
  87891. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  87892. /**
  87893. * push line into the position, normal and index buffer
  87894. * @protected
  87895. */
  87896. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  87897. /**
  87898. * Generates lines edges from adjacencjes
  87899. * @private
  87900. */
  87901. _generateEdgesLines(): void;
  87902. /**
  87903. * Checks wether or not the edges renderer is ready to render.
  87904. * @return true if ready, otherwise false.
  87905. */
  87906. isReady(): boolean;
  87907. /**
  87908. * Renders the edges of the attached mesh,
  87909. */
  87910. render(): void;
  87911. }
  87912. /**
  87913. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  87914. */
  87915. export class LineEdgesRenderer extends EdgesRenderer {
  87916. /**
  87917. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  87918. * @param source LineMesh used to generate edges
  87919. * @param epsilon not important (specified angle for edge detection)
  87920. * @param checkVerticesInsteadOfIndices not important for LineMesh
  87921. */
  87922. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  87923. /**
  87924. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  87925. */
  87926. _generateEdgesLines(): void;
  87927. }
  87928. }
  87929. declare module BABYLON {
  87930. /**
  87931. * This represents the object necessary to create a rendering group.
  87932. * This is exclusively used and created by the rendering manager.
  87933. * To modify the behavior, you use the available helpers in your scene or meshes.
  87934. * @hidden
  87935. */
  87936. export class RenderingGroup {
  87937. index: number;
  87938. private static _zeroVector;
  87939. private _scene;
  87940. private _opaqueSubMeshes;
  87941. private _transparentSubMeshes;
  87942. private _alphaTestSubMeshes;
  87943. private _depthOnlySubMeshes;
  87944. private _particleSystems;
  87945. private _spriteManagers;
  87946. private _opaqueSortCompareFn;
  87947. private _alphaTestSortCompareFn;
  87948. private _transparentSortCompareFn;
  87949. private _renderOpaque;
  87950. private _renderAlphaTest;
  87951. private _renderTransparent;
  87952. /** @hidden */
  87953. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87954. onBeforeTransparentRendering: () => void;
  87955. /**
  87956. * Set the opaque sort comparison function.
  87957. * If null the sub meshes will be render in the order they were created
  87958. */
  87959. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87960. /**
  87961. * Set the alpha test sort comparison function.
  87962. * If null the sub meshes will be render in the order they were created
  87963. */
  87964. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87965. /**
  87966. * Set the transparent sort comparison function.
  87967. * If null the sub meshes will be render in the order they were created
  87968. */
  87969. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87970. /**
  87971. * Creates a new rendering group.
  87972. * @param index The rendering group index
  87973. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87974. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87975. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87976. */
  87977. 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>);
  87978. /**
  87979. * Render all the sub meshes contained in the group.
  87980. * @param customRenderFunction Used to override the default render behaviour of the group.
  87981. * @returns true if rendered some submeshes.
  87982. */
  87983. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87984. /**
  87985. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87986. * @param subMeshes The submeshes to render
  87987. */
  87988. private renderOpaqueSorted;
  87989. /**
  87990. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87991. * @param subMeshes The submeshes to render
  87992. */
  87993. private renderAlphaTestSorted;
  87994. /**
  87995. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87996. * @param subMeshes The submeshes to render
  87997. */
  87998. private renderTransparentSorted;
  87999. /**
  88000. * Renders the submeshes in a specified order.
  88001. * @param subMeshes The submeshes to sort before render
  88002. * @param sortCompareFn The comparison function use to sort
  88003. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  88004. * @param transparent Specifies to activate blending if true
  88005. */
  88006. private static renderSorted;
  88007. /**
  88008. * Renders the submeshes in the order they were dispatched (no sort applied).
  88009. * @param subMeshes The submeshes to render
  88010. */
  88011. private static renderUnsorted;
  88012. /**
  88013. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88014. * are rendered back to front if in the same alpha index.
  88015. *
  88016. * @param a The first submesh
  88017. * @param b The second submesh
  88018. * @returns The result of the comparison
  88019. */
  88020. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  88021. /**
  88022. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88023. * are rendered back to front.
  88024. *
  88025. * @param a The first submesh
  88026. * @param b The second submesh
  88027. * @returns The result of the comparison
  88028. */
  88029. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  88030. /**
  88031. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88032. * are rendered front to back (prevent overdraw).
  88033. *
  88034. * @param a The first submesh
  88035. * @param b The second submesh
  88036. * @returns The result of the comparison
  88037. */
  88038. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88039. /**
  88040. * Resets the different lists of submeshes to prepare a new frame.
  88041. */
  88042. prepare(): void;
  88043. dispose(): void;
  88044. /**
  88045. * Inserts the submesh in its correct queue depending on its material.
  88046. * @param subMesh The submesh to dispatch
  88047. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88048. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88049. */
  88050. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88051. dispatchSprites(spriteManager: ISpriteManager): void;
  88052. dispatchParticles(particleSystem: IParticleSystem): void;
  88053. private _renderParticles;
  88054. private _renderSprites;
  88055. }
  88056. }
  88057. declare module BABYLON {
  88058. /**
  88059. * Interface describing the different options available in the rendering manager
  88060. * regarding Auto Clear between groups.
  88061. */
  88062. export interface IRenderingManagerAutoClearSetup {
  88063. /**
  88064. * Defines whether or not autoclear is enable.
  88065. */
  88066. autoClear: boolean;
  88067. /**
  88068. * Defines whether or not to autoclear the depth buffer.
  88069. */
  88070. depth: boolean;
  88071. /**
  88072. * Defines whether or not to autoclear the stencil buffer.
  88073. */
  88074. stencil: boolean;
  88075. }
  88076. /**
  88077. * This class is used by the onRenderingGroupObservable
  88078. */
  88079. export class RenderingGroupInfo {
  88080. /**
  88081. * The Scene that being rendered
  88082. */
  88083. scene: Scene;
  88084. /**
  88085. * The camera currently used for the rendering pass
  88086. */
  88087. camera: Nullable<Camera>;
  88088. /**
  88089. * The ID of the renderingGroup being processed
  88090. */
  88091. renderingGroupId: number;
  88092. }
  88093. /**
  88094. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88095. * It is enable to manage the different groups as well as the different necessary sort functions.
  88096. * This should not be used directly aside of the few static configurations
  88097. */
  88098. export class RenderingManager {
  88099. /**
  88100. * The max id used for rendering groups (not included)
  88101. */
  88102. static MAX_RENDERINGGROUPS: number;
  88103. /**
  88104. * The min id used for rendering groups (included)
  88105. */
  88106. static MIN_RENDERINGGROUPS: number;
  88107. /**
  88108. * Used to globally prevent autoclearing scenes.
  88109. */
  88110. static AUTOCLEAR: boolean;
  88111. /**
  88112. * @hidden
  88113. */
  88114. _useSceneAutoClearSetup: boolean;
  88115. private _scene;
  88116. private _renderingGroups;
  88117. private _depthStencilBufferAlreadyCleaned;
  88118. private _autoClearDepthStencil;
  88119. private _customOpaqueSortCompareFn;
  88120. private _customAlphaTestSortCompareFn;
  88121. private _customTransparentSortCompareFn;
  88122. private _renderingGroupInfo;
  88123. /**
  88124. * Instantiates a new rendering group for a particular scene
  88125. * @param scene Defines the scene the groups belongs to
  88126. */
  88127. constructor(scene: Scene);
  88128. private _clearDepthStencilBuffer;
  88129. /**
  88130. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88131. * @hidden
  88132. */
  88133. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88134. /**
  88135. * Resets the different information of the group to prepare a new frame
  88136. * @hidden
  88137. */
  88138. reset(): void;
  88139. /**
  88140. * Dispose and release the group and its associated resources.
  88141. * @hidden
  88142. */
  88143. dispose(): void;
  88144. /**
  88145. * Clear the info related to rendering groups preventing retention points during dispose.
  88146. */
  88147. freeRenderingGroups(): void;
  88148. private _prepareRenderingGroup;
  88149. /**
  88150. * Add a sprite manager to the rendering manager in order to render it this frame.
  88151. * @param spriteManager Define the sprite manager to render
  88152. */
  88153. dispatchSprites(spriteManager: ISpriteManager): void;
  88154. /**
  88155. * Add a particle system to the rendering manager in order to render it this frame.
  88156. * @param particleSystem Define the particle system to render
  88157. */
  88158. dispatchParticles(particleSystem: IParticleSystem): void;
  88159. /**
  88160. * Add a submesh to the manager in order to render it this frame
  88161. * @param subMesh The submesh to dispatch
  88162. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88163. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88164. */
  88165. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88166. /**
  88167. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88168. * This allowed control for front to back rendering or reversly depending of the special needs.
  88169. *
  88170. * @param renderingGroupId The rendering group id corresponding to its index
  88171. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88172. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88173. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88174. */
  88175. 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;
  88176. /**
  88177. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88178. *
  88179. * @param renderingGroupId The rendering group id corresponding to its index
  88180. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88181. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88182. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88183. */
  88184. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88185. /**
  88186. * Gets the current auto clear configuration for one rendering group of the rendering
  88187. * manager.
  88188. * @param index the rendering group index to get the information for
  88189. * @returns The auto clear setup for the requested rendering group
  88190. */
  88191. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88192. }
  88193. }
  88194. declare module BABYLON {
  88195. /**
  88196. * This Helps creating a texture that will be created from a camera in your scene.
  88197. * It is basically a dynamic texture that could be used to create special effects for instance.
  88198. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  88199. */
  88200. export class RenderTargetTexture extends Texture {
  88201. isCube: boolean;
  88202. /**
  88203. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  88204. */
  88205. static readonly REFRESHRATE_RENDER_ONCE: number;
  88206. /**
  88207. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  88208. */
  88209. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  88210. /**
  88211. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  88212. * the central point of your effect and can save a lot of performances.
  88213. */
  88214. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  88215. /**
  88216. * Use this predicate to dynamically define the list of mesh you want to render.
  88217. * If set, the renderList property will be overwritten.
  88218. */
  88219. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  88220. private _renderList;
  88221. /**
  88222. * Use this list to define the list of mesh you want to render.
  88223. */
  88224. renderList: Nullable<Array<AbstractMesh>>;
  88225. private _hookArray;
  88226. /**
  88227. * Define if particles should be rendered in your texture.
  88228. */
  88229. renderParticles: boolean;
  88230. /**
  88231. * Define if sprites should be rendered in your texture.
  88232. */
  88233. renderSprites: boolean;
  88234. /**
  88235. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  88236. */
  88237. coordinatesMode: number;
  88238. /**
  88239. * Define the camera used to render the texture.
  88240. */
  88241. activeCamera: Nullable<Camera>;
  88242. /**
  88243. * Override the render function of the texture with your own one.
  88244. */
  88245. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  88246. /**
  88247. * Define if camera post processes should be use while rendering the texture.
  88248. */
  88249. useCameraPostProcesses: boolean;
  88250. /**
  88251. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  88252. */
  88253. ignoreCameraViewport: boolean;
  88254. private _postProcessManager;
  88255. private _postProcesses;
  88256. private _resizeObserver;
  88257. /**
  88258. * An event triggered when the texture is unbind.
  88259. */
  88260. onBeforeBindObservable: Observable<RenderTargetTexture>;
  88261. /**
  88262. * An event triggered when the texture is unbind.
  88263. */
  88264. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88265. private _onAfterUnbindObserver;
  88266. /**
  88267. * Set a after unbind callback in the texture.
  88268. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88269. */
  88270. onAfterUnbind: () => void;
  88271. /**
  88272. * An event triggered before rendering the texture
  88273. */
  88274. onBeforeRenderObservable: Observable<number>;
  88275. private _onBeforeRenderObserver;
  88276. /**
  88277. * Set a before render callback in the texture.
  88278. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88279. */
  88280. onBeforeRender: (faceIndex: number) => void;
  88281. /**
  88282. * An event triggered after rendering the texture
  88283. */
  88284. onAfterRenderObservable: Observable<number>;
  88285. private _onAfterRenderObserver;
  88286. /**
  88287. * Set a after render callback in the texture.
  88288. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  88289. */
  88290. onAfterRender: (faceIndex: number) => void;
  88291. /**
  88292. * An event triggered after the texture clear
  88293. */
  88294. onClearObservable: Observable<Engine>;
  88295. private _onClearObserver;
  88296. /**
  88297. * Set a clear callback in the texture.
  88298. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  88299. */
  88300. onClear: (Engine: Engine) => void;
  88301. /**
  88302. * An event triggered when the texture is resized.
  88303. */
  88304. onResizeObservable: Observable<RenderTargetTexture>;
  88305. /**
  88306. * Define the clear color of the Render Target if it should be different from the scene.
  88307. */
  88308. clearColor: Color4;
  88309. protected _size: number | {
  88310. width: number;
  88311. height: number;
  88312. };
  88313. protected _initialSizeParameter: number | {
  88314. width: number;
  88315. height: number;
  88316. } | {
  88317. ratio: number;
  88318. };
  88319. protected _sizeRatio: Nullable<number>;
  88320. /** @hidden */
  88321. _generateMipMaps: boolean;
  88322. protected _renderingManager: RenderingManager;
  88323. /** @hidden */
  88324. _waitingRenderList: string[];
  88325. protected _doNotChangeAspectRatio: boolean;
  88326. protected _currentRefreshId: number;
  88327. protected _refreshRate: number;
  88328. protected _textureMatrix: Matrix;
  88329. protected _samples: number;
  88330. protected _renderTargetOptions: RenderTargetCreationOptions;
  88331. /**
  88332. * Gets render target creation options that were used.
  88333. */
  88334. readonly renderTargetOptions: RenderTargetCreationOptions;
  88335. protected _engine: Engine;
  88336. protected _onRatioRescale(): void;
  88337. /**
  88338. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  88339. * It must define where the camera used to render the texture is set
  88340. */
  88341. boundingBoxPosition: Vector3;
  88342. private _boundingBoxSize;
  88343. /**
  88344. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  88345. * When defined, the cubemap will switch to local mode
  88346. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88347. * @example https://www.babylonjs-playground.com/#RNASML
  88348. */
  88349. boundingBoxSize: Vector3;
  88350. /**
  88351. * In case the RTT has been created with a depth texture, get the associated
  88352. * depth texture.
  88353. * Otherwise, return null.
  88354. */
  88355. depthStencilTexture: Nullable<InternalTexture>;
  88356. /**
  88357. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  88358. * or used a shadow, depth texture...
  88359. * @param name The friendly name of the texture
  88360. * @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)
  88361. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  88362. * @param generateMipMaps True if mip maps need to be generated after render.
  88363. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  88364. * @param type The type of the buffer in the RTT (int, half float, float...)
  88365. * @param isCube True if a cube texture needs to be created
  88366. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  88367. * @param generateDepthBuffer True to generate a depth buffer
  88368. * @param generateStencilBuffer True to generate a stencil buffer
  88369. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  88370. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  88371. * @param delayAllocation if the texture allocation should be delayed (default: false)
  88372. */
  88373. constructor(name: string, size: number | {
  88374. width: number;
  88375. height: number;
  88376. } | {
  88377. ratio: number;
  88378. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  88379. /**
  88380. * Creates a depth stencil texture.
  88381. * This is only available in WebGL 2 or with the depth texture extension available.
  88382. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  88383. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  88384. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  88385. */
  88386. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  88387. private _processSizeParameter;
  88388. /**
  88389. * Define the number of samples to use in case of MSAA.
  88390. * It defaults to one meaning no MSAA has been enabled.
  88391. */
  88392. samples: number;
  88393. /**
  88394. * Resets the refresh counter of the texture and start bak from scratch.
  88395. * Could be useful to regenerate the texture if it is setup to render only once.
  88396. */
  88397. resetRefreshCounter(): void;
  88398. /**
  88399. * Define the refresh rate of the texture or the rendering frequency.
  88400. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88401. */
  88402. refreshRate: number;
  88403. /**
  88404. * Adds a post process to the render target rendering passes.
  88405. * @param postProcess define the post process to add
  88406. */
  88407. addPostProcess(postProcess: PostProcess): void;
  88408. /**
  88409. * Clear all the post processes attached to the render target
  88410. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88411. */
  88412. clearPostProcesses(dispose?: boolean): void;
  88413. /**
  88414. * Remove one of the post process from the list of attached post processes to the texture
  88415. * @param postProcess define the post process to remove from the list
  88416. */
  88417. removePostProcess(postProcess: PostProcess): void;
  88418. /** @hidden */
  88419. _shouldRender(): boolean;
  88420. /**
  88421. * Gets the actual render size of the texture.
  88422. * @returns the width of the render size
  88423. */
  88424. getRenderSize(): number;
  88425. /**
  88426. * Gets the actual render width of the texture.
  88427. * @returns the width of the render size
  88428. */
  88429. getRenderWidth(): number;
  88430. /**
  88431. * Gets the actual render height of the texture.
  88432. * @returns the height of the render size
  88433. */
  88434. getRenderHeight(): number;
  88435. /**
  88436. * Get if the texture can be rescaled or not.
  88437. */
  88438. readonly canRescale: boolean;
  88439. /**
  88440. * Resize the texture using a ratio.
  88441. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88442. */
  88443. scale(ratio: number): void;
  88444. /**
  88445. * Get the texture reflection matrix used to rotate/transform the reflection.
  88446. * @returns the reflection matrix
  88447. */
  88448. getReflectionTextureMatrix(): Matrix;
  88449. /**
  88450. * Resize the texture to a new desired size.
  88451. * Be carrefull as it will recreate all the data in the new texture.
  88452. * @param size Define the new size. It can be:
  88453. * - a number for squared texture,
  88454. * - an object containing { width: number, height: number }
  88455. * - or an object containing a ratio { ratio: number }
  88456. */
  88457. resize(size: number | {
  88458. width: number;
  88459. height: number;
  88460. } | {
  88461. ratio: number;
  88462. }): void;
  88463. /**
  88464. * Renders all the objects from the render list into the texture.
  88465. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88466. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88467. */
  88468. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88469. private _bestReflectionRenderTargetDimension;
  88470. /**
  88471. * @hidden
  88472. * @param faceIndex face index to bind to if this is a cubetexture
  88473. */
  88474. _bindFrameBuffer(faceIndex?: number): void;
  88475. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88476. private renderToTarget;
  88477. /**
  88478. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88479. * This allowed control for front to back rendering or reversly depending of the special needs.
  88480. *
  88481. * @param renderingGroupId The rendering group id corresponding to its index
  88482. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88483. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88484. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88485. */
  88486. 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;
  88487. /**
  88488. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88489. *
  88490. * @param renderingGroupId The rendering group id corresponding to its index
  88491. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88492. */
  88493. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88494. /**
  88495. * Clones the texture.
  88496. * @returns the cloned texture
  88497. */
  88498. clone(): RenderTargetTexture;
  88499. /**
  88500. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88501. * @returns The JSON representation of the texture
  88502. */
  88503. serialize(): any;
  88504. /**
  88505. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  88506. */
  88507. disposeFramebufferObjects(): void;
  88508. /**
  88509. * Dispose the texture and release its associated resources.
  88510. */
  88511. dispose(): void;
  88512. /** @hidden */
  88513. _rebuild(): void;
  88514. /**
  88515. * Clear the info related to rendering groups preventing retention point in material dispose.
  88516. */
  88517. freeRenderingGroups(): void;
  88518. /**
  88519. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88520. * @returns the view count
  88521. */
  88522. getViewCount(): number;
  88523. }
  88524. }
  88525. declare module BABYLON {
  88526. /**
  88527. * Options for compiling materials.
  88528. */
  88529. export interface IMaterialCompilationOptions {
  88530. /**
  88531. * Defines whether clip planes are enabled.
  88532. */
  88533. clipPlane: boolean;
  88534. /**
  88535. * Defines whether instances are enabled.
  88536. */
  88537. useInstances: boolean;
  88538. }
  88539. /**
  88540. * Base class for the main features of a material in Babylon.js
  88541. */
  88542. export class Material implements IAnimatable {
  88543. /**
  88544. * Returns the triangle fill mode
  88545. */
  88546. static readonly TriangleFillMode: number;
  88547. /**
  88548. * Returns the wireframe mode
  88549. */
  88550. static readonly WireFrameFillMode: number;
  88551. /**
  88552. * Returns the point fill mode
  88553. */
  88554. static readonly PointFillMode: number;
  88555. /**
  88556. * Returns the point list draw mode
  88557. */
  88558. static readonly PointListDrawMode: number;
  88559. /**
  88560. * Returns the line list draw mode
  88561. */
  88562. static readonly LineListDrawMode: number;
  88563. /**
  88564. * Returns the line loop draw mode
  88565. */
  88566. static readonly LineLoopDrawMode: number;
  88567. /**
  88568. * Returns the line strip draw mode
  88569. */
  88570. static readonly LineStripDrawMode: number;
  88571. /**
  88572. * Returns the triangle strip draw mode
  88573. */
  88574. static readonly TriangleStripDrawMode: number;
  88575. /**
  88576. * Returns the triangle fan draw mode
  88577. */
  88578. static readonly TriangleFanDrawMode: number;
  88579. /**
  88580. * Stores the clock-wise side orientation
  88581. */
  88582. static readonly ClockWiseSideOrientation: number;
  88583. /**
  88584. * Stores the counter clock-wise side orientation
  88585. */
  88586. static readonly CounterClockWiseSideOrientation: number;
  88587. /**
  88588. * The dirty texture flag value
  88589. */
  88590. static readonly TextureDirtyFlag: number;
  88591. /**
  88592. * The dirty light flag value
  88593. */
  88594. static readonly LightDirtyFlag: number;
  88595. /**
  88596. * The dirty fresnel flag value
  88597. */
  88598. static readonly FresnelDirtyFlag: number;
  88599. /**
  88600. * The dirty attribute flag value
  88601. */
  88602. static readonly AttributesDirtyFlag: number;
  88603. /**
  88604. * The dirty misc flag value
  88605. */
  88606. static readonly MiscDirtyFlag: number;
  88607. /**
  88608. * The all dirty flag value
  88609. */
  88610. static readonly AllDirtyFlag: number;
  88611. /**
  88612. * The ID of the material
  88613. */
  88614. id: string;
  88615. /**
  88616. * Gets or sets the unique id of the material
  88617. */
  88618. uniqueId: number;
  88619. /**
  88620. * The name of the material
  88621. */
  88622. name: string;
  88623. /**
  88624. * Gets or sets user defined metadata
  88625. */
  88626. metadata: any;
  88627. /**
  88628. * For internal use only. Please do not use.
  88629. */
  88630. reservedDataStore: any;
  88631. /**
  88632. * Specifies if the ready state should be checked on each call
  88633. */
  88634. checkReadyOnEveryCall: boolean;
  88635. /**
  88636. * Specifies if the ready state should be checked once
  88637. */
  88638. checkReadyOnlyOnce: boolean;
  88639. /**
  88640. * The state of the material
  88641. */
  88642. state: string;
  88643. /**
  88644. * The alpha value of the material
  88645. */
  88646. protected _alpha: number;
  88647. /**
  88648. * List of inspectable custom properties (used by the Inspector)
  88649. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88650. */
  88651. inspectableCustomProperties: IInspectable[];
  88652. /**
  88653. * Sets the alpha value of the material
  88654. */
  88655. /**
  88656. * Gets the alpha value of the material
  88657. */
  88658. alpha: number;
  88659. /**
  88660. * Specifies if back face culling is enabled
  88661. */
  88662. protected _backFaceCulling: boolean;
  88663. /**
  88664. * Sets the back-face culling state
  88665. */
  88666. /**
  88667. * Gets the back-face culling state
  88668. */
  88669. backFaceCulling: boolean;
  88670. /**
  88671. * Stores the value for side orientation
  88672. */
  88673. sideOrientation: number;
  88674. /**
  88675. * Callback triggered when the material is compiled
  88676. */
  88677. onCompiled: Nullable<(effect: Effect) => void>;
  88678. /**
  88679. * Callback triggered when an error occurs
  88680. */
  88681. onError: Nullable<(effect: Effect, errors: string) => void>;
  88682. /**
  88683. * Callback triggered to get the render target textures
  88684. */
  88685. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88686. /**
  88687. * Gets a boolean indicating that current material needs to register RTT
  88688. */
  88689. readonly hasRenderTargetTextures: boolean;
  88690. /**
  88691. * Specifies if the material should be serialized
  88692. */
  88693. doNotSerialize: boolean;
  88694. /**
  88695. * @hidden
  88696. */
  88697. _storeEffectOnSubMeshes: boolean;
  88698. /**
  88699. * Stores the animations for the material
  88700. */
  88701. animations: Nullable<Array<Animation>>;
  88702. /**
  88703. * An event triggered when the material is disposed
  88704. */
  88705. onDisposeObservable: Observable<Material>;
  88706. /**
  88707. * An observer which watches for dispose events
  88708. */
  88709. private _onDisposeObserver;
  88710. private _onUnBindObservable;
  88711. /**
  88712. * Called during a dispose event
  88713. */
  88714. onDispose: () => void;
  88715. private _onBindObservable;
  88716. /**
  88717. * An event triggered when the material is bound
  88718. */
  88719. readonly onBindObservable: Observable<AbstractMesh>;
  88720. /**
  88721. * An observer which watches for bind events
  88722. */
  88723. private _onBindObserver;
  88724. /**
  88725. * Called during a bind event
  88726. */
  88727. onBind: (Mesh: AbstractMesh) => void;
  88728. /**
  88729. * An event triggered when the material is unbound
  88730. */
  88731. readonly onUnBindObservable: Observable<Material>;
  88732. /**
  88733. * Stores the value of the alpha mode
  88734. */
  88735. private _alphaMode;
  88736. /**
  88737. * Sets the value of the alpha mode.
  88738. *
  88739. * | Value | Type | Description |
  88740. * | --- | --- | --- |
  88741. * | 0 | ALPHA_DISABLE | |
  88742. * | 1 | ALPHA_ADD | |
  88743. * | 2 | ALPHA_COMBINE | |
  88744. * | 3 | ALPHA_SUBTRACT | |
  88745. * | 4 | ALPHA_MULTIPLY | |
  88746. * | 5 | ALPHA_MAXIMIZED | |
  88747. * | 6 | ALPHA_ONEONE | |
  88748. * | 7 | ALPHA_PREMULTIPLIED | |
  88749. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88750. * | 9 | ALPHA_INTERPOLATE | |
  88751. * | 10 | ALPHA_SCREENMODE | |
  88752. *
  88753. */
  88754. /**
  88755. * Gets the value of the alpha mode
  88756. */
  88757. alphaMode: number;
  88758. /**
  88759. * Stores the state of the need depth pre-pass value
  88760. */
  88761. private _needDepthPrePass;
  88762. /**
  88763. * Sets the need depth pre-pass value
  88764. */
  88765. /**
  88766. * Gets the depth pre-pass value
  88767. */
  88768. needDepthPrePass: boolean;
  88769. /**
  88770. * Specifies if depth writing should be disabled
  88771. */
  88772. disableDepthWrite: boolean;
  88773. /**
  88774. * Specifies if depth writing should be forced
  88775. */
  88776. forceDepthWrite: boolean;
  88777. /**
  88778. * Specifies the depth function that should be used. 0 means the default engine function
  88779. */
  88780. depthFunction: number;
  88781. /**
  88782. * Specifies if there should be a separate pass for culling
  88783. */
  88784. separateCullingPass: boolean;
  88785. /**
  88786. * Stores the state specifing if fog should be enabled
  88787. */
  88788. private _fogEnabled;
  88789. /**
  88790. * Sets the state for enabling fog
  88791. */
  88792. /**
  88793. * Gets the value of the fog enabled state
  88794. */
  88795. fogEnabled: boolean;
  88796. /**
  88797. * Stores the size of points
  88798. */
  88799. pointSize: number;
  88800. /**
  88801. * Stores the z offset value
  88802. */
  88803. zOffset: number;
  88804. /**
  88805. * Gets a value specifying if wireframe mode is enabled
  88806. */
  88807. /**
  88808. * Sets the state of wireframe mode
  88809. */
  88810. wireframe: boolean;
  88811. /**
  88812. * Gets the value specifying if point clouds are enabled
  88813. */
  88814. /**
  88815. * Sets the state of point cloud mode
  88816. */
  88817. pointsCloud: boolean;
  88818. /**
  88819. * Gets the material fill mode
  88820. */
  88821. /**
  88822. * Sets the material fill mode
  88823. */
  88824. fillMode: number;
  88825. /**
  88826. * @hidden
  88827. * Stores the effects for the material
  88828. */
  88829. _effect: Nullable<Effect>;
  88830. /**
  88831. * @hidden
  88832. * Specifies if the material was previously ready
  88833. */
  88834. _wasPreviouslyReady: boolean;
  88835. /**
  88836. * Specifies if uniform buffers should be used
  88837. */
  88838. private _useUBO;
  88839. /**
  88840. * Stores a reference to the scene
  88841. */
  88842. private _scene;
  88843. /**
  88844. * Stores the fill mode state
  88845. */
  88846. private _fillMode;
  88847. /**
  88848. * Specifies if the depth write state should be cached
  88849. */
  88850. private _cachedDepthWriteState;
  88851. /**
  88852. * Specifies if the depth function state should be cached
  88853. */
  88854. private _cachedDepthFunctionState;
  88855. /**
  88856. * Stores the uniform buffer
  88857. */
  88858. protected _uniformBuffer: UniformBuffer;
  88859. /** @hidden */
  88860. _indexInSceneMaterialArray: number;
  88861. /** @hidden */
  88862. meshMap: Nullable<{
  88863. [id: string]: AbstractMesh | undefined;
  88864. }>;
  88865. /**
  88866. * Creates a material instance
  88867. * @param name defines the name of the material
  88868. * @param scene defines the scene to reference
  88869. * @param doNotAdd specifies if the material should be added to the scene
  88870. */
  88871. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  88872. /**
  88873. * Returns a string representation of the current material
  88874. * @param fullDetails defines a boolean indicating which levels of logging is desired
  88875. * @returns a string with material information
  88876. */
  88877. toString(fullDetails?: boolean): string;
  88878. /**
  88879. * Gets the class name of the material
  88880. * @returns a string with the class name of the material
  88881. */
  88882. getClassName(): string;
  88883. /**
  88884. * Specifies if updates for the material been locked
  88885. */
  88886. readonly isFrozen: boolean;
  88887. /**
  88888. * Locks updates for the material
  88889. */
  88890. freeze(): void;
  88891. /**
  88892. * Unlocks updates for the material
  88893. */
  88894. unfreeze(): void;
  88895. /**
  88896. * Specifies if the material is ready to be used
  88897. * @param mesh defines the mesh to check
  88898. * @param useInstances specifies if instances should be used
  88899. * @returns a boolean indicating if the material is ready to be used
  88900. */
  88901. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88902. /**
  88903. * Specifies that the submesh is ready to be used
  88904. * @param mesh defines the mesh to check
  88905. * @param subMesh defines which submesh to check
  88906. * @param useInstances specifies that instances should be used
  88907. * @returns a boolean indicating that the submesh is ready or not
  88908. */
  88909. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88910. /**
  88911. * Returns the material effect
  88912. * @returns the effect associated with the material
  88913. */
  88914. getEffect(): Nullable<Effect>;
  88915. /**
  88916. * Returns the current scene
  88917. * @returns a Scene
  88918. */
  88919. getScene(): Scene;
  88920. /**
  88921. * Specifies if the material will require alpha blending
  88922. * @returns a boolean specifying if alpha blending is needed
  88923. */
  88924. needAlphaBlending(): boolean;
  88925. /**
  88926. * Specifies if the mesh will require alpha blending
  88927. * @param mesh defines the mesh to check
  88928. * @returns a boolean specifying if alpha blending is needed for the mesh
  88929. */
  88930. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  88931. /**
  88932. * Specifies if this material should be rendered in alpha test mode
  88933. * @returns a boolean specifying if an alpha test is needed.
  88934. */
  88935. needAlphaTesting(): boolean;
  88936. /**
  88937. * Gets the texture used for the alpha test
  88938. * @returns the texture to use for alpha testing
  88939. */
  88940. getAlphaTestTexture(): Nullable<BaseTexture>;
  88941. /**
  88942. * Marks the material to indicate that it needs to be re-calculated
  88943. */
  88944. markDirty(): void;
  88945. /** @hidden */
  88946. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  88947. /**
  88948. * Binds the material to the mesh
  88949. * @param world defines the world transformation matrix
  88950. * @param mesh defines the mesh to bind the material to
  88951. */
  88952. bind(world: Matrix, mesh?: Mesh): void;
  88953. /**
  88954. * Binds the submesh to the material
  88955. * @param world defines the world transformation matrix
  88956. * @param mesh defines the mesh containing the submesh
  88957. * @param subMesh defines the submesh to bind the material to
  88958. */
  88959. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88960. /**
  88961. * Binds the world matrix to the material
  88962. * @param world defines the world transformation matrix
  88963. */
  88964. bindOnlyWorldMatrix(world: Matrix): void;
  88965. /**
  88966. * Binds the scene's uniform buffer to the effect.
  88967. * @param effect defines the effect to bind to the scene uniform buffer
  88968. * @param sceneUbo defines the uniform buffer storing scene data
  88969. */
  88970. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88971. /**
  88972. * Binds the view matrix to the effect
  88973. * @param effect defines the effect to bind the view matrix to
  88974. */
  88975. bindView(effect: Effect): void;
  88976. /**
  88977. * Binds the view projection matrix to the effect
  88978. * @param effect defines the effect to bind the view projection matrix to
  88979. */
  88980. bindViewProjection(effect: Effect): void;
  88981. /**
  88982. * Specifies if material alpha testing should be turned on for the mesh
  88983. * @param mesh defines the mesh to check
  88984. */
  88985. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88986. /**
  88987. * Processes to execute after binding the material to a mesh
  88988. * @param mesh defines the rendered mesh
  88989. */
  88990. protected _afterBind(mesh?: Mesh): void;
  88991. /**
  88992. * Unbinds the material from the mesh
  88993. */
  88994. unbind(): void;
  88995. /**
  88996. * Gets the active textures from the material
  88997. * @returns an array of textures
  88998. */
  88999. getActiveTextures(): BaseTexture[];
  89000. /**
  89001. * Specifies if the material uses a texture
  89002. * @param texture defines the texture to check against the material
  89003. * @returns a boolean specifying if the material uses the texture
  89004. */
  89005. hasTexture(texture: BaseTexture): boolean;
  89006. /**
  89007. * Makes a duplicate of the material, and gives it a new name
  89008. * @param name defines the new name for the duplicated material
  89009. * @returns the cloned material
  89010. */
  89011. clone(name: string): Nullable<Material>;
  89012. /**
  89013. * Gets the meshes bound to the material
  89014. * @returns an array of meshes bound to the material
  89015. */
  89016. getBindedMeshes(): AbstractMesh[];
  89017. /**
  89018. * Force shader compilation
  89019. * @param mesh defines the mesh associated with this material
  89020. * @param onCompiled defines a function to execute once the material is compiled
  89021. * @param options defines the options to configure the compilation
  89022. * @param onError defines a function to execute if the material fails compiling
  89023. */
  89024. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  89025. /**
  89026. * Force shader compilation
  89027. * @param mesh defines the mesh that will use this material
  89028. * @param options defines additional options for compiling the shaders
  89029. * @returns a promise that resolves when the compilation completes
  89030. */
  89031. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  89032. private static readonly _AllDirtyCallBack;
  89033. private static readonly _ImageProcessingDirtyCallBack;
  89034. private static readonly _TextureDirtyCallBack;
  89035. private static readonly _FresnelDirtyCallBack;
  89036. private static readonly _MiscDirtyCallBack;
  89037. private static readonly _LightsDirtyCallBack;
  89038. private static readonly _AttributeDirtyCallBack;
  89039. private static _FresnelAndMiscDirtyCallBack;
  89040. private static _TextureAndMiscDirtyCallBack;
  89041. private static readonly _DirtyCallbackArray;
  89042. private static readonly _RunDirtyCallBacks;
  89043. /**
  89044. * Marks a define in the material to indicate that it needs to be re-computed
  89045. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89046. */
  89047. markAsDirty(flag: number): void;
  89048. /**
  89049. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89050. * @param func defines a function which checks material defines against the submeshes
  89051. */
  89052. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89053. /**
  89054. * Indicates that we need to re-calculated for all submeshes
  89055. */
  89056. protected _markAllSubMeshesAsAllDirty(): void;
  89057. /**
  89058. * Indicates that image processing needs to be re-calculated for all submeshes
  89059. */
  89060. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89061. /**
  89062. * Indicates that textures need to be re-calculated for all submeshes
  89063. */
  89064. protected _markAllSubMeshesAsTexturesDirty(): void;
  89065. /**
  89066. * Indicates that fresnel needs to be re-calculated for all submeshes
  89067. */
  89068. protected _markAllSubMeshesAsFresnelDirty(): void;
  89069. /**
  89070. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89071. */
  89072. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89073. /**
  89074. * Indicates that lights need to be re-calculated for all submeshes
  89075. */
  89076. protected _markAllSubMeshesAsLightsDirty(): void;
  89077. /**
  89078. * Indicates that attributes need to be re-calculated for all submeshes
  89079. */
  89080. protected _markAllSubMeshesAsAttributesDirty(): void;
  89081. /**
  89082. * Indicates that misc needs to be re-calculated for all submeshes
  89083. */
  89084. protected _markAllSubMeshesAsMiscDirty(): void;
  89085. /**
  89086. * Indicates that textures and misc need to be re-calculated for all submeshes
  89087. */
  89088. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89089. /**
  89090. * Disposes the material
  89091. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89092. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89093. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89094. */
  89095. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89096. /** @hidden */
  89097. private releaseVertexArrayObject;
  89098. /**
  89099. * Serializes this material
  89100. * @returns the serialized material object
  89101. */
  89102. serialize(): any;
  89103. /**
  89104. * Creates a material from parsed material data
  89105. * @param parsedMaterial defines parsed material data
  89106. * @param scene defines the hosting scene
  89107. * @param rootUrl defines the root URL to use to load textures
  89108. * @returns a new material
  89109. */
  89110. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89111. }
  89112. }
  89113. declare module BABYLON {
  89114. /**
  89115. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89116. * separate meshes. This can be use to improve performances.
  89117. * @see http://doc.babylonjs.com/how_to/multi_materials
  89118. */
  89119. export class MultiMaterial extends Material {
  89120. private _subMaterials;
  89121. /**
  89122. * Gets or Sets the list of Materials used within the multi material.
  89123. * They need to be ordered according to the submeshes order in the associated mesh
  89124. */
  89125. subMaterials: Nullable<Material>[];
  89126. /**
  89127. * Function used to align with Node.getChildren()
  89128. * @returns the list of Materials used within the multi material
  89129. */
  89130. getChildren(): Nullable<Material>[];
  89131. /**
  89132. * Instantiates a new Multi Material
  89133. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89134. * separate meshes. This can be use to improve performances.
  89135. * @see http://doc.babylonjs.com/how_to/multi_materials
  89136. * @param name Define the name in the scene
  89137. * @param scene Define the scene the material belongs to
  89138. */
  89139. constructor(name: string, scene: Scene);
  89140. private _hookArray;
  89141. /**
  89142. * Get one of the submaterial by its index in the submaterials array
  89143. * @param index The index to look the sub material at
  89144. * @returns The Material if the index has been defined
  89145. */
  89146. getSubMaterial(index: number): Nullable<Material>;
  89147. /**
  89148. * Get the list of active textures for the whole sub materials list.
  89149. * @returns All the textures that will be used during the rendering
  89150. */
  89151. getActiveTextures(): BaseTexture[];
  89152. /**
  89153. * Gets the current class name of the material e.g. "MultiMaterial"
  89154. * Mainly use in serialization.
  89155. * @returns the class name
  89156. */
  89157. getClassName(): string;
  89158. /**
  89159. * Checks if the material is ready to render the requested sub mesh
  89160. * @param mesh Define the mesh the submesh belongs to
  89161. * @param subMesh Define the sub mesh to look readyness for
  89162. * @param useInstances Define whether or not the material is used with instances
  89163. * @returns true if ready, otherwise false
  89164. */
  89165. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89166. /**
  89167. * Clones the current material and its related sub materials
  89168. * @param name Define the name of the newly cloned material
  89169. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89170. * @returns the cloned material
  89171. */
  89172. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89173. /**
  89174. * Serializes the materials into a JSON representation.
  89175. * @returns the JSON representation
  89176. */
  89177. serialize(): any;
  89178. /**
  89179. * Dispose the material and release its associated resources
  89180. * @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)
  89181. * @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)
  89182. * @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)
  89183. */
  89184. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  89185. /**
  89186. * Creates a MultiMaterial from parsed MultiMaterial data.
  89187. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  89188. * @param scene defines the hosting scene
  89189. * @returns a new MultiMaterial
  89190. */
  89191. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  89192. }
  89193. }
  89194. declare module BABYLON {
  89195. /**
  89196. * Base class for submeshes
  89197. */
  89198. export class BaseSubMesh {
  89199. /** @hidden */
  89200. _materialDefines: Nullable<MaterialDefines>;
  89201. /** @hidden */
  89202. _materialEffect: Nullable<Effect>;
  89203. /**
  89204. * Gets associated effect
  89205. */
  89206. readonly effect: Nullable<Effect>;
  89207. /**
  89208. * Sets associated effect (effect used to render this submesh)
  89209. * @param effect defines the effect to associate with
  89210. * @param defines defines the set of defines used to compile this effect
  89211. */
  89212. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  89213. }
  89214. /**
  89215. * Defines a subdivision inside a mesh
  89216. */
  89217. export class SubMesh extends BaseSubMesh implements ICullable {
  89218. /** the material index to use */
  89219. materialIndex: number;
  89220. /** vertex index start */
  89221. verticesStart: number;
  89222. /** vertices count */
  89223. verticesCount: number;
  89224. /** index start */
  89225. indexStart: number;
  89226. /** indices count */
  89227. indexCount: number;
  89228. /** @hidden */
  89229. _linesIndexCount: number;
  89230. private _mesh;
  89231. private _renderingMesh;
  89232. private _boundingInfo;
  89233. private _linesIndexBuffer;
  89234. /** @hidden */
  89235. _lastColliderWorldVertices: Nullable<Vector3[]>;
  89236. /** @hidden */
  89237. _trianglePlanes: Plane[];
  89238. /** @hidden */
  89239. _lastColliderTransformMatrix: Nullable<Matrix>;
  89240. /** @hidden */
  89241. _renderId: number;
  89242. /** @hidden */
  89243. _alphaIndex: number;
  89244. /** @hidden */
  89245. _distanceToCamera: number;
  89246. /** @hidden */
  89247. _id: number;
  89248. private _currentMaterial;
  89249. /**
  89250. * Add a new submesh to a mesh
  89251. * @param materialIndex defines the material index to use
  89252. * @param verticesStart defines vertex index start
  89253. * @param verticesCount defines vertices count
  89254. * @param indexStart defines index start
  89255. * @param indexCount defines indices count
  89256. * @param mesh defines the parent mesh
  89257. * @param renderingMesh defines an optional rendering mesh
  89258. * @param createBoundingBox defines if bounding box should be created for this submesh
  89259. * @returns the new submesh
  89260. */
  89261. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  89262. /**
  89263. * Creates a new submesh
  89264. * @param materialIndex defines the material index to use
  89265. * @param verticesStart defines vertex index start
  89266. * @param verticesCount defines vertices count
  89267. * @param indexStart defines index start
  89268. * @param indexCount defines indices count
  89269. * @param mesh defines the parent mesh
  89270. * @param renderingMesh defines an optional rendering mesh
  89271. * @param createBoundingBox defines if bounding box should be created for this submesh
  89272. */
  89273. constructor(
  89274. /** the material index to use */
  89275. materialIndex: number,
  89276. /** vertex index start */
  89277. verticesStart: number,
  89278. /** vertices count */
  89279. verticesCount: number,
  89280. /** index start */
  89281. indexStart: number,
  89282. /** indices count */
  89283. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  89284. /**
  89285. * Returns true if this submesh covers the entire parent mesh
  89286. * @ignorenaming
  89287. */
  89288. readonly IsGlobal: boolean;
  89289. /**
  89290. * Returns the submesh BoudingInfo object
  89291. * @returns current bounding info (or mesh's one if the submesh is global)
  89292. */
  89293. getBoundingInfo(): BoundingInfo;
  89294. /**
  89295. * Sets the submesh BoundingInfo
  89296. * @param boundingInfo defines the new bounding info to use
  89297. * @returns the SubMesh
  89298. */
  89299. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  89300. /**
  89301. * Returns the mesh of the current submesh
  89302. * @return the parent mesh
  89303. */
  89304. getMesh(): AbstractMesh;
  89305. /**
  89306. * Returns the rendering mesh of the submesh
  89307. * @returns the rendering mesh (could be different from parent mesh)
  89308. */
  89309. getRenderingMesh(): Mesh;
  89310. /**
  89311. * Returns the submesh material
  89312. * @returns null or the current material
  89313. */
  89314. getMaterial(): Nullable<Material>;
  89315. /**
  89316. * Sets a new updated BoundingInfo object to the submesh
  89317. * @param data defines an optional position array to use to determine the bounding info
  89318. * @returns the SubMesh
  89319. */
  89320. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  89321. /** @hidden */
  89322. _checkCollision(collider: Collider): boolean;
  89323. /**
  89324. * Updates the submesh BoundingInfo
  89325. * @param world defines the world matrix to use to update the bounding info
  89326. * @returns the submesh
  89327. */
  89328. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  89329. /**
  89330. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89331. * @param frustumPlanes defines the frustum planes
  89332. * @returns true if the submesh is intersecting with the frustum
  89333. */
  89334. isInFrustum(frustumPlanes: Plane[]): boolean;
  89335. /**
  89336. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89337. * @param frustumPlanes defines the frustum planes
  89338. * @returns true if the submesh is inside the frustum
  89339. */
  89340. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89341. /**
  89342. * Renders the submesh
  89343. * @param enableAlphaMode defines if alpha needs to be used
  89344. * @returns the submesh
  89345. */
  89346. render(enableAlphaMode: boolean): SubMesh;
  89347. /**
  89348. * @hidden
  89349. */
  89350. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  89351. /**
  89352. * Checks if the submesh intersects with a ray
  89353. * @param ray defines the ray to test
  89354. * @returns true is the passed ray intersects the submesh bounding box
  89355. */
  89356. canIntersects(ray: Ray): boolean;
  89357. /**
  89358. * Intersects current submesh with a ray
  89359. * @param ray defines the ray to test
  89360. * @param positions defines mesh's positions array
  89361. * @param indices defines mesh's indices array
  89362. * @param fastCheck defines if only bounding info should be used
  89363. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89364. * @returns intersection info or null if no intersection
  89365. */
  89366. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  89367. /** @hidden */
  89368. private _intersectLines;
  89369. /** @hidden */
  89370. private _intersectUnIndexedLines;
  89371. /** @hidden */
  89372. private _intersectTriangles;
  89373. /** @hidden */
  89374. private _intersectUnIndexedTriangles;
  89375. /** @hidden */
  89376. _rebuild(): void;
  89377. /**
  89378. * Creates a new submesh from the passed mesh
  89379. * @param newMesh defines the new hosting mesh
  89380. * @param newRenderingMesh defines an optional rendering mesh
  89381. * @returns the new submesh
  89382. */
  89383. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  89384. /**
  89385. * Release associated resources
  89386. */
  89387. dispose(): void;
  89388. /**
  89389. * Gets the class name
  89390. * @returns the string "SubMesh".
  89391. */
  89392. getClassName(): string;
  89393. /**
  89394. * Creates a new submesh from indices data
  89395. * @param materialIndex the index of the main mesh material
  89396. * @param startIndex the index where to start the copy in the mesh indices array
  89397. * @param indexCount the number of indices to copy then from the startIndex
  89398. * @param mesh the main mesh to create the submesh from
  89399. * @param renderingMesh the optional rendering mesh
  89400. * @returns a new submesh
  89401. */
  89402. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89403. }
  89404. }
  89405. declare module BABYLON {
  89406. /**
  89407. * Class used to represent data loading progression
  89408. */
  89409. export class SceneLoaderFlags {
  89410. private static _ForceFullSceneLoadingForIncremental;
  89411. private static _ShowLoadingScreen;
  89412. private static _CleanBoneMatrixWeights;
  89413. private static _loggingLevel;
  89414. /**
  89415. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89416. */
  89417. static ForceFullSceneLoadingForIncremental: boolean;
  89418. /**
  89419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89420. */
  89421. static ShowLoadingScreen: boolean;
  89422. /**
  89423. * Defines the current logging level (while loading the scene)
  89424. * @ignorenaming
  89425. */
  89426. static loggingLevel: number;
  89427. /**
  89428. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89429. */
  89430. static CleanBoneMatrixWeights: boolean;
  89431. }
  89432. }
  89433. declare module BABYLON {
  89434. /**
  89435. * Class used to store geometry data (vertex buffers + index buffer)
  89436. */
  89437. export class Geometry implements IGetSetVerticesData {
  89438. /**
  89439. * Gets or sets the ID of the geometry
  89440. */
  89441. id: string;
  89442. /**
  89443. * Gets or sets the unique ID of the geometry
  89444. */
  89445. uniqueId: number;
  89446. /**
  89447. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89448. */
  89449. delayLoadState: number;
  89450. /**
  89451. * Gets the file containing the data to load when running in delay load state
  89452. */
  89453. delayLoadingFile: Nullable<string>;
  89454. /**
  89455. * Callback called when the geometry is updated
  89456. */
  89457. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89458. private _scene;
  89459. private _engine;
  89460. private _meshes;
  89461. private _totalVertices;
  89462. /** @hidden */
  89463. _indices: IndicesArray;
  89464. /** @hidden */
  89465. _vertexBuffers: {
  89466. [key: string]: VertexBuffer;
  89467. };
  89468. private _isDisposed;
  89469. private _extend;
  89470. private _boundingBias;
  89471. /** @hidden */
  89472. _delayInfo: Array<string>;
  89473. private _indexBuffer;
  89474. private _indexBufferIsUpdatable;
  89475. /** @hidden */
  89476. _boundingInfo: Nullable<BoundingInfo>;
  89477. /** @hidden */
  89478. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89479. /** @hidden */
  89480. _softwareSkinningFrameId: number;
  89481. private _vertexArrayObjects;
  89482. private _updatable;
  89483. /** @hidden */
  89484. _positions: Nullable<Vector3[]>;
  89485. /**
  89486. * 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
  89487. */
  89488. /**
  89489. * 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
  89490. */
  89491. boundingBias: Vector2;
  89492. /**
  89493. * Static function used to attach a new empty geometry to a mesh
  89494. * @param mesh defines the mesh to attach the geometry to
  89495. * @returns the new Geometry
  89496. */
  89497. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89498. /**
  89499. * Creates a new geometry
  89500. * @param id defines the unique ID
  89501. * @param scene defines the hosting scene
  89502. * @param vertexData defines the VertexData used to get geometry data
  89503. * @param updatable defines if geometry must be updatable (false by default)
  89504. * @param mesh defines the mesh that will be associated with the geometry
  89505. */
  89506. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  89507. /**
  89508. * Gets the current extend of the geometry
  89509. */
  89510. readonly extend: {
  89511. minimum: Vector3;
  89512. maximum: Vector3;
  89513. };
  89514. /**
  89515. * Gets the hosting scene
  89516. * @returns the hosting Scene
  89517. */
  89518. getScene(): Scene;
  89519. /**
  89520. * Gets the hosting engine
  89521. * @returns the hosting Engine
  89522. */
  89523. getEngine(): Engine;
  89524. /**
  89525. * Defines if the geometry is ready to use
  89526. * @returns true if the geometry is ready to be used
  89527. */
  89528. isReady(): boolean;
  89529. /**
  89530. * Gets a value indicating that the geometry should not be serialized
  89531. */
  89532. readonly doNotSerialize: boolean;
  89533. /** @hidden */
  89534. _rebuild(): void;
  89535. /**
  89536. * Affects all geometry data in one call
  89537. * @param vertexData defines the geometry data
  89538. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89539. */
  89540. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89541. /**
  89542. * Set specific vertex data
  89543. * @param kind defines the data kind (Position, normal, etc...)
  89544. * @param data defines the vertex data to use
  89545. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89546. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89547. */
  89548. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89549. /**
  89550. * Removes a specific vertex data
  89551. * @param kind defines the data kind (Position, normal, etc...)
  89552. */
  89553. removeVerticesData(kind: string): void;
  89554. /**
  89555. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89556. * @param buffer defines the vertex buffer to use
  89557. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89558. */
  89559. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89560. /**
  89561. * Update a specific vertex buffer
  89562. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89563. * It will do nothing if the buffer is not updatable
  89564. * @param kind defines the data kind (Position, normal, etc...)
  89565. * @param data defines the data to use
  89566. * @param offset defines the offset in the target buffer where to store the data
  89567. * @param useBytes set to true if the offset is in bytes
  89568. */
  89569. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89570. /**
  89571. * Update a specific vertex buffer
  89572. * This function will create a new buffer if the current one is not updatable
  89573. * @param kind defines the data kind (Position, normal, etc...)
  89574. * @param data defines the data to use
  89575. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89576. */
  89577. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89578. private _updateBoundingInfo;
  89579. /** @hidden */
  89580. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89581. /**
  89582. * Gets total number of vertices
  89583. * @returns the total number of vertices
  89584. */
  89585. getTotalVertices(): number;
  89586. /**
  89587. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89588. * @param kind defines the data kind (Position, normal, etc...)
  89589. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89590. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89591. * @returns a float array containing vertex data
  89592. */
  89593. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89594. /**
  89595. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89596. * @param kind defines the data kind (Position, normal, etc...)
  89597. * @returns true if the vertex buffer with the specified kind is updatable
  89598. */
  89599. isVertexBufferUpdatable(kind: string): boolean;
  89600. /**
  89601. * Gets a specific vertex buffer
  89602. * @param kind defines the data kind (Position, normal, etc...)
  89603. * @returns a VertexBuffer
  89604. */
  89605. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89606. /**
  89607. * Returns all vertex buffers
  89608. * @return an object holding all vertex buffers indexed by kind
  89609. */
  89610. getVertexBuffers(): Nullable<{
  89611. [key: string]: VertexBuffer;
  89612. }>;
  89613. /**
  89614. * Gets a boolean indicating if specific vertex buffer is present
  89615. * @param kind defines the data kind (Position, normal, etc...)
  89616. * @returns true if data is present
  89617. */
  89618. isVerticesDataPresent(kind: string): boolean;
  89619. /**
  89620. * Gets a list of all attached data kinds (Position, normal, etc...)
  89621. * @returns a list of string containing all kinds
  89622. */
  89623. getVerticesDataKinds(): string[];
  89624. /**
  89625. * Update index buffer
  89626. * @param indices defines the indices to store in the index buffer
  89627. * @param offset defines the offset in the target buffer where to store the data
  89628. * @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)
  89629. */
  89630. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89631. /**
  89632. * Creates a new index buffer
  89633. * @param indices defines the indices to store in the index buffer
  89634. * @param totalVertices defines the total number of vertices (could be null)
  89635. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89636. */
  89637. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89638. /**
  89639. * Return the total number of indices
  89640. * @returns the total number of indices
  89641. */
  89642. getTotalIndices(): number;
  89643. /**
  89644. * Gets the index buffer array
  89645. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89646. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89647. * @returns the index buffer array
  89648. */
  89649. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89650. /**
  89651. * Gets the index buffer
  89652. * @return the index buffer
  89653. */
  89654. getIndexBuffer(): Nullable<DataBuffer>;
  89655. /** @hidden */
  89656. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  89657. /**
  89658. * Release the associated resources for a specific mesh
  89659. * @param mesh defines the source mesh
  89660. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  89661. */
  89662. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  89663. /**
  89664. * Apply current geometry to a given mesh
  89665. * @param mesh defines the mesh to apply geometry to
  89666. */
  89667. applyToMesh(mesh: Mesh): void;
  89668. private _updateExtend;
  89669. private _applyToMesh;
  89670. private notifyUpdate;
  89671. /**
  89672. * Load the geometry if it was flagged as delay loaded
  89673. * @param scene defines the hosting scene
  89674. * @param onLoaded defines a callback called when the geometry is loaded
  89675. */
  89676. load(scene: Scene, onLoaded?: () => void): void;
  89677. private _queueLoad;
  89678. /**
  89679. * Invert the geometry to move from a right handed system to a left handed one.
  89680. */
  89681. toLeftHanded(): void;
  89682. /** @hidden */
  89683. _resetPointsArrayCache(): void;
  89684. /** @hidden */
  89685. _generatePointsArray(): boolean;
  89686. /**
  89687. * Gets a value indicating if the geometry is disposed
  89688. * @returns true if the geometry was disposed
  89689. */
  89690. isDisposed(): boolean;
  89691. private _disposeVertexArrayObjects;
  89692. /**
  89693. * Free all associated resources
  89694. */
  89695. dispose(): void;
  89696. /**
  89697. * Clone the current geometry into a new geometry
  89698. * @param id defines the unique ID of the new geometry
  89699. * @returns a new geometry object
  89700. */
  89701. copy(id: string): Geometry;
  89702. /**
  89703. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89704. * @return a JSON representation of the current geometry data (without the vertices data)
  89705. */
  89706. serialize(): any;
  89707. private toNumberArray;
  89708. /**
  89709. * Serialize all vertices data into a JSON oject
  89710. * @returns a JSON representation of the current geometry data
  89711. */
  89712. serializeVerticeData(): any;
  89713. /**
  89714. * Extracts a clone of a mesh geometry
  89715. * @param mesh defines the source mesh
  89716. * @param id defines the unique ID of the new geometry object
  89717. * @returns the new geometry object
  89718. */
  89719. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89720. /**
  89721. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89722. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89723. * Be aware Math.random() could cause collisions, but:
  89724. * "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"
  89725. * @returns a string containing a new GUID
  89726. */
  89727. static RandomId(): string;
  89728. /** @hidden */
  89729. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89730. private static _CleanMatricesWeights;
  89731. /**
  89732. * Create a new geometry from persisted data (Using .babylon file format)
  89733. * @param parsedVertexData defines the persisted data
  89734. * @param scene defines the hosting scene
  89735. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89736. * @returns the new geometry object
  89737. */
  89738. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89739. }
  89740. }
  89741. declare module BABYLON {
  89742. /**
  89743. * Define an interface for all classes that will get and set the data on vertices
  89744. */
  89745. export interface IGetSetVerticesData {
  89746. /**
  89747. * Gets a boolean indicating if specific vertex data is present
  89748. * @param kind defines the vertex data kind to use
  89749. * @returns true is data kind is present
  89750. */
  89751. isVerticesDataPresent(kind: string): boolean;
  89752. /**
  89753. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89754. * @param kind defines the data kind (Position, normal, etc...)
  89755. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89756. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89757. * @returns a float array containing vertex data
  89758. */
  89759. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89760. /**
  89761. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89762. * @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.
  89763. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89764. * @returns the indices array or an empty array if the mesh has no geometry
  89765. */
  89766. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89767. /**
  89768. * Set specific vertex data
  89769. * @param kind defines the data kind (Position, normal, etc...)
  89770. * @param data defines the vertex data to use
  89771. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89772. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89773. */
  89774. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  89775. /**
  89776. * Update a specific associated vertex buffer
  89777. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89778. * - VertexBuffer.PositionKind
  89779. * - VertexBuffer.UVKind
  89780. * - VertexBuffer.UV2Kind
  89781. * - VertexBuffer.UV3Kind
  89782. * - VertexBuffer.UV4Kind
  89783. * - VertexBuffer.UV5Kind
  89784. * - VertexBuffer.UV6Kind
  89785. * - VertexBuffer.ColorKind
  89786. * - VertexBuffer.MatricesIndicesKind
  89787. * - VertexBuffer.MatricesIndicesExtraKind
  89788. * - VertexBuffer.MatricesWeightsKind
  89789. * - VertexBuffer.MatricesWeightsExtraKind
  89790. * @param data defines the data source
  89791. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89792. * @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)
  89793. */
  89794. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  89795. /**
  89796. * Creates a new index buffer
  89797. * @param indices defines the indices to store in the index buffer
  89798. * @param totalVertices defines the total number of vertices (could be null)
  89799. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89800. */
  89801. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  89802. }
  89803. /**
  89804. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89805. */
  89806. export class VertexData {
  89807. /**
  89808. * Mesh side orientation : usually the external or front surface
  89809. */
  89810. static readonly FRONTSIDE: number;
  89811. /**
  89812. * Mesh side orientation : usually the internal or back surface
  89813. */
  89814. static readonly BACKSIDE: number;
  89815. /**
  89816. * Mesh side orientation : both internal and external or front and back surfaces
  89817. */
  89818. static readonly DOUBLESIDE: number;
  89819. /**
  89820. * Mesh side orientation : by default, `FRONTSIDE`
  89821. */
  89822. static readonly DEFAULTSIDE: number;
  89823. /**
  89824. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  89825. */
  89826. positions: Nullable<FloatArray>;
  89827. /**
  89828. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  89829. */
  89830. normals: Nullable<FloatArray>;
  89831. /**
  89832. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  89833. */
  89834. tangents: Nullable<FloatArray>;
  89835. /**
  89836. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89837. */
  89838. uvs: Nullable<FloatArray>;
  89839. /**
  89840. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89841. */
  89842. uvs2: Nullable<FloatArray>;
  89843. /**
  89844. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89845. */
  89846. uvs3: Nullable<FloatArray>;
  89847. /**
  89848. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89849. */
  89850. uvs4: Nullable<FloatArray>;
  89851. /**
  89852. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89853. */
  89854. uvs5: Nullable<FloatArray>;
  89855. /**
  89856. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89857. */
  89858. uvs6: Nullable<FloatArray>;
  89859. /**
  89860. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  89861. */
  89862. colors: Nullable<FloatArray>;
  89863. /**
  89864. * 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).
  89865. */
  89866. matricesIndices: Nullable<FloatArray>;
  89867. /**
  89868. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  89869. */
  89870. matricesWeights: Nullable<FloatArray>;
  89871. /**
  89872. * An array extending the number of possible indices
  89873. */
  89874. matricesIndicesExtra: Nullable<FloatArray>;
  89875. /**
  89876. * An array extending the number of possible weights when the number of indices is extended
  89877. */
  89878. matricesWeightsExtra: Nullable<FloatArray>;
  89879. /**
  89880. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  89881. */
  89882. indices: Nullable<IndicesArray>;
  89883. /**
  89884. * Uses the passed data array to set the set the values for the specified kind of data
  89885. * @param data a linear array of floating numbers
  89886. * @param kind the type of data that is being set, eg positions, colors etc
  89887. */
  89888. set(data: FloatArray, kind: string): void;
  89889. /**
  89890. * Associates the vertexData to the passed Mesh.
  89891. * Sets it as updatable or not (default `false`)
  89892. * @param mesh the mesh the vertexData is applied to
  89893. * @param updatable when used and having the value true allows new data to update the vertexData
  89894. * @returns the VertexData
  89895. */
  89896. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  89897. /**
  89898. * Associates the vertexData to the passed Geometry.
  89899. * Sets it as updatable or not (default `false`)
  89900. * @param geometry the geometry the vertexData is applied to
  89901. * @param updatable when used and having the value true allows new data to update the vertexData
  89902. * @returns VertexData
  89903. */
  89904. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  89905. /**
  89906. * Updates the associated mesh
  89907. * @param mesh the mesh to be updated
  89908. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89909. * @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
  89910. * @returns VertexData
  89911. */
  89912. updateMesh(mesh: Mesh): VertexData;
  89913. /**
  89914. * Updates the associated geometry
  89915. * @param geometry the geometry to be updated
  89916. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89917. * @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
  89918. * @returns VertexData.
  89919. */
  89920. updateGeometry(geometry: Geometry): VertexData;
  89921. private _applyTo;
  89922. private _update;
  89923. /**
  89924. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89925. * @param matrix the transforming matrix
  89926. * @returns the VertexData
  89927. */
  89928. transform(matrix: Matrix): VertexData;
  89929. /**
  89930. * Merges the passed VertexData into the current one
  89931. * @param other the VertexData to be merged into the current one
  89932. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89933. * @returns the modified VertexData
  89934. */
  89935. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  89936. private _mergeElement;
  89937. private _validate;
  89938. /**
  89939. * Serializes the VertexData
  89940. * @returns a serialized object
  89941. */
  89942. serialize(): any;
  89943. /**
  89944. * Extracts the vertexData from a mesh
  89945. * @param mesh the mesh from which to extract the VertexData
  89946. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89947. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89948. * @returns the object VertexData associated to the passed mesh
  89949. */
  89950. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89951. /**
  89952. * Extracts the vertexData from the geometry
  89953. * @param geometry the geometry from which to extract the VertexData
  89954. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89955. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89956. * @returns the object VertexData associated to the passed mesh
  89957. */
  89958. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89959. private static _ExtractFrom;
  89960. /**
  89961. * Creates the VertexData for a Ribbon
  89962. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89963. * * pathArray array of paths, each of which an array of successive Vector3
  89964. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89965. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89966. * * 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
  89967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89968. * * 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)
  89969. * * 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)
  89970. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89971. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89972. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89973. * @returns the VertexData of the ribbon
  89974. */
  89975. static CreateRibbon(options: {
  89976. pathArray: Vector3[][];
  89977. closeArray?: boolean;
  89978. closePath?: boolean;
  89979. offset?: number;
  89980. sideOrientation?: number;
  89981. frontUVs?: Vector4;
  89982. backUVs?: Vector4;
  89983. invertUV?: boolean;
  89984. uvs?: Vector2[];
  89985. colors?: Color4[];
  89986. }): VertexData;
  89987. /**
  89988. * Creates the VertexData for a box
  89989. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89990. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89991. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89992. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89993. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89994. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89995. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89997. * * 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)
  89998. * * 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)
  89999. * @returns the VertexData of the box
  90000. */
  90001. static CreateBox(options: {
  90002. size?: number;
  90003. width?: number;
  90004. height?: number;
  90005. depth?: number;
  90006. faceUV?: Vector4[];
  90007. faceColors?: Color4[];
  90008. sideOrientation?: number;
  90009. frontUVs?: Vector4;
  90010. backUVs?: Vector4;
  90011. }): VertexData;
  90012. /**
  90013. * Creates the VertexData for a tiled box
  90014. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90015. * * faceTiles sets the pattern, tile size and number of tiles for a face
  90016. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90017. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90018. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90019. * @returns the VertexData of the box
  90020. */
  90021. static CreateTiledBox(options: {
  90022. pattern?: number;
  90023. width?: number;
  90024. height?: number;
  90025. depth?: number;
  90026. tileSize?: number;
  90027. tileWidth?: number;
  90028. tileHeight?: number;
  90029. alignHorizontal?: number;
  90030. alignVertical?: number;
  90031. faceUV?: Vector4[];
  90032. faceColors?: Color4[];
  90033. sideOrientation?: number;
  90034. }): VertexData;
  90035. /**
  90036. * Creates the VertexData for a tiled plane
  90037. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90038. * * pattern a limited pattern arrangement depending on the number
  90039. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  90040. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  90041. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  90042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90043. * * 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)
  90044. * * 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)
  90045. * @returns the VertexData of the tiled plane
  90046. */
  90047. static CreateTiledPlane(options: {
  90048. pattern?: number;
  90049. tileSize?: number;
  90050. tileWidth?: number;
  90051. tileHeight?: number;
  90052. size?: number;
  90053. width?: number;
  90054. height?: number;
  90055. alignHorizontal?: number;
  90056. alignVertical?: number;
  90057. sideOrientation?: number;
  90058. frontUVs?: Vector4;
  90059. backUVs?: Vector4;
  90060. }): VertexData;
  90061. /**
  90062. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90063. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90064. * * segments sets the number of horizontal strips optional, default 32
  90065. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90066. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90067. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90068. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90069. * * 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
  90070. * * 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
  90071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90072. * * 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)
  90073. * * 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)
  90074. * @returns the VertexData of the ellipsoid
  90075. */
  90076. static CreateSphere(options: {
  90077. segments?: number;
  90078. diameter?: number;
  90079. diameterX?: number;
  90080. diameterY?: number;
  90081. diameterZ?: number;
  90082. arc?: number;
  90083. slice?: number;
  90084. sideOrientation?: number;
  90085. frontUVs?: Vector4;
  90086. backUVs?: Vector4;
  90087. }): VertexData;
  90088. /**
  90089. * Creates the VertexData for a cylinder, cone or prism
  90090. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90091. * * height sets the height (y direction) of the cylinder, optional, default 2
  90092. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90093. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90094. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90095. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90096. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90097. * * 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
  90098. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90099. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90100. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90101. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90102. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90103. * * 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)
  90104. * * 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)
  90105. * @returns the VertexData of the cylinder, cone or prism
  90106. */
  90107. static CreateCylinder(options: {
  90108. height?: number;
  90109. diameterTop?: number;
  90110. diameterBottom?: number;
  90111. diameter?: number;
  90112. tessellation?: number;
  90113. subdivisions?: number;
  90114. arc?: number;
  90115. faceColors?: Color4[];
  90116. faceUV?: Vector4[];
  90117. hasRings?: boolean;
  90118. enclose?: boolean;
  90119. sideOrientation?: number;
  90120. frontUVs?: Vector4;
  90121. backUVs?: Vector4;
  90122. }): VertexData;
  90123. /**
  90124. * Creates the VertexData for a torus
  90125. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90126. * * diameter the diameter of the torus, optional default 1
  90127. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90128. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90129. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90130. * * 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)
  90131. * * 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)
  90132. * @returns the VertexData of the torus
  90133. */
  90134. static CreateTorus(options: {
  90135. diameter?: number;
  90136. thickness?: number;
  90137. tessellation?: number;
  90138. sideOrientation?: number;
  90139. frontUVs?: Vector4;
  90140. backUVs?: Vector4;
  90141. }): VertexData;
  90142. /**
  90143. * Creates the VertexData of the LineSystem
  90144. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90145. * - lines an array of lines, each line being an array of successive Vector3
  90146. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90147. * @returns the VertexData of the LineSystem
  90148. */
  90149. static CreateLineSystem(options: {
  90150. lines: Vector3[][];
  90151. colors?: Nullable<Color4[][]>;
  90152. }): VertexData;
  90153. /**
  90154. * Create the VertexData for a DashedLines
  90155. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90156. * - points an array successive Vector3
  90157. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90158. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90159. * - dashNb the intended total number of dashes, optional, default 200
  90160. * @returns the VertexData for the DashedLines
  90161. */
  90162. static CreateDashedLines(options: {
  90163. points: Vector3[];
  90164. dashSize?: number;
  90165. gapSize?: number;
  90166. dashNb?: number;
  90167. }): VertexData;
  90168. /**
  90169. * Creates the VertexData for a Ground
  90170. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90171. * - width the width (x direction) of the ground, optional, default 1
  90172. * - height the height (z direction) of the ground, optional, default 1
  90173. * - subdivisions the number of subdivisions per side, optional, default 1
  90174. * @returns the VertexData of the Ground
  90175. */
  90176. static CreateGround(options: {
  90177. width?: number;
  90178. height?: number;
  90179. subdivisions?: number;
  90180. subdivisionsX?: number;
  90181. subdivisionsY?: number;
  90182. }): VertexData;
  90183. /**
  90184. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90185. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90186. * * xmin the ground minimum X coordinate, optional, default -1
  90187. * * zmin the ground minimum Z coordinate, optional, default -1
  90188. * * xmax the ground maximum X coordinate, optional, default 1
  90189. * * zmax the ground maximum Z coordinate, optional, default 1
  90190. * * 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}
  90191. * * 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}
  90192. * @returns the VertexData of the TiledGround
  90193. */
  90194. static CreateTiledGround(options: {
  90195. xmin: number;
  90196. zmin: number;
  90197. xmax: number;
  90198. zmax: number;
  90199. subdivisions?: {
  90200. w: number;
  90201. h: number;
  90202. };
  90203. precision?: {
  90204. w: number;
  90205. h: number;
  90206. };
  90207. }): VertexData;
  90208. /**
  90209. * Creates the VertexData of the Ground designed from a heightmap
  90210. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90211. * * width the width (x direction) of the ground
  90212. * * height the height (z direction) of the ground
  90213. * * subdivisions the number of subdivisions per side
  90214. * * minHeight the minimum altitude on the ground, optional, default 0
  90215. * * maxHeight the maximum altitude on the ground, optional default 1
  90216. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90217. * * buffer the array holding the image color data
  90218. * * bufferWidth the width of image
  90219. * * bufferHeight the height of image
  90220. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90221. * @returns the VertexData of the Ground designed from a heightmap
  90222. */
  90223. static CreateGroundFromHeightMap(options: {
  90224. width: number;
  90225. height: number;
  90226. subdivisions: number;
  90227. minHeight: number;
  90228. maxHeight: number;
  90229. colorFilter: Color3;
  90230. buffer: Uint8Array;
  90231. bufferWidth: number;
  90232. bufferHeight: number;
  90233. alphaFilter: number;
  90234. }): VertexData;
  90235. /**
  90236. * Creates the VertexData for a Plane
  90237. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90238. * * size sets the width and height of the plane to the value of size, optional default 1
  90239. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90240. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90241. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90242. * * 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)
  90243. * * 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)
  90244. * @returns the VertexData of the box
  90245. */
  90246. static CreatePlane(options: {
  90247. size?: number;
  90248. width?: number;
  90249. height?: number;
  90250. sideOrientation?: number;
  90251. frontUVs?: Vector4;
  90252. backUVs?: Vector4;
  90253. }): VertexData;
  90254. /**
  90255. * Creates the VertexData of the Disc or regular Polygon
  90256. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90257. * * radius the radius of the disc, optional default 0.5
  90258. * * tessellation the number of polygon sides, optional, default 64
  90259. * * 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
  90260. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90261. * * 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)
  90262. * * 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)
  90263. * @returns the VertexData of the box
  90264. */
  90265. static CreateDisc(options: {
  90266. radius?: number;
  90267. tessellation?: number;
  90268. arc?: number;
  90269. sideOrientation?: number;
  90270. frontUVs?: Vector4;
  90271. backUVs?: Vector4;
  90272. }): VertexData;
  90273. /**
  90274. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90275. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90276. * @param polygon a mesh built from polygonTriangulation.build()
  90277. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90278. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90279. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90280. * @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)
  90281. * @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)
  90282. * @returns the VertexData of the Polygon
  90283. */
  90284. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  90285. /**
  90286. * Creates the VertexData of the IcoSphere
  90287. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90288. * * radius the radius of the IcoSphere, optional default 1
  90289. * * radiusX allows stretching in the x direction, optional, default radius
  90290. * * radiusY allows stretching in the y direction, optional, default radius
  90291. * * radiusZ allows stretching in the z direction, optional, default radius
  90292. * * flat when true creates a flat shaded mesh, optional, default true
  90293. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90294. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90295. * * 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)
  90296. * * 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)
  90297. * @returns the VertexData of the IcoSphere
  90298. */
  90299. static CreateIcoSphere(options: {
  90300. radius?: number;
  90301. radiusX?: number;
  90302. radiusY?: number;
  90303. radiusZ?: number;
  90304. flat?: boolean;
  90305. subdivisions?: number;
  90306. sideOrientation?: number;
  90307. frontUVs?: Vector4;
  90308. backUVs?: Vector4;
  90309. }): VertexData;
  90310. /**
  90311. * Creates the VertexData for a Polyhedron
  90312. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90313. * * type provided types are:
  90314. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90315. * * 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)
  90316. * * size the size of the IcoSphere, optional default 1
  90317. * * sizeX allows stretching in the x direction, optional, default size
  90318. * * sizeY allows stretching in the y direction, optional, default size
  90319. * * sizeZ allows stretching in the z direction, optional, default size
  90320. * * 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
  90321. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90322. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90323. * * flat when true creates a flat shaded mesh, optional, default true
  90324. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90325. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90326. * * 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)
  90327. * * 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)
  90328. * @returns the VertexData of the Polyhedron
  90329. */
  90330. static CreatePolyhedron(options: {
  90331. type?: number;
  90332. size?: number;
  90333. sizeX?: number;
  90334. sizeY?: number;
  90335. sizeZ?: number;
  90336. custom?: any;
  90337. faceUV?: Vector4[];
  90338. faceColors?: Color4[];
  90339. flat?: boolean;
  90340. sideOrientation?: number;
  90341. frontUVs?: Vector4;
  90342. backUVs?: Vector4;
  90343. }): VertexData;
  90344. /**
  90345. * Creates the VertexData for a TorusKnot
  90346. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90347. * * radius the radius of the torus knot, optional, default 2
  90348. * * tube the thickness of the tube, optional, default 0.5
  90349. * * radialSegments the number of sides on each tube segments, optional, default 32
  90350. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90351. * * p the number of windings around the z axis, optional, default 2
  90352. * * q the number of windings around the x axis, optional, default 3
  90353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90354. * * 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)
  90355. * * 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)
  90356. * @returns the VertexData of the Torus Knot
  90357. */
  90358. static CreateTorusKnot(options: {
  90359. radius?: number;
  90360. tube?: number;
  90361. radialSegments?: number;
  90362. tubularSegments?: number;
  90363. p?: number;
  90364. q?: number;
  90365. sideOrientation?: number;
  90366. frontUVs?: Vector4;
  90367. backUVs?: Vector4;
  90368. }): VertexData;
  90369. /**
  90370. * Compute normals for given positions and indices
  90371. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90372. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90373. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90374. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90375. * * facetNormals : optional array of facet normals (vector3)
  90376. * * facetPositions : optional array of facet positions (vector3)
  90377. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90378. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90379. * * bInfo : optional bounding info, required for facetPartitioning computation
  90380. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90381. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90382. * * useRightHandedSystem: optional boolean to for right handed system computation
  90383. * * depthSort : optional boolean to enable the facet depth sort computation
  90384. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90385. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90386. */
  90387. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  90388. facetNormals?: any;
  90389. facetPositions?: any;
  90390. facetPartitioning?: any;
  90391. ratio?: number;
  90392. bInfo?: any;
  90393. bbSize?: Vector3;
  90394. subDiv?: any;
  90395. useRightHandedSystem?: boolean;
  90396. depthSort?: boolean;
  90397. distanceTo?: Vector3;
  90398. depthSortedFacets?: any;
  90399. }): void;
  90400. /** @hidden */
  90401. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90402. /**
  90403. * Applies VertexData created from the imported parameters to the geometry
  90404. * @param parsedVertexData the parsed data from an imported file
  90405. * @param geometry the geometry to apply the VertexData to
  90406. */
  90407. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90408. }
  90409. }
  90410. declare module BABYLON {
  90411. /**
  90412. * Defines a target to use with MorphTargetManager
  90413. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90414. */
  90415. export class MorphTarget implements IAnimatable {
  90416. /** defines the name of the target */
  90417. name: string;
  90418. /**
  90419. * Gets or sets the list of animations
  90420. */
  90421. animations: Animation[];
  90422. private _scene;
  90423. private _positions;
  90424. private _normals;
  90425. private _tangents;
  90426. private _uvs;
  90427. private _influence;
  90428. private _uniqueId;
  90429. /**
  90430. * Observable raised when the influence changes
  90431. */
  90432. onInfluenceChanged: Observable<boolean>;
  90433. /** @hidden */
  90434. _onDataLayoutChanged: Observable<void>;
  90435. /**
  90436. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90437. */
  90438. influence: number;
  90439. /**
  90440. * Gets or sets the id of the morph Target
  90441. */
  90442. id: string;
  90443. private _animationPropertiesOverride;
  90444. /**
  90445. * Gets or sets the animation properties override
  90446. */
  90447. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90448. /**
  90449. * Creates a new MorphTarget
  90450. * @param name defines the name of the target
  90451. * @param influence defines the influence to use
  90452. * @param scene defines the scene the morphtarget belongs to
  90453. */
  90454. constructor(
  90455. /** defines the name of the target */
  90456. name: string, influence?: number, scene?: Nullable<Scene>);
  90457. /**
  90458. * Gets the unique ID of this manager
  90459. */
  90460. readonly uniqueId: number;
  90461. /**
  90462. * Gets a boolean defining if the target contains position data
  90463. */
  90464. readonly hasPositions: boolean;
  90465. /**
  90466. * Gets a boolean defining if the target contains normal data
  90467. */
  90468. readonly hasNormals: boolean;
  90469. /**
  90470. * Gets a boolean defining if the target contains tangent data
  90471. */
  90472. readonly hasTangents: boolean;
  90473. /**
  90474. * Gets a boolean defining if the target contains texture coordinates data
  90475. */
  90476. readonly hasUVs: boolean;
  90477. /**
  90478. * Affects position data to this target
  90479. * @param data defines the position data to use
  90480. */
  90481. setPositions(data: Nullable<FloatArray>): void;
  90482. /**
  90483. * Gets the position data stored in this target
  90484. * @returns a FloatArray containing the position data (or null if not present)
  90485. */
  90486. getPositions(): Nullable<FloatArray>;
  90487. /**
  90488. * Affects normal data to this target
  90489. * @param data defines the normal data to use
  90490. */
  90491. setNormals(data: Nullable<FloatArray>): void;
  90492. /**
  90493. * Gets the normal data stored in this target
  90494. * @returns a FloatArray containing the normal data (or null if not present)
  90495. */
  90496. getNormals(): Nullable<FloatArray>;
  90497. /**
  90498. * Affects tangent data to this target
  90499. * @param data defines the tangent data to use
  90500. */
  90501. setTangents(data: Nullable<FloatArray>): void;
  90502. /**
  90503. * Gets the tangent data stored in this target
  90504. * @returns a FloatArray containing the tangent data (or null if not present)
  90505. */
  90506. getTangents(): Nullable<FloatArray>;
  90507. /**
  90508. * Affects texture coordinates data to this target
  90509. * @param data defines the texture coordinates data to use
  90510. */
  90511. setUVs(data: Nullable<FloatArray>): void;
  90512. /**
  90513. * Gets the texture coordinates data stored in this target
  90514. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  90515. */
  90516. getUVs(): Nullable<FloatArray>;
  90517. /**
  90518. * Clone the current target
  90519. * @returns a new MorphTarget
  90520. */
  90521. clone(): MorphTarget;
  90522. /**
  90523. * Serializes the current target into a Serialization object
  90524. * @returns the serialized object
  90525. */
  90526. serialize(): any;
  90527. /**
  90528. * Returns the string "MorphTarget"
  90529. * @returns "MorphTarget"
  90530. */
  90531. getClassName(): string;
  90532. /**
  90533. * Creates a new target from serialized data
  90534. * @param serializationObject defines the serialized data to use
  90535. * @returns a new MorphTarget
  90536. */
  90537. static Parse(serializationObject: any): MorphTarget;
  90538. /**
  90539. * Creates a MorphTarget from mesh data
  90540. * @param mesh defines the source mesh
  90541. * @param name defines the name to use for the new target
  90542. * @param influence defines the influence to attach to the target
  90543. * @returns a new MorphTarget
  90544. */
  90545. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90546. }
  90547. }
  90548. declare module BABYLON {
  90549. /**
  90550. * This class is used to deform meshes using morphing between different targets
  90551. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90552. */
  90553. export class MorphTargetManager {
  90554. private _targets;
  90555. private _targetInfluenceChangedObservers;
  90556. private _targetDataLayoutChangedObservers;
  90557. private _activeTargets;
  90558. private _scene;
  90559. private _influences;
  90560. private _supportsNormals;
  90561. private _supportsTangents;
  90562. private _supportsUVs;
  90563. private _vertexCount;
  90564. private _uniqueId;
  90565. private _tempInfluences;
  90566. /**
  90567. * Gets or sets a boolean indicating if normals must be morphed
  90568. */
  90569. enableNormalMorphing: boolean;
  90570. /**
  90571. * Gets or sets a boolean indicating if tangents must be morphed
  90572. */
  90573. enableTangentMorphing: boolean;
  90574. /**
  90575. * Gets or sets a boolean indicating if UV must be morphed
  90576. */
  90577. enableUVMorphing: boolean;
  90578. /**
  90579. * Creates a new MorphTargetManager
  90580. * @param scene defines the current scene
  90581. */
  90582. constructor(scene?: Nullable<Scene>);
  90583. /**
  90584. * Gets the unique ID of this manager
  90585. */
  90586. readonly uniqueId: number;
  90587. /**
  90588. * Gets the number of vertices handled by this manager
  90589. */
  90590. readonly vertexCount: number;
  90591. /**
  90592. * Gets a boolean indicating if this manager supports morphing of normals
  90593. */
  90594. readonly supportsNormals: boolean;
  90595. /**
  90596. * Gets a boolean indicating if this manager supports morphing of tangents
  90597. */
  90598. readonly supportsTangents: boolean;
  90599. /**
  90600. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90601. */
  90602. readonly supportsUVs: boolean;
  90603. /**
  90604. * Gets the number of targets stored in this manager
  90605. */
  90606. readonly numTargets: number;
  90607. /**
  90608. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90609. */
  90610. readonly numInfluencers: number;
  90611. /**
  90612. * Gets the list of influences (one per target)
  90613. */
  90614. readonly influences: Float32Array;
  90615. /**
  90616. * Gets the active target at specified index. An active target is a target with an influence > 0
  90617. * @param index defines the index to check
  90618. * @returns the requested target
  90619. */
  90620. getActiveTarget(index: number): MorphTarget;
  90621. /**
  90622. * Gets the target at specified index
  90623. * @param index defines the index to check
  90624. * @returns the requested target
  90625. */
  90626. getTarget(index: number): MorphTarget;
  90627. /**
  90628. * Add a new target to this manager
  90629. * @param target defines the target to add
  90630. */
  90631. addTarget(target: MorphTarget): void;
  90632. /**
  90633. * Removes a target from the manager
  90634. * @param target defines the target to remove
  90635. */
  90636. removeTarget(target: MorphTarget): void;
  90637. /**
  90638. * Clone the current manager
  90639. * @returns a new MorphTargetManager
  90640. */
  90641. clone(): MorphTargetManager;
  90642. /**
  90643. * Serializes the current manager into a Serialization object
  90644. * @returns the serialized object
  90645. */
  90646. serialize(): any;
  90647. private _syncActiveTargets;
  90648. /**
  90649. * Syncrhonize the targets with all the meshes using this morph target manager
  90650. */
  90651. synchronize(): void;
  90652. /**
  90653. * Creates a new MorphTargetManager from serialized data
  90654. * @param serializationObject defines the serialized data
  90655. * @param scene defines the hosting scene
  90656. * @returns the new MorphTargetManager
  90657. */
  90658. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  90659. }
  90660. }
  90661. declare module BABYLON {
  90662. /**
  90663. * Class used to represent a specific level of detail of a mesh
  90664. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90665. */
  90666. export class MeshLODLevel {
  90667. /** Defines the distance where this level should start being displayed */
  90668. distance: number;
  90669. /** Defines the mesh to use to render this level */
  90670. mesh: Nullable<Mesh>;
  90671. /**
  90672. * Creates a new LOD level
  90673. * @param distance defines the distance where this level should star being displayed
  90674. * @param mesh defines the mesh to use to render this level
  90675. */
  90676. constructor(
  90677. /** Defines the distance where this level should start being displayed */
  90678. distance: number,
  90679. /** Defines the mesh to use to render this level */
  90680. mesh: Nullable<Mesh>);
  90681. }
  90682. }
  90683. declare module BABYLON {
  90684. /**
  90685. * Mesh representing the gorund
  90686. */
  90687. export class GroundMesh extends Mesh {
  90688. /** If octree should be generated */
  90689. generateOctree: boolean;
  90690. private _heightQuads;
  90691. /** @hidden */
  90692. _subdivisionsX: number;
  90693. /** @hidden */
  90694. _subdivisionsY: number;
  90695. /** @hidden */
  90696. _width: number;
  90697. /** @hidden */
  90698. _height: number;
  90699. /** @hidden */
  90700. _minX: number;
  90701. /** @hidden */
  90702. _maxX: number;
  90703. /** @hidden */
  90704. _minZ: number;
  90705. /** @hidden */
  90706. _maxZ: number;
  90707. constructor(name: string, scene: Scene);
  90708. /**
  90709. * "GroundMesh"
  90710. * @returns "GroundMesh"
  90711. */
  90712. getClassName(): string;
  90713. /**
  90714. * The minimum of x and y subdivisions
  90715. */
  90716. readonly subdivisions: number;
  90717. /**
  90718. * X subdivisions
  90719. */
  90720. readonly subdivisionsX: number;
  90721. /**
  90722. * Y subdivisions
  90723. */
  90724. readonly subdivisionsY: number;
  90725. /**
  90726. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90727. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90728. * @param chunksCount the number of subdivisions for x and y
  90729. * @param octreeBlocksSize (Default: 32)
  90730. */
  90731. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90732. /**
  90733. * Returns a height (y) value in the Worl system :
  90734. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90735. * @param x x coordinate
  90736. * @param z z coordinate
  90737. * @returns the ground y position if (x, z) are outside the ground surface.
  90738. */
  90739. getHeightAtCoordinates(x: number, z: number): number;
  90740. /**
  90741. * Returns a normalized vector (Vector3) orthogonal to the ground
  90742. * at the ground coordinates (x, z) expressed in the World system.
  90743. * @param x x coordinate
  90744. * @param z z coordinate
  90745. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90746. */
  90747. getNormalAtCoordinates(x: number, z: number): Vector3;
  90748. /**
  90749. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90750. * at the ground coordinates (x, z) expressed in the World system.
  90751. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90752. * @param x x coordinate
  90753. * @param z z coordinate
  90754. * @param ref vector to store the result
  90755. * @returns the GroundMesh.
  90756. */
  90757. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90758. /**
  90759. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90760. * if the ground has been updated.
  90761. * This can be used in the render loop.
  90762. * @returns the GroundMesh.
  90763. */
  90764. updateCoordinateHeights(): GroundMesh;
  90765. private _getFacetAt;
  90766. private _initHeightQuads;
  90767. private _computeHeightQuads;
  90768. /**
  90769. * Serializes this ground mesh
  90770. * @param serializationObject object to write serialization to
  90771. */
  90772. serialize(serializationObject: any): void;
  90773. /**
  90774. * Parses a serialized ground mesh
  90775. * @param parsedMesh the serialized mesh
  90776. * @param scene the scene to create the ground mesh in
  90777. * @returns the created ground mesh
  90778. */
  90779. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  90780. }
  90781. }
  90782. declare module BABYLON {
  90783. /**
  90784. * Interface for Physics-Joint data
  90785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90786. */
  90787. export interface PhysicsJointData {
  90788. /**
  90789. * The main pivot of the joint
  90790. */
  90791. mainPivot?: Vector3;
  90792. /**
  90793. * The connected pivot of the joint
  90794. */
  90795. connectedPivot?: Vector3;
  90796. /**
  90797. * The main axis of the joint
  90798. */
  90799. mainAxis?: Vector3;
  90800. /**
  90801. * The connected axis of the joint
  90802. */
  90803. connectedAxis?: Vector3;
  90804. /**
  90805. * The collision of the joint
  90806. */
  90807. collision?: boolean;
  90808. /**
  90809. * Native Oimo/Cannon/Energy data
  90810. */
  90811. nativeParams?: any;
  90812. }
  90813. /**
  90814. * This is a holder class for the physics joint created by the physics plugin
  90815. * It holds a set of functions to control the underlying joint
  90816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90817. */
  90818. export class PhysicsJoint {
  90819. /**
  90820. * The type of the physics joint
  90821. */
  90822. type: number;
  90823. /**
  90824. * The data for the physics joint
  90825. */
  90826. jointData: PhysicsJointData;
  90827. private _physicsJoint;
  90828. protected _physicsPlugin: IPhysicsEnginePlugin;
  90829. /**
  90830. * Initializes the physics joint
  90831. * @param type The type of the physics joint
  90832. * @param jointData The data for the physics joint
  90833. */
  90834. constructor(
  90835. /**
  90836. * The type of the physics joint
  90837. */
  90838. type: number,
  90839. /**
  90840. * The data for the physics joint
  90841. */
  90842. jointData: PhysicsJointData);
  90843. /**
  90844. * Gets the physics joint
  90845. */
  90846. /**
  90847. * Sets the physics joint
  90848. */
  90849. physicsJoint: any;
  90850. /**
  90851. * Sets the physics plugin
  90852. */
  90853. physicsPlugin: IPhysicsEnginePlugin;
  90854. /**
  90855. * Execute a function that is physics-plugin specific.
  90856. * @param {Function} func the function that will be executed.
  90857. * It accepts two parameters: the physics world and the physics joint
  90858. */
  90859. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  90860. /**
  90861. * Distance-Joint type
  90862. */
  90863. static DistanceJoint: number;
  90864. /**
  90865. * Hinge-Joint type
  90866. */
  90867. static HingeJoint: number;
  90868. /**
  90869. * Ball-and-Socket joint type
  90870. */
  90871. static BallAndSocketJoint: number;
  90872. /**
  90873. * Wheel-Joint type
  90874. */
  90875. static WheelJoint: number;
  90876. /**
  90877. * Slider-Joint type
  90878. */
  90879. static SliderJoint: number;
  90880. /**
  90881. * Prismatic-Joint type
  90882. */
  90883. static PrismaticJoint: number;
  90884. /**
  90885. * Universal-Joint type
  90886. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  90887. */
  90888. static UniversalJoint: number;
  90889. /**
  90890. * Hinge-Joint 2 type
  90891. */
  90892. static Hinge2Joint: number;
  90893. /**
  90894. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  90895. */
  90896. static PointToPointJoint: number;
  90897. /**
  90898. * Spring-Joint type
  90899. */
  90900. static SpringJoint: number;
  90901. /**
  90902. * Lock-Joint type
  90903. */
  90904. static LockJoint: number;
  90905. }
  90906. /**
  90907. * A class representing a physics distance joint
  90908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90909. */
  90910. export class DistanceJoint extends PhysicsJoint {
  90911. /**
  90912. *
  90913. * @param jointData The data for the Distance-Joint
  90914. */
  90915. constructor(jointData: DistanceJointData);
  90916. /**
  90917. * Update the predefined distance.
  90918. * @param maxDistance The maximum preferred distance
  90919. * @param minDistance The minimum preferred distance
  90920. */
  90921. updateDistance(maxDistance: number, minDistance?: number): void;
  90922. }
  90923. /**
  90924. * Represents a Motor-Enabled Joint
  90925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90926. */
  90927. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  90928. /**
  90929. * Initializes the Motor-Enabled Joint
  90930. * @param type The type of the joint
  90931. * @param jointData The physica joint data for the joint
  90932. */
  90933. constructor(type: number, jointData: PhysicsJointData);
  90934. /**
  90935. * Set the motor values.
  90936. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90937. * @param force the force to apply
  90938. * @param maxForce max force for this motor.
  90939. */
  90940. setMotor(force?: number, maxForce?: number): void;
  90941. /**
  90942. * Set the motor's limits.
  90943. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90944. * @param upperLimit The upper limit of the motor
  90945. * @param lowerLimit The lower limit of the motor
  90946. */
  90947. setLimit(upperLimit: number, lowerLimit?: number): void;
  90948. }
  90949. /**
  90950. * This class represents a single physics Hinge-Joint
  90951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90952. */
  90953. export class HingeJoint extends MotorEnabledJoint {
  90954. /**
  90955. * Initializes the Hinge-Joint
  90956. * @param jointData The joint data for the Hinge-Joint
  90957. */
  90958. constructor(jointData: PhysicsJointData);
  90959. /**
  90960. * Set the motor values.
  90961. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90962. * @param {number} force the force to apply
  90963. * @param {number} maxForce max force for this motor.
  90964. */
  90965. setMotor(force?: number, maxForce?: number): void;
  90966. /**
  90967. * Set the motor's limits.
  90968. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90969. * @param upperLimit The upper limit of the motor
  90970. * @param lowerLimit The lower limit of the motor
  90971. */
  90972. setLimit(upperLimit: number, lowerLimit?: number): void;
  90973. }
  90974. /**
  90975. * This class represents a dual hinge physics joint (same as wheel joint)
  90976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90977. */
  90978. export class Hinge2Joint extends MotorEnabledJoint {
  90979. /**
  90980. * Initializes the Hinge2-Joint
  90981. * @param jointData The joint data for the Hinge2-Joint
  90982. */
  90983. constructor(jointData: PhysicsJointData);
  90984. /**
  90985. * Set the motor values.
  90986. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90987. * @param {number} targetSpeed the speed the motor is to reach
  90988. * @param {number} maxForce max force for this motor.
  90989. * @param {motorIndex} the motor's index, 0 or 1.
  90990. */
  90991. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90992. /**
  90993. * Set the motor limits.
  90994. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90995. * @param {number} upperLimit the upper limit
  90996. * @param {number} lowerLimit lower limit
  90997. * @param {motorIndex} the motor's index, 0 or 1.
  90998. */
  90999. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91000. }
  91001. /**
  91002. * Interface for a motor enabled joint
  91003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91004. */
  91005. export interface IMotorEnabledJoint {
  91006. /**
  91007. * Physics joint
  91008. */
  91009. physicsJoint: any;
  91010. /**
  91011. * Sets the motor of the motor-enabled joint
  91012. * @param force The force of the motor
  91013. * @param maxForce The maximum force of the motor
  91014. * @param motorIndex The index of the motor
  91015. */
  91016. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  91017. /**
  91018. * Sets the limit of the motor
  91019. * @param upperLimit The upper limit of the motor
  91020. * @param lowerLimit The lower limit of the motor
  91021. * @param motorIndex The index of the motor
  91022. */
  91023. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91024. }
  91025. /**
  91026. * Joint data for a Distance-Joint
  91027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91028. */
  91029. export interface DistanceJointData extends PhysicsJointData {
  91030. /**
  91031. * Max distance the 2 joint objects can be apart
  91032. */
  91033. maxDistance: number;
  91034. }
  91035. /**
  91036. * Joint data from a spring joint
  91037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91038. */
  91039. export interface SpringJointData extends PhysicsJointData {
  91040. /**
  91041. * Length of the spring
  91042. */
  91043. length: number;
  91044. /**
  91045. * Stiffness of the spring
  91046. */
  91047. stiffness: number;
  91048. /**
  91049. * Damping of the spring
  91050. */
  91051. damping: number;
  91052. /** this callback will be called when applying the force to the impostors. */
  91053. forceApplicationCallback: () => void;
  91054. }
  91055. }
  91056. declare module BABYLON {
  91057. /**
  91058. * Holds the data for the raycast result
  91059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91060. */
  91061. export class PhysicsRaycastResult {
  91062. private _hasHit;
  91063. private _hitDistance;
  91064. private _hitNormalWorld;
  91065. private _hitPointWorld;
  91066. private _rayFromWorld;
  91067. private _rayToWorld;
  91068. /**
  91069. * Gets if there was a hit
  91070. */
  91071. readonly hasHit: boolean;
  91072. /**
  91073. * Gets the distance from the hit
  91074. */
  91075. readonly hitDistance: number;
  91076. /**
  91077. * Gets the hit normal/direction in the world
  91078. */
  91079. readonly hitNormalWorld: Vector3;
  91080. /**
  91081. * Gets the hit point in the world
  91082. */
  91083. readonly hitPointWorld: Vector3;
  91084. /**
  91085. * Gets the ray "start point" of the ray in the world
  91086. */
  91087. readonly rayFromWorld: Vector3;
  91088. /**
  91089. * Gets the ray "end point" of the ray in the world
  91090. */
  91091. readonly rayToWorld: Vector3;
  91092. /**
  91093. * Sets the hit data (normal & point in world space)
  91094. * @param hitNormalWorld defines the normal in world space
  91095. * @param hitPointWorld defines the point in world space
  91096. */
  91097. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91098. /**
  91099. * Sets the distance from the start point to the hit point
  91100. * @param distance
  91101. */
  91102. setHitDistance(distance: number): void;
  91103. /**
  91104. * Calculates the distance manually
  91105. */
  91106. calculateHitDistance(): void;
  91107. /**
  91108. * Resets all the values to default
  91109. * @param from The from point on world space
  91110. * @param to The to point on world space
  91111. */
  91112. reset(from?: Vector3, to?: Vector3): void;
  91113. }
  91114. /**
  91115. * Interface for the size containing width and height
  91116. */
  91117. interface IXYZ {
  91118. /**
  91119. * X
  91120. */
  91121. x: number;
  91122. /**
  91123. * Y
  91124. */
  91125. y: number;
  91126. /**
  91127. * Z
  91128. */
  91129. z: number;
  91130. }
  91131. }
  91132. declare module BABYLON {
  91133. /**
  91134. * Interface used to describe a physics joint
  91135. */
  91136. export interface PhysicsImpostorJoint {
  91137. /** Defines the main impostor to which the joint is linked */
  91138. mainImpostor: PhysicsImpostor;
  91139. /** Defines the impostor that is connected to the main impostor using this joint */
  91140. connectedImpostor: PhysicsImpostor;
  91141. /** Defines the joint itself */
  91142. joint: PhysicsJoint;
  91143. }
  91144. /** @hidden */
  91145. export interface IPhysicsEnginePlugin {
  91146. world: any;
  91147. name: string;
  91148. setGravity(gravity: Vector3): void;
  91149. setTimeStep(timeStep: number): void;
  91150. getTimeStep(): number;
  91151. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91152. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91153. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91154. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91155. removePhysicsBody(impostor: PhysicsImpostor): void;
  91156. generateJoint(joint: PhysicsImpostorJoint): void;
  91157. removeJoint(joint: PhysicsImpostorJoint): void;
  91158. isSupported(): boolean;
  91159. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91160. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91161. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91162. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91163. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91164. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91165. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91166. getBodyMass(impostor: PhysicsImpostor): number;
  91167. getBodyFriction(impostor: PhysicsImpostor): number;
  91168. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91169. getBodyRestitution(impostor: PhysicsImpostor): number;
  91170. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  91171. getBodyPressure?(impostor: PhysicsImpostor): number;
  91172. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  91173. getBodyStiffness?(impostor: PhysicsImpostor): number;
  91174. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  91175. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  91176. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  91177. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  91178. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  91179. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91180. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91181. sleepBody(impostor: PhysicsImpostor): void;
  91182. wakeUpBody(impostor: PhysicsImpostor): void;
  91183. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91184. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  91185. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  91186. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91187. getRadius(impostor: PhysicsImpostor): number;
  91188. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  91189. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  91190. dispose(): void;
  91191. }
  91192. /**
  91193. * Interface used to define a physics engine
  91194. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  91195. */
  91196. export interface IPhysicsEngine {
  91197. /**
  91198. * Gets the gravity vector used by the simulation
  91199. */
  91200. gravity: Vector3;
  91201. /**
  91202. * Sets the gravity vector used by the simulation
  91203. * @param gravity defines the gravity vector to use
  91204. */
  91205. setGravity(gravity: Vector3): void;
  91206. /**
  91207. * Set the time step of the physics engine.
  91208. * Default is 1/60.
  91209. * To slow it down, enter 1/600 for example.
  91210. * To speed it up, 1/30
  91211. * @param newTimeStep the new timestep to apply to this world.
  91212. */
  91213. setTimeStep(newTimeStep: number): void;
  91214. /**
  91215. * Get the time step of the physics engine.
  91216. * @returns the current time step
  91217. */
  91218. getTimeStep(): number;
  91219. /**
  91220. * Release all resources
  91221. */
  91222. dispose(): void;
  91223. /**
  91224. * Gets the name of the current physics plugin
  91225. * @returns the name of the plugin
  91226. */
  91227. getPhysicsPluginName(): string;
  91228. /**
  91229. * Adding a new impostor for the impostor tracking.
  91230. * This will be done by the impostor itself.
  91231. * @param impostor the impostor to add
  91232. */
  91233. addImpostor(impostor: PhysicsImpostor): void;
  91234. /**
  91235. * Remove an impostor from the engine.
  91236. * This impostor and its mesh will not longer be updated by the physics engine.
  91237. * @param impostor the impostor to remove
  91238. */
  91239. removeImpostor(impostor: PhysicsImpostor): void;
  91240. /**
  91241. * Add a joint to the physics engine
  91242. * @param mainImpostor defines the main impostor to which the joint is added.
  91243. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  91244. * @param joint defines the joint that will connect both impostors.
  91245. */
  91246. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91247. /**
  91248. * Removes a joint from the simulation
  91249. * @param mainImpostor defines the impostor used with the joint
  91250. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  91251. * @param joint defines the joint to remove
  91252. */
  91253. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91254. /**
  91255. * Gets the current plugin used to run the simulation
  91256. * @returns current plugin
  91257. */
  91258. getPhysicsPlugin(): IPhysicsEnginePlugin;
  91259. /**
  91260. * Gets the list of physic impostors
  91261. * @returns an array of PhysicsImpostor
  91262. */
  91263. getImpostors(): Array<PhysicsImpostor>;
  91264. /**
  91265. * Gets the impostor for a physics enabled object
  91266. * @param object defines the object impersonated by the impostor
  91267. * @returns the PhysicsImpostor or null if not found
  91268. */
  91269. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91270. /**
  91271. * Gets the impostor for a physics body object
  91272. * @param body defines physics body used by the impostor
  91273. * @returns the PhysicsImpostor or null if not found
  91274. */
  91275. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  91276. /**
  91277. * Does a raycast in the physics world
  91278. * @param from when should the ray start?
  91279. * @param to when should the ray end?
  91280. * @returns PhysicsRaycastResult
  91281. */
  91282. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91283. /**
  91284. * Called by the scene. No need to call it.
  91285. * @param delta defines the timespam between frames
  91286. */
  91287. _step(delta: number): void;
  91288. }
  91289. }
  91290. declare module BABYLON {
  91291. /**
  91292. * The interface for the physics imposter parameters
  91293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91294. */
  91295. export interface PhysicsImpostorParameters {
  91296. /**
  91297. * The mass of the physics imposter
  91298. */
  91299. mass: number;
  91300. /**
  91301. * The friction of the physics imposter
  91302. */
  91303. friction?: number;
  91304. /**
  91305. * The coefficient of restitution of the physics imposter
  91306. */
  91307. restitution?: number;
  91308. /**
  91309. * The native options of the physics imposter
  91310. */
  91311. nativeOptions?: any;
  91312. /**
  91313. * Specifies if the parent should be ignored
  91314. */
  91315. ignoreParent?: boolean;
  91316. /**
  91317. * Specifies if bi-directional transformations should be disabled
  91318. */
  91319. disableBidirectionalTransformation?: boolean;
  91320. /**
  91321. * The pressure inside the physics imposter, soft object only
  91322. */
  91323. pressure?: number;
  91324. /**
  91325. * The stiffness the physics imposter, soft object only
  91326. */
  91327. stiffness?: number;
  91328. /**
  91329. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  91330. */
  91331. velocityIterations?: number;
  91332. /**
  91333. * The number of iterations used in maintaining consistent vertex positions, soft object only
  91334. */
  91335. positionIterations?: number;
  91336. /**
  91337. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  91338. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  91339. * Add to fix multiple points
  91340. */
  91341. fixedPoints?: number;
  91342. /**
  91343. * The collision margin around a soft object
  91344. */
  91345. margin?: number;
  91346. /**
  91347. * The collision margin around a soft object
  91348. */
  91349. damping?: number;
  91350. /**
  91351. * The path for a rope based on an extrusion
  91352. */
  91353. path?: any;
  91354. /**
  91355. * The shape of an extrusion used for a rope based on an extrusion
  91356. */
  91357. shape?: any;
  91358. }
  91359. /**
  91360. * Interface for a physics-enabled object
  91361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91362. */
  91363. export interface IPhysicsEnabledObject {
  91364. /**
  91365. * The position of the physics-enabled object
  91366. */
  91367. position: Vector3;
  91368. /**
  91369. * The rotation of the physics-enabled object
  91370. */
  91371. rotationQuaternion: Nullable<Quaternion>;
  91372. /**
  91373. * The scale of the physics-enabled object
  91374. */
  91375. scaling: Vector3;
  91376. /**
  91377. * The rotation of the physics-enabled object
  91378. */
  91379. rotation?: Vector3;
  91380. /**
  91381. * The parent of the physics-enabled object
  91382. */
  91383. parent?: any;
  91384. /**
  91385. * The bounding info of the physics-enabled object
  91386. * @returns The bounding info of the physics-enabled object
  91387. */
  91388. getBoundingInfo(): BoundingInfo;
  91389. /**
  91390. * Computes the world matrix
  91391. * @param force Specifies if the world matrix should be computed by force
  91392. * @returns A world matrix
  91393. */
  91394. computeWorldMatrix(force: boolean): Matrix;
  91395. /**
  91396. * Gets the world matrix
  91397. * @returns A world matrix
  91398. */
  91399. getWorldMatrix?(): Matrix;
  91400. /**
  91401. * Gets the child meshes
  91402. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91403. * @returns An array of abstract meshes
  91404. */
  91405. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91406. /**
  91407. * Gets the vertex data
  91408. * @param kind The type of vertex data
  91409. * @returns A nullable array of numbers, or a float32 array
  91410. */
  91411. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91412. /**
  91413. * Gets the indices from the mesh
  91414. * @returns A nullable array of index arrays
  91415. */
  91416. getIndices?(): Nullable<IndicesArray>;
  91417. /**
  91418. * Gets the scene from the mesh
  91419. * @returns the indices array or null
  91420. */
  91421. getScene?(): Scene;
  91422. /**
  91423. * Gets the absolute position from the mesh
  91424. * @returns the absolute position
  91425. */
  91426. getAbsolutePosition(): Vector3;
  91427. /**
  91428. * Gets the absolute pivot point from the mesh
  91429. * @returns the absolute pivot point
  91430. */
  91431. getAbsolutePivotPoint(): Vector3;
  91432. /**
  91433. * Rotates the mesh
  91434. * @param axis The axis of rotation
  91435. * @param amount The amount of rotation
  91436. * @param space The space of the rotation
  91437. * @returns The rotation transform node
  91438. */
  91439. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91440. /**
  91441. * Translates the mesh
  91442. * @param axis The axis of translation
  91443. * @param distance The distance of translation
  91444. * @param space The space of the translation
  91445. * @returns The transform node
  91446. */
  91447. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91448. /**
  91449. * Sets the absolute position of the mesh
  91450. * @param absolutePosition The absolute position of the mesh
  91451. * @returns The transform node
  91452. */
  91453. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91454. /**
  91455. * Gets the class name of the mesh
  91456. * @returns The class name
  91457. */
  91458. getClassName(): string;
  91459. }
  91460. /**
  91461. * Represents a physics imposter
  91462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91463. */
  91464. export class PhysicsImpostor {
  91465. /**
  91466. * The physics-enabled object used as the physics imposter
  91467. */
  91468. object: IPhysicsEnabledObject;
  91469. /**
  91470. * The type of the physics imposter
  91471. */
  91472. type: number;
  91473. private _options;
  91474. private _scene?;
  91475. /**
  91476. * The default object size of the imposter
  91477. */
  91478. static DEFAULT_OBJECT_SIZE: Vector3;
  91479. /**
  91480. * The identity quaternion of the imposter
  91481. */
  91482. static IDENTITY_QUATERNION: Quaternion;
  91483. /** @hidden */
  91484. _pluginData: any;
  91485. private _physicsEngine;
  91486. private _physicsBody;
  91487. private _bodyUpdateRequired;
  91488. private _onBeforePhysicsStepCallbacks;
  91489. private _onAfterPhysicsStepCallbacks;
  91490. /** @hidden */
  91491. _onPhysicsCollideCallbacks: Array<{
  91492. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91493. otherImpostors: Array<PhysicsImpostor>;
  91494. }>;
  91495. private _deltaPosition;
  91496. private _deltaRotation;
  91497. private _deltaRotationConjugated;
  91498. /** @hidden */
  91499. _isFromLine: boolean;
  91500. private _parent;
  91501. private _isDisposed;
  91502. private static _tmpVecs;
  91503. private static _tmpQuat;
  91504. /**
  91505. * Specifies if the physics imposter is disposed
  91506. */
  91507. readonly isDisposed: boolean;
  91508. /**
  91509. * Gets the mass of the physics imposter
  91510. */
  91511. mass: number;
  91512. /**
  91513. * Gets the coefficient of friction
  91514. */
  91515. /**
  91516. * Sets the coefficient of friction
  91517. */
  91518. friction: number;
  91519. /**
  91520. * Gets the coefficient of restitution
  91521. */
  91522. /**
  91523. * Sets the coefficient of restitution
  91524. */
  91525. restitution: number;
  91526. /**
  91527. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  91528. */
  91529. /**
  91530. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  91531. */
  91532. pressure: number;
  91533. /**
  91534. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91535. */
  91536. /**
  91537. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91538. */
  91539. stiffness: number;
  91540. /**
  91541. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91542. */
  91543. /**
  91544. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91545. */
  91546. velocityIterations: number;
  91547. /**
  91548. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91549. */
  91550. /**
  91551. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91552. */
  91553. positionIterations: number;
  91554. /**
  91555. * The unique id of the physics imposter
  91556. * set by the physics engine when adding this impostor to the array
  91557. */
  91558. uniqueId: number;
  91559. /**
  91560. * @hidden
  91561. */
  91562. soft: boolean;
  91563. /**
  91564. * @hidden
  91565. */
  91566. segments: number;
  91567. private _joints;
  91568. /**
  91569. * Initializes the physics imposter
  91570. * @param object The physics-enabled object used as the physics imposter
  91571. * @param type The type of the physics imposter
  91572. * @param _options The options for the physics imposter
  91573. * @param _scene The Babylon scene
  91574. */
  91575. constructor(
  91576. /**
  91577. * The physics-enabled object used as the physics imposter
  91578. */
  91579. object: IPhysicsEnabledObject,
  91580. /**
  91581. * The type of the physics imposter
  91582. */
  91583. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91584. /**
  91585. * This function will completly initialize this impostor.
  91586. * It will create a new body - but only if this mesh has no parent.
  91587. * If it has, this impostor will not be used other than to define the impostor
  91588. * of the child mesh.
  91589. * @hidden
  91590. */
  91591. _init(): void;
  91592. private _getPhysicsParent;
  91593. /**
  91594. * Should a new body be generated.
  91595. * @returns boolean specifying if body initialization is required
  91596. */
  91597. isBodyInitRequired(): boolean;
  91598. /**
  91599. * Sets the updated scaling
  91600. * @param updated Specifies if the scaling is updated
  91601. */
  91602. setScalingUpdated(): void;
  91603. /**
  91604. * Force a regeneration of this or the parent's impostor's body.
  91605. * Use under cautious - This will remove all joints already implemented.
  91606. */
  91607. forceUpdate(): void;
  91608. /**
  91609. * Gets the body that holds this impostor. Either its own, or its parent.
  91610. */
  91611. /**
  91612. * Set the physics body. Used mainly by the physics engine/plugin
  91613. */
  91614. physicsBody: any;
  91615. /**
  91616. * Get the parent of the physics imposter
  91617. * @returns Physics imposter or null
  91618. */
  91619. /**
  91620. * Sets the parent of the physics imposter
  91621. */
  91622. parent: Nullable<PhysicsImpostor>;
  91623. /**
  91624. * Resets the update flags
  91625. */
  91626. resetUpdateFlags(): void;
  91627. /**
  91628. * Gets the object extend size
  91629. * @returns the object extend size
  91630. */
  91631. getObjectExtendSize(): Vector3;
  91632. /**
  91633. * Gets the object center
  91634. * @returns The object center
  91635. */
  91636. getObjectCenter(): Vector3;
  91637. /**
  91638. * Get a specific parametes from the options parameter
  91639. * @param paramName The object parameter name
  91640. * @returns The object parameter
  91641. */
  91642. getParam(paramName: string): any;
  91643. /**
  91644. * Sets a specific parameter in the options given to the physics plugin
  91645. * @param paramName The parameter name
  91646. * @param value The value of the parameter
  91647. */
  91648. setParam(paramName: string, value: number): void;
  91649. /**
  91650. * Specifically change the body's mass option. Won't recreate the physics body object
  91651. * @param mass The mass of the physics imposter
  91652. */
  91653. setMass(mass: number): void;
  91654. /**
  91655. * Gets the linear velocity
  91656. * @returns linear velocity or null
  91657. */
  91658. getLinearVelocity(): Nullable<Vector3>;
  91659. /**
  91660. * Sets the linear velocity
  91661. * @param velocity linear velocity or null
  91662. */
  91663. setLinearVelocity(velocity: Nullable<Vector3>): void;
  91664. /**
  91665. * Gets the angular velocity
  91666. * @returns angular velocity or null
  91667. */
  91668. getAngularVelocity(): Nullable<Vector3>;
  91669. /**
  91670. * Sets the angular velocity
  91671. * @param velocity The velocity or null
  91672. */
  91673. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91674. /**
  91675. * Execute a function with the physics plugin native code
  91676. * Provide a function the will have two variables - the world object and the physics body object
  91677. * @param func The function to execute with the physics plugin native code
  91678. */
  91679. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91680. /**
  91681. * Register a function that will be executed before the physics world is stepping forward
  91682. * @param func The function to execute before the physics world is stepped forward
  91683. */
  91684. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91685. /**
  91686. * Unregister a function that will be executed before the physics world is stepping forward
  91687. * @param func The function to execute before the physics world is stepped forward
  91688. */
  91689. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91690. /**
  91691. * Register a function that will be executed after the physics step
  91692. * @param func The function to execute after physics step
  91693. */
  91694. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91695. /**
  91696. * Unregisters a function that will be executed after the physics step
  91697. * @param func The function to execute after physics step
  91698. */
  91699. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91700. /**
  91701. * register a function that will be executed when this impostor collides against a different body
  91702. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91703. * @param func Callback that is executed on collision
  91704. */
  91705. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91706. /**
  91707. * Unregisters the physics imposter on contact
  91708. * @param collideAgainst The physics object to collide against
  91709. * @param func Callback to execute on collision
  91710. */
  91711. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91712. private _tmpQuat;
  91713. private _tmpQuat2;
  91714. /**
  91715. * Get the parent rotation
  91716. * @returns The parent rotation
  91717. */
  91718. getParentsRotation(): Quaternion;
  91719. /**
  91720. * this function is executed by the physics engine.
  91721. */
  91722. beforeStep: () => void;
  91723. /**
  91724. * this function is executed by the physics engine
  91725. */
  91726. afterStep: () => void;
  91727. /**
  91728. * Legacy collision detection event support
  91729. */
  91730. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91731. /**
  91732. * event and body object due to cannon's event-based architecture.
  91733. */
  91734. onCollide: (e: {
  91735. body: any;
  91736. }) => void;
  91737. /**
  91738. * Apply a force
  91739. * @param force The force to apply
  91740. * @param contactPoint The contact point for the force
  91741. * @returns The physics imposter
  91742. */
  91743. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91744. /**
  91745. * Apply an impulse
  91746. * @param force The impulse force
  91747. * @param contactPoint The contact point for the impulse force
  91748. * @returns The physics imposter
  91749. */
  91750. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91751. /**
  91752. * A help function to create a joint
  91753. * @param otherImpostor A physics imposter used to create a joint
  91754. * @param jointType The type of joint
  91755. * @param jointData The data for the joint
  91756. * @returns The physics imposter
  91757. */
  91758. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91759. /**
  91760. * Add a joint to this impostor with a different impostor
  91761. * @param otherImpostor A physics imposter used to add a joint
  91762. * @param joint The joint to add
  91763. * @returns The physics imposter
  91764. */
  91765. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  91766. /**
  91767. * Add an anchor to a cloth impostor
  91768. * @param otherImpostor rigid impostor to anchor to
  91769. * @param width ratio across width from 0 to 1
  91770. * @param height ratio up height from 0 to 1
  91771. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  91772. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  91773. * @returns impostor the soft imposter
  91774. */
  91775. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91776. /**
  91777. * Add a hook to a rope impostor
  91778. * @param otherImpostor rigid impostor to anchor to
  91779. * @param length ratio across rope from 0 to 1
  91780. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  91781. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  91782. * @returns impostor the rope imposter
  91783. */
  91784. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91785. /**
  91786. * Will keep this body still, in a sleep mode.
  91787. * @returns the physics imposter
  91788. */
  91789. sleep(): PhysicsImpostor;
  91790. /**
  91791. * Wake the body up.
  91792. * @returns The physics imposter
  91793. */
  91794. wakeUp(): PhysicsImpostor;
  91795. /**
  91796. * Clones the physics imposter
  91797. * @param newObject The physics imposter clones to this physics-enabled object
  91798. * @returns A nullable physics imposter
  91799. */
  91800. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91801. /**
  91802. * Disposes the physics imposter
  91803. */
  91804. dispose(): void;
  91805. /**
  91806. * Sets the delta position
  91807. * @param position The delta position amount
  91808. */
  91809. setDeltaPosition(position: Vector3): void;
  91810. /**
  91811. * Sets the delta rotation
  91812. * @param rotation The delta rotation amount
  91813. */
  91814. setDeltaRotation(rotation: Quaternion): void;
  91815. /**
  91816. * Gets the box size of the physics imposter and stores the result in the input parameter
  91817. * @param result Stores the box size
  91818. * @returns The physics imposter
  91819. */
  91820. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  91821. /**
  91822. * Gets the radius of the physics imposter
  91823. * @returns Radius of the physics imposter
  91824. */
  91825. getRadius(): number;
  91826. /**
  91827. * Sync a bone with this impostor
  91828. * @param bone The bone to sync to the impostor.
  91829. * @param boneMesh The mesh that the bone is influencing.
  91830. * @param jointPivot The pivot of the joint / bone in local space.
  91831. * @param distToJoint Optional distance from the impostor to the joint.
  91832. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91833. */
  91834. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  91835. /**
  91836. * Sync impostor to a bone
  91837. * @param bone The bone that the impostor will be synced to.
  91838. * @param boneMesh The mesh that the bone is influencing.
  91839. * @param jointPivot The pivot of the joint / bone in local space.
  91840. * @param distToJoint Optional distance from the impostor to the joint.
  91841. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91842. * @param boneAxis Optional vector3 axis the bone is aligned with
  91843. */
  91844. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  91845. /**
  91846. * No-Imposter type
  91847. */
  91848. static NoImpostor: number;
  91849. /**
  91850. * Sphere-Imposter type
  91851. */
  91852. static SphereImpostor: number;
  91853. /**
  91854. * Box-Imposter type
  91855. */
  91856. static BoxImpostor: number;
  91857. /**
  91858. * Plane-Imposter type
  91859. */
  91860. static PlaneImpostor: number;
  91861. /**
  91862. * Mesh-imposter type
  91863. */
  91864. static MeshImpostor: number;
  91865. /**
  91866. * Capsule-Impostor type (Ammo.js plugin only)
  91867. */
  91868. static CapsuleImpostor: number;
  91869. /**
  91870. * Cylinder-Imposter type
  91871. */
  91872. static CylinderImpostor: number;
  91873. /**
  91874. * Particle-Imposter type
  91875. */
  91876. static ParticleImpostor: number;
  91877. /**
  91878. * Heightmap-Imposter type
  91879. */
  91880. static HeightmapImpostor: number;
  91881. /**
  91882. * ConvexHull-Impostor type (Ammo.js plugin only)
  91883. */
  91884. static ConvexHullImpostor: number;
  91885. /**
  91886. * Rope-Imposter type
  91887. */
  91888. static RopeImpostor: number;
  91889. /**
  91890. * Cloth-Imposter type
  91891. */
  91892. static ClothImpostor: number;
  91893. /**
  91894. * Softbody-Imposter type
  91895. */
  91896. static SoftbodyImpostor: number;
  91897. }
  91898. }
  91899. declare module BABYLON {
  91900. /**
  91901. * @hidden
  91902. **/
  91903. export class _CreationDataStorage {
  91904. closePath?: boolean;
  91905. closeArray?: boolean;
  91906. idx: number[];
  91907. dashSize: number;
  91908. gapSize: number;
  91909. path3D: Path3D;
  91910. pathArray: Vector3[][];
  91911. arc: number;
  91912. radius: number;
  91913. cap: number;
  91914. tessellation: number;
  91915. }
  91916. /**
  91917. * @hidden
  91918. **/
  91919. class _InstanceDataStorage {
  91920. visibleInstances: any;
  91921. batchCache: _InstancesBatch;
  91922. instancesBufferSize: number;
  91923. instancesBuffer: Nullable<Buffer>;
  91924. instancesData: Float32Array;
  91925. overridenInstanceCount: number;
  91926. isFrozen: boolean;
  91927. previousBatch: Nullable<_InstancesBatch>;
  91928. hardwareInstancedRendering: boolean;
  91929. sideOrientation: number;
  91930. manualUpdate: boolean;
  91931. }
  91932. /**
  91933. * @hidden
  91934. **/
  91935. export class _InstancesBatch {
  91936. mustReturn: boolean;
  91937. visibleInstances: Nullable<InstancedMesh[]>[];
  91938. renderSelf: boolean[];
  91939. hardwareInstancedRendering: boolean[];
  91940. }
  91941. /**
  91942. * Class used to represent renderable models
  91943. */
  91944. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  91945. /**
  91946. * Mesh side orientation : usually the external or front surface
  91947. */
  91948. static readonly FRONTSIDE: number;
  91949. /**
  91950. * Mesh side orientation : usually the internal or back surface
  91951. */
  91952. static readonly BACKSIDE: number;
  91953. /**
  91954. * Mesh side orientation : both internal and external or front and back surfaces
  91955. */
  91956. static readonly DOUBLESIDE: number;
  91957. /**
  91958. * Mesh side orientation : by default, `FRONTSIDE`
  91959. */
  91960. static readonly DEFAULTSIDE: number;
  91961. /**
  91962. * Mesh cap setting : no cap
  91963. */
  91964. static readonly NO_CAP: number;
  91965. /**
  91966. * Mesh cap setting : one cap at the beginning of the mesh
  91967. */
  91968. static readonly CAP_START: number;
  91969. /**
  91970. * Mesh cap setting : one cap at the end of the mesh
  91971. */
  91972. static readonly CAP_END: number;
  91973. /**
  91974. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91975. */
  91976. static readonly CAP_ALL: number;
  91977. /**
  91978. * Mesh pattern setting : no flip or rotate
  91979. */
  91980. static readonly NO_FLIP: number;
  91981. /**
  91982. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91983. */
  91984. static readonly FLIP_TILE: number;
  91985. /**
  91986. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91987. */
  91988. static readonly ROTATE_TILE: number;
  91989. /**
  91990. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91991. */
  91992. static readonly FLIP_ROW: number;
  91993. /**
  91994. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91995. */
  91996. static readonly ROTATE_ROW: number;
  91997. /**
  91998. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91999. */
  92000. static readonly FLIP_N_ROTATE_TILE: number;
  92001. /**
  92002. * Mesh pattern setting : rotate pattern and rotate
  92003. */
  92004. static readonly FLIP_N_ROTATE_ROW: number;
  92005. /**
  92006. * Mesh tile positioning : part tiles same on left/right or top/bottom
  92007. */
  92008. static readonly CENTER: number;
  92009. /**
  92010. * Mesh tile positioning : part tiles on left
  92011. */
  92012. static readonly LEFT: number;
  92013. /**
  92014. * Mesh tile positioning : part tiles on right
  92015. */
  92016. static readonly RIGHT: number;
  92017. /**
  92018. * Mesh tile positioning : part tiles on top
  92019. */
  92020. static readonly TOP: number;
  92021. /**
  92022. * Mesh tile positioning : part tiles on bottom
  92023. */
  92024. static readonly BOTTOM: number;
  92025. /**
  92026. * Gets the default side orientation.
  92027. * @param orientation the orientation to value to attempt to get
  92028. * @returns the default orientation
  92029. * @hidden
  92030. */
  92031. static _GetDefaultSideOrientation(orientation?: number): number;
  92032. private _internalMeshDataInfo;
  92033. /**
  92034. * An event triggered before rendering the mesh
  92035. */
  92036. readonly onBeforeRenderObservable: Observable<Mesh>;
  92037. /**
  92038. * An event triggered before binding the mesh
  92039. */
  92040. readonly onBeforeBindObservable: Observable<Mesh>;
  92041. /**
  92042. * An event triggered after rendering the mesh
  92043. */
  92044. readonly onAfterRenderObservable: Observable<Mesh>;
  92045. /**
  92046. * An event triggered before drawing the mesh
  92047. */
  92048. readonly onBeforeDrawObservable: Observable<Mesh>;
  92049. private _onBeforeDrawObserver;
  92050. /**
  92051. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92052. */
  92053. onBeforeDraw: () => void;
  92054. readonly hasInstances: boolean;
  92055. /**
  92056. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92057. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92058. */
  92059. delayLoadState: number;
  92060. /**
  92061. * Gets the list of instances created from this mesh
  92062. * it is not supposed to be modified manually.
  92063. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92064. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92065. */
  92066. instances: InstancedMesh[];
  92067. /**
  92068. * Gets the file containing delay loading data for this mesh
  92069. */
  92070. delayLoadingFile: string;
  92071. /** @hidden */
  92072. _binaryInfo: any;
  92073. /**
  92074. * User defined function used to change how LOD level selection is done
  92075. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92076. */
  92077. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92078. /**
  92079. * Gets or sets the morph target manager
  92080. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92081. */
  92082. morphTargetManager: Nullable<MorphTargetManager>;
  92083. /** @hidden */
  92084. _creationDataStorage: Nullable<_CreationDataStorage>;
  92085. /** @hidden */
  92086. _geometry: Nullable<Geometry>;
  92087. /** @hidden */
  92088. _delayInfo: Array<string>;
  92089. /** @hidden */
  92090. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92091. /** @hidden */
  92092. _instanceDataStorage: _InstanceDataStorage;
  92093. private _effectiveMaterial;
  92094. /** @hidden */
  92095. _shouldGenerateFlatShading: boolean;
  92096. /** @hidden */
  92097. _originalBuilderSideOrientation: number;
  92098. /**
  92099. * Use this property to change the original side orientation defined at construction time
  92100. */
  92101. overrideMaterialSideOrientation: Nullable<number>;
  92102. /**
  92103. * Gets the source mesh (the one used to clone this one from)
  92104. */
  92105. readonly source: Nullable<Mesh>;
  92106. /**
  92107. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92108. */
  92109. isUnIndexed: boolean;
  92110. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92111. readonly worldMatrixInstancedBuffer: Float32Array;
  92112. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92113. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92114. /**
  92115. * @constructor
  92116. * @param name The value used by scene.getMeshByName() to do a lookup.
  92117. * @param scene The scene to add this mesh to.
  92118. * @param parent The parent of this mesh, if it has one
  92119. * @param source An optional Mesh from which geometry is shared, cloned.
  92120. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92121. * When false, achieved by calling a clone(), also passing False.
  92122. * This will make creation of children, recursive.
  92123. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92124. */
  92125. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92126. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92127. doNotInstantiate: boolean;
  92128. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92129. /**
  92130. * Gets the class name
  92131. * @returns the string "Mesh".
  92132. */
  92133. getClassName(): string;
  92134. /** @hidden */
  92135. readonly _isMesh: boolean;
  92136. /**
  92137. * Returns a description of this mesh
  92138. * @param fullDetails define if full details about this mesh must be used
  92139. * @returns a descriptive string representing this mesh
  92140. */
  92141. toString(fullDetails?: boolean): string;
  92142. /** @hidden */
  92143. _unBindEffect(): void;
  92144. /**
  92145. * Gets a boolean indicating if this mesh has LOD
  92146. */
  92147. readonly hasLODLevels: boolean;
  92148. /**
  92149. * Gets the list of MeshLODLevel associated with the current mesh
  92150. * @returns an array of MeshLODLevel
  92151. */
  92152. getLODLevels(): MeshLODLevel[];
  92153. private _sortLODLevels;
  92154. /**
  92155. * Add a mesh as LOD level triggered at the given distance.
  92156. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92157. * @param distance The distance from the center of the object to show this level
  92158. * @param mesh The mesh to be added as LOD level (can be null)
  92159. * @return This mesh (for chaining)
  92160. */
  92161. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  92162. /**
  92163. * Returns the LOD level mesh at the passed distance or null if not found.
  92164. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92165. * @param distance The distance from the center of the object to show this level
  92166. * @returns a Mesh or `null`
  92167. */
  92168. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  92169. /**
  92170. * Remove a mesh from the LOD array
  92171. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92172. * @param mesh defines the mesh to be removed
  92173. * @return This mesh (for chaining)
  92174. */
  92175. removeLODLevel(mesh: Mesh): Mesh;
  92176. /**
  92177. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  92178. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92179. * @param camera defines the camera to use to compute distance
  92180. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  92181. * @return This mesh (for chaining)
  92182. */
  92183. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  92184. /**
  92185. * Gets the mesh internal Geometry object
  92186. */
  92187. readonly geometry: Nullable<Geometry>;
  92188. /**
  92189. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  92190. * @returns the total number of vertices
  92191. */
  92192. getTotalVertices(): number;
  92193. /**
  92194. * Returns the content of an associated vertex buffer
  92195. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92196. * - VertexBuffer.PositionKind
  92197. * - VertexBuffer.UVKind
  92198. * - VertexBuffer.UV2Kind
  92199. * - VertexBuffer.UV3Kind
  92200. * - VertexBuffer.UV4Kind
  92201. * - VertexBuffer.UV5Kind
  92202. * - VertexBuffer.UV6Kind
  92203. * - VertexBuffer.ColorKind
  92204. * - VertexBuffer.MatricesIndicesKind
  92205. * - VertexBuffer.MatricesIndicesExtraKind
  92206. * - VertexBuffer.MatricesWeightsKind
  92207. * - VertexBuffer.MatricesWeightsExtraKind
  92208. * @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
  92209. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  92210. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  92211. */
  92212. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92213. /**
  92214. * Returns the mesh VertexBuffer object from the requested `kind`
  92215. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92216. * - VertexBuffer.PositionKind
  92217. * - VertexBuffer.NormalKind
  92218. * - VertexBuffer.UVKind
  92219. * - VertexBuffer.UV2Kind
  92220. * - VertexBuffer.UV3Kind
  92221. * - VertexBuffer.UV4Kind
  92222. * - VertexBuffer.UV5Kind
  92223. * - VertexBuffer.UV6Kind
  92224. * - VertexBuffer.ColorKind
  92225. * - VertexBuffer.MatricesIndicesKind
  92226. * - VertexBuffer.MatricesIndicesExtraKind
  92227. * - VertexBuffer.MatricesWeightsKind
  92228. * - VertexBuffer.MatricesWeightsExtraKind
  92229. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  92230. */
  92231. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92232. /**
  92233. * Tests if a specific vertex buffer is associated with this mesh
  92234. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92235. * - VertexBuffer.PositionKind
  92236. * - VertexBuffer.NormalKind
  92237. * - VertexBuffer.UVKind
  92238. * - VertexBuffer.UV2Kind
  92239. * - VertexBuffer.UV3Kind
  92240. * - VertexBuffer.UV4Kind
  92241. * - VertexBuffer.UV5Kind
  92242. * - VertexBuffer.UV6Kind
  92243. * - VertexBuffer.ColorKind
  92244. * - VertexBuffer.MatricesIndicesKind
  92245. * - VertexBuffer.MatricesIndicesExtraKind
  92246. * - VertexBuffer.MatricesWeightsKind
  92247. * - VertexBuffer.MatricesWeightsExtraKind
  92248. * @returns a boolean
  92249. */
  92250. isVerticesDataPresent(kind: string): boolean;
  92251. /**
  92252. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  92253. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92254. * - VertexBuffer.PositionKind
  92255. * - VertexBuffer.UVKind
  92256. * - VertexBuffer.UV2Kind
  92257. * - VertexBuffer.UV3Kind
  92258. * - VertexBuffer.UV4Kind
  92259. * - VertexBuffer.UV5Kind
  92260. * - VertexBuffer.UV6Kind
  92261. * - VertexBuffer.ColorKind
  92262. * - VertexBuffer.MatricesIndicesKind
  92263. * - VertexBuffer.MatricesIndicesExtraKind
  92264. * - VertexBuffer.MatricesWeightsKind
  92265. * - VertexBuffer.MatricesWeightsExtraKind
  92266. * @returns a boolean
  92267. */
  92268. isVertexBufferUpdatable(kind: string): boolean;
  92269. /**
  92270. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  92271. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92272. * - VertexBuffer.PositionKind
  92273. * - VertexBuffer.NormalKind
  92274. * - VertexBuffer.UVKind
  92275. * - VertexBuffer.UV2Kind
  92276. * - VertexBuffer.UV3Kind
  92277. * - VertexBuffer.UV4Kind
  92278. * - VertexBuffer.UV5Kind
  92279. * - VertexBuffer.UV6Kind
  92280. * - VertexBuffer.ColorKind
  92281. * - VertexBuffer.MatricesIndicesKind
  92282. * - VertexBuffer.MatricesIndicesExtraKind
  92283. * - VertexBuffer.MatricesWeightsKind
  92284. * - VertexBuffer.MatricesWeightsExtraKind
  92285. * @returns an array of strings
  92286. */
  92287. getVerticesDataKinds(): string[];
  92288. /**
  92289. * Returns a positive integer : the total number of indices in this mesh geometry.
  92290. * @returns the numner of indices or zero if the mesh has no geometry.
  92291. */
  92292. getTotalIndices(): number;
  92293. /**
  92294. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92295. * @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.
  92296. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92297. * @returns the indices array or an empty array if the mesh has no geometry
  92298. */
  92299. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92300. readonly isBlocked: boolean;
  92301. /**
  92302. * Determine if the current mesh is ready to be rendered
  92303. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92304. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  92305. * @returns true if all associated assets are ready (material, textures, shaders)
  92306. */
  92307. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  92308. /**
  92309. * 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.
  92310. */
  92311. readonly areNormalsFrozen: boolean;
  92312. /**
  92313. * 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.
  92314. * @returns the current mesh
  92315. */
  92316. freezeNormals(): Mesh;
  92317. /**
  92318. * 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
  92319. * @returns the current mesh
  92320. */
  92321. unfreezeNormals(): Mesh;
  92322. /**
  92323. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  92324. */
  92325. overridenInstanceCount: number;
  92326. /** @hidden */
  92327. _preActivate(): Mesh;
  92328. /** @hidden */
  92329. _preActivateForIntermediateRendering(renderId: number): Mesh;
  92330. /** @hidden */
  92331. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  92332. /**
  92333. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92334. * This means the mesh underlying bounding box and sphere are recomputed.
  92335. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92336. * @returns the current mesh
  92337. */
  92338. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  92339. /** @hidden */
  92340. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  92341. /**
  92342. * This function will subdivide the mesh into multiple submeshes
  92343. * @param count defines the expected number of submeshes
  92344. */
  92345. subdivide(count: number): void;
  92346. /**
  92347. * Copy a FloatArray into a specific associated vertex buffer
  92348. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92349. * - VertexBuffer.PositionKind
  92350. * - VertexBuffer.UVKind
  92351. * - VertexBuffer.UV2Kind
  92352. * - VertexBuffer.UV3Kind
  92353. * - VertexBuffer.UV4Kind
  92354. * - VertexBuffer.UV5Kind
  92355. * - VertexBuffer.UV6Kind
  92356. * - VertexBuffer.ColorKind
  92357. * - VertexBuffer.MatricesIndicesKind
  92358. * - VertexBuffer.MatricesIndicesExtraKind
  92359. * - VertexBuffer.MatricesWeightsKind
  92360. * - VertexBuffer.MatricesWeightsExtraKind
  92361. * @param data defines the data source
  92362. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92363. * @param stride defines the data stride size (can be null)
  92364. * @returns the current mesh
  92365. */
  92366. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92367. /**
  92368. * Delete a vertex buffer associated with this mesh
  92369. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  92370. * - VertexBuffer.PositionKind
  92371. * - VertexBuffer.UVKind
  92372. * - VertexBuffer.UV2Kind
  92373. * - VertexBuffer.UV3Kind
  92374. * - VertexBuffer.UV4Kind
  92375. * - VertexBuffer.UV5Kind
  92376. * - VertexBuffer.UV6Kind
  92377. * - VertexBuffer.ColorKind
  92378. * - VertexBuffer.MatricesIndicesKind
  92379. * - VertexBuffer.MatricesIndicesExtraKind
  92380. * - VertexBuffer.MatricesWeightsKind
  92381. * - VertexBuffer.MatricesWeightsExtraKind
  92382. */
  92383. removeVerticesData(kind: string): void;
  92384. /**
  92385. * Flags an associated vertex buffer as updatable
  92386. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  92387. * - VertexBuffer.PositionKind
  92388. * - VertexBuffer.UVKind
  92389. * - VertexBuffer.UV2Kind
  92390. * - VertexBuffer.UV3Kind
  92391. * - VertexBuffer.UV4Kind
  92392. * - VertexBuffer.UV5Kind
  92393. * - VertexBuffer.UV6Kind
  92394. * - VertexBuffer.ColorKind
  92395. * - VertexBuffer.MatricesIndicesKind
  92396. * - VertexBuffer.MatricesIndicesExtraKind
  92397. * - VertexBuffer.MatricesWeightsKind
  92398. * - VertexBuffer.MatricesWeightsExtraKind
  92399. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92400. */
  92401. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  92402. /**
  92403. * Sets the mesh global Vertex Buffer
  92404. * @param buffer defines the buffer to use
  92405. * @returns the current mesh
  92406. */
  92407. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92408. /**
  92409. * Update a specific associated vertex buffer
  92410. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92411. * - VertexBuffer.PositionKind
  92412. * - VertexBuffer.UVKind
  92413. * - VertexBuffer.UV2Kind
  92414. * - VertexBuffer.UV3Kind
  92415. * - VertexBuffer.UV4Kind
  92416. * - VertexBuffer.UV5Kind
  92417. * - VertexBuffer.UV6Kind
  92418. * - VertexBuffer.ColorKind
  92419. * - VertexBuffer.MatricesIndicesKind
  92420. * - VertexBuffer.MatricesIndicesExtraKind
  92421. * - VertexBuffer.MatricesWeightsKind
  92422. * - VertexBuffer.MatricesWeightsExtraKind
  92423. * @param data defines the data source
  92424. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92425. * @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)
  92426. * @returns the current mesh
  92427. */
  92428. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92429. /**
  92430. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92431. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92432. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92433. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92434. * @returns the current mesh
  92435. */
  92436. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92437. /**
  92438. * Creates a un-shared specific occurence of the geometry for the mesh.
  92439. * @returns the current mesh
  92440. */
  92441. makeGeometryUnique(): Mesh;
  92442. /**
  92443. * Set the index buffer of this mesh
  92444. * @param indices defines the source data
  92445. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92446. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92447. * @returns the current mesh
  92448. */
  92449. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92450. /**
  92451. * Update the current index buffer
  92452. * @param indices defines the source data
  92453. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92454. * @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)
  92455. * @returns the current mesh
  92456. */
  92457. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92458. /**
  92459. * Invert the geometry to move from a right handed system to a left handed one.
  92460. * @returns the current mesh
  92461. */
  92462. toLeftHanded(): Mesh;
  92463. /** @hidden */
  92464. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92465. /** @hidden */
  92466. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92467. /**
  92468. * Registers for this mesh a javascript function called just before the rendering process
  92469. * @param func defines the function to call before rendering this mesh
  92470. * @returns the current mesh
  92471. */
  92472. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92473. /**
  92474. * Disposes a previously registered javascript function called before the rendering
  92475. * @param func defines the function to remove
  92476. * @returns the current mesh
  92477. */
  92478. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92479. /**
  92480. * Registers for this mesh a javascript function called just after the rendering is complete
  92481. * @param func defines the function to call after rendering this mesh
  92482. * @returns the current mesh
  92483. */
  92484. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92485. /**
  92486. * Disposes a previously registered javascript function called after the rendering.
  92487. * @param func defines the function to remove
  92488. * @returns the current mesh
  92489. */
  92490. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92491. /** @hidden */
  92492. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  92493. /** @hidden */
  92494. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92495. /** @hidden */
  92496. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92497. /** @hidden */
  92498. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  92499. /** @hidden */
  92500. _rebuild(): void;
  92501. /** @hidden */
  92502. _freeze(): void;
  92503. /** @hidden */
  92504. _unFreeze(): void;
  92505. /**
  92506. * 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
  92507. * @param subMesh defines the subMesh to render
  92508. * @param enableAlphaMode defines if alpha mode can be changed
  92509. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  92510. * @returns the current mesh
  92511. */
  92512. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  92513. private _onBeforeDraw;
  92514. /**
  92515. * Renormalize the mesh and patch it up if there are no weights
  92516. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  92517. * However in the case of zero weights then we set just a single influence to 1.
  92518. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  92519. */
  92520. cleanMatrixWeights(): void;
  92521. private normalizeSkinFourWeights;
  92522. private normalizeSkinWeightsAndExtra;
  92523. /**
  92524. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  92525. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  92526. * the user know there was an issue with importing the mesh
  92527. * @returns a validation object with skinned, valid and report string
  92528. */
  92529. validateSkinning(): {
  92530. skinned: boolean;
  92531. valid: boolean;
  92532. report: string;
  92533. };
  92534. /** @hidden */
  92535. _checkDelayState(): Mesh;
  92536. private _queueLoad;
  92537. /**
  92538. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92539. * A mesh is in the frustum if its bounding box intersects the frustum
  92540. * @param frustumPlanes defines the frustum to test
  92541. * @returns true if the mesh is in the frustum planes
  92542. */
  92543. isInFrustum(frustumPlanes: Plane[]): boolean;
  92544. /**
  92545. * Sets the mesh material by the material or multiMaterial `id` property
  92546. * @param id is a string identifying the material or the multiMaterial
  92547. * @returns the current mesh
  92548. */
  92549. setMaterialByID(id: string): Mesh;
  92550. /**
  92551. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92552. * @returns an array of IAnimatable
  92553. */
  92554. getAnimatables(): IAnimatable[];
  92555. /**
  92556. * Modifies the mesh geometry according to the passed transformation matrix.
  92557. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92558. * The mesh normals are modified using the same transformation.
  92559. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92560. * @param transform defines the transform matrix to use
  92561. * @see http://doc.babylonjs.com/resources/baking_transformations
  92562. * @returns the current mesh
  92563. */
  92564. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92565. /**
  92566. * Modifies the mesh geometry according to its own current World Matrix.
  92567. * The mesh World Matrix is then reset.
  92568. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92569. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92570. * @see http://doc.babylonjs.com/resources/baking_transformations
  92571. * @returns the current mesh
  92572. */
  92573. bakeCurrentTransformIntoVertices(): Mesh;
  92574. /** @hidden */
  92575. readonly _positions: Nullable<Vector3[]>;
  92576. /** @hidden */
  92577. _resetPointsArrayCache(): Mesh;
  92578. /** @hidden */
  92579. _generatePointsArray(): boolean;
  92580. /**
  92581. * Returns a new Mesh object generated from the current mesh properties.
  92582. * This method must not get confused with createInstance()
  92583. * @param name is a string, the name given to the new mesh
  92584. * @param newParent can be any Node object (default `null`)
  92585. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92586. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92587. * @returns a new mesh
  92588. */
  92589. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92590. /**
  92591. * Releases resources associated with this mesh.
  92592. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92593. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92594. */
  92595. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92596. /** @hidden */
  92597. _disposeInstanceSpecificData(): void;
  92598. /**
  92599. * Modifies the mesh geometry according to a displacement map.
  92600. * 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.
  92601. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92602. * @param url is a string, the URL from the image file is to be downloaded.
  92603. * @param minHeight is the lower limit of the displacement.
  92604. * @param maxHeight is the upper limit of the displacement.
  92605. * @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.
  92606. * @param uvOffset is an optional vector2 used to offset UV.
  92607. * @param uvScale is an optional vector2 used to scale UV.
  92608. * @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.
  92609. * @returns the Mesh.
  92610. */
  92611. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92612. /**
  92613. * Modifies the mesh geometry according to a displacementMap buffer.
  92614. * 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.
  92615. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92616. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92617. * @param heightMapWidth is the width of the buffer image.
  92618. * @param heightMapHeight is the height of the buffer image.
  92619. * @param minHeight is the lower limit of the displacement.
  92620. * @param maxHeight is the upper limit of the displacement.
  92621. * @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.
  92622. * @param uvOffset is an optional vector2 used to offset UV.
  92623. * @param uvScale is an optional vector2 used to scale UV.
  92624. * @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.
  92625. * @returns the Mesh.
  92626. */
  92627. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92628. /**
  92629. * Modify the mesh to get a flat shading rendering.
  92630. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92631. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92632. * @returns current mesh
  92633. */
  92634. convertToFlatShadedMesh(): Mesh;
  92635. /**
  92636. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92637. * In other words, more vertices, no more indices and a single bigger VBO.
  92638. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92639. * @returns current mesh
  92640. */
  92641. convertToUnIndexedMesh(): Mesh;
  92642. /**
  92643. * Inverses facet orientations.
  92644. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92645. * @param flipNormals will also inverts the normals
  92646. * @returns current mesh
  92647. */
  92648. flipFaces(flipNormals?: boolean): Mesh;
  92649. /**
  92650. * Increase the number of facets and hence vertices in a mesh
  92651. * Vertex normals are interpolated from existing vertex normals
  92652. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92653. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  92654. */
  92655. increaseVertices(numberPerEdge: number): void;
  92656. /**
  92657. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  92658. * This will undo any application of covertToFlatShadedMesh
  92659. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92660. */
  92661. forceSharedVertices(): void;
  92662. /** @hidden */
  92663. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  92664. /** @hidden */
  92665. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  92666. /**
  92667. * Creates a new InstancedMesh object from the mesh model.
  92668. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92669. * @param name defines the name of the new instance
  92670. * @returns a new InstancedMesh
  92671. */
  92672. createInstance(name: string): InstancedMesh;
  92673. /**
  92674. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  92675. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92676. * @returns the current mesh
  92677. */
  92678. synchronizeInstances(): Mesh;
  92679. /**
  92680. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92681. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92682. * This should be used together with the simplification to avoid disappearing triangles.
  92683. * @param successCallback an optional success callback to be called after the optimization finished.
  92684. * @returns the current mesh
  92685. */
  92686. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92687. /**
  92688. * Serialize current mesh
  92689. * @param serializationObject defines the object which will receive the serialization data
  92690. */
  92691. serialize(serializationObject: any): void;
  92692. /** @hidden */
  92693. _syncGeometryWithMorphTargetManager(): void;
  92694. /** @hidden */
  92695. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92696. /**
  92697. * Returns a new Mesh object parsed from the source provided.
  92698. * @param parsedMesh is the source
  92699. * @param scene defines the hosting scene
  92700. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92701. * @returns a new Mesh
  92702. */
  92703. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92704. /**
  92705. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92706. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92707. * @param name defines the name of the mesh to create
  92708. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92709. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92710. * @param closePath creates a seam between the first and the last points of each path of the path array
  92711. * @param offset is taken in account only if the `pathArray` is containing a single path
  92712. * @param scene defines the hosting scene
  92713. * @param updatable defines if the mesh must be flagged as updatable
  92714. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92715. * @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)
  92716. * @returns a new Mesh
  92717. */
  92718. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92719. /**
  92720. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92721. * @param name defines the name of the mesh to create
  92722. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92723. * @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
  92724. * @param scene defines the hosting scene
  92725. * @param updatable defines if the mesh must be flagged as updatable
  92726. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92727. * @returns a new Mesh
  92728. */
  92729. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92730. /**
  92731. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92732. * @param name defines the name of the mesh to create
  92733. * @param size sets the size (float) of each box side (default 1)
  92734. * @param scene defines the hosting scene
  92735. * @param updatable defines if the mesh must be flagged as updatable
  92736. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92737. * @returns a new Mesh
  92738. */
  92739. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92740. /**
  92741. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92742. * @param name defines the name of the mesh to create
  92743. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92744. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92745. * @param scene defines the hosting scene
  92746. * @param updatable defines if the mesh must be flagged as updatable
  92747. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92748. * @returns a new Mesh
  92749. */
  92750. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92751. /**
  92752. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92753. * @param name defines the name of the mesh to create
  92754. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92755. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92756. * @param scene defines the hosting scene
  92757. * @returns a new Mesh
  92758. */
  92759. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92760. /**
  92761. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92762. * @param name defines the name of the mesh to create
  92763. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92764. * @param diameterTop set the top cap diameter (floats, default 1)
  92765. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92766. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92767. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92768. * @param scene defines the hosting scene
  92769. * @param updatable defines if the mesh must be flagged as updatable
  92770. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92771. * @returns a new Mesh
  92772. */
  92773. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  92774. /**
  92775. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92776. * @param name defines the name of the mesh to create
  92777. * @param diameter sets the diameter size (float) of the torus (default 1)
  92778. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92779. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92780. * @param scene defines the hosting scene
  92781. * @param updatable defines if the mesh must be flagged as updatable
  92782. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92783. * @returns a new Mesh
  92784. */
  92785. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92786. /**
  92787. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92788. * @param name defines the name of the mesh to create
  92789. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92790. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92791. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92792. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92793. * @param p the number of windings on X axis (positive integers, default 2)
  92794. * @param q the number of windings on Y axis (positive integers, default 3)
  92795. * @param scene defines the hosting scene
  92796. * @param updatable defines if the mesh must be flagged as updatable
  92797. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92798. * @returns a new Mesh
  92799. */
  92800. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92801. /**
  92802. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92803. * @param name defines the name of the mesh to create
  92804. * @param points is an array successive Vector3
  92805. * @param scene defines the hosting scene
  92806. * @param updatable defines if the mesh must be flagged as updatable
  92807. * @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).
  92808. * @returns a new Mesh
  92809. */
  92810. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  92811. /**
  92812. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92813. * @param name defines the name of the mesh to create
  92814. * @param points is an array successive Vector3
  92815. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92816. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92817. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92818. * @param scene defines the hosting scene
  92819. * @param updatable defines if the mesh must be flagged as updatable
  92820. * @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)
  92821. * @returns a new Mesh
  92822. */
  92823. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  92824. /**
  92825. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92826. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92827. * 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.
  92828. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92829. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92830. * Remember you can only change the shape positions, not their number when updating a polygon.
  92831. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92832. * @param name defines the name of the mesh to create
  92833. * @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
  92834. * @param scene defines the hosting scene
  92835. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92836. * @param updatable defines if the mesh must be flagged as updatable
  92837. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92838. * @param earcutInjection can be used to inject your own earcut reference
  92839. * @returns a new Mesh
  92840. */
  92841. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92842. /**
  92843. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92844. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92845. * @param name defines the name of the mesh to create
  92846. * @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
  92847. * @param depth defines the height of extrusion
  92848. * @param scene defines the hosting scene
  92849. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92850. * @param updatable defines if the mesh must be flagged as updatable
  92851. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92852. * @param earcutInjection can be used to inject your own earcut reference
  92853. * @returns a new Mesh
  92854. */
  92855. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92856. /**
  92857. * Creates an extruded shape mesh.
  92858. * 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
  92859. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92860. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92861. * @param name defines the name of the mesh to create
  92862. * @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
  92863. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92864. * @param scale is the value to scale the shape
  92865. * @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
  92866. * @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
  92867. * @param scene defines the hosting scene
  92868. * @param updatable defines if the mesh must be flagged as updatable
  92869. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92870. * @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)
  92871. * @returns a new Mesh
  92872. */
  92873. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92874. /**
  92875. * Creates an custom extruded shape mesh.
  92876. * The custom extrusion is a parametric shape.
  92877. * It has no predefined shape. Its final shape will depend on the input parameters.
  92878. * Please consider using the same method from the MeshBuilder class instead
  92879. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92880. * @param name defines the name of the mesh to create
  92881. * @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
  92882. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92883. * @param scaleFunction is a custom Javascript function called on each path point
  92884. * @param rotationFunction is a custom Javascript function called on each path point
  92885. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92886. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  92887. * @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
  92888. * @param scene defines the hosting scene
  92889. * @param updatable defines if the mesh must be flagged as updatable
  92890. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92891. * @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)
  92892. * @returns a new Mesh
  92893. */
  92894. 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;
  92895. /**
  92896. * Creates lathe mesh.
  92897. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  92898. * Please consider using the same method from the MeshBuilder class instead
  92899. * @param name defines the name of the mesh to create
  92900. * @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
  92901. * @param radius is the radius value of the lathe
  92902. * @param tessellation is the side number of the lathe.
  92903. * @param scene defines the hosting scene
  92904. * @param updatable defines if the mesh must be flagged as updatable
  92905. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92906. * @returns a new Mesh
  92907. */
  92908. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92909. /**
  92910. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  92911. * @param name defines the name of the mesh to create
  92912. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92913. * @param scene defines the hosting scene
  92914. * @param updatable defines if the mesh must be flagged as updatable
  92915. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92916. * @returns a new Mesh
  92917. */
  92918. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92919. /**
  92920. * Creates a ground mesh.
  92921. * Please consider using the same method from the MeshBuilder class instead
  92922. * @param name defines the name of the mesh to create
  92923. * @param width set the width of the ground
  92924. * @param height set the height of the ground
  92925. * @param subdivisions sets the number of subdivisions per side
  92926. * @param scene defines the hosting scene
  92927. * @param updatable defines if the mesh must be flagged as updatable
  92928. * @returns a new Mesh
  92929. */
  92930. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  92931. /**
  92932. * Creates a tiled ground mesh.
  92933. * Please consider using the same method from the MeshBuilder class instead
  92934. * @param name defines the name of the mesh to create
  92935. * @param xmin set the ground minimum X coordinate
  92936. * @param zmin set the ground minimum Y coordinate
  92937. * @param xmax set the ground maximum X coordinate
  92938. * @param zmax set the ground maximum Z coordinate
  92939. * @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
  92940. * @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
  92941. * @param scene defines the hosting scene
  92942. * @param updatable defines if the mesh must be flagged as updatable
  92943. * @returns a new Mesh
  92944. */
  92945. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  92946. w: number;
  92947. h: number;
  92948. }, precision: {
  92949. w: number;
  92950. h: number;
  92951. }, scene: Scene, updatable?: boolean): Mesh;
  92952. /**
  92953. * Creates a ground mesh from a height map.
  92954. * Please consider using the same method from the MeshBuilder class instead
  92955. * @see http://doc.babylonjs.com/babylon101/height_map
  92956. * @param name defines the name of the mesh to create
  92957. * @param url sets the URL of the height map image resource
  92958. * @param width set the ground width size
  92959. * @param height set the ground height size
  92960. * @param subdivisions sets the number of subdivision per side
  92961. * @param minHeight is the minimum altitude on the ground
  92962. * @param maxHeight is the maximum altitude on the ground
  92963. * @param scene defines the hosting scene
  92964. * @param updatable defines if the mesh must be flagged as updatable
  92965. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92966. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92967. * @returns a new Mesh
  92968. */
  92969. 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;
  92970. /**
  92971. * Creates a tube mesh.
  92972. * The tube is a parametric shape.
  92973. * It has no predefined shape. Its final shape will depend on the input parameters.
  92974. * Please consider using the same method from the MeshBuilder class instead
  92975. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92976. * @param name defines the name of the mesh to create
  92977. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92978. * @param radius sets the tube radius size
  92979. * @param tessellation is the number of sides on the tubular surface
  92980. * @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
  92981. * @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
  92982. * @param scene defines the hosting scene
  92983. * @param updatable defines if the mesh must be flagged as updatable
  92984. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92985. * @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)
  92986. * @returns a new Mesh
  92987. */
  92988. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92989. (i: number, distance: number): number;
  92990. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92991. /**
  92992. * Creates a polyhedron mesh.
  92993. * Please consider using the same method from the MeshBuilder class instead.
  92994. * * 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
  92995. * * The parameter `size` (positive float, default 1) sets the polygon size
  92996. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92997. * * 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`
  92998. * * 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
  92999. * * 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)`)
  93000. * * 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
  93001. * * 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
  93002. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93003. * * If you create a double-sided mesh, you can choose what parts of 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
  93004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93005. * @param name defines the name of the mesh to create
  93006. * @param options defines the options used to create the mesh
  93007. * @param scene defines the hosting scene
  93008. * @returns a new Mesh
  93009. */
  93010. static CreatePolyhedron(name: string, options: {
  93011. type?: number;
  93012. size?: number;
  93013. sizeX?: number;
  93014. sizeY?: number;
  93015. sizeZ?: number;
  93016. custom?: any;
  93017. faceUV?: Vector4[];
  93018. faceColors?: Color4[];
  93019. updatable?: boolean;
  93020. sideOrientation?: number;
  93021. }, scene: Scene): Mesh;
  93022. /**
  93023. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  93024. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  93025. * * 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`)
  93026. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  93027. * * 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
  93028. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93029. * * If you create a double-sided mesh, you can choose what parts of 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
  93030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93031. * @param name defines the name of the mesh
  93032. * @param options defines the options used to create the mesh
  93033. * @param scene defines the hosting scene
  93034. * @returns a new Mesh
  93035. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  93036. */
  93037. static CreateIcoSphere(name: string, options: {
  93038. radius?: number;
  93039. flat?: boolean;
  93040. subdivisions?: number;
  93041. sideOrientation?: number;
  93042. updatable?: boolean;
  93043. }, scene: Scene): Mesh;
  93044. /**
  93045. * Creates a decal mesh.
  93046. * Please consider using the same method from the MeshBuilder class instead.
  93047. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93048. * @param name defines the name of the mesh
  93049. * @param sourceMesh defines the mesh receiving the decal
  93050. * @param position sets the position of the decal in world coordinates
  93051. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93052. * @param size sets the decal scaling
  93053. * @param angle sets the angle to rotate the decal
  93054. * @returns a new Mesh
  93055. */
  93056. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93057. /**
  93058. * Prepare internal position array for software CPU skinning
  93059. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93060. */
  93061. setPositionsForCPUSkinning(): Float32Array;
  93062. /**
  93063. * Prepare internal normal array for software CPU skinning
  93064. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93065. */
  93066. setNormalsForCPUSkinning(): Float32Array;
  93067. /**
  93068. * Updates the vertex buffer by applying transformation from the bones
  93069. * @param skeleton defines the skeleton to apply to current mesh
  93070. * @returns the current mesh
  93071. */
  93072. applySkeleton(skeleton: Skeleton): Mesh;
  93073. /**
  93074. * 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
  93075. * @param meshes defines the list of meshes to scan
  93076. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93077. */
  93078. static MinMax(meshes: AbstractMesh[]): {
  93079. min: Vector3;
  93080. max: Vector3;
  93081. };
  93082. /**
  93083. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93084. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93085. * @returns a vector3
  93086. */
  93087. static Center(meshesOrMinMaxVector: {
  93088. min: Vector3;
  93089. max: Vector3;
  93090. } | AbstractMesh[]): Vector3;
  93091. /**
  93092. * Merge the array of meshes into a single mesh for performance reasons.
  93093. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93094. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93095. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93096. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93097. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93098. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93099. * @returns a new mesh
  93100. */
  93101. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93102. /** @hidden */
  93103. addInstance(instance: InstancedMesh): void;
  93104. /** @hidden */
  93105. removeInstance(instance: InstancedMesh): void;
  93106. }
  93107. }
  93108. declare module BABYLON {
  93109. /**
  93110. * This is the base class of all the camera used in the application.
  93111. * @see http://doc.babylonjs.com/features/cameras
  93112. */
  93113. export class Camera extends Node {
  93114. /** @hidden */
  93115. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93116. /**
  93117. * This is the default projection mode used by the cameras.
  93118. * It helps recreating a feeling of perspective and better appreciate depth.
  93119. * This is the best way to simulate real life cameras.
  93120. */
  93121. static readonly PERSPECTIVE_CAMERA: number;
  93122. /**
  93123. * This helps creating camera with an orthographic mode.
  93124. * 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.
  93125. */
  93126. static readonly ORTHOGRAPHIC_CAMERA: number;
  93127. /**
  93128. * This is the default FOV mode for perspective cameras.
  93129. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93130. */
  93131. static readonly FOVMODE_VERTICAL_FIXED: number;
  93132. /**
  93133. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93134. */
  93135. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93136. /**
  93137. * This specifies ther is no need for a camera rig.
  93138. * Basically only one eye is rendered corresponding to the camera.
  93139. */
  93140. static readonly RIG_MODE_NONE: number;
  93141. /**
  93142. * Simulates a camera Rig with one blue eye and one red eye.
  93143. * This can be use with 3d blue and red glasses.
  93144. */
  93145. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93146. /**
  93147. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93148. */
  93149. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93150. /**
  93151. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93152. */
  93153. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93154. /**
  93155. * Defines that both eyes of the camera will be rendered over under each other.
  93156. */
  93157. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93158. /**
  93159. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93160. */
  93161. static readonly RIG_MODE_VR: number;
  93162. /**
  93163. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93164. */
  93165. static readonly RIG_MODE_WEBVR: number;
  93166. /**
  93167. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93168. */
  93169. static readonly RIG_MODE_CUSTOM: number;
  93170. /**
  93171. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93172. */
  93173. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93174. /**
  93175. * Define the input manager associated with the camera.
  93176. */
  93177. inputs: CameraInputsManager<Camera>;
  93178. /** @hidden */
  93179. _position: Vector3;
  93180. /**
  93181. * Define the current local position of the camera in the scene
  93182. */
  93183. position: Vector3;
  93184. /**
  93185. * The vector the camera should consider as up.
  93186. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93187. */
  93188. upVector: Vector3;
  93189. /**
  93190. * Define the current limit on the left side for an orthographic camera
  93191. * In scene unit
  93192. */
  93193. orthoLeft: Nullable<number>;
  93194. /**
  93195. * Define the current limit on the right side for an orthographic camera
  93196. * In scene unit
  93197. */
  93198. orthoRight: Nullable<number>;
  93199. /**
  93200. * Define the current limit on the bottom side for an orthographic camera
  93201. * In scene unit
  93202. */
  93203. orthoBottom: Nullable<number>;
  93204. /**
  93205. * Define the current limit on the top side for an orthographic camera
  93206. * In scene unit
  93207. */
  93208. orthoTop: Nullable<number>;
  93209. /**
  93210. * Field Of View is set in Radians. (default is 0.8)
  93211. */
  93212. fov: number;
  93213. /**
  93214. * Define the minimum distance the camera can see from.
  93215. * This is important to note that the depth buffer are not infinite and the closer it starts
  93216. * the more your scene might encounter depth fighting issue.
  93217. */
  93218. minZ: number;
  93219. /**
  93220. * Define the maximum distance the camera can see to.
  93221. * This is important to note that the depth buffer are not infinite and the further it end
  93222. * the more your scene might encounter depth fighting issue.
  93223. */
  93224. maxZ: number;
  93225. /**
  93226. * Define the default inertia of the camera.
  93227. * This helps giving a smooth feeling to the camera movement.
  93228. */
  93229. inertia: number;
  93230. /**
  93231. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93232. */
  93233. mode: number;
  93234. /**
  93235. * Define wether the camera is intermediate.
  93236. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93237. */
  93238. isIntermediate: boolean;
  93239. /**
  93240. * Define the viewport of the camera.
  93241. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93242. */
  93243. viewport: Viewport;
  93244. /**
  93245. * Restricts the camera to viewing objects with the same layerMask.
  93246. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93247. */
  93248. layerMask: number;
  93249. /**
  93250. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93251. */
  93252. fovMode: number;
  93253. /**
  93254. * Rig mode of the camera.
  93255. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93256. * This is normally controlled byt the camera themselves as internal use.
  93257. */
  93258. cameraRigMode: number;
  93259. /**
  93260. * Defines the distance between both "eyes" in case of a RIG
  93261. */
  93262. interaxialDistance: number;
  93263. /**
  93264. * Defines if stereoscopic rendering is done side by side or over under.
  93265. */
  93266. isStereoscopicSideBySide: boolean;
  93267. /**
  93268. * 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
  93269. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93270. * else in the scene. (Eg. security camera)
  93271. *
  93272. * 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)
  93273. */
  93274. customRenderTargets: RenderTargetTexture[];
  93275. /**
  93276. * When set, the camera will render to this render target instead of the default canvas
  93277. *
  93278. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  93279. */
  93280. outputRenderTarget: Nullable<RenderTargetTexture>;
  93281. /**
  93282. * Observable triggered when the camera view matrix has changed.
  93283. */
  93284. onViewMatrixChangedObservable: Observable<Camera>;
  93285. /**
  93286. * Observable triggered when the camera Projection matrix has changed.
  93287. */
  93288. onProjectionMatrixChangedObservable: Observable<Camera>;
  93289. /**
  93290. * Observable triggered when the inputs have been processed.
  93291. */
  93292. onAfterCheckInputsObservable: Observable<Camera>;
  93293. /**
  93294. * Observable triggered when reset has been called and applied to the camera.
  93295. */
  93296. onRestoreStateObservable: Observable<Camera>;
  93297. /** @hidden */
  93298. _cameraRigParams: any;
  93299. /** @hidden */
  93300. _rigCameras: Camera[];
  93301. /** @hidden */
  93302. _rigPostProcess: Nullable<PostProcess>;
  93303. protected _webvrViewMatrix: Matrix;
  93304. /** @hidden */
  93305. _skipRendering: boolean;
  93306. /** @hidden */
  93307. _projectionMatrix: Matrix;
  93308. /** @hidden */
  93309. _postProcesses: Nullable<PostProcess>[];
  93310. /** @hidden */
  93311. _activeMeshes: SmartArray<AbstractMesh>;
  93312. protected _globalPosition: Vector3;
  93313. /** @hidden */
  93314. _computedViewMatrix: Matrix;
  93315. private _doNotComputeProjectionMatrix;
  93316. private _transformMatrix;
  93317. private _frustumPlanes;
  93318. private _refreshFrustumPlanes;
  93319. private _storedFov;
  93320. private _stateStored;
  93321. /**
  93322. * Instantiates a new camera object.
  93323. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93324. * @see http://doc.babylonjs.com/features/cameras
  93325. * @param name Defines the name of the camera in the scene
  93326. * @param position Defines the position of the camera
  93327. * @param scene Defines the scene the camera belongs too
  93328. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93329. */
  93330. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93331. /**
  93332. * Store current camera state (fov, position, etc..)
  93333. * @returns the camera
  93334. */
  93335. storeState(): Camera;
  93336. /**
  93337. * Restores the camera state values if it has been stored. You must call storeState() first
  93338. */
  93339. protected _restoreStateValues(): boolean;
  93340. /**
  93341. * Restored camera state. You must call storeState() first.
  93342. * @returns true if restored and false otherwise
  93343. */
  93344. restoreState(): boolean;
  93345. /**
  93346. * Gets the class name of the camera.
  93347. * @returns the class name
  93348. */
  93349. getClassName(): string;
  93350. /** @hidden */
  93351. readonly _isCamera: boolean;
  93352. /**
  93353. * Gets a string representation of the camera useful for debug purpose.
  93354. * @param fullDetails Defines that a more verboe level of logging is required
  93355. * @returns the string representation
  93356. */
  93357. toString(fullDetails?: boolean): string;
  93358. /**
  93359. * Gets the current world space position of the camera.
  93360. */
  93361. readonly globalPosition: Vector3;
  93362. /**
  93363. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93364. * @returns the active meshe list
  93365. */
  93366. getActiveMeshes(): SmartArray<AbstractMesh>;
  93367. /**
  93368. * Check wether a mesh is part of the current active mesh list of the camera
  93369. * @param mesh Defines the mesh to check
  93370. * @returns true if active, false otherwise
  93371. */
  93372. isActiveMesh(mesh: Mesh): boolean;
  93373. /**
  93374. * Is this camera ready to be used/rendered
  93375. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93376. * @return true if the camera is ready
  93377. */
  93378. isReady(completeCheck?: boolean): boolean;
  93379. /** @hidden */
  93380. _initCache(): void;
  93381. /** @hidden */
  93382. _updateCache(ignoreParentClass?: boolean): void;
  93383. /** @hidden */
  93384. _isSynchronized(): boolean;
  93385. /** @hidden */
  93386. _isSynchronizedViewMatrix(): boolean;
  93387. /** @hidden */
  93388. _isSynchronizedProjectionMatrix(): boolean;
  93389. /**
  93390. * Attach the input controls to a specific dom element to get the input from.
  93391. * @param element Defines the element the controls should be listened from
  93392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93393. */
  93394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93395. /**
  93396. * Detach the current controls from the specified dom element.
  93397. * @param element Defines the element to stop listening the inputs from
  93398. */
  93399. detachControl(element: HTMLElement): void;
  93400. /**
  93401. * Update the camera state according to the different inputs gathered during the frame.
  93402. */
  93403. update(): void;
  93404. /** @hidden */
  93405. _checkInputs(): void;
  93406. /** @hidden */
  93407. readonly rigCameras: Camera[];
  93408. /**
  93409. * Gets the post process used by the rig cameras
  93410. */
  93411. readonly rigPostProcess: Nullable<PostProcess>;
  93412. /**
  93413. * Internal, gets the first post proces.
  93414. * @returns the first post process to be run on this camera.
  93415. */
  93416. _getFirstPostProcess(): Nullable<PostProcess>;
  93417. private _cascadePostProcessesToRigCams;
  93418. /**
  93419. * Attach a post process to the camera.
  93420. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93421. * @param postProcess The post process to attach to the camera
  93422. * @param insertAt The position of the post process in case several of them are in use in the scene
  93423. * @returns the position the post process has been inserted at
  93424. */
  93425. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93426. /**
  93427. * Detach a post process to the camera.
  93428. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93429. * @param postProcess The post process to detach from the camera
  93430. */
  93431. detachPostProcess(postProcess: PostProcess): void;
  93432. /**
  93433. * Gets the current world matrix of the camera
  93434. */
  93435. getWorldMatrix(): Matrix;
  93436. /** @hidden */
  93437. _getViewMatrix(): Matrix;
  93438. /**
  93439. * Gets the current view matrix of the camera.
  93440. * @param force forces the camera to recompute the matrix without looking at the cached state
  93441. * @returns the view matrix
  93442. */
  93443. getViewMatrix(force?: boolean): Matrix;
  93444. /**
  93445. * Freeze the projection matrix.
  93446. * It will prevent the cache check of the camera projection compute and can speed up perf
  93447. * if no parameter of the camera are meant to change
  93448. * @param projection Defines manually a projection if necessary
  93449. */
  93450. freezeProjectionMatrix(projection?: Matrix): void;
  93451. /**
  93452. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93453. */
  93454. unfreezeProjectionMatrix(): void;
  93455. /**
  93456. * Gets the current projection matrix of the camera.
  93457. * @param force forces the camera to recompute the matrix without looking at the cached state
  93458. * @returns the projection matrix
  93459. */
  93460. getProjectionMatrix(force?: boolean): Matrix;
  93461. /**
  93462. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93463. * @returns a Matrix
  93464. */
  93465. getTransformationMatrix(): Matrix;
  93466. private _updateFrustumPlanes;
  93467. /**
  93468. * Checks if a cullable object (mesh...) is in the camera frustum
  93469. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93470. * @param target The object to check
  93471. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93472. * @returns true if the object is in frustum otherwise false
  93473. */
  93474. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93475. /**
  93476. * Checks if a cullable object (mesh...) is in the camera frustum
  93477. * Unlike isInFrustum this cheks the full bounding box
  93478. * @param target The object to check
  93479. * @returns true if the object is in frustum otherwise false
  93480. */
  93481. isCompletelyInFrustum(target: ICullable): boolean;
  93482. /**
  93483. * Gets a ray in the forward direction from the camera.
  93484. * @param length Defines the length of the ray to create
  93485. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93486. * @param origin Defines the start point of the ray which defaults to the camera position
  93487. * @returns the forward ray
  93488. */
  93489. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93490. /**
  93491. * Releases resources associated with this node.
  93492. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93493. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93494. */
  93495. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93496. /** @hidden */
  93497. _isLeftCamera: boolean;
  93498. /**
  93499. * Gets the left camera of a rig setup in case of Rigged Camera
  93500. */
  93501. readonly isLeftCamera: boolean;
  93502. /** @hidden */
  93503. _isRightCamera: boolean;
  93504. /**
  93505. * Gets the right camera of a rig setup in case of Rigged Camera
  93506. */
  93507. readonly isRightCamera: boolean;
  93508. /**
  93509. * Gets the left camera of a rig setup in case of Rigged Camera
  93510. */
  93511. readonly leftCamera: Nullable<FreeCamera>;
  93512. /**
  93513. * Gets the right camera of a rig setup in case of Rigged Camera
  93514. */
  93515. readonly rightCamera: Nullable<FreeCamera>;
  93516. /**
  93517. * Gets the left camera target of a rig setup in case of Rigged Camera
  93518. * @returns the target position
  93519. */
  93520. getLeftTarget(): Nullable<Vector3>;
  93521. /**
  93522. * Gets the right camera target of a rig setup in case of Rigged Camera
  93523. * @returns the target position
  93524. */
  93525. getRightTarget(): Nullable<Vector3>;
  93526. /**
  93527. * @hidden
  93528. */
  93529. setCameraRigMode(mode: number, rigParams: any): void;
  93530. /** @hidden */
  93531. static _setStereoscopicRigMode(camera: Camera): void;
  93532. /** @hidden */
  93533. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93534. /** @hidden */
  93535. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93536. /** @hidden */
  93537. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93538. /** @hidden */
  93539. _getVRProjectionMatrix(): Matrix;
  93540. protected _updateCameraRotationMatrix(): void;
  93541. protected _updateWebVRCameraRotationMatrix(): void;
  93542. /**
  93543. * This function MUST be overwritten by the different WebVR cameras available.
  93544. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93545. * @hidden
  93546. */
  93547. _getWebVRProjectionMatrix(): Matrix;
  93548. /**
  93549. * This function MUST be overwritten by the different WebVR cameras available.
  93550. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93551. * @hidden
  93552. */
  93553. _getWebVRViewMatrix(): Matrix;
  93554. /** @hidden */
  93555. setCameraRigParameter(name: string, value: any): void;
  93556. /**
  93557. * needs to be overridden by children so sub has required properties to be copied
  93558. * @hidden
  93559. */
  93560. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93561. /**
  93562. * May need to be overridden by children
  93563. * @hidden
  93564. */
  93565. _updateRigCameras(): void;
  93566. /** @hidden */
  93567. _setupInputs(): void;
  93568. /**
  93569. * Serialiaze the camera setup to a json represention
  93570. * @returns the JSON representation
  93571. */
  93572. serialize(): any;
  93573. /**
  93574. * Clones the current camera.
  93575. * @param name The cloned camera name
  93576. * @returns the cloned camera
  93577. */
  93578. clone(name: string): Camera;
  93579. /**
  93580. * Gets the direction of the camera relative to a given local axis.
  93581. * @param localAxis Defines the reference axis to provide a relative direction.
  93582. * @return the direction
  93583. */
  93584. getDirection(localAxis: Vector3): Vector3;
  93585. /**
  93586. * Returns the current camera absolute rotation
  93587. */
  93588. readonly absoluteRotation: Quaternion;
  93589. /**
  93590. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93591. * @param localAxis Defines the reference axis to provide a relative direction.
  93592. * @param result Defines the vector to store the result in
  93593. */
  93594. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93595. /**
  93596. * Gets a camera constructor for a given camera type
  93597. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93598. * @param name The name of the camera the result will be able to instantiate
  93599. * @param scene The scene the result will construct the camera in
  93600. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93601. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93602. * @returns a factory method to construc the camera
  93603. */
  93604. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93605. /**
  93606. * Compute the world matrix of the camera.
  93607. * @returns the camera world matrix
  93608. */
  93609. computeWorldMatrix(): Matrix;
  93610. /**
  93611. * Parse a JSON and creates the camera from the parsed information
  93612. * @param parsedCamera The JSON to parse
  93613. * @param scene The scene to instantiate the camera in
  93614. * @returns the newly constructed camera
  93615. */
  93616. static Parse(parsedCamera: any, scene: Scene): Camera;
  93617. }
  93618. }
  93619. declare module BABYLON {
  93620. /**
  93621. * Class containing static functions to help procedurally build meshes
  93622. */
  93623. export class DiscBuilder {
  93624. /**
  93625. * Creates a plane polygonal mesh. By default, this is a disc
  93626. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93627. * * 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
  93628. * * 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
  93629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93632. * @param name defines the name of the mesh
  93633. * @param options defines the options used to create the mesh
  93634. * @param scene defines the hosting scene
  93635. * @returns the plane polygonal mesh
  93636. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93637. */
  93638. static CreateDisc(name: string, options: {
  93639. radius?: number;
  93640. tessellation?: number;
  93641. arc?: number;
  93642. updatable?: boolean;
  93643. sideOrientation?: number;
  93644. frontUVs?: Vector4;
  93645. backUVs?: Vector4;
  93646. }, scene?: Nullable<Scene>): Mesh;
  93647. }
  93648. }
  93649. declare module BABYLON {
  93650. /**
  93651. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93652. *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.
  93653. * The SPS is also a particle system. It provides some methods to manage the particles.
  93654. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  93655. *
  93656. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  93657. */
  93658. export class SolidParticleSystem implements IDisposable {
  93659. /**
  93660. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  93661. * Example : var p = SPS.particles[i];
  93662. */
  93663. particles: SolidParticle[];
  93664. /**
  93665. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  93666. */
  93667. nbParticles: number;
  93668. /**
  93669. * If the particles must ever face the camera (default false). Useful for planar particles.
  93670. */
  93671. billboard: boolean;
  93672. /**
  93673. * Recompute normals when adding a shape
  93674. */
  93675. recomputeNormals: boolean;
  93676. /**
  93677. * This a counter ofr your own usage. It's not set by any SPS functions.
  93678. */
  93679. counter: number;
  93680. /**
  93681. * The SPS name. This name is also given to the underlying mesh.
  93682. */
  93683. name: string;
  93684. /**
  93685. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93686. */
  93687. mesh: Mesh;
  93688. /**
  93689. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93690. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93691. */
  93692. vars: any;
  93693. /**
  93694. * This array is populated when the SPS is set as 'pickable'.
  93695. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93696. * Each element of this array is an object `{idx: int, faceId: int}`.
  93697. * `idx` is the picked particle index in the `SPS.particles` array
  93698. * `faceId` is the picked face index counted within this particle.
  93699. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93700. */
  93701. pickedParticles: {
  93702. idx: number;
  93703. faceId: number;
  93704. }[];
  93705. /**
  93706. * This array is populated when `enableDepthSort` is set to true.
  93707. * Each element of this array is an instance of the class DepthSortedParticle.
  93708. */
  93709. depthSortedParticles: DepthSortedParticle[];
  93710. /**
  93711. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93712. * @hidden
  93713. */
  93714. _bSphereOnly: boolean;
  93715. /**
  93716. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93717. * @hidden
  93718. */
  93719. _bSphereRadiusFactor: number;
  93720. private _scene;
  93721. private _positions;
  93722. private _indices;
  93723. private _normals;
  93724. private _colors;
  93725. private _uvs;
  93726. private _indices32;
  93727. private _positions32;
  93728. private _normals32;
  93729. private _fixedNormal32;
  93730. private _colors32;
  93731. private _uvs32;
  93732. private _index;
  93733. private _updatable;
  93734. private _pickable;
  93735. private _isVisibilityBoxLocked;
  93736. private _alwaysVisible;
  93737. private _depthSort;
  93738. private _expandable;
  93739. private _shapeCounter;
  93740. private _copy;
  93741. private _color;
  93742. private _computeParticleColor;
  93743. private _computeParticleTexture;
  93744. private _computeParticleRotation;
  93745. private _computeParticleVertex;
  93746. private _computeBoundingBox;
  93747. private _depthSortParticles;
  93748. private _camera;
  93749. private _mustUnrotateFixedNormals;
  93750. private _particlesIntersect;
  93751. private _needs32Bits;
  93752. private _isNotBuilt;
  93753. private _lastParticleId;
  93754. private _idxOfId;
  93755. /**
  93756. * Creates a SPS (Solid Particle System) object.
  93757. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93758. * @param scene (Scene) is the scene in which the SPS is added.
  93759. * @param options defines the options of the sps e.g.
  93760. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  93761. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  93762. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  93763. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  93764. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  93765. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  93766. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  93767. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  93768. */
  93769. constructor(name: string, scene: Scene, options?: {
  93770. updatable?: boolean;
  93771. isPickable?: boolean;
  93772. enableDepthSort?: boolean;
  93773. particleIntersection?: boolean;
  93774. boundingSphereOnly?: boolean;
  93775. bSphereRadiusFactor?: number;
  93776. expandable?: boolean;
  93777. });
  93778. /**
  93779. * Builds the SPS underlying mesh. Returns a standard Mesh.
  93780. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  93781. * @returns the created mesh
  93782. */
  93783. buildMesh(): Mesh;
  93784. /**
  93785. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  93786. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  93787. * Thus the particles generated from `digest()` have their property `position` set yet.
  93788. * @param mesh ( Mesh ) is the mesh to be digested
  93789. * @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
  93790. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  93791. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  93792. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93793. * @returns the current SPS
  93794. */
  93795. digest(mesh: Mesh, options?: {
  93796. facetNb?: number;
  93797. number?: number;
  93798. delta?: number;
  93799. storage?: [];
  93800. }): SolidParticleSystem;
  93801. /**
  93802. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  93803. * @hidden
  93804. */
  93805. private _unrotateFixedNormals;
  93806. /**
  93807. * Resets the temporary working copy particle
  93808. * @hidden
  93809. */
  93810. private _resetCopy;
  93811. /**
  93812. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  93813. * @param p the current index in the positions array to be updated
  93814. * @param shape a Vector3 array, the shape geometry
  93815. * @param positions the positions array to be updated
  93816. * @param meshInd the shape indices array
  93817. * @param indices the indices array to be updated
  93818. * @param meshUV the shape uv array
  93819. * @param uvs the uv array to be updated
  93820. * @param meshCol the shape color array
  93821. * @param colors the color array to be updated
  93822. * @param meshNor the shape normals array
  93823. * @param normals the normals array to be updated
  93824. * @param idx the particle index
  93825. * @param idxInShape the particle index in its shape
  93826. * @param options the addShape() method passed options
  93827. * @hidden
  93828. */
  93829. private _meshBuilder;
  93830. /**
  93831. * Returns a shape Vector3 array from positions float array
  93832. * @param positions float array
  93833. * @returns a vector3 array
  93834. * @hidden
  93835. */
  93836. private _posToShape;
  93837. /**
  93838. * Returns a shapeUV array from a float uvs (array deep copy)
  93839. * @param uvs as a float array
  93840. * @returns a shapeUV array
  93841. * @hidden
  93842. */
  93843. private _uvsToShapeUV;
  93844. /**
  93845. * Adds a new particle object in the particles array
  93846. * @param idx particle index in particles array
  93847. * @param id particle id
  93848. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  93849. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  93850. * @param model particle ModelShape object
  93851. * @param shapeId model shape identifier
  93852. * @param idxInShape index of the particle in the current model
  93853. * @param bInfo model bounding info object
  93854. * @param storage target storage array, if any
  93855. * @hidden
  93856. */
  93857. private _addParticle;
  93858. /**
  93859. * Adds some particles to the SPS from the model shape. Returns the shape id.
  93860. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  93861. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  93862. * @param nb (positive integer) the number of particles to be created from this model
  93863. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  93864. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  93865. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93866. * @returns the number of shapes in the system
  93867. */
  93868. addShape(mesh: Mesh, nb: number, options?: {
  93869. positionFunction?: any;
  93870. vertexFunction?: any;
  93871. storage?: [];
  93872. }): number;
  93873. /**
  93874. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  93875. * @hidden
  93876. */
  93877. private _rebuildParticle;
  93878. /**
  93879. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  93880. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  93881. * @returns the SPS.
  93882. */
  93883. rebuildMesh(reset?: boolean): SolidParticleSystem;
  93884. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  93885. * Returns an array with the removed particles.
  93886. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  93887. * The SPS can't be empty so at least one particle needs to remain in place.
  93888. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  93889. * @param start index of the first particle to remove
  93890. * @param end index of the last particle to remove (included)
  93891. * @returns an array populated with the removed particles
  93892. */
  93893. removeParticles(start: number, end: number): SolidParticle[];
  93894. /**
  93895. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  93896. * @param solidParticleArray an array populated with Solid Particles objects
  93897. * @returns the SPS
  93898. */
  93899. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  93900. /**
  93901. * Creates a new particle and modifies the SPS mesh geometry :
  93902. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  93903. * - calls _addParticle() to populate the particle array
  93904. * factorized code from addShape() and insertParticlesFromArray()
  93905. * @param idx particle index in the particles array
  93906. * @param i particle index in its shape
  93907. * @param modelShape particle ModelShape object
  93908. * @param shape shape vertex array
  93909. * @param meshInd shape indices array
  93910. * @param meshUV shape uv array
  93911. * @param meshCol shape color array
  93912. * @param meshNor shape normals array
  93913. * @param bbInfo shape bounding info
  93914. * @param storage target particle storage
  93915. * @options addShape() passed options
  93916. * @hidden
  93917. */
  93918. private _insertNewParticle;
  93919. /**
  93920. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  93921. * This method calls `updateParticle()` for each particle of the SPS.
  93922. * For an animated SPS, it is usually called within the render loop.
  93923. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  93924. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  93925. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  93926. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  93927. * @returns the SPS.
  93928. */
  93929. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  93930. /**
  93931. * Disposes the SPS.
  93932. */
  93933. dispose(): void;
  93934. /**
  93935. * Returns a SolidParticle object from its identifier : particle.id
  93936. * @param id (integer) the particle Id
  93937. * @returns the searched particle or null if not found in the SPS.
  93938. */
  93939. getParticleById(id: number): Nullable<SolidParticle>;
  93940. /**
  93941. * Returns a new array populated with the particles having the passed shapeId.
  93942. * @param shapeId (integer) the shape identifier
  93943. * @returns a new solid particle array
  93944. */
  93945. getParticlesByShapeId(shapeId: number): SolidParticle[];
  93946. /**
  93947. * Populates the passed array "ref" with the particles having the passed shapeId.
  93948. * @param shapeId the shape identifier
  93949. * @returns the SPS
  93950. * @param ref
  93951. */
  93952. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  93953. /**
  93954. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  93955. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93956. * @returns the SPS.
  93957. */
  93958. refreshVisibleSize(): SolidParticleSystem;
  93959. /**
  93960. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  93961. * @param size the size (float) of the visibility box
  93962. * note : this doesn't lock the SPS mesh bounding box.
  93963. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93964. */
  93965. setVisibilityBox(size: number): void;
  93966. /**
  93967. * Gets whether the SPS as always visible or not
  93968. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93969. */
  93970. /**
  93971. * Sets the SPS as always visible or not
  93972. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93973. */
  93974. isAlwaysVisible: boolean;
  93975. /**
  93976. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93977. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93978. */
  93979. /**
  93980. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93981. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93982. */
  93983. isVisibilityBoxLocked: boolean;
  93984. /**
  93985. * Tells to `setParticles()` to compute the particle rotations or not.
  93986. * Default value : true. The SPS is faster when it's set to false.
  93987. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93988. */
  93989. /**
  93990. * Gets if `setParticles()` computes the particle rotations or not.
  93991. * Default value : true. The SPS is faster when it's set to false.
  93992. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93993. */
  93994. computeParticleRotation: boolean;
  93995. /**
  93996. * Tells to `setParticles()` to compute the particle colors or not.
  93997. * Default value : true. The SPS is faster when it's set to false.
  93998. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93999. */
  94000. /**
  94001. * Gets if `setParticles()` computes the particle colors or not.
  94002. * Default value : true. The SPS is faster when it's set to false.
  94003. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  94004. */
  94005. computeParticleColor: boolean;
  94006. /**
  94007. * Gets if `setParticles()` computes the particle textures or not.
  94008. * Default value : true. The SPS is faster when it's set to false.
  94009. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  94010. */
  94011. computeParticleTexture: boolean;
  94012. /**
  94013. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  94014. * Default value : false. The SPS is faster when it's set to false.
  94015. * Note : the particle custom vertex positions aren't stored values.
  94016. */
  94017. /**
  94018. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  94019. * Default value : false. The SPS is faster when it's set to false.
  94020. * Note : the particle custom vertex positions aren't stored values.
  94021. */
  94022. computeParticleVertex: boolean;
  94023. /**
  94024. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  94025. */
  94026. /**
  94027. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  94028. */
  94029. computeBoundingBox: boolean;
  94030. /**
  94031. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  94032. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94033. * Default : `true`
  94034. */
  94035. /**
  94036. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  94037. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94038. * Default : `true`
  94039. */
  94040. depthSortParticles: boolean;
  94041. /**
  94042. * Gets if the SPS is created as expandable at construction time.
  94043. * Default : `false`
  94044. */
  94045. readonly expandable: boolean;
  94046. /**
  94047. * This function does nothing. It may be overwritten to set all the particle first values.
  94048. * The SPS doesn't call this function, you may have to call it by your own.
  94049. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94050. */
  94051. initParticles(): void;
  94052. /**
  94053. * This function does nothing. It may be overwritten to recycle a particle.
  94054. * The SPS doesn't call this function, you may have to call it by your own.
  94055. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94056. * @param particle The particle to recycle
  94057. * @returns the recycled particle
  94058. */
  94059. recycleParticle(particle: SolidParticle): SolidParticle;
  94060. /**
  94061. * Updates a particle : this function should be overwritten by the user.
  94062. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  94063. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94064. * @example : just set a particle position or velocity and recycle conditions
  94065. * @param particle The particle to update
  94066. * @returns the updated particle
  94067. */
  94068. updateParticle(particle: SolidParticle): SolidParticle;
  94069. /**
  94070. * Updates a vertex of a particle : it can be overwritten by the user.
  94071. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  94072. * @param particle the current particle
  94073. * @param vertex the current index of the current particle
  94074. * @param pt the index of the current vertex in the particle shape
  94075. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  94076. * @example : just set a vertex particle position
  94077. * @returns the updated vertex
  94078. */
  94079. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  94080. /**
  94081. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  94082. * This does nothing and may be overwritten by the user.
  94083. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94084. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94085. * @param update the boolean update value actually passed to setParticles()
  94086. */
  94087. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94088. /**
  94089. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  94090. * This will be passed three parameters.
  94091. * This does nothing and may be overwritten by the user.
  94092. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94093. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94094. * @param update the boolean update value actually passed to setParticles()
  94095. */
  94096. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94097. }
  94098. }
  94099. declare module BABYLON {
  94100. /**
  94101. * Represents one particle of a solid particle system.
  94102. */
  94103. export class SolidParticle {
  94104. /**
  94105. * particle global index
  94106. */
  94107. idx: number;
  94108. /**
  94109. * particle identifier
  94110. */
  94111. id: number;
  94112. /**
  94113. * The color of the particle
  94114. */
  94115. color: Nullable<Color4>;
  94116. /**
  94117. * The world space position of the particle.
  94118. */
  94119. position: Vector3;
  94120. /**
  94121. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  94122. */
  94123. rotation: Vector3;
  94124. /**
  94125. * The world space rotation quaternion of the particle.
  94126. */
  94127. rotationQuaternion: Nullable<Quaternion>;
  94128. /**
  94129. * The scaling of the particle.
  94130. */
  94131. scaling: Vector3;
  94132. /**
  94133. * The uvs of the particle.
  94134. */
  94135. uvs: Vector4;
  94136. /**
  94137. * The current speed of the particle.
  94138. */
  94139. velocity: Vector3;
  94140. /**
  94141. * The pivot point in the particle local space.
  94142. */
  94143. pivot: Vector3;
  94144. /**
  94145. * Must the particle be translated from its pivot point in its local space ?
  94146. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  94147. * Default : false
  94148. */
  94149. translateFromPivot: boolean;
  94150. /**
  94151. * Is the particle active or not ?
  94152. */
  94153. alive: boolean;
  94154. /**
  94155. * Is the particle visible or not ?
  94156. */
  94157. isVisible: boolean;
  94158. /**
  94159. * Index of this particle in the global "positions" array (Internal use)
  94160. * @hidden
  94161. */
  94162. _pos: number;
  94163. /**
  94164. * @hidden Index of this particle in the global "indices" array (Internal use)
  94165. */
  94166. _ind: number;
  94167. /**
  94168. * @hidden ModelShape of this particle (Internal use)
  94169. */
  94170. _model: ModelShape;
  94171. /**
  94172. * ModelShape id of this particle
  94173. */
  94174. shapeId: number;
  94175. /**
  94176. * Index of the particle in its shape id
  94177. */
  94178. idxInShape: number;
  94179. /**
  94180. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  94181. */
  94182. _modelBoundingInfo: BoundingInfo;
  94183. /**
  94184. * @hidden Particle BoundingInfo object (Internal use)
  94185. */
  94186. _boundingInfo: BoundingInfo;
  94187. /**
  94188. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  94189. */
  94190. _sps: SolidParticleSystem;
  94191. /**
  94192. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  94193. */
  94194. _stillInvisible: boolean;
  94195. /**
  94196. * @hidden Last computed particle rotation matrix
  94197. */
  94198. _rotationMatrix: number[];
  94199. /**
  94200. * Parent particle Id, if any.
  94201. * Default null.
  94202. */
  94203. parentId: Nullable<number>;
  94204. /**
  94205. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  94206. * The possible values are :
  94207. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94208. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94209. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94210. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94211. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94212. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  94213. * */
  94214. cullingStrategy: number;
  94215. /**
  94216. * @hidden Internal global position in the SPS.
  94217. */
  94218. _globalPosition: Vector3;
  94219. /**
  94220. * Creates a Solid Particle object.
  94221. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  94222. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  94223. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  94224. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  94225. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  94226. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  94227. * @param shapeId (integer) is the model shape identifier in the SPS.
  94228. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  94229. * @param sps defines the sps it is associated to
  94230. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  94231. */
  94232. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  94233. /**
  94234. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  94235. * @param target the particle target
  94236. * @returns the current particle
  94237. */
  94238. copyToRef(target: SolidParticle): SolidParticle;
  94239. /**
  94240. * Legacy support, changed scale to scaling
  94241. */
  94242. /**
  94243. * Legacy support, changed scale to scaling
  94244. */
  94245. scale: Vector3;
  94246. /**
  94247. * Legacy support, changed quaternion to rotationQuaternion
  94248. */
  94249. /**
  94250. * Legacy support, changed quaternion to rotationQuaternion
  94251. */
  94252. quaternion: Nullable<Quaternion>;
  94253. /**
  94254. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  94255. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  94256. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  94257. * @returns true if it intersects
  94258. */
  94259. intersectsMesh(target: Mesh | SolidParticle): boolean;
  94260. /**
  94261. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  94262. * A particle is in the frustum if its bounding box intersects the frustum
  94263. * @param frustumPlanes defines the frustum to test
  94264. * @returns true if the particle is in the frustum planes
  94265. */
  94266. isInFrustum(frustumPlanes: Plane[]): boolean;
  94267. /**
  94268. * get the rotation matrix of the particle
  94269. * @hidden
  94270. */
  94271. getRotationMatrix(m: Matrix): void;
  94272. }
  94273. /**
  94274. * Represents the shape of the model used by one particle of a solid particle system.
  94275. * SPS internal tool, don't use it manually.
  94276. */
  94277. export class ModelShape {
  94278. /**
  94279. * The shape id
  94280. * @hidden
  94281. */
  94282. shapeID: number;
  94283. /**
  94284. * flat array of model positions (internal use)
  94285. * @hidden
  94286. */
  94287. _shape: Vector3[];
  94288. /**
  94289. * flat array of model UVs (internal use)
  94290. * @hidden
  94291. */
  94292. _shapeUV: number[];
  94293. /**
  94294. * color array of the model
  94295. * @hidden
  94296. */
  94297. _shapeColors: number[];
  94298. /**
  94299. * indices array of the model
  94300. * @hidden
  94301. */
  94302. _indices: number[];
  94303. /**
  94304. * normals array of the model
  94305. * @hidden
  94306. */
  94307. _normals: number[];
  94308. /**
  94309. * length of the shape in the model indices array (internal use)
  94310. * @hidden
  94311. */
  94312. _indicesLength: number;
  94313. /**
  94314. * Custom position function (internal use)
  94315. * @hidden
  94316. */
  94317. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  94318. /**
  94319. * Custom vertex function (internal use)
  94320. * @hidden
  94321. */
  94322. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  94323. /**
  94324. * 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.
  94325. * SPS internal tool, don't use it manually.
  94326. * @hidden
  94327. */
  94328. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  94329. }
  94330. /**
  94331. * Represents a Depth Sorted Particle in the solid particle system.
  94332. */
  94333. export class DepthSortedParticle {
  94334. /**
  94335. * Index of the particle in the "indices" array
  94336. */
  94337. ind: number;
  94338. /**
  94339. * Length of the particle shape in the "indices" array
  94340. */
  94341. indicesLength: number;
  94342. /**
  94343. * Squared distance from the particle to the camera
  94344. */
  94345. sqDistance: number;
  94346. }
  94347. }
  94348. declare module BABYLON {
  94349. /**
  94350. * @hidden
  94351. */
  94352. export class _MeshCollisionData {
  94353. _checkCollisions: boolean;
  94354. _collisionMask: number;
  94355. _collisionGroup: number;
  94356. _collider: Nullable<Collider>;
  94357. _oldPositionForCollisions: Vector3;
  94358. _diffPositionForCollisions: Vector3;
  94359. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  94360. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  94361. }
  94362. }
  94363. declare module BABYLON {
  94364. /** @hidden */
  94365. class _FacetDataStorage {
  94366. facetPositions: Vector3[];
  94367. facetNormals: Vector3[];
  94368. facetPartitioning: number[][];
  94369. facetNb: number;
  94370. partitioningSubdivisions: number;
  94371. partitioningBBoxRatio: number;
  94372. facetDataEnabled: boolean;
  94373. facetParameters: any;
  94374. bbSize: Vector3;
  94375. subDiv: {
  94376. max: number;
  94377. X: number;
  94378. Y: number;
  94379. Z: number;
  94380. };
  94381. facetDepthSort: boolean;
  94382. facetDepthSortEnabled: boolean;
  94383. depthSortedIndices: IndicesArray;
  94384. depthSortedFacets: {
  94385. ind: number;
  94386. sqDistance: number;
  94387. }[];
  94388. facetDepthSortFunction: (f1: {
  94389. ind: number;
  94390. sqDistance: number;
  94391. }, f2: {
  94392. ind: number;
  94393. sqDistance: number;
  94394. }) => number;
  94395. facetDepthSortFrom: Vector3;
  94396. facetDepthSortOrigin: Vector3;
  94397. invertedMatrix: Matrix;
  94398. }
  94399. /**
  94400. * @hidden
  94401. **/
  94402. class _InternalAbstractMeshDataInfo {
  94403. _hasVertexAlpha: boolean;
  94404. _useVertexColors: boolean;
  94405. _numBoneInfluencers: number;
  94406. _applyFog: boolean;
  94407. _receiveShadows: boolean;
  94408. _facetData: _FacetDataStorage;
  94409. _visibility: number;
  94410. _skeleton: Nullable<Skeleton>;
  94411. _layerMask: number;
  94412. _computeBonesUsingShaders: boolean;
  94413. _isActive: boolean;
  94414. _onlyForInstances: boolean;
  94415. _isActiveIntermediate: boolean;
  94416. _onlyForInstancesIntermediate: boolean;
  94417. _actAsRegularMesh: boolean;
  94418. }
  94419. /**
  94420. * Class used to store all common mesh properties
  94421. */
  94422. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  94423. /** No occlusion */
  94424. static OCCLUSION_TYPE_NONE: number;
  94425. /** Occlusion set to optimisitic */
  94426. static OCCLUSION_TYPE_OPTIMISTIC: number;
  94427. /** Occlusion set to strict */
  94428. static OCCLUSION_TYPE_STRICT: number;
  94429. /** Use an accurante occlusion algorithm */
  94430. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  94431. /** Use a conservative occlusion algorithm */
  94432. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  94433. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94434. * Test order :
  94435. * Is the bounding sphere outside the frustum ?
  94436. * If not, are the bounding box vertices outside the frustum ?
  94437. * It not, then the cullable object is in the frustum.
  94438. */
  94439. static readonly CULLINGSTRATEGY_STANDARD: number;
  94440. /** Culling strategy : Bounding Sphere Only.
  94441. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94442. * It's also less accurate than the standard because some not visible objects can still be selected.
  94443. * Test : is the bounding sphere outside the frustum ?
  94444. * If not, then the cullable object is in the frustum.
  94445. */
  94446. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  94447. /** Culling strategy : Optimistic Inclusion.
  94448. * This in an inclusion test first, then the standard exclusion test.
  94449. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94450. * 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.
  94451. * Anyway, it's as accurate as the standard strategy.
  94452. * Test :
  94453. * Is the cullable object bounding sphere center in the frustum ?
  94454. * If not, apply the default culling strategy.
  94455. */
  94456. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  94457. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  94458. * This in an inclusion test first, then the bounding sphere only exclusion test.
  94459. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  94460. * 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.
  94461. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  94462. * Test :
  94463. * Is the cullable object bounding sphere center in the frustum ?
  94464. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  94465. */
  94466. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  94467. /**
  94468. * No billboard
  94469. */
  94470. static readonly BILLBOARDMODE_NONE: number;
  94471. /** Billboard on X axis */
  94472. static readonly BILLBOARDMODE_X: number;
  94473. /** Billboard on Y axis */
  94474. static readonly BILLBOARDMODE_Y: number;
  94475. /** Billboard on Z axis */
  94476. static readonly BILLBOARDMODE_Z: number;
  94477. /** Billboard on all axes */
  94478. static readonly BILLBOARDMODE_ALL: number;
  94479. /** Billboard on using position instead of orientation */
  94480. static readonly BILLBOARDMODE_USE_POSITION: number;
  94481. /** @hidden */
  94482. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  94483. /**
  94484. * The culling strategy to use to check whether the mesh must be rendered or not.
  94485. * This value can be changed at any time and will be used on the next render mesh selection.
  94486. * The possible values are :
  94487. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94488. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94489. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94490. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94491. * Please read each static variable documentation to get details about the culling process.
  94492. * */
  94493. cullingStrategy: number;
  94494. /**
  94495. * Gets the number of facets in the mesh
  94496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94497. */
  94498. readonly facetNb: number;
  94499. /**
  94500. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  94501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94502. */
  94503. partitioningSubdivisions: number;
  94504. /**
  94505. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  94506. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  94507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94508. */
  94509. partitioningBBoxRatio: number;
  94510. /**
  94511. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  94512. * Works only for updatable meshes.
  94513. * Doesn't work with multi-materials
  94514. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94515. */
  94516. mustDepthSortFacets: boolean;
  94517. /**
  94518. * The location (Vector3) where the facet depth sort must be computed from.
  94519. * By default, the active camera position.
  94520. * Used only when facet depth sort is enabled
  94521. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94522. */
  94523. facetDepthSortFrom: Vector3;
  94524. /**
  94525. * gets a boolean indicating if facetData is enabled
  94526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94527. */
  94528. readonly isFacetDataEnabled: boolean;
  94529. /** @hidden */
  94530. _updateNonUniformScalingState(value: boolean): boolean;
  94531. /**
  94532. * An event triggered when this mesh collides with another one
  94533. */
  94534. onCollideObservable: Observable<AbstractMesh>;
  94535. /** Set a function to call when this mesh collides with another one */
  94536. onCollide: () => void;
  94537. /**
  94538. * An event triggered when the collision's position changes
  94539. */
  94540. onCollisionPositionChangeObservable: Observable<Vector3>;
  94541. /** Set a function to call when the collision's position changes */
  94542. onCollisionPositionChange: () => void;
  94543. /**
  94544. * An event triggered when material is changed
  94545. */
  94546. onMaterialChangedObservable: Observable<AbstractMesh>;
  94547. /**
  94548. * Gets or sets the orientation for POV movement & rotation
  94549. */
  94550. definedFacingForward: boolean;
  94551. /** @hidden */
  94552. _occlusionQuery: Nullable<WebGLQuery>;
  94553. /** @hidden */
  94554. _renderingGroup: Nullable<RenderingGroup>;
  94555. /**
  94556. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94557. */
  94558. /**
  94559. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94560. */
  94561. visibility: number;
  94562. /** Gets or sets the alpha index used to sort transparent meshes
  94563. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  94564. */
  94565. alphaIndex: number;
  94566. /**
  94567. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  94568. */
  94569. isVisible: boolean;
  94570. /**
  94571. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  94572. */
  94573. isPickable: boolean;
  94574. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  94575. showSubMeshesBoundingBox: boolean;
  94576. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  94577. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  94578. */
  94579. isBlocker: boolean;
  94580. /**
  94581. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  94582. */
  94583. enablePointerMoveEvents: boolean;
  94584. /**
  94585. * Specifies the rendering group id for this mesh (0 by default)
  94586. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  94587. */
  94588. renderingGroupId: number;
  94589. private _material;
  94590. /** Gets or sets current material */
  94591. material: Nullable<Material>;
  94592. /**
  94593. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  94594. * @see http://doc.babylonjs.com/babylon101/shadows
  94595. */
  94596. receiveShadows: boolean;
  94597. /** Defines color to use when rendering outline */
  94598. outlineColor: Color3;
  94599. /** Define width to use when rendering outline */
  94600. outlineWidth: number;
  94601. /** Defines color to use when rendering overlay */
  94602. overlayColor: Color3;
  94603. /** Defines alpha to use when rendering overlay */
  94604. overlayAlpha: number;
  94605. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  94606. hasVertexAlpha: boolean;
  94607. /** 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) */
  94608. useVertexColors: boolean;
  94609. /**
  94610. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  94611. */
  94612. computeBonesUsingShaders: boolean;
  94613. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  94614. numBoneInfluencers: number;
  94615. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  94616. applyFog: boolean;
  94617. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  94618. useOctreeForRenderingSelection: boolean;
  94619. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  94620. useOctreeForPicking: boolean;
  94621. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  94622. useOctreeForCollisions: boolean;
  94623. /**
  94624. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  94625. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  94626. */
  94627. layerMask: number;
  94628. /**
  94629. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  94630. */
  94631. alwaysSelectAsActiveMesh: boolean;
  94632. /**
  94633. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  94634. */
  94635. doNotSyncBoundingInfo: boolean;
  94636. /**
  94637. * Gets or sets the current action manager
  94638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94639. */
  94640. actionManager: Nullable<AbstractActionManager>;
  94641. private _meshCollisionData;
  94642. /**
  94643. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  94644. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94645. */
  94646. ellipsoid: Vector3;
  94647. /**
  94648. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  94649. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94650. */
  94651. ellipsoidOffset: Vector3;
  94652. /**
  94653. * Gets or sets a collision mask used to mask collisions (default is -1).
  94654. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94655. */
  94656. collisionMask: number;
  94657. /**
  94658. * Gets or sets the current collision group mask (-1 by default).
  94659. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94660. */
  94661. collisionGroup: number;
  94662. /**
  94663. * Defines edge width used when edgesRenderer is enabled
  94664. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94665. */
  94666. edgesWidth: number;
  94667. /**
  94668. * Defines edge color used when edgesRenderer is enabled
  94669. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94670. */
  94671. edgesColor: Color4;
  94672. /** @hidden */
  94673. _edgesRenderer: Nullable<IEdgesRenderer>;
  94674. /** @hidden */
  94675. _masterMesh: Nullable<AbstractMesh>;
  94676. /** @hidden */
  94677. _boundingInfo: Nullable<BoundingInfo>;
  94678. /** @hidden */
  94679. _renderId: number;
  94680. /**
  94681. * Gets or sets the list of subMeshes
  94682. * @see http://doc.babylonjs.com/how_to/multi_materials
  94683. */
  94684. subMeshes: SubMesh[];
  94685. /** @hidden */
  94686. _intersectionsInProgress: AbstractMesh[];
  94687. /** @hidden */
  94688. _unIndexed: boolean;
  94689. /** @hidden */
  94690. _lightSources: Light[];
  94691. /** Gets the list of lights affecting that mesh */
  94692. readonly lightSources: Light[];
  94693. /** @hidden */
  94694. readonly _positions: Nullable<Vector3[]>;
  94695. /** @hidden */
  94696. _waitingData: {
  94697. lods: Nullable<any>;
  94698. actions: Nullable<any>;
  94699. freezeWorldMatrix: Nullable<boolean>;
  94700. };
  94701. /** @hidden */
  94702. _bonesTransformMatrices: Nullable<Float32Array>;
  94703. /** @hidden */
  94704. _transformMatrixTexture: Nullable<RawTexture>;
  94705. /**
  94706. * Gets or sets a skeleton to apply skining transformations
  94707. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94708. */
  94709. skeleton: Nullable<Skeleton>;
  94710. /**
  94711. * An event triggered when the mesh is rebuilt.
  94712. */
  94713. onRebuildObservable: Observable<AbstractMesh>;
  94714. /**
  94715. * Creates a new AbstractMesh
  94716. * @param name defines the name of the mesh
  94717. * @param scene defines the hosting scene
  94718. */
  94719. constructor(name: string, scene?: Nullable<Scene>);
  94720. /**
  94721. * Returns the string "AbstractMesh"
  94722. * @returns "AbstractMesh"
  94723. */
  94724. getClassName(): string;
  94725. /**
  94726. * Gets a string representation of the current mesh
  94727. * @param fullDetails defines a boolean indicating if full details must be included
  94728. * @returns a string representation of the current mesh
  94729. */
  94730. toString(fullDetails?: boolean): string;
  94731. /**
  94732. * @hidden
  94733. */
  94734. protected _getEffectiveParent(): Nullable<Node>;
  94735. /** @hidden */
  94736. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94737. /** @hidden */
  94738. _rebuild(): void;
  94739. /** @hidden */
  94740. _resyncLightSources(): void;
  94741. /** @hidden */
  94742. _resyncLighSource(light: Light): void;
  94743. /** @hidden */
  94744. _unBindEffect(): void;
  94745. /** @hidden */
  94746. _removeLightSource(light: Light, dispose: boolean): void;
  94747. private _markSubMeshesAsDirty;
  94748. /** @hidden */
  94749. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  94750. /** @hidden */
  94751. _markSubMeshesAsAttributesDirty(): void;
  94752. /** @hidden */
  94753. _markSubMeshesAsMiscDirty(): void;
  94754. /**
  94755. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  94756. */
  94757. scaling: Vector3;
  94758. /**
  94759. * Returns true if the mesh is blocked. Implemented by child classes
  94760. */
  94761. readonly isBlocked: boolean;
  94762. /**
  94763. * Returns the mesh itself by default. Implemented by child classes
  94764. * @param camera defines the camera to use to pick the right LOD level
  94765. * @returns the currentAbstractMesh
  94766. */
  94767. getLOD(camera: Camera): Nullable<AbstractMesh>;
  94768. /**
  94769. * Returns 0 by default. Implemented by child classes
  94770. * @returns an integer
  94771. */
  94772. getTotalVertices(): number;
  94773. /**
  94774. * Returns a positive integer : the total number of indices in this mesh geometry.
  94775. * @returns the numner of indices or zero if the mesh has no geometry.
  94776. */
  94777. getTotalIndices(): number;
  94778. /**
  94779. * Returns null by default. Implemented by child classes
  94780. * @returns null
  94781. */
  94782. getIndices(): Nullable<IndicesArray>;
  94783. /**
  94784. * Returns the array of the requested vertex data kind. Implemented by child classes
  94785. * @param kind defines the vertex data kind to use
  94786. * @returns null
  94787. */
  94788. getVerticesData(kind: string): Nullable<FloatArray>;
  94789. /**
  94790. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94791. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94792. * Note that a new underlying VertexBuffer object is created each call.
  94793. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94794. * @param kind defines vertex data kind:
  94795. * * VertexBuffer.PositionKind
  94796. * * VertexBuffer.UVKind
  94797. * * VertexBuffer.UV2Kind
  94798. * * VertexBuffer.UV3Kind
  94799. * * VertexBuffer.UV4Kind
  94800. * * VertexBuffer.UV5Kind
  94801. * * VertexBuffer.UV6Kind
  94802. * * VertexBuffer.ColorKind
  94803. * * VertexBuffer.MatricesIndicesKind
  94804. * * VertexBuffer.MatricesIndicesExtraKind
  94805. * * VertexBuffer.MatricesWeightsKind
  94806. * * VertexBuffer.MatricesWeightsExtraKind
  94807. * @param data defines the data source
  94808. * @param updatable defines if the data must be flagged as updatable (or static)
  94809. * @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
  94810. * @returns the current mesh
  94811. */
  94812. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94813. /**
  94814. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94815. * If the mesh has no geometry, it is simply returned as it is.
  94816. * @param kind defines vertex data kind:
  94817. * * VertexBuffer.PositionKind
  94818. * * VertexBuffer.UVKind
  94819. * * VertexBuffer.UV2Kind
  94820. * * VertexBuffer.UV3Kind
  94821. * * VertexBuffer.UV4Kind
  94822. * * VertexBuffer.UV5Kind
  94823. * * VertexBuffer.UV6Kind
  94824. * * VertexBuffer.ColorKind
  94825. * * VertexBuffer.MatricesIndicesKind
  94826. * * VertexBuffer.MatricesIndicesExtraKind
  94827. * * VertexBuffer.MatricesWeightsKind
  94828. * * VertexBuffer.MatricesWeightsExtraKind
  94829. * @param data defines the data source
  94830. * @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
  94831. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  94832. * @returns the current mesh
  94833. */
  94834. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94835. /**
  94836. * Sets the mesh indices,
  94837. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94838. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  94839. * @param totalVertices Defines the total number of vertices
  94840. * @returns the current mesh
  94841. */
  94842. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  94843. /**
  94844. * Gets a boolean indicating if specific vertex data is present
  94845. * @param kind defines the vertex data kind to use
  94846. * @returns true is data kind is present
  94847. */
  94848. isVerticesDataPresent(kind: string): boolean;
  94849. /**
  94850. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  94851. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  94852. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  94853. * @returns a BoundingInfo
  94854. */
  94855. getBoundingInfo(): BoundingInfo;
  94856. /**
  94857. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94858. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94859. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94860. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94861. * @returns the current mesh
  94862. */
  94863. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  94864. /**
  94865. * Overwrite the current bounding info
  94866. * @param boundingInfo defines the new bounding info
  94867. * @returns the current mesh
  94868. */
  94869. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  94870. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  94871. readonly useBones: boolean;
  94872. /** @hidden */
  94873. _preActivate(): void;
  94874. /** @hidden */
  94875. _preActivateForIntermediateRendering(renderId: number): void;
  94876. /** @hidden */
  94877. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94878. /** @hidden */
  94879. _postActivate(): void;
  94880. /** @hidden */
  94881. _freeze(): void;
  94882. /** @hidden */
  94883. _unFreeze(): void;
  94884. /**
  94885. * Gets the current world matrix
  94886. * @returns a Matrix
  94887. */
  94888. getWorldMatrix(): Matrix;
  94889. /** @hidden */
  94890. _getWorldMatrixDeterminant(): number;
  94891. /**
  94892. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  94893. */
  94894. readonly isAnInstance: boolean;
  94895. /**
  94896. * Gets a boolean indicating if this mesh has instances
  94897. */
  94898. readonly hasInstances: boolean;
  94899. /**
  94900. * Perform relative position change from the point of view of behind the front of the mesh.
  94901. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94902. * Supports definition of mesh facing forward or backward
  94903. * @param amountRight defines the distance on the right axis
  94904. * @param amountUp defines the distance on the up axis
  94905. * @param amountForward defines the distance on the forward axis
  94906. * @returns the current mesh
  94907. */
  94908. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  94909. /**
  94910. * Calculate relative position change from the point of view of behind the front of the mesh.
  94911. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94912. * Supports definition of mesh facing forward or backward
  94913. * @param amountRight defines the distance on the right axis
  94914. * @param amountUp defines the distance on the up axis
  94915. * @param amountForward defines the distance on the forward axis
  94916. * @returns the new displacement vector
  94917. */
  94918. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  94919. /**
  94920. * Perform relative rotation change from the point of view of behind the front of the mesh.
  94921. * Supports definition of mesh facing forward or backward
  94922. * @param flipBack defines the flip
  94923. * @param twirlClockwise defines the twirl
  94924. * @param tiltRight defines the tilt
  94925. * @returns the current mesh
  94926. */
  94927. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  94928. /**
  94929. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  94930. * Supports definition of mesh facing forward or backward.
  94931. * @param flipBack defines the flip
  94932. * @param twirlClockwise defines the twirl
  94933. * @param tiltRight defines the tilt
  94934. * @returns the new rotation vector
  94935. */
  94936. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  94937. /**
  94938. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94939. * This means the mesh underlying bounding box and sphere are recomputed.
  94940. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94941. * @returns the current mesh
  94942. */
  94943. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  94944. /** @hidden */
  94945. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  94946. /** @hidden */
  94947. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  94948. /** @hidden */
  94949. _updateBoundingInfo(): AbstractMesh;
  94950. /** @hidden */
  94951. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  94952. /** @hidden */
  94953. protected _afterComputeWorldMatrix(): void;
  94954. /** @hidden */
  94955. readonly _effectiveMesh: AbstractMesh;
  94956. /**
  94957. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  94958. * A mesh is in the frustum if its bounding box intersects the frustum
  94959. * @param frustumPlanes defines the frustum to test
  94960. * @returns true if the mesh is in the frustum planes
  94961. */
  94962. isInFrustum(frustumPlanes: Plane[]): boolean;
  94963. /**
  94964. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  94965. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  94966. * @param frustumPlanes defines the frustum to test
  94967. * @returns true if the mesh is completely in the frustum planes
  94968. */
  94969. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94970. /**
  94971. * True if the mesh intersects another mesh or a SolidParticle object
  94972. * @param mesh defines a target mesh or SolidParticle to test
  94973. * @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)
  94974. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  94975. * @returns true if there is an intersection
  94976. */
  94977. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  94978. /**
  94979. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  94980. * @param point defines the point to test
  94981. * @returns true if there is an intersection
  94982. */
  94983. intersectsPoint(point: Vector3): boolean;
  94984. /**
  94985. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  94986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94987. */
  94988. checkCollisions: boolean;
  94989. /**
  94990. * Gets Collider object used to compute collisions (not physics)
  94991. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94992. */
  94993. readonly collider: Nullable<Collider>;
  94994. /**
  94995. * Move the mesh using collision engine
  94996. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94997. * @param displacement defines the requested displacement vector
  94998. * @returns the current mesh
  94999. */
  95000. moveWithCollisions(displacement: Vector3): AbstractMesh;
  95001. private _onCollisionPositionChange;
  95002. /** @hidden */
  95003. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  95004. /** @hidden */
  95005. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  95006. /** @hidden */
  95007. _checkCollision(collider: Collider): AbstractMesh;
  95008. /** @hidden */
  95009. _generatePointsArray(): boolean;
  95010. /**
  95011. * Checks if the passed Ray intersects with the mesh
  95012. * @param ray defines the ray to use
  95013. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  95014. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95015. * @returns the picking info
  95016. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  95017. */
  95018. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  95019. /**
  95020. * Clones the current mesh
  95021. * @param name defines the mesh name
  95022. * @param newParent defines the new mesh parent
  95023. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  95024. * @returns the new mesh
  95025. */
  95026. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  95027. /**
  95028. * Disposes all the submeshes of the current meshnp
  95029. * @returns the current mesh
  95030. */
  95031. releaseSubMeshes(): AbstractMesh;
  95032. /**
  95033. * Releases resources associated with this abstract mesh.
  95034. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95035. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95036. */
  95037. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95038. /**
  95039. * Adds the passed mesh as a child to the current mesh
  95040. * @param mesh defines the child mesh
  95041. * @returns the current mesh
  95042. */
  95043. addChild(mesh: AbstractMesh): AbstractMesh;
  95044. /**
  95045. * Removes the passed mesh from the current mesh children list
  95046. * @param mesh defines the child mesh
  95047. * @returns the current mesh
  95048. */
  95049. removeChild(mesh: AbstractMesh): AbstractMesh;
  95050. /** @hidden */
  95051. private _initFacetData;
  95052. /**
  95053. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  95054. * This method can be called within the render loop.
  95055. * 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
  95056. * @returns the current mesh
  95057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95058. */
  95059. updateFacetData(): AbstractMesh;
  95060. /**
  95061. * Returns the facetLocalNormals array.
  95062. * The normals are expressed in the mesh local spac
  95063. * @returns an array of Vector3
  95064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95065. */
  95066. getFacetLocalNormals(): Vector3[];
  95067. /**
  95068. * Returns the facetLocalPositions array.
  95069. * The facet positions are expressed in the mesh local space
  95070. * @returns an array of Vector3
  95071. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95072. */
  95073. getFacetLocalPositions(): Vector3[];
  95074. /**
  95075. * Returns the facetLocalPartioning array
  95076. * @returns an array of array of numbers
  95077. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95078. */
  95079. getFacetLocalPartitioning(): number[][];
  95080. /**
  95081. * Returns the i-th facet position in the world system.
  95082. * This method allocates a new Vector3 per call
  95083. * @param i defines the facet index
  95084. * @returns a new Vector3
  95085. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95086. */
  95087. getFacetPosition(i: number): Vector3;
  95088. /**
  95089. * Sets the reference Vector3 with the i-th facet position in the world system
  95090. * @param i defines the facet index
  95091. * @param ref defines the target vector
  95092. * @returns the current mesh
  95093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95094. */
  95095. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  95096. /**
  95097. * Returns the i-th facet normal in the world system.
  95098. * This method allocates a new Vector3 per call
  95099. * @param i defines the facet index
  95100. * @returns a new Vector3
  95101. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95102. */
  95103. getFacetNormal(i: number): Vector3;
  95104. /**
  95105. * Sets the reference Vector3 with the i-th facet normal in the world system
  95106. * @param i defines the facet index
  95107. * @param ref defines the target vector
  95108. * @returns the current mesh
  95109. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95110. */
  95111. getFacetNormalToRef(i: number, ref: Vector3): this;
  95112. /**
  95113. * 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)
  95114. * @param x defines x coordinate
  95115. * @param y defines y coordinate
  95116. * @param z defines z coordinate
  95117. * @returns the array of facet indexes
  95118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95119. */
  95120. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  95121. /**
  95122. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  95123. * @param projected sets as the (x,y,z) world projection on the facet
  95124. * @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
  95125. * @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
  95126. * @param x defines x coordinate
  95127. * @param y defines y coordinate
  95128. * @param z defines z coordinate
  95129. * @returns the face index if found (or null instead)
  95130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95131. */
  95132. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95133. /**
  95134. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  95135. * @param projected sets as the (x,y,z) local projection on the facet
  95136. * @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
  95137. * @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
  95138. * @param x defines x coordinate
  95139. * @param y defines y coordinate
  95140. * @param z defines z coordinate
  95141. * @returns the face index if found (or null instead)
  95142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95143. */
  95144. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95145. /**
  95146. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  95147. * @returns the parameters
  95148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95149. */
  95150. getFacetDataParameters(): any;
  95151. /**
  95152. * Disables the feature FacetData and frees the related memory
  95153. * @returns the current mesh
  95154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95155. */
  95156. disableFacetData(): AbstractMesh;
  95157. /**
  95158. * Updates the AbstractMesh indices array
  95159. * @param indices defines the data source
  95160. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95161. * @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)
  95162. * @returns the current mesh
  95163. */
  95164. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95165. /**
  95166. * Creates new normals data for the mesh
  95167. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  95168. * @returns the current mesh
  95169. */
  95170. createNormals(updatable: boolean): AbstractMesh;
  95171. /**
  95172. * Align the mesh with a normal
  95173. * @param normal defines the normal to use
  95174. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  95175. * @returns the current mesh
  95176. */
  95177. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  95178. /** @hidden */
  95179. _checkOcclusionQuery(): boolean;
  95180. /**
  95181. * Disables the mesh edge rendering mode
  95182. * @returns the currentAbstractMesh
  95183. */
  95184. disableEdgesRendering(): AbstractMesh;
  95185. /**
  95186. * Enables the edge rendering mode on the mesh.
  95187. * This mode makes the mesh edges visible
  95188. * @param epsilon defines the maximal distance between two angles to detect a face
  95189. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95190. * @returns the currentAbstractMesh
  95191. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95192. */
  95193. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95194. }
  95195. }
  95196. declare module BABYLON {
  95197. /**
  95198. * Interface used to define ActionEvent
  95199. */
  95200. export interface IActionEvent {
  95201. /** The mesh or sprite that triggered the action */
  95202. source: any;
  95203. /** The X mouse cursor position at the time of the event */
  95204. pointerX: number;
  95205. /** The Y mouse cursor position at the time of the event */
  95206. pointerY: number;
  95207. /** The mesh that is currently pointed at (can be null) */
  95208. meshUnderPointer: Nullable<AbstractMesh>;
  95209. /** the original (browser) event that triggered the ActionEvent */
  95210. sourceEvent?: any;
  95211. /** additional data for the event */
  95212. additionalData?: any;
  95213. }
  95214. /**
  95215. * ActionEvent is the event being sent when an action is triggered.
  95216. */
  95217. export class ActionEvent implements IActionEvent {
  95218. /** The mesh or sprite that triggered the action */
  95219. source: any;
  95220. /** The X mouse cursor position at the time of the event */
  95221. pointerX: number;
  95222. /** The Y mouse cursor position at the time of the event */
  95223. pointerY: number;
  95224. /** The mesh that is currently pointed at (can be null) */
  95225. meshUnderPointer: Nullable<AbstractMesh>;
  95226. /** the original (browser) event that triggered the ActionEvent */
  95227. sourceEvent?: any;
  95228. /** additional data for the event */
  95229. additionalData?: any;
  95230. /**
  95231. * Creates a new ActionEvent
  95232. * @param source The mesh or sprite that triggered the action
  95233. * @param pointerX The X mouse cursor position at the time of the event
  95234. * @param pointerY The Y mouse cursor position at the time of the event
  95235. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  95236. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  95237. * @param additionalData additional data for the event
  95238. */
  95239. constructor(
  95240. /** The mesh or sprite that triggered the action */
  95241. source: any,
  95242. /** The X mouse cursor position at the time of the event */
  95243. pointerX: number,
  95244. /** The Y mouse cursor position at the time of the event */
  95245. pointerY: number,
  95246. /** The mesh that is currently pointed at (can be null) */
  95247. meshUnderPointer: Nullable<AbstractMesh>,
  95248. /** the original (browser) event that triggered the ActionEvent */
  95249. sourceEvent?: any,
  95250. /** additional data for the event */
  95251. additionalData?: any);
  95252. /**
  95253. * Helper function to auto-create an ActionEvent from a source mesh.
  95254. * @param source The source mesh that triggered the event
  95255. * @param evt The original (browser) event
  95256. * @param additionalData additional data for the event
  95257. * @returns the new ActionEvent
  95258. */
  95259. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  95260. /**
  95261. * Helper function to auto-create an ActionEvent from a source sprite
  95262. * @param source The source sprite that triggered the event
  95263. * @param scene Scene associated with the sprite
  95264. * @param evt The original (browser) event
  95265. * @param additionalData additional data for the event
  95266. * @returns the new ActionEvent
  95267. */
  95268. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  95269. /**
  95270. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  95271. * @param scene the scene where the event occurred
  95272. * @param evt The original (browser) event
  95273. * @returns the new ActionEvent
  95274. */
  95275. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  95276. /**
  95277. * Helper function to auto-create an ActionEvent from a primitive
  95278. * @param prim defines the target primitive
  95279. * @param pointerPos defines the pointer position
  95280. * @param evt The original (browser) event
  95281. * @param additionalData additional data for the event
  95282. * @returns the new ActionEvent
  95283. */
  95284. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  95285. }
  95286. }
  95287. declare module BABYLON {
  95288. /**
  95289. * Abstract class used to decouple action Manager from scene and meshes.
  95290. * Do not instantiate.
  95291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95292. */
  95293. export abstract class AbstractActionManager implements IDisposable {
  95294. /** Gets the list of active triggers */
  95295. static Triggers: {
  95296. [key: string]: number;
  95297. };
  95298. /** Gets the cursor to use when hovering items */
  95299. hoverCursor: string;
  95300. /** Gets the list of actions */
  95301. actions: IAction[];
  95302. /**
  95303. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  95304. */
  95305. isRecursive: boolean;
  95306. /**
  95307. * Releases all associated resources
  95308. */
  95309. abstract dispose(): void;
  95310. /**
  95311. * Does this action manager has pointer triggers
  95312. */
  95313. abstract readonly hasPointerTriggers: boolean;
  95314. /**
  95315. * Does this action manager has pick triggers
  95316. */
  95317. abstract readonly hasPickTriggers: boolean;
  95318. /**
  95319. * Process a specific trigger
  95320. * @param trigger defines the trigger to process
  95321. * @param evt defines the event details to be processed
  95322. */
  95323. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  95324. /**
  95325. * Does this action manager handles actions of any of the given triggers
  95326. * @param triggers defines the triggers to be tested
  95327. * @return a boolean indicating whether one (or more) of the triggers is handled
  95328. */
  95329. abstract hasSpecificTriggers(triggers: number[]): boolean;
  95330. /**
  95331. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95332. * speed.
  95333. * @param triggerA defines the trigger to be tested
  95334. * @param triggerB defines the trigger to be tested
  95335. * @return a boolean indicating whether one (or more) of the triggers is handled
  95336. */
  95337. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95338. /**
  95339. * Does this action manager handles actions of a given trigger
  95340. * @param trigger defines the trigger to be tested
  95341. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95342. * @return whether the trigger is handled
  95343. */
  95344. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95345. /**
  95346. * Serialize this manager to a JSON object
  95347. * @param name defines the property name to store this manager
  95348. * @returns a JSON representation of this manager
  95349. */
  95350. abstract serialize(name: string): any;
  95351. /**
  95352. * Registers an action to this action manager
  95353. * @param action defines the action to be registered
  95354. * @return the action amended (prepared) after registration
  95355. */
  95356. abstract registerAction(action: IAction): Nullable<IAction>;
  95357. /**
  95358. * Unregisters an action to this action manager
  95359. * @param action defines the action to be unregistered
  95360. * @return a boolean indicating whether the action has been unregistered
  95361. */
  95362. abstract unregisterAction(action: IAction): Boolean;
  95363. /**
  95364. * Does exist one action manager with at least one trigger
  95365. **/
  95366. static readonly HasTriggers: boolean;
  95367. /**
  95368. * Does exist one action manager with at least one pick trigger
  95369. **/
  95370. static readonly HasPickTriggers: boolean;
  95371. /**
  95372. * Does exist one action manager that handles actions of a given trigger
  95373. * @param trigger defines the trigger to be tested
  95374. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  95375. **/
  95376. static HasSpecificTrigger(trigger: number): boolean;
  95377. }
  95378. }
  95379. declare module BABYLON {
  95380. /**
  95381. * Defines how a node can be built from a string name.
  95382. */
  95383. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  95384. /**
  95385. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  95386. */
  95387. export class Node implements IBehaviorAware<Node> {
  95388. /** @hidden */
  95389. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  95390. private static _NodeConstructors;
  95391. /**
  95392. * Add a new node constructor
  95393. * @param type defines the type name of the node to construct
  95394. * @param constructorFunc defines the constructor function
  95395. */
  95396. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  95397. /**
  95398. * Returns a node constructor based on type name
  95399. * @param type defines the type name
  95400. * @param name defines the new node name
  95401. * @param scene defines the hosting scene
  95402. * @param options defines optional options to transmit to constructors
  95403. * @returns the new constructor or null
  95404. */
  95405. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  95406. /**
  95407. * Gets or sets the name of the node
  95408. */
  95409. name: string;
  95410. /**
  95411. * Gets or sets the id of the node
  95412. */
  95413. id: string;
  95414. /**
  95415. * Gets or sets the unique id of the node
  95416. */
  95417. uniqueId: number;
  95418. /**
  95419. * Gets or sets a string used to store user defined state for the node
  95420. */
  95421. state: string;
  95422. /**
  95423. * Gets or sets an object used to store user defined information for the node
  95424. */
  95425. metadata: any;
  95426. /**
  95427. * For internal use only. Please do not use.
  95428. */
  95429. reservedDataStore: any;
  95430. /**
  95431. * List of inspectable custom properties (used by the Inspector)
  95432. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95433. */
  95434. inspectableCustomProperties: IInspectable[];
  95435. private _doNotSerialize;
  95436. /**
  95437. * Gets or sets a boolean used to define if the node must be serialized
  95438. */
  95439. doNotSerialize: boolean;
  95440. /** @hidden */
  95441. _isDisposed: boolean;
  95442. /**
  95443. * Gets a list of Animations associated with the node
  95444. */
  95445. animations: Animation[];
  95446. protected _ranges: {
  95447. [name: string]: Nullable<AnimationRange>;
  95448. };
  95449. /**
  95450. * Callback raised when the node is ready to be used
  95451. */
  95452. onReady: Nullable<(node: Node) => void>;
  95453. private _isEnabled;
  95454. private _isParentEnabled;
  95455. private _isReady;
  95456. /** @hidden */
  95457. _currentRenderId: number;
  95458. private _parentUpdateId;
  95459. /** @hidden */
  95460. _childUpdateId: number;
  95461. /** @hidden */
  95462. _waitingParentId: Nullable<string>;
  95463. /** @hidden */
  95464. _scene: Scene;
  95465. /** @hidden */
  95466. _cache: any;
  95467. private _parentNode;
  95468. private _children;
  95469. /** @hidden */
  95470. _worldMatrix: Matrix;
  95471. /** @hidden */
  95472. _worldMatrixDeterminant: number;
  95473. /** @hidden */
  95474. _worldMatrixDeterminantIsDirty: boolean;
  95475. /** @hidden */
  95476. private _sceneRootNodesIndex;
  95477. /**
  95478. * Gets a boolean indicating if the node has been disposed
  95479. * @returns true if the node was disposed
  95480. */
  95481. isDisposed(): boolean;
  95482. /**
  95483. * Gets or sets the parent of the node (without keeping the current position in the scene)
  95484. * @see https://doc.babylonjs.com/how_to/parenting
  95485. */
  95486. parent: Nullable<Node>;
  95487. /** @hidden */
  95488. _addToSceneRootNodes(): void;
  95489. /** @hidden */
  95490. _removeFromSceneRootNodes(): void;
  95491. private _animationPropertiesOverride;
  95492. /**
  95493. * Gets or sets the animation properties override
  95494. */
  95495. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95496. /**
  95497. * Gets a string idenfifying the name of the class
  95498. * @returns "Node" string
  95499. */
  95500. getClassName(): string;
  95501. /** @hidden */
  95502. readonly _isNode: boolean;
  95503. /**
  95504. * An event triggered when the mesh is disposed
  95505. */
  95506. onDisposeObservable: Observable<Node>;
  95507. private _onDisposeObserver;
  95508. /**
  95509. * Sets a callback that will be raised when the node will be disposed
  95510. */
  95511. onDispose: () => void;
  95512. /**
  95513. * Creates a new Node
  95514. * @param name the name and id to be given to this node
  95515. * @param scene the scene this node will be added to
  95516. */
  95517. constructor(name: string, scene?: Nullable<Scene>);
  95518. /**
  95519. * Gets the scene of the node
  95520. * @returns a scene
  95521. */
  95522. getScene(): Scene;
  95523. /**
  95524. * Gets the engine of the node
  95525. * @returns a Engine
  95526. */
  95527. getEngine(): Engine;
  95528. private _behaviors;
  95529. /**
  95530. * Attach a behavior to the node
  95531. * @see http://doc.babylonjs.com/features/behaviour
  95532. * @param behavior defines the behavior to attach
  95533. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  95534. * @returns the current Node
  95535. */
  95536. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  95537. /**
  95538. * Remove an attached behavior
  95539. * @see http://doc.babylonjs.com/features/behaviour
  95540. * @param behavior defines the behavior to attach
  95541. * @returns the current Node
  95542. */
  95543. removeBehavior(behavior: Behavior<Node>): Node;
  95544. /**
  95545. * Gets the list of attached behaviors
  95546. * @see http://doc.babylonjs.com/features/behaviour
  95547. */
  95548. readonly behaviors: Behavior<Node>[];
  95549. /**
  95550. * Gets an attached behavior by name
  95551. * @param name defines the name of the behavior to look for
  95552. * @see http://doc.babylonjs.com/features/behaviour
  95553. * @returns null if behavior was not found else the requested behavior
  95554. */
  95555. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  95556. /**
  95557. * Returns the latest update of the World matrix
  95558. * @returns a Matrix
  95559. */
  95560. getWorldMatrix(): Matrix;
  95561. /** @hidden */
  95562. _getWorldMatrixDeterminant(): number;
  95563. /**
  95564. * Returns directly the latest state of the mesh World matrix.
  95565. * A Matrix is returned.
  95566. */
  95567. readonly worldMatrixFromCache: Matrix;
  95568. /** @hidden */
  95569. _initCache(): void;
  95570. /** @hidden */
  95571. updateCache(force?: boolean): void;
  95572. /** @hidden */
  95573. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95574. /** @hidden */
  95575. _updateCache(ignoreParentClass?: boolean): void;
  95576. /** @hidden */
  95577. _isSynchronized(): boolean;
  95578. /** @hidden */
  95579. _markSyncedWithParent(): void;
  95580. /** @hidden */
  95581. isSynchronizedWithParent(): boolean;
  95582. /** @hidden */
  95583. isSynchronized(): boolean;
  95584. /**
  95585. * Is this node ready to be used/rendered
  95586. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95587. * @return true if the node is ready
  95588. */
  95589. isReady(completeCheck?: boolean): boolean;
  95590. /**
  95591. * Is this node enabled?
  95592. * 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
  95593. * @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
  95594. * @return whether this node (and its parent) is enabled
  95595. */
  95596. isEnabled(checkAncestors?: boolean): boolean;
  95597. /** @hidden */
  95598. protected _syncParentEnabledState(): void;
  95599. /**
  95600. * Set the enabled state of this node
  95601. * @param value defines the new enabled state
  95602. */
  95603. setEnabled(value: boolean): void;
  95604. /**
  95605. * Is this node a descendant of the given node?
  95606. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  95607. * @param ancestor defines the parent node to inspect
  95608. * @returns a boolean indicating if this node is a descendant of the given node
  95609. */
  95610. isDescendantOf(ancestor: Node): boolean;
  95611. /** @hidden */
  95612. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  95613. /**
  95614. * Will return all nodes that have this node as ascendant
  95615. * @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
  95616. * @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
  95617. * @return all children nodes of all types
  95618. */
  95619. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  95620. /**
  95621. * Get all child-meshes of this node
  95622. * @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)
  95623. * @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
  95624. * @returns an array of AbstractMesh
  95625. */
  95626. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  95627. /**
  95628. * Get all direct children of this node
  95629. * @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
  95630. * @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)
  95631. * @returns an array of Node
  95632. */
  95633. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  95634. /** @hidden */
  95635. _setReady(state: boolean): void;
  95636. /**
  95637. * Get an animation by name
  95638. * @param name defines the name of the animation to look for
  95639. * @returns null if not found else the requested animation
  95640. */
  95641. getAnimationByName(name: string): Nullable<Animation>;
  95642. /**
  95643. * Creates an animation range for this node
  95644. * @param name defines the name of the range
  95645. * @param from defines the starting key
  95646. * @param to defines the end key
  95647. */
  95648. createAnimationRange(name: string, from: number, to: number): void;
  95649. /**
  95650. * Delete a specific animation range
  95651. * @param name defines the name of the range to delete
  95652. * @param deleteFrames defines if animation frames from the range must be deleted as well
  95653. */
  95654. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95655. /**
  95656. * Get an animation range by name
  95657. * @param name defines the name of the animation range to look for
  95658. * @returns null if not found else the requested animation range
  95659. */
  95660. getAnimationRange(name: string): Nullable<AnimationRange>;
  95661. /**
  95662. * Gets the list of all animation ranges defined on this node
  95663. * @returns an array
  95664. */
  95665. getAnimationRanges(): Nullable<AnimationRange>[];
  95666. /**
  95667. * Will start the animation sequence
  95668. * @param name defines the range frames for animation sequence
  95669. * @param loop defines if the animation should loop (false by default)
  95670. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  95671. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  95672. * @returns the object created for this animation. If range does not exist, it will return null
  95673. */
  95674. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95675. /**
  95676. * Serialize animation ranges into a JSON compatible object
  95677. * @returns serialization object
  95678. */
  95679. serializeAnimationRanges(): any;
  95680. /**
  95681. * Computes the world matrix of the node
  95682. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95683. * @returns the world matrix
  95684. */
  95685. computeWorldMatrix(force?: boolean): Matrix;
  95686. /**
  95687. * Releases resources associated with this node.
  95688. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95689. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95690. */
  95691. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95692. /**
  95693. * Parse animation range data from a serialization object and store them into a given node
  95694. * @param node defines where to store the animation ranges
  95695. * @param parsedNode defines the serialization object to read data from
  95696. * @param scene defines the hosting scene
  95697. */
  95698. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  95699. /**
  95700. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  95701. * @param includeDescendants Include bounding info from descendants as well (true by default)
  95702. * @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
  95703. * @returns the new bounding vectors
  95704. */
  95705. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  95706. min: Vector3;
  95707. max: Vector3;
  95708. };
  95709. }
  95710. }
  95711. declare module BABYLON {
  95712. /**
  95713. * @hidden
  95714. */
  95715. export class _IAnimationState {
  95716. key: number;
  95717. repeatCount: number;
  95718. workValue?: any;
  95719. loopMode?: number;
  95720. offsetValue?: any;
  95721. highLimitValue?: any;
  95722. }
  95723. /**
  95724. * Class used to store any kind of animation
  95725. */
  95726. export class Animation {
  95727. /**Name of the animation */
  95728. name: string;
  95729. /**Property to animate */
  95730. targetProperty: string;
  95731. /**The frames per second of the animation */
  95732. framePerSecond: number;
  95733. /**The data type of the animation */
  95734. dataType: number;
  95735. /**The loop mode of the animation */
  95736. loopMode?: number | undefined;
  95737. /**Specifies if blending should be enabled */
  95738. enableBlending?: boolean | undefined;
  95739. /**
  95740. * Use matrix interpolation instead of using direct key value when animating matrices
  95741. */
  95742. static AllowMatricesInterpolation: boolean;
  95743. /**
  95744. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  95745. */
  95746. static AllowMatrixDecomposeForInterpolation: boolean;
  95747. /**
  95748. * Stores the key frames of the animation
  95749. */
  95750. private _keys;
  95751. /**
  95752. * Stores the easing function of the animation
  95753. */
  95754. private _easingFunction;
  95755. /**
  95756. * @hidden Internal use only
  95757. */
  95758. _runtimeAnimations: RuntimeAnimation[];
  95759. /**
  95760. * The set of event that will be linked to this animation
  95761. */
  95762. private _events;
  95763. /**
  95764. * Stores an array of target property paths
  95765. */
  95766. targetPropertyPath: string[];
  95767. /**
  95768. * Stores the blending speed of the animation
  95769. */
  95770. blendingSpeed: number;
  95771. /**
  95772. * Stores the animation ranges for the animation
  95773. */
  95774. private _ranges;
  95775. /**
  95776. * @hidden Internal use
  95777. */
  95778. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  95779. /**
  95780. * Sets up an animation
  95781. * @param property The property to animate
  95782. * @param animationType The animation type to apply
  95783. * @param framePerSecond The frames per second of the animation
  95784. * @param easingFunction The easing function used in the animation
  95785. * @returns The created animation
  95786. */
  95787. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  95788. /**
  95789. * Create and start an animation on a node
  95790. * @param name defines the name of the global animation that will be run on all nodes
  95791. * @param node defines the root node where the animation will take place
  95792. * @param targetProperty defines property to animate
  95793. * @param framePerSecond defines the number of frame per second yo use
  95794. * @param totalFrame defines the number of frames in total
  95795. * @param from defines the initial value
  95796. * @param to defines the final value
  95797. * @param loopMode defines which loop mode you want to use (off by default)
  95798. * @param easingFunction defines the easing function to use (linear by default)
  95799. * @param onAnimationEnd defines the callback to call when animation end
  95800. * @returns the animatable created for this animation
  95801. */
  95802. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95803. /**
  95804. * Create and start an animation on a node and its descendants
  95805. * @param name defines the name of the global animation that will be run on all nodes
  95806. * @param node defines the root node where the animation will take place
  95807. * @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
  95808. * @param targetProperty defines property to animate
  95809. * @param framePerSecond defines the number of frame per second to use
  95810. * @param totalFrame defines the number of frames in total
  95811. * @param from defines the initial value
  95812. * @param to defines the final value
  95813. * @param loopMode defines which loop mode you want to use (off by default)
  95814. * @param easingFunction defines the easing function to use (linear by default)
  95815. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95816. * @returns the list of animatables created for all nodes
  95817. * @example https://www.babylonjs-playground.com/#MH0VLI
  95818. */
  95819. 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[]>;
  95820. /**
  95821. * Creates a new animation, merges it with the existing animations and starts it
  95822. * @param name Name of the animation
  95823. * @param node Node which contains the scene that begins the animations
  95824. * @param targetProperty Specifies which property to animate
  95825. * @param framePerSecond The frames per second of the animation
  95826. * @param totalFrame The total number of frames
  95827. * @param from The frame at the beginning of the animation
  95828. * @param to The frame at the end of the animation
  95829. * @param loopMode Specifies the loop mode of the animation
  95830. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  95831. * @param onAnimationEnd Callback to run once the animation is complete
  95832. * @returns Nullable animation
  95833. */
  95834. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95835. /**
  95836. * Transition property of an host to the target Value
  95837. * @param property The property to transition
  95838. * @param targetValue The target Value of the property
  95839. * @param host The object where the property to animate belongs
  95840. * @param scene Scene used to run the animation
  95841. * @param frameRate Framerate (in frame/s) to use
  95842. * @param transition The transition type we want to use
  95843. * @param duration The duration of the animation, in milliseconds
  95844. * @param onAnimationEnd Callback trigger at the end of the animation
  95845. * @returns Nullable animation
  95846. */
  95847. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  95848. /**
  95849. * Return the array of runtime animations currently using this animation
  95850. */
  95851. readonly runtimeAnimations: RuntimeAnimation[];
  95852. /**
  95853. * Specifies if any of the runtime animations are currently running
  95854. */
  95855. readonly hasRunningRuntimeAnimations: boolean;
  95856. /**
  95857. * Initializes the animation
  95858. * @param name Name of the animation
  95859. * @param targetProperty Property to animate
  95860. * @param framePerSecond The frames per second of the animation
  95861. * @param dataType The data type of the animation
  95862. * @param loopMode The loop mode of the animation
  95863. * @param enableBlending Specifies if blending should be enabled
  95864. */
  95865. constructor(
  95866. /**Name of the animation */
  95867. name: string,
  95868. /**Property to animate */
  95869. targetProperty: string,
  95870. /**The frames per second of the animation */
  95871. framePerSecond: number,
  95872. /**The data type of the animation */
  95873. dataType: number,
  95874. /**The loop mode of the animation */
  95875. loopMode?: number | undefined,
  95876. /**Specifies if blending should be enabled */
  95877. enableBlending?: boolean | undefined);
  95878. /**
  95879. * Converts the animation to a string
  95880. * @param fullDetails support for multiple levels of logging within scene loading
  95881. * @returns String form of the animation
  95882. */
  95883. toString(fullDetails?: boolean): string;
  95884. /**
  95885. * Add an event to this animation
  95886. * @param event Event to add
  95887. */
  95888. addEvent(event: AnimationEvent): void;
  95889. /**
  95890. * Remove all events found at the given frame
  95891. * @param frame The frame to remove events from
  95892. */
  95893. removeEvents(frame: number): void;
  95894. /**
  95895. * Retrieves all the events from the animation
  95896. * @returns Events from the animation
  95897. */
  95898. getEvents(): AnimationEvent[];
  95899. /**
  95900. * Creates an animation range
  95901. * @param name Name of the animation range
  95902. * @param from Starting frame of the animation range
  95903. * @param to Ending frame of the animation
  95904. */
  95905. createRange(name: string, from: number, to: number): void;
  95906. /**
  95907. * Deletes an animation range by name
  95908. * @param name Name of the animation range to delete
  95909. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  95910. */
  95911. deleteRange(name: string, deleteFrames?: boolean): void;
  95912. /**
  95913. * Gets the animation range by name, or null if not defined
  95914. * @param name Name of the animation range
  95915. * @returns Nullable animation range
  95916. */
  95917. getRange(name: string): Nullable<AnimationRange>;
  95918. /**
  95919. * Gets the key frames from the animation
  95920. * @returns The key frames of the animation
  95921. */
  95922. getKeys(): Array<IAnimationKey>;
  95923. /**
  95924. * Gets the highest frame rate of the animation
  95925. * @returns Highest frame rate of the animation
  95926. */
  95927. getHighestFrame(): number;
  95928. /**
  95929. * Gets the easing function of the animation
  95930. * @returns Easing function of the animation
  95931. */
  95932. getEasingFunction(): IEasingFunction;
  95933. /**
  95934. * Sets the easing function of the animation
  95935. * @param easingFunction A custom mathematical formula for animation
  95936. */
  95937. setEasingFunction(easingFunction: EasingFunction): void;
  95938. /**
  95939. * Interpolates a scalar linearly
  95940. * @param startValue Start value of the animation curve
  95941. * @param endValue End value of the animation curve
  95942. * @param gradient Scalar amount to interpolate
  95943. * @returns Interpolated scalar value
  95944. */
  95945. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  95946. /**
  95947. * Interpolates a scalar cubically
  95948. * @param startValue Start value of the animation curve
  95949. * @param outTangent End tangent of the animation
  95950. * @param endValue End value of the animation curve
  95951. * @param inTangent Start tangent of the animation curve
  95952. * @param gradient Scalar amount to interpolate
  95953. * @returns Interpolated scalar value
  95954. */
  95955. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  95956. /**
  95957. * Interpolates a quaternion using a spherical linear interpolation
  95958. * @param startValue Start value of the animation curve
  95959. * @param endValue End value of the animation curve
  95960. * @param gradient Scalar amount to interpolate
  95961. * @returns Interpolated quaternion value
  95962. */
  95963. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  95964. /**
  95965. * Interpolates a quaternion cubically
  95966. * @param startValue Start value of the animation curve
  95967. * @param outTangent End tangent of the animation curve
  95968. * @param endValue End value of the animation curve
  95969. * @param inTangent Start tangent of the animation curve
  95970. * @param gradient Scalar amount to interpolate
  95971. * @returns Interpolated quaternion value
  95972. */
  95973. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  95974. /**
  95975. * Interpolates a Vector3 linearl
  95976. * @param startValue Start value of the animation curve
  95977. * @param endValue End value of the animation curve
  95978. * @param gradient Scalar amount to interpolate
  95979. * @returns Interpolated scalar value
  95980. */
  95981. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  95982. /**
  95983. * Interpolates a Vector3 cubically
  95984. * @param startValue Start value of the animation curve
  95985. * @param outTangent End tangent of the animation
  95986. * @param endValue End value of the animation curve
  95987. * @param inTangent Start tangent of the animation curve
  95988. * @param gradient Scalar amount to interpolate
  95989. * @returns InterpolatedVector3 value
  95990. */
  95991. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  95992. /**
  95993. * Interpolates a Vector2 linearly
  95994. * @param startValue Start value of the animation curve
  95995. * @param endValue End value of the animation curve
  95996. * @param gradient Scalar amount to interpolate
  95997. * @returns Interpolated Vector2 value
  95998. */
  95999. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  96000. /**
  96001. * Interpolates a Vector2 cubically
  96002. * @param startValue Start value of the animation curve
  96003. * @param outTangent End tangent of the animation
  96004. * @param endValue End value of the animation curve
  96005. * @param inTangent Start tangent of the animation curve
  96006. * @param gradient Scalar amount to interpolate
  96007. * @returns Interpolated Vector2 value
  96008. */
  96009. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  96010. /**
  96011. * Interpolates a size linearly
  96012. * @param startValue Start value of the animation curve
  96013. * @param endValue End value of the animation curve
  96014. * @param gradient Scalar amount to interpolate
  96015. * @returns Interpolated Size value
  96016. */
  96017. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  96018. /**
  96019. * Interpolates a Color3 linearly
  96020. * @param startValue Start value of the animation curve
  96021. * @param endValue End value of the animation curve
  96022. * @param gradient Scalar amount to interpolate
  96023. * @returns Interpolated Color3 value
  96024. */
  96025. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  96026. /**
  96027. * Interpolates a Color4 linearly
  96028. * @param startValue Start value of the animation curve
  96029. * @param endValue End value of the animation curve
  96030. * @param gradient Scalar amount to interpolate
  96031. * @returns Interpolated Color3 value
  96032. */
  96033. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  96034. /**
  96035. * @hidden Internal use only
  96036. */
  96037. _getKeyValue(value: any): any;
  96038. /**
  96039. * @hidden Internal use only
  96040. */
  96041. _interpolate(currentFrame: number, state: _IAnimationState): any;
  96042. /**
  96043. * Defines the function to use to interpolate matrices
  96044. * @param startValue defines the start matrix
  96045. * @param endValue defines the end matrix
  96046. * @param gradient defines the gradient between both matrices
  96047. * @param result defines an optional target matrix where to store the interpolation
  96048. * @returns the interpolated matrix
  96049. */
  96050. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  96051. /**
  96052. * Makes a copy of the animation
  96053. * @returns Cloned animation
  96054. */
  96055. clone(): Animation;
  96056. /**
  96057. * Sets the key frames of the animation
  96058. * @param values The animation key frames to set
  96059. */
  96060. setKeys(values: Array<IAnimationKey>): void;
  96061. /**
  96062. * Serializes the animation to an object
  96063. * @returns Serialized object
  96064. */
  96065. serialize(): any;
  96066. /**
  96067. * Float animation type
  96068. */
  96069. static readonly ANIMATIONTYPE_FLOAT: number;
  96070. /**
  96071. * Vector3 animation type
  96072. */
  96073. static readonly ANIMATIONTYPE_VECTOR3: number;
  96074. /**
  96075. * Quaternion animation type
  96076. */
  96077. static readonly ANIMATIONTYPE_QUATERNION: number;
  96078. /**
  96079. * Matrix animation type
  96080. */
  96081. static readonly ANIMATIONTYPE_MATRIX: number;
  96082. /**
  96083. * Color3 animation type
  96084. */
  96085. static readonly ANIMATIONTYPE_COLOR3: number;
  96086. /**
  96087. * Color3 animation type
  96088. */
  96089. static readonly ANIMATIONTYPE_COLOR4: number;
  96090. /**
  96091. * Vector2 animation type
  96092. */
  96093. static readonly ANIMATIONTYPE_VECTOR2: number;
  96094. /**
  96095. * Size animation type
  96096. */
  96097. static readonly ANIMATIONTYPE_SIZE: number;
  96098. /**
  96099. * Relative Loop Mode
  96100. */
  96101. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  96102. /**
  96103. * Cycle Loop Mode
  96104. */
  96105. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  96106. /**
  96107. * Constant Loop Mode
  96108. */
  96109. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  96110. /** @hidden */
  96111. static _UniversalLerp(left: any, right: any, amount: number): any;
  96112. /**
  96113. * Parses an animation object and creates an animation
  96114. * @param parsedAnimation Parsed animation object
  96115. * @returns Animation object
  96116. */
  96117. static Parse(parsedAnimation: any): Animation;
  96118. /**
  96119. * Appends the serialized animations from the source animations
  96120. * @param source Source containing the animations
  96121. * @param destination Target to store the animations
  96122. */
  96123. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96124. }
  96125. }
  96126. declare module BABYLON {
  96127. /**
  96128. * Interface containing an array of animations
  96129. */
  96130. export interface IAnimatable {
  96131. /**
  96132. * Array of animations
  96133. */
  96134. animations: Nullable<Array<Animation>>;
  96135. }
  96136. }
  96137. declare module BABYLON {
  96138. /**
  96139. * This represents all the required information to add a fresnel effect on a material:
  96140. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96141. */
  96142. export class FresnelParameters {
  96143. private _isEnabled;
  96144. /**
  96145. * Define if the fresnel effect is enable or not.
  96146. */
  96147. isEnabled: boolean;
  96148. /**
  96149. * Define the color used on edges (grazing angle)
  96150. */
  96151. leftColor: Color3;
  96152. /**
  96153. * Define the color used on center
  96154. */
  96155. rightColor: Color3;
  96156. /**
  96157. * Define bias applied to computed fresnel term
  96158. */
  96159. bias: number;
  96160. /**
  96161. * Defined the power exponent applied to fresnel term
  96162. */
  96163. power: number;
  96164. /**
  96165. * Clones the current fresnel and its valuues
  96166. * @returns a clone fresnel configuration
  96167. */
  96168. clone(): FresnelParameters;
  96169. /**
  96170. * Serializes the current fresnel parameters to a JSON representation.
  96171. * @return the JSON serialization
  96172. */
  96173. serialize(): any;
  96174. /**
  96175. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96176. * @param parsedFresnelParameters Define the JSON representation
  96177. * @returns the parsed parameters
  96178. */
  96179. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96180. }
  96181. }
  96182. declare module BABYLON {
  96183. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  96184. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96185. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96186. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96187. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96188. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96189. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96190. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96191. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96192. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96193. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96194. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96195. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96196. /**
  96197. * Decorator used to define property that can be serialized as reference to a camera
  96198. * @param sourceName defines the name of the property to decorate
  96199. */
  96200. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96201. /**
  96202. * Class used to help serialization objects
  96203. */
  96204. export class SerializationHelper {
  96205. /** @hidden */
  96206. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  96207. /** @hidden */
  96208. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  96209. /** @hidden */
  96210. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  96211. /** @hidden */
  96212. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  96213. /**
  96214. * Appends the serialized animations from the source animations
  96215. * @param source Source containing the animations
  96216. * @param destination Target to store the animations
  96217. */
  96218. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96219. /**
  96220. * Static function used to serialized a specific entity
  96221. * @param entity defines the entity to serialize
  96222. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  96223. * @returns a JSON compatible object representing the serialization of the entity
  96224. */
  96225. static Serialize<T>(entity: T, serializationObject?: any): any;
  96226. /**
  96227. * Creates a new entity from a serialization data object
  96228. * @param creationFunction defines a function used to instanciated the new entity
  96229. * @param source defines the source serialization data
  96230. * @param scene defines the hosting scene
  96231. * @param rootUrl defines the root url for resources
  96232. * @returns a new entity
  96233. */
  96234. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  96235. /**
  96236. * Clones an object
  96237. * @param creationFunction defines the function used to instanciate the new object
  96238. * @param source defines the source object
  96239. * @returns the cloned object
  96240. */
  96241. static Clone<T>(creationFunction: () => T, source: T): T;
  96242. /**
  96243. * Instanciates a new object based on a source one (some data will be shared between both object)
  96244. * @param creationFunction defines the function used to instanciate the new object
  96245. * @param source defines the source object
  96246. * @returns the new object
  96247. */
  96248. static Instanciate<T>(creationFunction: () => T, source: T): T;
  96249. }
  96250. }
  96251. declare module BABYLON {
  96252. /**
  96253. * Class used to manipulate GUIDs
  96254. */
  96255. export class GUID {
  96256. /**
  96257. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96258. * Be aware Math.random() could cause collisions, but:
  96259. * "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"
  96260. * @returns a pseudo random id
  96261. */
  96262. static RandomId(): string;
  96263. }
  96264. }
  96265. declare module BABYLON {
  96266. /**
  96267. * Base class of all the textures in babylon.
  96268. * It groups all the common properties the materials, post process, lights... might need
  96269. * in order to make a correct use of the texture.
  96270. */
  96271. export class BaseTexture implements IAnimatable {
  96272. /**
  96273. * Default anisotropic filtering level for the application.
  96274. * It is set to 4 as a good tradeoff between perf and quality.
  96275. */
  96276. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  96277. /**
  96278. * Gets or sets the unique id of the texture
  96279. */
  96280. uniqueId: number;
  96281. /**
  96282. * Define the name of the texture.
  96283. */
  96284. name: string;
  96285. /**
  96286. * Gets or sets an object used to store user defined information.
  96287. */
  96288. metadata: any;
  96289. /**
  96290. * For internal use only. Please do not use.
  96291. */
  96292. reservedDataStore: any;
  96293. private _hasAlpha;
  96294. /**
  96295. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  96296. */
  96297. hasAlpha: boolean;
  96298. /**
  96299. * Defines if the alpha value should be determined via the rgb values.
  96300. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  96301. */
  96302. getAlphaFromRGB: boolean;
  96303. /**
  96304. * Intensity or strength of the texture.
  96305. * It is commonly used by materials to fine tune the intensity of the texture
  96306. */
  96307. level: number;
  96308. /**
  96309. * Define the UV chanel to use starting from 0 and defaulting to 0.
  96310. * This is part of the texture as textures usually maps to one uv set.
  96311. */
  96312. coordinatesIndex: number;
  96313. private _coordinatesMode;
  96314. /**
  96315. * How a texture is mapped.
  96316. *
  96317. * | Value | Type | Description |
  96318. * | ----- | ----------------------------------- | ----------- |
  96319. * | 0 | EXPLICIT_MODE | |
  96320. * | 1 | SPHERICAL_MODE | |
  96321. * | 2 | PLANAR_MODE | |
  96322. * | 3 | CUBIC_MODE | |
  96323. * | 4 | PROJECTION_MODE | |
  96324. * | 5 | SKYBOX_MODE | |
  96325. * | 6 | INVCUBIC_MODE | |
  96326. * | 7 | EQUIRECTANGULAR_MODE | |
  96327. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  96328. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  96329. */
  96330. coordinatesMode: number;
  96331. /**
  96332. * | Value | Type | Description |
  96333. * | ----- | ------------------ | ----------- |
  96334. * | 0 | CLAMP_ADDRESSMODE | |
  96335. * | 1 | WRAP_ADDRESSMODE | |
  96336. * | 2 | MIRROR_ADDRESSMODE | |
  96337. */
  96338. wrapU: number;
  96339. /**
  96340. * | Value | Type | Description |
  96341. * | ----- | ------------------ | ----------- |
  96342. * | 0 | CLAMP_ADDRESSMODE | |
  96343. * | 1 | WRAP_ADDRESSMODE | |
  96344. * | 2 | MIRROR_ADDRESSMODE | |
  96345. */
  96346. wrapV: number;
  96347. /**
  96348. * | Value | Type | Description |
  96349. * | ----- | ------------------ | ----------- |
  96350. * | 0 | CLAMP_ADDRESSMODE | |
  96351. * | 1 | WRAP_ADDRESSMODE | |
  96352. * | 2 | MIRROR_ADDRESSMODE | |
  96353. */
  96354. wrapR: number;
  96355. /**
  96356. * With compliant hardware and browser (supporting anisotropic filtering)
  96357. * this defines the level of anisotropic filtering in the texture.
  96358. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  96359. */
  96360. anisotropicFilteringLevel: number;
  96361. /**
  96362. * Define if the texture is a cube texture or if false a 2d texture.
  96363. */
  96364. isCube: boolean;
  96365. /**
  96366. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  96367. */
  96368. is3D: boolean;
  96369. /**
  96370. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  96371. */
  96372. is2DArray: boolean;
  96373. /**
  96374. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  96375. * HDR texture are usually stored in linear space.
  96376. * This only impacts the PBR and Background materials
  96377. */
  96378. gammaSpace: boolean;
  96379. /**
  96380. * Gets or sets whether or not the texture contains RGBD data.
  96381. */
  96382. isRGBD: boolean;
  96383. /**
  96384. * Is Z inverted in the texture (useful in a cube texture).
  96385. */
  96386. invertZ: boolean;
  96387. /**
  96388. * Are mip maps generated for this texture or not.
  96389. */
  96390. readonly noMipmap: boolean;
  96391. /**
  96392. * @hidden
  96393. */
  96394. lodLevelInAlpha: boolean;
  96395. /**
  96396. * With prefiltered texture, defined the offset used during the prefiltering steps.
  96397. */
  96398. lodGenerationOffset: number;
  96399. /**
  96400. * With prefiltered texture, defined the scale used during the prefiltering steps.
  96401. */
  96402. lodGenerationScale: number;
  96403. /**
  96404. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  96405. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  96406. * average roughness values.
  96407. */
  96408. linearSpecularLOD: boolean;
  96409. /**
  96410. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  96411. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  96412. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  96413. */
  96414. irradianceTexture: Nullable<BaseTexture>;
  96415. /**
  96416. * Define if the texture is a render target.
  96417. */
  96418. isRenderTarget: boolean;
  96419. /**
  96420. * Define the unique id of the texture in the scene.
  96421. */
  96422. readonly uid: string;
  96423. /**
  96424. * Return a string representation of the texture.
  96425. * @returns the texture as a string
  96426. */
  96427. toString(): string;
  96428. /**
  96429. * Get the class name of the texture.
  96430. * @returns "BaseTexture"
  96431. */
  96432. getClassName(): string;
  96433. /**
  96434. * Define the list of animation attached to the texture.
  96435. */
  96436. animations: Animation[];
  96437. /**
  96438. * An event triggered when the texture is disposed.
  96439. */
  96440. onDisposeObservable: Observable<BaseTexture>;
  96441. private _onDisposeObserver;
  96442. /**
  96443. * Callback triggered when the texture has been disposed.
  96444. * Kept for back compatibility, you can use the onDisposeObservable instead.
  96445. */
  96446. onDispose: () => void;
  96447. /**
  96448. * Define the current state of the loading sequence when in delayed load mode.
  96449. */
  96450. delayLoadState: number;
  96451. private _scene;
  96452. /** @hidden */
  96453. _texture: Nullable<InternalTexture>;
  96454. private _uid;
  96455. /**
  96456. * Define if the texture is preventinga material to render or not.
  96457. * If not and the texture is not ready, the engine will use a default black texture instead.
  96458. */
  96459. readonly isBlocking: boolean;
  96460. /**
  96461. * Instantiates a new BaseTexture.
  96462. * Base class of all the textures in babylon.
  96463. * It groups all the common properties the materials, post process, lights... might need
  96464. * in order to make a correct use of the texture.
  96465. * @param scene Define the scene the texture blongs to
  96466. */
  96467. constructor(scene: Nullable<Scene>);
  96468. /**
  96469. * Get the scene the texture belongs to.
  96470. * @returns the scene or null if undefined
  96471. */
  96472. getScene(): Nullable<Scene>;
  96473. /**
  96474. * Get the texture transform matrix used to offset tile the texture for istance.
  96475. * @returns the transformation matrix
  96476. */
  96477. getTextureMatrix(): Matrix;
  96478. /**
  96479. * Get the texture reflection matrix used to rotate/transform the reflection.
  96480. * @returns the reflection matrix
  96481. */
  96482. getReflectionTextureMatrix(): Matrix;
  96483. /**
  96484. * Get the underlying lower level texture from Babylon.
  96485. * @returns the insternal texture
  96486. */
  96487. getInternalTexture(): Nullable<InternalTexture>;
  96488. /**
  96489. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  96490. * @returns true if ready or not blocking
  96491. */
  96492. isReadyOrNotBlocking(): boolean;
  96493. /**
  96494. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  96495. * @returns true if fully ready
  96496. */
  96497. isReady(): boolean;
  96498. private _cachedSize;
  96499. /**
  96500. * Get the size of the texture.
  96501. * @returns the texture size.
  96502. */
  96503. getSize(): ISize;
  96504. /**
  96505. * Get the base size of the texture.
  96506. * It can be different from the size if the texture has been resized for POT for instance
  96507. * @returns the base size
  96508. */
  96509. getBaseSize(): ISize;
  96510. /**
  96511. * Update the sampling mode of the texture.
  96512. * Default is Trilinear mode.
  96513. *
  96514. * | Value | Type | Description |
  96515. * | ----- | ------------------ | ----------- |
  96516. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  96517. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  96518. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  96519. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  96520. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  96521. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  96522. * | 7 | NEAREST_LINEAR | |
  96523. * | 8 | NEAREST_NEAREST | |
  96524. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  96525. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  96526. * | 11 | LINEAR_LINEAR | |
  96527. * | 12 | LINEAR_NEAREST | |
  96528. *
  96529. * > _mag_: magnification filter (close to the viewer)
  96530. * > _min_: minification filter (far from the viewer)
  96531. * > _mip_: filter used between mip map levels
  96532. *@param samplingMode Define the new sampling mode of the texture
  96533. */
  96534. updateSamplingMode(samplingMode: number): void;
  96535. /**
  96536. * Scales the texture if is `canRescale()`
  96537. * @param ratio the resize factor we want to use to rescale
  96538. */
  96539. scale(ratio: number): void;
  96540. /**
  96541. * Get if the texture can rescale.
  96542. */
  96543. readonly canRescale: boolean;
  96544. /** @hidden */
  96545. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  96546. /** @hidden */
  96547. _rebuild(): void;
  96548. /**
  96549. * Triggers the load sequence in delayed load mode.
  96550. */
  96551. delayLoad(): void;
  96552. /**
  96553. * Clones the texture.
  96554. * @returns the cloned texture
  96555. */
  96556. clone(): Nullable<BaseTexture>;
  96557. /**
  96558. * Get the texture underlying type (INT, FLOAT...)
  96559. */
  96560. readonly textureType: number;
  96561. /**
  96562. * Get the texture underlying format (RGB, RGBA...)
  96563. */
  96564. readonly textureFormat: number;
  96565. /**
  96566. * Indicates that textures need to be re-calculated for all materials
  96567. */
  96568. protected _markAllSubMeshesAsTexturesDirty(): void;
  96569. /**
  96570. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  96571. * This will returns an RGBA array buffer containing either in values (0-255) or
  96572. * float values (0-1) depending of the underlying buffer type.
  96573. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96574. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96575. * @param buffer defines a user defined buffer to fill with data (can be null)
  96576. * @returns The Array buffer containing the pixels data.
  96577. */
  96578. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  96579. /**
  96580. * Release and destroy the underlying lower level texture aka internalTexture.
  96581. */
  96582. releaseInternalTexture(): void;
  96583. /** @hidden */
  96584. readonly _lodTextureHigh: Nullable<BaseTexture>;
  96585. /** @hidden */
  96586. readonly _lodTextureMid: Nullable<BaseTexture>;
  96587. /** @hidden */
  96588. readonly _lodTextureLow: Nullable<BaseTexture>;
  96589. /**
  96590. * Dispose the texture and release its associated resources.
  96591. */
  96592. dispose(): void;
  96593. /**
  96594. * Serialize the texture into a JSON representation that can be parsed later on.
  96595. * @returns the JSON representation of the texture
  96596. */
  96597. serialize(): any;
  96598. /**
  96599. * Helper function to be called back once a list of texture contains only ready textures.
  96600. * @param textures Define the list of textures to wait for
  96601. * @param callback Define the callback triggered once the entire list will be ready
  96602. */
  96603. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  96604. }
  96605. }
  96606. declare module BABYLON {
  96607. /**
  96608. * Options to be used when creating an effect.
  96609. */
  96610. export interface IEffectCreationOptions {
  96611. /**
  96612. * Atrributes that will be used in the shader.
  96613. */
  96614. attributes: string[];
  96615. /**
  96616. * Uniform varible names that will be set in the shader.
  96617. */
  96618. uniformsNames: string[];
  96619. /**
  96620. * Uniform buffer variable names that will be set in the shader.
  96621. */
  96622. uniformBuffersNames: string[];
  96623. /**
  96624. * Sampler texture variable names that will be set in the shader.
  96625. */
  96626. samplers: string[];
  96627. /**
  96628. * Define statements that will be set in the shader.
  96629. */
  96630. defines: any;
  96631. /**
  96632. * Possible fallbacks for this effect to improve performance when needed.
  96633. */
  96634. fallbacks: Nullable<IEffectFallbacks>;
  96635. /**
  96636. * Callback that will be called when the shader is compiled.
  96637. */
  96638. onCompiled: Nullable<(effect: Effect) => void>;
  96639. /**
  96640. * Callback that will be called if an error occurs during shader compilation.
  96641. */
  96642. onError: Nullable<(effect: Effect, errors: string) => void>;
  96643. /**
  96644. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96645. */
  96646. indexParameters?: any;
  96647. /**
  96648. * Max number of lights that can be used in the shader.
  96649. */
  96650. maxSimultaneousLights?: number;
  96651. /**
  96652. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  96653. */
  96654. transformFeedbackVaryings?: Nullable<string[]>;
  96655. }
  96656. /**
  96657. * Effect containing vertex and fragment shader that can be executed on an object.
  96658. */
  96659. export class Effect implements IDisposable {
  96660. /**
  96661. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96662. */
  96663. static ShadersRepository: string;
  96664. /**
  96665. * Name of the effect.
  96666. */
  96667. name: any;
  96668. /**
  96669. * String container all the define statements that should be set on the shader.
  96670. */
  96671. defines: string;
  96672. /**
  96673. * Callback that will be called when the shader is compiled.
  96674. */
  96675. onCompiled: Nullable<(effect: Effect) => void>;
  96676. /**
  96677. * Callback that will be called if an error occurs during shader compilation.
  96678. */
  96679. onError: Nullable<(effect: Effect, errors: string) => void>;
  96680. /**
  96681. * Callback that will be called when effect is bound.
  96682. */
  96683. onBind: Nullable<(effect: Effect) => void>;
  96684. /**
  96685. * Unique ID of the effect.
  96686. */
  96687. uniqueId: number;
  96688. /**
  96689. * Observable that will be called when the shader is compiled.
  96690. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  96691. */
  96692. onCompileObservable: Observable<Effect>;
  96693. /**
  96694. * Observable that will be called if an error occurs during shader compilation.
  96695. */
  96696. onErrorObservable: Observable<Effect>;
  96697. /** @hidden */
  96698. _onBindObservable: Nullable<Observable<Effect>>;
  96699. /**
  96700. * Observable that will be called when effect is bound.
  96701. */
  96702. readonly onBindObservable: Observable<Effect>;
  96703. /** @hidden */
  96704. _bonesComputationForcedToCPU: boolean;
  96705. private static _uniqueIdSeed;
  96706. private _engine;
  96707. private _uniformBuffersNames;
  96708. private _uniformsNames;
  96709. private _samplerList;
  96710. private _samplers;
  96711. private _isReady;
  96712. private _compilationError;
  96713. private _allFallbacksProcessed;
  96714. private _attributesNames;
  96715. private _attributes;
  96716. private _uniforms;
  96717. /**
  96718. * Key for the effect.
  96719. * @hidden
  96720. */
  96721. _key: string;
  96722. private _indexParameters;
  96723. private _fallbacks;
  96724. private _vertexSourceCode;
  96725. private _fragmentSourceCode;
  96726. private _vertexSourceCodeOverride;
  96727. private _fragmentSourceCodeOverride;
  96728. private _transformFeedbackVaryings;
  96729. /**
  96730. * Compiled shader to webGL program.
  96731. * @hidden
  96732. */
  96733. _pipelineContext: Nullable<IPipelineContext>;
  96734. private _valueCache;
  96735. private static _baseCache;
  96736. /**
  96737. * Instantiates an effect.
  96738. * An effect can be used to create/manage/execute vertex and fragment shaders.
  96739. * @param baseName Name of the effect.
  96740. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  96741. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  96742. * @param samplers List of sampler variables that will be passed to the shader.
  96743. * @param engine Engine to be used to render the effect
  96744. * @param defines Define statements to be added to the shader.
  96745. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  96746. * @param onCompiled Callback that will be called when the shader is compiled.
  96747. * @param onError Callback that will be called if an error occurs during shader compilation.
  96748. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96749. */
  96750. 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);
  96751. private _useFinalCode;
  96752. /**
  96753. * Unique key for this effect
  96754. */
  96755. readonly key: string;
  96756. /**
  96757. * If the effect has been compiled and prepared.
  96758. * @returns if the effect is compiled and prepared.
  96759. */
  96760. isReady(): boolean;
  96761. private _isReadyInternal;
  96762. /**
  96763. * The engine the effect was initialized with.
  96764. * @returns the engine.
  96765. */
  96766. getEngine(): Engine;
  96767. /**
  96768. * The pipeline context for this effect
  96769. * @returns the associated pipeline context
  96770. */
  96771. getPipelineContext(): Nullable<IPipelineContext>;
  96772. /**
  96773. * The set of names of attribute variables for the shader.
  96774. * @returns An array of attribute names.
  96775. */
  96776. getAttributesNames(): string[];
  96777. /**
  96778. * Returns the attribute at the given index.
  96779. * @param index The index of the attribute.
  96780. * @returns The location of the attribute.
  96781. */
  96782. getAttributeLocation(index: number): number;
  96783. /**
  96784. * Returns the attribute based on the name of the variable.
  96785. * @param name of the attribute to look up.
  96786. * @returns the attribute location.
  96787. */
  96788. getAttributeLocationByName(name: string): number;
  96789. /**
  96790. * The number of attributes.
  96791. * @returns the numnber of attributes.
  96792. */
  96793. getAttributesCount(): number;
  96794. /**
  96795. * Gets the index of a uniform variable.
  96796. * @param uniformName of the uniform to look up.
  96797. * @returns the index.
  96798. */
  96799. getUniformIndex(uniformName: string): number;
  96800. /**
  96801. * Returns the attribute based on the name of the variable.
  96802. * @param uniformName of the uniform to look up.
  96803. * @returns the location of the uniform.
  96804. */
  96805. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  96806. /**
  96807. * Returns an array of sampler variable names
  96808. * @returns The array of sampler variable neames.
  96809. */
  96810. getSamplers(): string[];
  96811. /**
  96812. * The error from the last compilation.
  96813. * @returns the error string.
  96814. */
  96815. getCompilationError(): string;
  96816. /**
  96817. * Gets a boolean indicating that all fallbacks were used during compilation
  96818. * @returns true if all fallbacks were used
  96819. */
  96820. allFallbacksProcessed(): boolean;
  96821. /**
  96822. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  96823. * @param func The callback to be used.
  96824. */
  96825. executeWhenCompiled(func: (effect: Effect) => void): void;
  96826. private _checkIsReady;
  96827. private _loadShader;
  96828. /**
  96829. * Recompiles the webGL program
  96830. * @param vertexSourceCode The source code for the vertex shader.
  96831. * @param fragmentSourceCode The source code for the fragment shader.
  96832. * @param onCompiled Callback called when completed.
  96833. * @param onError Callback called on error.
  96834. * @hidden
  96835. */
  96836. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  96837. /**
  96838. * Prepares the effect
  96839. * @hidden
  96840. */
  96841. _prepareEffect(): void;
  96842. private _processCompilationErrors;
  96843. /**
  96844. * Checks if the effect is supported. (Must be called after compilation)
  96845. */
  96846. readonly isSupported: boolean;
  96847. /**
  96848. * Binds a texture to the engine to be used as output of the shader.
  96849. * @param channel Name of the output variable.
  96850. * @param texture Texture to bind.
  96851. * @hidden
  96852. */
  96853. _bindTexture(channel: string, texture: InternalTexture): void;
  96854. /**
  96855. * Sets a texture on the engine to be used in the shader.
  96856. * @param channel Name of the sampler variable.
  96857. * @param texture Texture to set.
  96858. */
  96859. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  96860. /**
  96861. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  96862. * @param channel Name of the sampler variable.
  96863. * @param texture Texture to set.
  96864. */
  96865. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  96866. /**
  96867. * Sets an array of textures on the engine to be used in the shader.
  96868. * @param channel Name of the variable.
  96869. * @param textures Textures to set.
  96870. */
  96871. setTextureArray(channel: string, textures: BaseTexture[]): void;
  96872. /**
  96873. * 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)
  96874. * @param channel Name of the sampler variable.
  96875. * @param postProcess Post process to get the input texture from.
  96876. */
  96877. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  96878. /**
  96879. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  96880. * 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)
  96881. * @param channel Name of the sampler variable.
  96882. * @param postProcess Post process to get the output texture from.
  96883. */
  96884. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  96885. /** @hidden */
  96886. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  96887. /** @hidden */
  96888. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  96889. /** @hidden */
  96890. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  96891. /** @hidden */
  96892. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  96893. /**
  96894. * Binds a buffer to a uniform.
  96895. * @param buffer Buffer to bind.
  96896. * @param name Name of the uniform variable to bind to.
  96897. */
  96898. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  96899. /**
  96900. * Binds block to a uniform.
  96901. * @param blockName Name of the block to bind.
  96902. * @param index Index to bind.
  96903. */
  96904. bindUniformBlock(blockName: string, index: number): void;
  96905. /**
  96906. * Sets an interger value on a uniform variable.
  96907. * @param uniformName Name of the variable.
  96908. * @param value Value to be set.
  96909. * @returns this effect.
  96910. */
  96911. setInt(uniformName: string, value: number): Effect;
  96912. /**
  96913. * Sets an int array on a uniform variable.
  96914. * @param uniformName Name of the variable.
  96915. * @param array array to be set.
  96916. * @returns this effect.
  96917. */
  96918. setIntArray(uniformName: string, array: Int32Array): Effect;
  96919. /**
  96920. * 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)
  96921. * @param uniformName Name of the variable.
  96922. * @param array array to be set.
  96923. * @returns this effect.
  96924. */
  96925. setIntArray2(uniformName: string, array: Int32Array): Effect;
  96926. /**
  96927. * 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)
  96928. * @param uniformName Name of the variable.
  96929. * @param array array to be set.
  96930. * @returns this effect.
  96931. */
  96932. setIntArray3(uniformName: string, array: Int32Array): Effect;
  96933. /**
  96934. * 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)
  96935. * @param uniformName Name of the variable.
  96936. * @param array array to be set.
  96937. * @returns this effect.
  96938. */
  96939. setIntArray4(uniformName: string, array: Int32Array): Effect;
  96940. /**
  96941. * Sets an float array on a uniform variable.
  96942. * @param uniformName Name of the variable.
  96943. * @param array array to be set.
  96944. * @returns this effect.
  96945. */
  96946. setFloatArray(uniformName: string, array: Float32Array): Effect;
  96947. /**
  96948. * 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)
  96949. * @param uniformName Name of the variable.
  96950. * @param array array to be set.
  96951. * @returns this effect.
  96952. */
  96953. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  96954. /**
  96955. * 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)
  96956. * @param uniformName Name of the variable.
  96957. * @param array array to be set.
  96958. * @returns this effect.
  96959. */
  96960. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  96961. /**
  96962. * 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)
  96963. * @param uniformName Name of the variable.
  96964. * @param array array to be set.
  96965. * @returns this effect.
  96966. */
  96967. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  96968. /**
  96969. * Sets an array on a uniform variable.
  96970. * @param uniformName Name of the variable.
  96971. * @param array array to be set.
  96972. * @returns this effect.
  96973. */
  96974. setArray(uniformName: string, array: number[]): Effect;
  96975. /**
  96976. * 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)
  96977. * @param uniformName Name of the variable.
  96978. * @param array array to be set.
  96979. * @returns this effect.
  96980. */
  96981. setArray2(uniformName: string, array: number[]): Effect;
  96982. /**
  96983. * 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)
  96984. * @param uniformName Name of the variable.
  96985. * @param array array to be set.
  96986. * @returns this effect.
  96987. */
  96988. setArray3(uniformName: string, array: number[]): Effect;
  96989. /**
  96990. * 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)
  96991. * @param uniformName Name of the variable.
  96992. * @param array array to be set.
  96993. * @returns this effect.
  96994. */
  96995. setArray4(uniformName: string, array: number[]): Effect;
  96996. /**
  96997. * Sets matrices on a uniform variable.
  96998. * @param uniformName Name of the variable.
  96999. * @param matrices matrices to be set.
  97000. * @returns this effect.
  97001. */
  97002. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  97003. /**
  97004. * Sets matrix on a uniform variable.
  97005. * @param uniformName Name of the variable.
  97006. * @param matrix matrix to be set.
  97007. * @returns this effect.
  97008. */
  97009. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  97010. /**
  97011. * 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)
  97012. * @param uniformName Name of the variable.
  97013. * @param matrix matrix to be set.
  97014. * @returns this effect.
  97015. */
  97016. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  97017. /**
  97018. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  97019. * @param uniformName Name of the variable.
  97020. * @param matrix matrix to be set.
  97021. * @returns this effect.
  97022. */
  97023. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  97024. /**
  97025. * Sets a float on a uniform variable.
  97026. * @param uniformName Name of the variable.
  97027. * @param value value to be set.
  97028. * @returns this effect.
  97029. */
  97030. setFloat(uniformName: string, value: number): Effect;
  97031. /**
  97032. * Sets a boolean on a uniform variable.
  97033. * @param uniformName Name of the variable.
  97034. * @param bool value to be set.
  97035. * @returns this effect.
  97036. */
  97037. setBool(uniformName: string, bool: boolean): Effect;
  97038. /**
  97039. * Sets a Vector2 on a uniform variable.
  97040. * @param uniformName Name of the variable.
  97041. * @param vector2 vector2 to be set.
  97042. * @returns this effect.
  97043. */
  97044. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  97045. /**
  97046. * Sets a float2 on a uniform variable.
  97047. * @param uniformName Name of the variable.
  97048. * @param x First float in float2.
  97049. * @param y Second float in float2.
  97050. * @returns this effect.
  97051. */
  97052. setFloat2(uniformName: string, x: number, y: number): Effect;
  97053. /**
  97054. * Sets a Vector3 on a uniform variable.
  97055. * @param uniformName Name of the variable.
  97056. * @param vector3 Value to be set.
  97057. * @returns this effect.
  97058. */
  97059. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  97060. /**
  97061. * Sets a float3 on a uniform variable.
  97062. * @param uniformName Name of the variable.
  97063. * @param x First float in float3.
  97064. * @param y Second float in float3.
  97065. * @param z Third float in float3.
  97066. * @returns this effect.
  97067. */
  97068. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  97069. /**
  97070. * Sets a Vector4 on a uniform variable.
  97071. * @param uniformName Name of the variable.
  97072. * @param vector4 Value to be set.
  97073. * @returns this effect.
  97074. */
  97075. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  97076. /**
  97077. * Sets a float4 on a uniform variable.
  97078. * @param uniformName Name of the variable.
  97079. * @param x First float in float4.
  97080. * @param y Second float in float4.
  97081. * @param z Third float in float4.
  97082. * @param w Fourth float in float4.
  97083. * @returns this effect.
  97084. */
  97085. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  97086. /**
  97087. * Sets a Color3 on a uniform variable.
  97088. * @param uniformName Name of the variable.
  97089. * @param color3 Value to be set.
  97090. * @returns this effect.
  97091. */
  97092. setColor3(uniformName: string, color3: IColor3Like): Effect;
  97093. /**
  97094. * Sets a Color4 on a uniform variable.
  97095. * @param uniformName Name of the variable.
  97096. * @param color3 Value to be set.
  97097. * @param alpha Alpha value to be set.
  97098. * @returns this effect.
  97099. */
  97100. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  97101. /**
  97102. * Sets a Color4 on a uniform variable
  97103. * @param uniformName defines the name of the variable
  97104. * @param color4 defines the value to be set
  97105. * @returns this effect.
  97106. */
  97107. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  97108. /** Release all associated resources */
  97109. dispose(): void;
  97110. /**
  97111. * This function will add a new shader to the shader store
  97112. * @param name the name of the shader
  97113. * @param pixelShader optional pixel shader content
  97114. * @param vertexShader optional vertex shader content
  97115. */
  97116. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  97117. /**
  97118. * Store of each shader (The can be looked up using effect.key)
  97119. */
  97120. static ShadersStore: {
  97121. [key: string]: string;
  97122. };
  97123. /**
  97124. * Store of each included file for a shader (The can be looked up using effect.key)
  97125. */
  97126. static IncludesShadersStore: {
  97127. [key: string]: string;
  97128. };
  97129. /**
  97130. * Resets the cache of effects.
  97131. */
  97132. static ResetCache(): void;
  97133. }
  97134. }
  97135. declare module BABYLON {
  97136. /**
  97137. * Interface used to describe the capabilities of the engine relatively to the current browser
  97138. */
  97139. export interface EngineCapabilities {
  97140. /** Maximum textures units per fragment shader */
  97141. maxTexturesImageUnits: number;
  97142. /** Maximum texture units per vertex shader */
  97143. maxVertexTextureImageUnits: number;
  97144. /** Maximum textures units in the entire pipeline */
  97145. maxCombinedTexturesImageUnits: number;
  97146. /** Maximum texture size */
  97147. maxTextureSize: number;
  97148. /** Maximum cube texture size */
  97149. maxCubemapTextureSize: number;
  97150. /** Maximum render texture size */
  97151. maxRenderTextureSize: number;
  97152. /** Maximum number of vertex attributes */
  97153. maxVertexAttribs: number;
  97154. /** Maximum number of varyings */
  97155. maxVaryingVectors: number;
  97156. /** Maximum number of uniforms per vertex shader */
  97157. maxVertexUniformVectors: number;
  97158. /** Maximum number of uniforms per fragment shader */
  97159. maxFragmentUniformVectors: number;
  97160. /** Defines if standard derivates (dx/dy) are supported */
  97161. standardDerivatives: boolean;
  97162. /** Defines if s3tc texture compression is supported */
  97163. s3tc?: WEBGL_compressed_texture_s3tc;
  97164. /** Defines if pvrtc texture compression is supported */
  97165. pvrtc: any;
  97166. /** Defines if etc1 texture compression is supported */
  97167. etc1: any;
  97168. /** Defines if etc2 texture compression is supported */
  97169. etc2: any;
  97170. /** Defines if astc texture compression is supported */
  97171. astc: any;
  97172. /** Defines if float textures are supported */
  97173. textureFloat: boolean;
  97174. /** Defines if vertex array objects are supported */
  97175. vertexArrayObject: boolean;
  97176. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  97177. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  97178. /** Gets the maximum level of anisotropy supported */
  97179. maxAnisotropy: number;
  97180. /** Defines if instancing is supported */
  97181. instancedArrays: boolean;
  97182. /** Defines if 32 bits indices are supported */
  97183. uintIndices: boolean;
  97184. /** Defines if high precision shaders are supported */
  97185. highPrecisionShaderSupported: boolean;
  97186. /** Defines if depth reading in the fragment shader is supported */
  97187. fragmentDepthSupported: boolean;
  97188. /** Defines if float texture linear filtering is supported*/
  97189. textureFloatLinearFiltering: boolean;
  97190. /** Defines if rendering to float textures is supported */
  97191. textureFloatRender: boolean;
  97192. /** Defines if half float textures are supported*/
  97193. textureHalfFloat: boolean;
  97194. /** Defines if half float texture linear filtering is supported*/
  97195. textureHalfFloatLinearFiltering: boolean;
  97196. /** Defines if rendering to half float textures is supported */
  97197. textureHalfFloatRender: boolean;
  97198. /** Defines if textureLOD shader command is supported */
  97199. textureLOD: boolean;
  97200. /** Defines if draw buffers extension is supported */
  97201. drawBuffersExtension: boolean;
  97202. /** Defines if depth textures are supported */
  97203. depthTextureExtension: boolean;
  97204. /** Defines if float color buffer are supported */
  97205. colorBufferFloat: boolean;
  97206. /** Gets disjoint timer query extension (null if not supported) */
  97207. timerQuery?: EXT_disjoint_timer_query;
  97208. /** Defines if timestamp can be used with timer query */
  97209. canUseTimestampForTimerQuery: boolean;
  97210. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  97211. multiview?: any;
  97212. /** Function used to let the system compiles shaders in background */
  97213. parallelShaderCompile?: {
  97214. COMPLETION_STATUS_KHR: number;
  97215. };
  97216. /** Max number of texture samples for MSAA */
  97217. maxMSAASamples: number;
  97218. /** Defines if the blend min max extension is supported */
  97219. blendMinMax: boolean;
  97220. }
  97221. }
  97222. declare module BABYLON {
  97223. /**
  97224. * @hidden
  97225. **/
  97226. export class DepthCullingState {
  97227. private _isDepthTestDirty;
  97228. private _isDepthMaskDirty;
  97229. private _isDepthFuncDirty;
  97230. private _isCullFaceDirty;
  97231. private _isCullDirty;
  97232. private _isZOffsetDirty;
  97233. private _isFrontFaceDirty;
  97234. private _depthTest;
  97235. private _depthMask;
  97236. private _depthFunc;
  97237. private _cull;
  97238. private _cullFace;
  97239. private _zOffset;
  97240. private _frontFace;
  97241. /**
  97242. * Initializes the state.
  97243. */
  97244. constructor();
  97245. readonly isDirty: boolean;
  97246. zOffset: number;
  97247. cullFace: Nullable<number>;
  97248. cull: Nullable<boolean>;
  97249. depthFunc: Nullable<number>;
  97250. depthMask: boolean;
  97251. depthTest: boolean;
  97252. frontFace: Nullable<number>;
  97253. reset(): void;
  97254. apply(gl: WebGLRenderingContext): void;
  97255. }
  97256. }
  97257. declare module BABYLON {
  97258. /**
  97259. * @hidden
  97260. **/
  97261. export class StencilState {
  97262. /** 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 */
  97263. static readonly ALWAYS: number;
  97264. /** Passed to stencilOperation to specify that stencil value must be kept */
  97265. static readonly KEEP: number;
  97266. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97267. static readonly REPLACE: number;
  97268. private _isStencilTestDirty;
  97269. private _isStencilMaskDirty;
  97270. private _isStencilFuncDirty;
  97271. private _isStencilOpDirty;
  97272. private _stencilTest;
  97273. private _stencilMask;
  97274. private _stencilFunc;
  97275. private _stencilFuncRef;
  97276. private _stencilFuncMask;
  97277. private _stencilOpStencilFail;
  97278. private _stencilOpDepthFail;
  97279. private _stencilOpStencilDepthPass;
  97280. readonly isDirty: boolean;
  97281. stencilFunc: number;
  97282. stencilFuncRef: number;
  97283. stencilFuncMask: number;
  97284. stencilOpStencilFail: number;
  97285. stencilOpDepthFail: number;
  97286. stencilOpStencilDepthPass: number;
  97287. stencilMask: number;
  97288. stencilTest: boolean;
  97289. constructor();
  97290. reset(): void;
  97291. apply(gl: WebGLRenderingContext): void;
  97292. }
  97293. }
  97294. declare module BABYLON {
  97295. /**
  97296. * @hidden
  97297. **/
  97298. export class AlphaState {
  97299. private _isAlphaBlendDirty;
  97300. private _isBlendFunctionParametersDirty;
  97301. private _isBlendEquationParametersDirty;
  97302. private _isBlendConstantsDirty;
  97303. private _alphaBlend;
  97304. private _blendFunctionParameters;
  97305. private _blendEquationParameters;
  97306. private _blendConstants;
  97307. /**
  97308. * Initializes the state.
  97309. */
  97310. constructor();
  97311. readonly isDirty: boolean;
  97312. alphaBlend: boolean;
  97313. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  97314. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  97315. setAlphaEquationParameters(rgb: number, alpha: number): void;
  97316. reset(): void;
  97317. apply(gl: WebGLRenderingContext): void;
  97318. }
  97319. }
  97320. declare module BABYLON {
  97321. /** @hidden */
  97322. export class WebGL2ShaderProcessor implements IShaderProcessor {
  97323. attributeProcessor(attribute: string): string;
  97324. varyingProcessor(varying: string, isFragment: boolean): string;
  97325. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  97326. }
  97327. }
  97328. declare module BABYLON {
  97329. /**
  97330. * Interface for attribute information associated with buffer instanciation
  97331. */
  97332. export interface InstancingAttributeInfo {
  97333. /**
  97334. * Index/offset of the attribute in the vertex shader
  97335. */
  97336. index: number;
  97337. /**
  97338. * size of the attribute, 1, 2, 3 or 4
  97339. */
  97340. attributeSize: number;
  97341. /**
  97342. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  97343. * default is FLOAT
  97344. */
  97345. attributeType: number;
  97346. /**
  97347. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  97348. */
  97349. normalized: boolean;
  97350. /**
  97351. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  97352. */
  97353. offset: number;
  97354. /**
  97355. * Name of the GLSL attribute, for debugging purpose only
  97356. */
  97357. attributeName: string;
  97358. }
  97359. }
  97360. declare module BABYLON {
  97361. interface ThinEngine {
  97362. /**
  97363. * Update a video texture
  97364. * @param texture defines the texture to update
  97365. * @param video defines the video element to use
  97366. * @param invertY defines if data must be stored with Y axis inverted
  97367. */
  97368. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97369. }
  97370. }
  97371. declare module BABYLON {
  97372. /**
  97373. * Settings for finer control over video usage
  97374. */
  97375. export interface VideoTextureSettings {
  97376. /**
  97377. * Applies `autoplay` to video, if specified
  97378. */
  97379. autoPlay?: boolean;
  97380. /**
  97381. * Applies `loop` to video, if specified
  97382. */
  97383. loop?: boolean;
  97384. /**
  97385. * Automatically updates internal texture from video at every frame in the render loop
  97386. */
  97387. autoUpdateTexture: boolean;
  97388. /**
  97389. * Image src displayed during the video loading or until the user interacts with the video.
  97390. */
  97391. poster?: string;
  97392. }
  97393. /**
  97394. * If you want to display a video in your scene, this is the special texture for that.
  97395. * This special texture works similar to other textures, with the exception of a few parameters.
  97396. * @see https://doc.babylonjs.com/how_to/video_texture
  97397. */
  97398. export class VideoTexture extends Texture {
  97399. /**
  97400. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  97401. */
  97402. readonly autoUpdateTexture: boolean;
  97403. /**
  97404. * The video instance used by the texture internally
  97405. */
  97406. readonly video: HTMLVideoElement;
  97407. private _onUserActionRequestedObservable;
  97408. /**
  97409. * Event triggerd when a dom action is required by the user to play the video.
  97410. * This happens due to recent changes in browser policies preventing video to auto start.
  97411. */
  97412. readonly onUserActionRequestedObservable: Observable<Texture>;
  97413. private _generateMipMaps;
  97414. private _engine;
  97415. private _stillImageCaptured;
  97416. private _displayingPosterTexture;
  97417. private _settings;
  97418. private _createInternalTextureOnEvent;
  97419. private _frameId;
  97420. /**
  97421. * Creates a video texture.
  97422. * If you want to display a video in your scene, this is the special texture for that.
  97423. * This special texture works similar to other textures, with the exception of a few parameters.
  97424. * @see https://doc.babylonjs.com/how_to/video_texture
  97425. * @param name optional name, will detect from video source, if not defined
  97426. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  97427. * @param scene is obviously the current scene.
  97428. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  97429. * @param invertY is false by default but can be used to invert video on Y axis
  97430. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  97431. * @param settings allows finer control over video usage
  97432. */
  97433. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  97434. private _getName;
  97435. private _getVideo;
  97436. private _createInternalTexture;
  97437. private reset;
  97438. /**
  97439. * @hidden Internal method to initiate `update`.
  97440. */
  97441. _rebuild(): void;
  97442. /**
  97443. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  97444. */
  97445. update(): void;
  97446. /**
  97447. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  97448. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  97449. */
  97450. updateTexture(isVisible: boolean): void;
  97451. protected _updateInternalTexture: () => void;
  97452. /**
  97453. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  97454. * @param url New url.
  97455. */
  97456. updateURL(url: string): void;
  97457. /**
  97458. * Dispose the texture and release its associated resources.
  97459. */
  97460. dispose(): void;
  97461. /**
  97462. * Creates a video texture straight from a stream.
  97463. * @param scene Define the scene the texture should be created in
  97464. * @param stream Define the stream the texture should be created from
  97465. * @returns The created video texture as a promise
  97466. */
  97467. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  97468. /**
  97469. * Creates a video texture straight from your WebCam video feed.
  97470. * @param scene Define the scene the texture should be created in
  97471. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97472. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97473. * @returns The created video texture as a promise
  97474. */
  97475. static CreateFromWebCamAsync(scene: Scene, constraints: {
  97476. minWidth: number;
  97477. maxWidth: number;
  97478. minHeight: number;
  97479. maxHeight: number;
  97480. deviceId: string;
  97481. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  97482. /**
  97483. * Creates a video texture straight from your WebCam video feed.
  97484. * @param scene Define the scene the texture should be created in
  97485. * @param onReady Define a callback to triggered once the texture will be ready
  97486. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97487. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97488. */
  97489. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  97490. minWidth: number;
  97491. maxWidth: number;
  97492. minHeight: number;
  97493. maxHeight: number;
  97494. deviceId: string;
  97495. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  97496. }
  97497. }
  97498. declare module BABYLON {
  97499. /**
  97500. * Defines the interface used by objects working like Scene
  97501. * @hidden
  97502. */
  97503. interface ISceneLike {
  97504. _addPendingData(data: any): void;
  97505. _removePendingData(data: any): void;
  97506. offlineProvider: IOfflineProvider;
  97507. }
  97508. /** Interface defining initialization parameters for Engine class */
  97509. export interface EngineOptions extends WebGLContextAttributes {
  97510. /**
  97511. * Defines if the engine should no exceed a specified device ratio
  97512. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  97513. */
  97514. limitDeviceRatio?: number;
  97515. /**
  97516. * Defines if webvr should be enabled automatically
  97517. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97518. */
  97519. autoEnableWebVR?: boolean;
  97520. /**
  97521. * Defines if webgl2 should be turned off even if supported
  97522. * @see http://doc.babylonjs.com/features/webgl2
  97523. */
  97524. disableWebGL2Support?: boolean;
  97525. /**
  97526. * Defines if webaudio should be initialized as well
  97527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97528. */
  97529. audioEngine?: boolean;
  97530. /**
  97531. * Defines if animations should run using a deterministic lock step
  97532. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97533. */
  97534. deterministicLockstep?: boolean;
  97535. /** Defines the maximum steps to use with deterministic lock step mode */
  97536. lockstepMaxSteps?: number;
  97537. /**
  97538. * Defines that engine should ignore context lost events
  97539. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  97540. */
  97541. doNotHandleContextLost?: boolean;
  97542. /**
  97543. * Defines that engine should ignore modifying touch action attribute and style
  97544. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  97545. */
  97546. doNotHandleTouchAction?: boolean;
  97547. /**
  97548. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  97549. */
  97550. useHighPrecisionFloats?: boolean;
  97551. }
  97552. /**
  97553. * The base engine class (root of all engines)
  97554. */
  97555. export class ThinEngine {
  97556. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  97557. static ExceptionList: ({
  97558. key: string;
  97559. capture: string;
  97560. captureConstraint: number;
  97561. targets: string[];
  97562. } | {
  97563. key: string;
  97564. capture: null;
  97565. captureConstraint: null;
  97566. targets: string[];
  97567. })[];
  97568. /** @hidden */
  97569. static _TextureLoaders: IInternalTextureLoader[];
  97570. /**
  97571. * Returns the current npm package of the sdk
  97572. */
  97573. static readonly NpmPackage: string;
  97574. /**
  97575. * Returns the current version of the framework
  97576. */
  97577. static readonly Version: string;
  97578. /**
  97579. * Returns a string describing the current engine
  97580. */
  97581. readonly description: string;
  97582. /**
  97583. * Gets or sets the epsilon value used by collision engine
  97584. */
  97585. static CollisionsEpsilon: number;
  97586. /**
  97587. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97588. */
  97589. static ShadersRepository: string;
  97590. /** @hidden */
  97591. _shaderProcessor: IShaderProcessor;
  97592. /**
  97593. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  97594. */
  97595. forcePOTTextures: boolean;
  97596. /**
  97597. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  97598. */
  97599. isFullscreen: boolean;
  97600. /**
  97601. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  97602. */
  97603. cullBackFaces: boolean;
  97604. /**
  97605. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  97606. */
  97607. renderEvenInBackground: boolean;
  97608. /**
  97609. * Gets or sets a boolean indicating that cache can be kept between frames
  97610. */
  97611. preventCacheWipeBetweenFrames: boolean;
  97612. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  97613. validateShaderPrograms: boolean;
  97614. /**
  97615. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  97616. */
  97617. disableUniformBuffers: boolean;
  97618. /** @hidden */
  97619. _uniformBuffers: UniformBuffer[];
  97620. /**
  97621. * Gets a boolean indicating that the engine supports uniform buffers
  97622. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  97623. */
  97624. readonly supportsUniformBuffers: boolean;
  97625. /** @hidden */
  97626. _gl: WebGLRenderingContext;
  97627. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  97628. protected _windowIsBackground: boolean;
  97629. protected _webGLVersion: number;
  97630. protected _creationOptions: EngineOptions;
  97631. protected _highPrecisionShadersAllowed: boolean;
  97632. /** @hidden */
  97633. readonly _shouldUseHighPrecisionShader: boolean;
  97634. /**
  97635. * Gets a boolean indicating that only power of 2 textures are supported
  97636. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  97637. */
  97638. readonly needPOTTextures: boolean;
  97639. /** @hidden */
  97640. _badOS: boolean;
  97641. /** @hidden */
  97642. _badDesktopOS: boolean;
  97643. private _hardwareScalingLevel;
  97644. /** @hidden */
  97645. _caps: EngineCapabilities;
  97646. private _isStencilEnable;
  97647. protected _colorWrite: boolean;
  97648. private _glVersion;
  97649. private _glRenderer;
  97650. private _glVendor;
  97651. /** @hidden */
  97652. _videoTextureSupported: boolean;
  97653. protected _renderingQueueLaunched: boolean;
  97654. protected _activeRenderLoops: (() => void)[];
  97655. /**
  97656. * Observable signaled when a context lost event is raised
  97657. */
  97658. onContextLostObservable: Observable<ThinEngine>;
  97659. /**
  97660. * Observable signaled when a context restored event is raised
  97661. */
  97662. onContextRestoredObservable: Observable<ThinEngine>;
  97663. private _onContextLost;
  97664. private _onContextRestored;
  97665. protected _contextWasLost: boolean;
  97666. /** @hidden */
  97667. _doNotHandleContextLost: boolean;
  97668. /**
  97669. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  97670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  97671. */
  97672. doNotHandleContextLost: boolean;
  97673. /**
  97674. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  97675. */
  97676. disableVertexArrayObjects: boolean;
  97677. /** @hidden */
  97678. protected _depthCullingState: DepthCullingState;
  97679. /** @hidden */
  97680. protected _stencilState: StencilState;
  97681. /** @hidden */
  97682. protected _alphaState: AlphaState;
  97683. /** @hidden */
  97684. _internalTexturesCache: InternalTexture[];
  97685. /** @hidden */
  97686. protected _activeChannel: number;
  97687. private _currentTextureChannel;
  97688. /** @hidden */
  97689. protected _boundTexturesCache: {
  97690. [key: string]: Nullable<InternalTexture>;
  97691. };
  97692. /** @hidden */
  97693. protected _currentEffect: Nullable<Effect>;
  97694. /** @hidden */
  97695. protected _currentProgram: Nullable<WebGLProgram>;
  97696. private _compiledEffects;
  97697. private _vertexAttribArraysEnabled;
  97698. /** @hidden */
  97699. protected _cachedViewport: Nullable<IViewportLike>;
  97700. private _cachedVertexArrayObject;
  97701. /** @hidden */
  97702. protected _cachedVertexBuffers: any;
  97703. /** @hidden */
  97704. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  97705. /** @hidden */
  97706. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  97707. /** @hidden */
  97708. _currentRenderTarget: Nullable<InternalTexture>;
  97709. private _uintIndicesCurrentlySet;
  97710. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  97711. /** @hidden */
  97712. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  97713. private _currentBufferPointers;
  97714. private _currentInstanceLocations;
  97715. private _currentInstanceBuffers;
  97716. private _textureUnits;
  97717. /** @hidden */
  97718. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97719. /** @hidden */
  97720. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97721. /** @hidden */
  97722. _boundRenderFunction: any;
  97723. private _vaoRecordInProgress;
  97724. private _mustWipeVertexAttributes;
  97725. private _emptyTexture;
  97726. private _emptyCubeTexture;
  97727. private _emptyTexture3D;
  97728. private _emptyTexture2DArray;
  97729. /** @hidden */
  97730. _frameHandler: number;
  97731. private _nextFreeTextureSlots;
  97732. private _maxSimultaneousTextures;
  97733. private _activeRequests;
  97734. protected _texturesSupported: string[];
  97735. /** @hidden */
  97736. _textureFormatInUse: Nullable<string>;
  97737. protected readonly _supportsHardwareTextureRescaling: boolean;
  97738. /**
  97739. * Gets the list of texture formats supported
  97740. */
  97741. readonly texturesSupported: Array<string>;
  97742. /**
  97743. * Gets the list of texture formats in use
  97744. */
  97745. readonly textureFormatInUse: Nullable<string>;
  97746. /**
  97747. * Gets the current viewport
  97748. */
  97749. readonly currentViewport: Nullable<IViewportLike>;
  97750. /**
  97751. * Gets the default empty texture
  97752. */
  97753. readonly emptyTexture: InternalTexture;
  97754. /**
  97755. * Gets the default empty 3D texture
  97756. */
  97757. readonly emptyTexture3D: InternalTexture;
  97758. /**
  97759. * Gets the default empty 2D array texture
  97760. */
  97761. readonly emptyTexture2DArray: InternalTexture;
  97762. /**
  97763. * Gets the default empty cube texture
  97764. */
  97765. readonly emptyCubeTexture: InternalTexture;
  97766. /**
  97767. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  97768. */
  97769. readonly premultipliedAlpha: boolean;
  97770. /**
  97771. * Observable event triggered before each texture is initialized
  97772. */
  97773. onBeforeTextureInitObservable: Observable<Texture>;
  97774. /**
  97775. * Creates a new engine
  97776. * @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
  97777. * @param antialias defines enable antialiasing (default: false)
  97778. * @param options defines further options to be sent to the getContext() function
  97779. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97780. */
  97781. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97782. private _rebuildInternalTextures;
  97783. private _rebuildEffects;
  97784. /**
  97785. * Gets a boolean indicating if all created effects are ready
  97786. * @returns true if all effects are ready
  97787. */
  97788. areAllEffectsReady(): boolean;
  97789. protected _rebuildBuffers(): void;
  97790. private _initGLContext;
  97791. /**
  97792. * Gets version of the current webGL context
  97793. */
  97794. readonly webGLVersion: number;
  97795. /**
  97796. * Gets a string idenfifying the name of the class
  97797. * @returns "Engine" string
  97798. */
  97799. getClassName(): string;
  97800. /**
  97801. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  97802. */
  97803. readonly isStencilEnable: boolean;
  97804. /** @hidden */
  97805. _prepareWorkingCanvas(): void;
  97806. /**
  97807. * Reset the texture cache to empty state
  97808. */
  97809. resetTextureCache(): void;
  97810. /**
  97811. * Gets an object containing information about the current webGL context
  97812. * @returns an object containing the vender, the renderer and the version of the current webGL context
  97813. */
  97814. getGlInfo(): {
  97815. vendor: string;
  97816. renderer: string;
  97817. version: string;
  97818. };
  97819. /**
  97820. * Defines the hardware scaling level.
  97821. * By default the hardware scaling level is computed from the window device ratio.
  97822. * 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.
  97823. * @param level defines the level to use
  97824. */
  97825. setHardwareScalingLevel(level: number): void;
  97826. /**
  97827. * Gets the current hardware scaling level.
  97828. * By default the hardware scaling level is computed from the window device ratio.
  97829. * 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.
  97830. * @returns a number indicating the current hardware scaling level
  97831. */
  97832. getHardwareScalingLevel(): number;
  97833. /**
  97834. * Gets the list of loaded textures
  97835. * @returns an array containing all loaded textures
  97836. */
  97837. getLoadedTexturesCache(): InternalTexture[];
  97838. /**
  97839. * Gets the object containing all engine capabilities
  97840. * @returns the EngineCapabilities object
  97841. */
  97842. getCaps(): EngineCapabilities;
  97843. /**
  97844. * stop executing a render loop function and remove it from the execution array
  97845. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  97846. */
  97847. stopRenderLoop(renderFunction?: () => void): void;
  97848. /** @hidden */
  97849. _renderLoop(): void;
  97850. /**
  97851. * Gets the HTML canvas attached with the current webGL context
  97852. * @returns a HTML canvas
  97853. */
  97854. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  97855. /**
  97856. * Gets host window
  97857. * @returns the host window object
  97858. */
  97859. getHostWindow(): Nullable<Window>;
  97860. /**
  97861. * Gets the current render width
  97862. * @param useScreen defines if screen size must be used (or the current render target if any)
  97863. * @returns a number defining the current render width
  97864. */
  97865. getRenderWidth(useScreen?: boolean): number;
  97866. /**
  97867. * Gets the current render height
  97868. * @param useScreen defines if screen size must be used (or the current render target if any)
  97869. * @returns a number defining the current render height
  97870. */
  97871. getRenderHeight(useScreen?: boolean): number;
  97872. /**
  97873. * Can be used to override the current requestAnimationFrame requester.
  97874. * @hidden
  97875. */
  97876. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  97877. /**
  97878. * Register and execute a render loop. The engine can have more than one render function
  97879. * @param renderFunction defines the function to continuously execute
  97880. */
  97881. runRenderLoop(renderFunction: () => void): void;
  97882. /**
  97883. * Clear the current render buffer or the current render target (if any is set up)
  97884. * @param color defines the color to use
  97885. * @param backBuffer defines if the back buffer must be cleared
  97886. * @param depth defines if the depth buffer must be cleared
  97887. * @param stencil defines if the stencil buffer must be cleared
  97888. */
  97889. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97890. private _viewportCached;
  97891. /** @hidden */
  97892. _viewport(x: number, y: number, width: number, height: number): void;
  97893. /**
  97894. * Set the WebGL's viewport
  97895. * @param viewport defines the viewport element to be used
  97896. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  97897. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  97898. */
  97899. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  97900. /**
  97901. * Begin a new frame
  97902. */
  97903. beginFrame(): void;
  97904. /**
  97905. * Enf the current frame
  97906. */
  97907. endFrame(): void;
  97908. /**
  97909. * Resize the view according to the canvas' size
  97910. */
  97911. resize(): void;
  97912. /**
  97913. * Force a specific size of the canvas
  97914. * @param width defines the new canvas' width
  97915. * @param height defines the new canvas' height
  97916. */
  97917. setSize(width: number, height: number): void;
  97918. /**
  97919. * Binds the frame buffer to the specified texture.
  97920. * @param texture The texture to render to or null for the default canvas
  97921. * @param faceIndex The face of the texture to render to in case of cube texture
  97922. * @param requiredWidth The width of the target to render to
  97923. * @param requiredHeight The height of the target to render to
  97924. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  97925. * @param depthStencilTexture The depth stencil texture to use to render
  97926. * @param lodLevel defines le lod level to bind to the frame buffer
  97927. */
  97928. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  97929. /** @hidden */
  97930. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  97931. /**
  97932. * Unbind the current render target texture from the webGL context
  97933. * @param texture defines the render target texture to unbind
  97934. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  97935. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  97936. */
  97937. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97938. /**
  97939. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  97940. */
  97941. flushFramebuffer(): void;
  97942. /**
  97943. * Unbind the current render target and bind the default framebuffer
  97944. */
  97945. restoreDefaultFramebuffer(): void;
  97946. /** @hidden */
  97947. protected _resetVertexBufferBinding(): void;
  97948. /**
  97949. * Creates a vertex buffer
  97950. * @param data the data for the vertex buffer
  97951. * @returns the new WebGL static buffer
  97952. */
  97953. createVertexBuffer(data: DataArray): DataBuffer;
  97954. private _createVertexBuffer;
  97955. /**
  97956. * Creates a dynamic vertex buffer
  97957. * @param data the data for the dynamic vertex buffer
  97958. * @returns the new WebGL dynamic buffer
  97959. */
  97960. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  97961. protected _resetIndexBufferBinding(): void;
  97962. /**
  97963. * Creates a new index buffer
  97964. * @param indices defines the content of the index buffer
  97965. * @param updatable defines if the index buffer must be updatable
  97966. * @returns a new webGL buffer
  97967. */
  97968. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  97969. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  97970. /**
  97971. * Bind a webGL buffer to the webGL context
  97972. * @param buffer defines the buffer to bind
  97973. */
  97974. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  97975. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  97976. private bindBuffer;
  97977. /**
  97978. * update the bound buffer with the given data
  97979. * @param data defines the data to update
  97980. */
  97981. updateArrayBuffer(data: Float32Array): void;
  97982. private _vertexAttribPointer;
  97983. private _bindIndexBufferWithCache;
  97984. private _bindVertexBuffersAttributes;
  97985. /**
  97986. * Records a vertex array object
  97987. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97988. * @param vertexBuffers defines the list of vertex buffers to store
  97989. * @param indexBuffer defines the index buffer to store
  97990. * @param effect defines the effect to store
  97991. * @returns the new vertex array object
  97992. */
  97993. recordVertexArrayObject(vertexBuffers: {
  97994. [key: string]: VertexBuffer;
  97995. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  97996. /**
  97997. * Bind a specific vertex array object
  97998. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97999. * @param vertexArrayObject defines the vertex array object to bind
  98000. * @param indexBuffer defines the index buffer to bind
  98001. */
  98002. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  98003. /**
  98004. * Bind webGl buffers directly to the webGL context
  98005. * @param vertexBuffer defines the vertex buffer to bind
  98006. * @param indexBuffer defines the index buffer to bind
  98007. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  98008. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  98009. * @param effect defines the effect associated with the vertex buffer
  98010. */
  98011. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  98012. private _unbindVertexArrayObject;
  98013. /**
  98014. * Bind a list of vertex buffers to the webGL context
  98015. * @param vertexBuffers defines the list of vertex buffers to bind
  98016. * @param indexBuffer defines the index buffer to bind
  98017. * @param effect defines the effect associated with the vertex buffers
  98018. */
  98019. bindBuffers(vertexBuffers: {
  98020. [key: string]: Nullable<VertexBuffer>;
  98021. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  98022. /**
  98023. * Unbind all instance attributes
  98024. */
  98025. unbindInstanceAttributes(): void;
  98026. /**
  98027. * Release and free the memory of a vertex array object
  98028. * @param vao defines the vertex array object to delete
  98029. */
  98030. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  98031. /** @hidden */
  98032. _releaseBuffer(buffer: DataBuffer): boolean;
  98033. protected _deleteBuffer(buffer: DataBuffer): void;
  98034. /**
  98035. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  98036. * @param instancesBuffer defines the webGL buffer to update and bind
  98037. * @param data defines the data to store in the buffer
  98038. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  98039. */
  98040. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  98041. /**
  98042. * Apply all cached states (depth, culling, stencil and alpha)
  98043. */
  98044. applyStates(): void;
  98045. /**
  98046. * Send a draw order
  98047. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98048. * @param indexStart defines the starting index
  98049. * @param indexCount defines the number of index to draw
  98050. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98051. */
  98052. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98053. /**
  98054. * Draw a list of points
  98055. * @param verticesStart defines the index of first vertex to draw
  98056. * @param verticesCount defines the count of vertices to draw
  98057. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98058. */
  98059. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98060. /**
  98061. * Draw a list of unindexed primitives
  98062. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98063. * @param verticesStart defines the index of first vertex to draw
  98064. * @param verticesCount defines the count of vertices to draw
  98065. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98066. */
  98067. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98068. /**
  98069. * Draw a list of indexed primitives
  98070. * @param fillMode defines the primitive to use
  98071. * @param indexStart defines the starting index
  98072. * @param indexCount defines the number of index to draw
  98073. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98074. */
  98075. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98076. /**
  98077. * Draw a list of unindexed primitives
  98078. * @param fillMode defines the primitive to use
  98079. * @param verticesStart defines the index of first vertex to draw
  98080. * @param verticesCount defines the count of vertices to draw
  98081. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98082. */
  98083. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98084. private _drawMode;
  98085. /** @hidden */
  98086. protected _reportDrawCall(): void;
  98087. /** @hidden */
  98088. _releaseEffect(effect: Effect): void;
  98089. /** @hidden */
  98090. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98091. /**
  98092. * Create a new effect (used to store vertex/fragment shaders)
  98093. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  98094. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  98095. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  98096. * @param samplers defines an array of string used to represent textures
  98097. * @param defines defines the string containing the defines to use to compile the shaders
  98098. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  98099. * @param onCompiled defines a function to call when the effect creation is successful
  98100. * @param onError defines a function to call when the effect creation has failed
  98101. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  98102. * @returns the new Effect
  98103. */
  98104. 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;
  98105. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  98106. private _compileShader;
  98107. private _compileRawShader;
  98108. /**
  98109. * Directly creates a webGL program
  98110. * @param pipelineContext defines the pipeline context to attach to
  98111. * @param vertexCode defines the vertex shader code to use
  98112. * @param fragmentCode defines the fragment shader code to use
  98113. * @param context defines the webGL context to use (if not set, the current one will be used)
  98114. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98115. * @returns the new webGL program
  98116. */
  98117. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98118. /**
  98119. * Creates a webGL program
  98120. * @param pipelineContext defines the pipeline context to attach to
  98121. * @param vertexCode defines the vertex shader code to use
  98122. * @param fragmentCode defines the fragment shader code to use
  98123. * @param defines defines the string containing the defines to use to compile the shaders
  98124. * @param context defines the webGL context to use (if not set, the current one will be used)
  98125. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98126. * @returns the new webGL program
  98127. */
  98128. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98129. /**
  98130. * Creates a new pipeline context
  98131. * @returns the new pipeline
  98132. */
  98133. createPipelineContext(): IPipelineContext;
  98134. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98135. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  98136. /** @hidden */
  98137. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  98138. /** @hidden */
  98139. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  98140. /** @hidden */
  98141. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  98142. /**
  98143. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  98144. * @param pipelineContext defines the pipeline context to use
  98145. * @param uniformsNames defines the list of uniform names
  98146. * @returns an array of webGL uniform locations
  98147. */
  98148. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  98149. /**
  98150. * Gets the lsit of active attributes for a given webGL program
  98151. * @param pipelineContext defines the pipeline context to use
  98152. * @param attributesNames defines the list of attribute names to get
  98153. * @returns an array of indices indicating the offset of each attribute
  98154. */
  98155. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  98156. /**
  98157. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  98158. * @param effect defines the effect to activate
  98159. */
  98160. enableEffect(effect: Nullable<Effect>): void;
  98161. /**
  98162. * Set the value of an uniform to a number (int)
  98163. * @param uniform defines the webGL uniform location where to store the value
  98164. * @param value defines the int number to store
  98165. */
  98166. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98167. /**
  98168. * Set the value of an uniform to an array of int32
  98169. * @param uniform defines the webGL uniform location where to store the value
  98170. * @param array defines the array of int32 to store
  98171. */
  98172. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98173. /**
  98174. * Set the value of an uniform to an array of int32 (stored as vec2)
  98175. * @param uniform defines the webGL uniform location where to store the value
  98176. * @param array defines the array of int32 to store
  98177. */
  98178. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98179. /**
  98180. * Set the value of an uniform to an array of int32 (stored as vec3)
  98181. * @param uniform defines the webGL uniform location where to store the value
  98182. * @param array defines the array of int32 to store
  98183. */
  98184. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98185. /**
  98186. * Set the value of an uniform to an array of int32 (stored as vec4)
  98187. * @param uniform defines the webGL uniform location where to store the value
  98188. * @param array defines the array of int32 to store
  98189. */
  98190. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98191. /**
  98192. * Set the value of an uniform to an array of number
  98193. * @param uniform defines the webGL uniform location where to store the value
  98194. * @param array defines the array of number to store
  98195. */
  98196. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98197. /**
  98198. * Set the value of an uniform to an array of number (stored as vec2)
  98199. * @param uniform defines the webGL uniform location where to store the value
  98200. * @param array defines the array of number to store
  98201. */
  98202. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98203. /**
  98204. * Set the value of an uniform to an array of number (stored as vec3)
  98205. * @param uniform defines the webGL uniform location where to store the value
  98206. * @param array defines the array of number to store
  98207. */
  98208. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98209. /**
  98210. * Set the value of an uniform to an array of number (stored as vec4)
  98211. * @param uniform defines the webGL uniform location where to store the value
  98212. * @param array defines the array of number to store
  98213. */
  98214. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98215. /**
  98216. * Set the value of an uniform to an array of float32 (stored as matrices)
  98217. * @param uniform defines the webGL uniform location where to store the value
  98218. * @param matrices defines the array of float32 to store
  98219. */
  98220. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  98221. /**
  98222. * Set the value of an uniform to a matrix (3x3)
  98223. * @param uniform defines the webGL uniform location where to store the value
  98224. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  98225. */
  98226. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98227. /**
  98228. * Set the value of an uniform to a matrix (2x2)
  98229. * @param uniform defines the webGL uniform location where to store the value
  98230. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  98231. */
  98232. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98233. /**
  98234. * Set the value of an uniform to a number (float)
  98235. * @param uniform defines the webGL uniform location where to store the value
  98236. * @param value defines the float number to store
  98237. */
  98238. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98239. /**
  98240. * Set the value of an uniform to a vec2
  98241. * @param uniform defines the webGL uniform location where to store the value
  98242. * @param x defines the 1st component of the value
  98243. * @param y defines the 2nd component of the value
  98244. */
  98245. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  98246. /**
  98247. * Set the value of an uniform to a vec3
  98248. * @param uniform defines the webGL uniform location where to store the value
  98249. * @param x defines the 1st component of the value
  98250. * @param y defines the 2nd component of the value
  98251. * @param z defines the 3rd component of the value
  98252. */
  98253. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  98254. /**
  98255. * Set the value of an uniform to a vec4
  98256. * @param uniform defines the webGL uniform location where to store the value
  98257. * @param x defines the 1st component of the value
  98258. * @param y defines the 2nd component of the value
  98259. * @param z defines the 3rd component of the value
  98260. * @param w defines the 4th component of the value
  98261. */
  98262. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  98263. /**
  98264. * Gets the depth culling state manager
  98265. */
  98266. readonly depthCullingState: DepthCullingState;
  98267. /**
  98268. * Gets the alpha state manager
  98269. */
  98270. readonly alphaState: AlphaState;
  98271. /**
  98272. * Gets the stencil state manager
  98273. */
  98274. readonly stencilState: StencilState;
  98275. /**
  98276. * Clears the list of texture accessible through engine.
  98277. * This can help preventing texture load conflict due to name collision.
  98278. */
  98279. clearInternalTexturesCache(): void;
  98280. /**
  98281. * Force the entire cache to be cleared
  98282. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  98283. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  98284. */
  98285. wipeCaches(bruteForce?: boolean): void;
  98286. /** @hidden */
  98287. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  98288. min: number;
  98289. mag: number;
  98290. };
  98291. /** @hidden */
  98292. _createTexture(): WebGLTexture;
  98293. /**
  98294. * Usually called from Texture.ts.
  98295. * Passed information to create a WebGLTexture
  98296. * @param urlArg defines a value which contains one of the following:
  98297. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  98298. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  98299. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  98300. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  98301. * @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)
  98302. * @param scene needed for loading to the correct scene
  98303. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  98304. * @param onLoad optional callback to be called upon successful completion
  98305. * @param onError optional callback to be called upon failure
  98306. * @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
  98307. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  98308. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  98309. * @param forcedExtension defines the extension to use to pick the right loader
  98310. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  98311. * @param mimeType defines an optional mime type
  98312. * @returns a InternalTexture for assignment back into BABYLON.Texture
  98313. */
  98314. 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;
  98315. /**
  98316. * @hidden
  98317. */
  98318. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98319. /**
  98320. * Creates a raw texture
  98321. * @param data defines the data to store in the texture
  98322. * @param width defines the width of the texture
  98323. * @param height defines the height of the texture
  98324. * @param format defines the format of the data
  98325. * @param generateMipMaps defines if the engine should generate the mip levels
  98326. * @param invertY defines if data must be stored with Y axis inverted
  98327. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98328. * @param compression defines the compression used (null by default)
  98329. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98330. * @returns the raw texture inside an InternalTexture
  98331. */
  98332. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  98333. /**
  98334. * Creates a new raw cube texture
  98335. * @param data defines the array of data to use to create each face
  98336. * @param size defines the size of the textures
  98337. * @param format defines the format of the data
  98338. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98339. * @param generateMipMaps defines if the engine should generate the mip levels
  98340. * @param invertY defines if data must be stored with Y axis inverted
  98341. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98342. * @param compression defines the compression used (null by default)
  98343. * @returns the cube texture as an InternalTexture
  98344. */
  98345. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  98346. /**
  98347. * Creates a new raw 3D texture
  98348. * @param data defines the data used to create the texture
  98349. * @param width defines the width of the texture
  98350. * @param height defines the height of the texture
  98351. * @param depth defines the depth of the texture
  98352. * @param format defines the format of the texture
  98353. * @param generateMipMaps defines if the engine must generate mip levels
  98354. * @param invertY defines if data must be stored with Y axis inverted
  98355. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98356. * @param compression defines the compressed used (can be null)
  98357. * @param textureType defines the compressed used (can be null)
  98358. * @returns a new raw 3D texture (stored in an InternalTexture)
  98359. */
  98360. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98361. /**
  98362. * Creates a new raw 2D array texture
  98363. * @param data defines the data used to create the texture
  98364. * @param width defines the width of the texture
  98365. * @param height defines the height of the texture
  98366. * @param depth defines the number of layers of the texture
  98367. * @param format defines the format of the texture
  98368. * @param generateMipMaps defines if the engine must generate mip levels
  98369. * @param invertY defines if data must be stored with Y axis inverted
  98370. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98371. * @param compression defines the compressed used (can be null)
  98372. * @param textureType defines the compressed used (can be null)
  98373. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98374. */
  98375. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98376. private _unpackFlipYCached;
  98377. /**
  98378. * In case you are sharing the context with other applications, it might
  98379. * be interested to not cache the unpack flip y state to ensure a consistent
  98380. * value would be set.
  98381. */
  98382. enableUnpackFlipYCached: boolean;
  98383. /** @hidden */
  98384. _unpackFlipY(value: boolean): void;
  98385. /** @hidden */
  98386. _getUnpackAlignement(): number;
  98387. /**
  98388. * Update the sampling mode of a given texture
  98389. * @param samplingMode defines the required sampling mode
  98390. * @param texture defines the texture to update
  98391. */
  98392. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98393. /** @hidden */
  98394. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  98395. width: number;
  98396. height: number;
  98397. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  98398. /** @hidden */
  98399. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98400. /** @hidden */
  98401. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  98402. /** @hidden */
  98403. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98404. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  98405. private _prepareWebGLTexture;
  98406. /** @hidden */
  98407. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  98408. /** @hidden */
  98409. _releaseFramebufferObjects(texture: InternalTexture): void;
  98410. /** @hidden */
  98411. _releaseTexture(texture: InternalTexture): void;
  98412. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  98413. protected _setProgram(program: WebGLProgram): void;
  98414. protected _boundUniforms: {
  98415. [key: number]: WebGLUniformLocation;
  98416. };
  98417. /**
  98418. * Binds an effect to the webGL context
  98419. * @param effect defines the effect to bind
  98420. */
  98421. bindSamplers(effect: Effect): void;
  98422. private _activateCurrentTexture;
  98423. /** @hidden */
  98424. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  98425. /** @hidden */
  98426. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  98427. /**
  98428. * Unbind all textures from the webGL context
  98429. */
  98430. unbindAllTextures(): void;
  98431. /**
  98432. * Sets a texture to the according uniform.
  98433. * @param channel The texture channel
  98434. * @param uniform The uniform to set
  98435. * @param texture The texture to apply
  98436. */
  98437. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  98438. private _bindSamplerUniformToChannel;
  98439. private _getTextureWrapMode;
  98440. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  98441. /**
  98442. * Sets an array of texture to the webGL context
  98443. * @param channel defines the channel where the texture array must be set
  98444. * @param uniform defines the associated uniform location
  98445. * @param textures defines the array of textures to bind
  98446. */
  98447. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  98448. /** @hidden */
  98449. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  98450. private _setTextureParameterFloat;
  98451. private _setTextureParameterInteger;
  98452. /**
  98453. * Unbind all vertex attributes from the webGL context
  98454. */
  98455. unbindAllAttributes(): void;
  98456. /**
  98457. * 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
  98458. */
  98459. releaseEffects(): void;
  98460. /**
  98461. * Dispose and release all associated resources
  98462. */
  98463. dispose(): void;
  98464. /**
  98465. * Attach a new callback raised when context lost event is fired
  98466. * @param callback defines the callback to call
  98467. */
  98468. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98469. /**
  98470. * Attach a new callback raised when context restored event is fired
  98471. * @param callback defines the callback to call
  98472. */
  98473. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98474. /**
  98475. * Get the current error code of the webGL context
  98476. * @returns the error code
  98477. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98478. */
  98479. getError(): number;
  98480. private _canRenderToFloatFramebuffer;
  98481. private _canRenderToHalfFloatFramebuffer;
  98482. private _canRenderToFramebuffer;
  98483. /** @hidden */
  98484. _getWebGLTextureType(type: number): number;
  98485. /** @hidden */
  98486. _getInternalFormat(format: number): number;
  98487. /** @hidden */
  98488. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  98489. /** @hidden */
  98490. _getRGBAMultiSampleBufferFormat(type: number): number;
  98491. /** @hidden */
  98492. _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;
  98493. /**
  98494. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  98495. * @returns true if the engine can be created
  98496. * @ignorenaming
  98497. */
  98498. static isSupported(): boolean;
  98499. /**
  98500. * Find the next highest power of two.
  98501. * @param x Number to start search from.
  98502. * @return Next highest power of two.
  98503. */
  98504. static CeilingPOT(x: number): number;
  98505. /**
  98506. * Find the next lowest power of two.
  98507. * @param x Number to start search from.
  98508. * @return Next lowest power of two.
  98509. */
  98510. static FloorPOT(x: number): number;
  98511. /**
  98512. * Find the nearest power of two.
  98513. * @param x Number to start search from.
  98514. * @return Next nearest power of two.
  98515. */
  98516. static NearestPOT(x: number): number;
  98517. /**
  98518. * Get the closest exponent of two
  98519. * @param value defines the value to approximate
  98520. * @param max defines the maximum value to return
  98521. * @param mode defines how to define the closest value
  98522. * @returns closest exponent of two of the given value
  98523. */
  98524. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  98525. /**
  98526. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98527. * @param func - the function to be called
  98528. * @param requester - the object that will request the next frame. Falls back to window.
  98529. * @returns frame number
  98530. */
  98531. static QueueNewFrame(func: () => void, requester?: any): number;
  98532. }
  98533. }
  98534. declare module BABYLON {
  98535. /**
  98536. * Class representing spherical harmonics coefficients to the 3rd degree
  98537. */
  98538. export class SphericalHarmonics {
  98539. /**
  98540. * Defines whether or not the harmonics have been prescaled for rendering.
  98541. */
  98542. preScaled: boolean;
  98543. /**
  98544. * The l0,0 coefficients of the spherical harmonics
  98545. */
  98546. l00: Vector3;
  98547. /**
  98548. * The l1,-1 coefficients of the spherical harmonics
  98549. */
  98550. l1_1: Vector3;
  98551. /**
  98552. * The l1,0 coefficients of the spherical harmonics
  98553. */
  98554. l10: Vector3;
  98555. /**
  98556. * The l1,1 coefficients of the spherical harmonics
  98557. */
  98558. l11: Vector3;
  98559. /**
  98560. * The l2,-2 coefficients of the spherical harmonics
  98561. */
  98562. l2_2: Vector3;
  98563. /**
  98564. * The l2,-1 coefficients of the spherical harmonics
  98565. */
  98566. l2_1: Vector3;
  98567. /**
  98568. * The l2,0 coefficients of the spherical harmonics
  98569. */
  98570. l20: Vector3;
  98571. /**
  98572. * The l2,1 coefficients of the spherical harmonics
  98573. */
  98574. l21: Vector3;
  98575. /**
  98576. * The l2,2 coefficients of the spherical harmonics
  98577. */
  98578. l22: Vector3;
  98579. /**
  98580. * Adds a light to the spherical harmonics
  98581. * @param direction the direction of the light
  98582. * @param color the color of the light
  98583. * @param deltaSolidAngle the delta solid angle of the light
  98584. */
  98585. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  98586. /**
  98587. * Scales the spherical harmonics by the given amount
  98588. * @param scale the amount to scale
  98589. */
  98590. scaleInPlace(scale: number): void;
  98591. /**
  98592. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  98593. *
  98594. * ```
  98595. * E_lm = A_l * L_lm
  98596. * ```
  98597. *
  98598. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  98599. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  98600. * the scaling factors are given in equation 9.
  98601. */
  98602. convertIncidentRadianceToIrradiance(): void;
  98603. /**
  98604. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  98605. *
  98606. * ```
  98607. * L = (1/pi) * E * rho
  98608. * ```
  98609. *
  98610. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  98611. */
  98612. convertIrradianceToLambertianRadiance(): void;
  98613. /**
  98614. * Integrates the reconstruction coefficients directly in to the SH preventing further
  98615. * required operations at run time.
  98616. *
  98617. * This is simply done by scaling back the SH with Ylm constants parameter.
  98618. * The trigonometric part being applied by the shader at run time.
  98619. */
  98620. preScaleForRendering(): void;
  98621. /**
  98622. * Constructs a spherical harmonics from an array.
  98623. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  98624. * @returns the spherical harmonics
  98625. */
  98626. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  98627. /**
  98628. * Gets the spherical harmonics from polynomial
  98629. * @param polynomial the spherical polynomial
  98630. * @returns the spherical harmonics
  98631. */
  98632. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  98633. }
  98634. /**
  98635. * Class representing spherical polynomial coefficients to the 3rd degree
  98636. */
  98637. export class SphericalPolynomial {
  98638. private _harmonics;
  98639. /**
  98640. * The spherical harmonics used to create the polynomials.
  98641. */
  98642. readonly preScaledHarmonics: SphericalHarmonics;
  98643. /**
  98644. * The x coefficients of the spherical polynomial
  98645. */
  98646. x: Vector3;
  98647. /**
  98648. * The y coefficients of the spherical polynomial
  98649. */
  98650. y: Vector3;
  98651. /**
  98652. * The z coefficients of the spherical polynomial
  98653. */
  98654. z: Vector3;
  98655. /**
  98656. * The xx coefficients of the spherical polynomial
  98657. */
  98658. xx: Vector3;
  98659. /**
  98660. * The yy coefficients of the spherical polynomial
  98661. */
  98662. yy: Vector3;
  98663. /**
  98664. * The zz coefficients of the spherical polynomial
  98665. */
  98666. zz: Vector3;
  98667. /**
  98668. * The xy coefficients of the spherical polynomial
  98669. */
  98670. xy: Vector3;
  98671. /**
  98672. * The yz coefficients of the spherical polynomial
  98673. */
  98674. yz: Vector3;
  98675. /**
  98676. * The zx coefficients of the spherical polynomial
  98677. */
  98678. zx: Vector3;
  98679. /**
  98680. * Adds an ambient color to the spherical polynomial
  98681. * @param color the color to add
  98682. */
  98683. addAmbient(color: Color3): void;
  98684. /**
  98685. * Scales the spherical polynomial by the given amount
  98686. * @param scale the amount to scale
  98687. */
  98688. scaleInPlace(scale: number): void;
  98689. /**
  98690. * Gets the spherical polynomial from harmonics
  98691. * @param harmonics the spherical harmonics
  98692. * @returns the spherical polynomial
  98693. */
  98694. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  98695. /**
  98696. * Constructs a spherical polynomial from an array.
  98697. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  98698. * @returns the spherical polynomial
  98699. */
  98700. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  98701. }
  98702. }
  98703. declare module BABYLON {
  98704. /**
  98705. * Defines the source of the internal texture
  98706. */
  98707. export enum InternalTextureSource {
  98708. /**
  98709. * The source of the texture data is unknown
  98710. */
  98711. Unknown = 0,
  98712. /**
  98713. * Texture data comes from an URL
  98714. */
  98715. Url = 1,
  98716. /**
  98717. * Texture data is only used for temporary storage
  98718. */
  98719. Temp = 2,
  98720. /**
  98721. * Texture data comes from raw data (ArrayBuffer)
  98722. */
  98723. Raw = 3,
  98724. /**
  98725. * Texture content is dynamic (video or dynamic texture)
  98726. */
  98727. Dynamic = 4,
  98728. /**
  98729. * Texture content is generated by rendering to it
  98730. */
  98731. RenderTarget = 5,
  98732. /**
  98733. * Texture content is part of a multi render target process
  98734. */
  98735. MultiRenderTarget = 6,
  98736. /**
  98737. * Texture data comes from a cube data file
  98738. */
  98739. Cube = 7,
  98740. /**
  98741. * Texture data comes from a raw cube data
  98742. */
  98743. CubeRaw = 8,
  98744. /**
  98745. * Texture data come from a prefiltered cube data file
  98746. */
  98747. CubePrefiltered = 9,
  98748. /**
  98749. * Texture content is raw 3D data
  98750. */
  98751. Raw3D = 10,
  98752. /**
  98753. * Texture content is raw 2D array data
  98754. */
  98755. Raw2DArray = 11,
  98756. /**
  98757. * Texture content is a depth texture
  98758. */
  98759. Depth = 12,
  98760. /**
  98761. * Texture data comes from a raw cube data encoded with RGBD
  98762. */
  98763. CubeRawRGBD = 13
  98764. }
  98765. /**
  98766. * Class used to store data associated with WebGL texture data for the engine
  98767. * This class should not be used directly
  98768. */
  98769. export class InternalTexture {
  98770. /** @hidden */
  98771. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  98772. /**
  98773. * Defines if the texture is ready
  98774. */
  98775. isReady: boolean;
  98776. /**
  98777. * Defines if the texture is a cube texture
  98778. */
  98779. isCube: boolean;
  98780. /**
  98781. * Defines if the texture contains 3D data
  98782. */
  98783. is3D: boolean;
  98784. /**
  98785. * Defines if the texture contains 2D array data
  98786. */
  98787. is2DArray: boolean;
  98788. /**
  98789. * Defines if the texture contains multiview data
  98790. */
  98791. isMultiview: boolean;
  98792. /**
  98793. * Gets the URL used to load this texture
  98794. */
  98795. url: string;
  98796. /**
  98797. * Gets the sampling mode of the texture
  98798. */
  98799. samplingMode: number;
  98800. /**
  98801. * Gets a boolean indicating if the texture needs mipmaps generation
  98802. */
  98803. generateMipMaps: boolean;
  98804. /**
  98805. * Gets the number of samples used by the texture (WebGL2+ only)
  98806. */
  98807. samples: number;
  98808. /**
  98809. * Gets the type of the texture (int, float...)
  98810. */
  98811. type: number;
  98812. /**
  98813. * Gets the format of the texture (RGB, RGBA...)
  98814. */
  98815. format: number;
  98816. /**
  98817. * Observable called when the texture is loaded
  98818. */
  98819. onLoadedObservable: Observable<InternalTexture>;
  98820. /**
  98821. * Gets the width of the texture
  98822. */
  98823. width: number;
  98824. /**
  98825. * Gets the height of the texture
  98826. */
  98827. height: number;
  98828. /**
  98829. * Gets the depth of the texture
  98830. */
  98831. depth: number;
  98832. /**
  98833. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  98834. */
  98835. baseWidth: number;
  98836. /**
  98837. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  98838. */
  98839. baseHeight: number;
  98840. /**
  98841. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  98842. */
  98843. baseDepth: number;
  98844. /**
  98845. * Gets a boolean indicating if the texture is inverted on Y axis
  98846. */
  98847. invertY: boolean;
  98848. /** @hidden */
  98849. _invertVScale: boolean;
  98850. /** @hidden */
  98851. _associatedChannel: number;
  98852. /** @hidden */
  98853. _source: InternalTextureSource;
  98854. /** @hidden */
  98855. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  98856. /** @hidden */
  98857. _bufferView: Nullable<ArrayBufferView>;
  98858. /** @hidden */
  98859. _bufferViewArray: Nullable<ArrayBufferView[]>;
  98860. /** @hidden */
  98861. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  98862. /** @hidden */
  98863. _size: number;
  98864. /** @hidden */
  98865. _extension: string;
  98866. /** @hidden */
  98867. _files: Nullable<string[]>;
  98868. /** @hidden */
  98869. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98870. /** @hidden */
  98871. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98872. /** @hidden */
  98873. _framebuffer: Nullable<WebGLFramebuffer>;
  98874. /** @hidden */
  98875. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  98876. /** @hidden */
  98877. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  98878. /** @hidden */
  98879. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  98880. /** @hidden */
  98881. _attachments: Nullable<number[]>;
  98882. /** @hidden */
  98883. _cachedCoordinatesMode: Nullable<number>;
  98884. /** @hidden */
  98885. _cachedWrapU: Nullable<number>;
  98886. /** @hidden */
  98887. _cachedWrapV: Nullable<number>;
  98888. /** @hidden */
  98889. _cachedWrapR: Nullable<number>;
  98890. /** @hidden */
  98891. _cachedAnisotropicFilteringLevel: Nullable<number>;
  98892. /** @hidden */
  98893. _isDisabled: boolean;
  98894. /** @hidden */
  98895. _compression: Nullable<string>;
  98896. /** @hidden */
  98897. _generateStencilBuffer: boolean;
  98898. /** @hidden */
  98899. _generateDepthBuffer: boolean;
  98900. /** @hidden */
  98901. _comparisonFunction: number;
  98902. /** @hidden */
  98903. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  98904. /** @hidden */
  98905. _lodGenerationScale: number;
  98906. /** @hidden */
  98907. _lodGenerationOffset: number;
  98908. /** @hidden */
  98909. _colorTextureArray: Nullable<WebGLTexture>;
  98910. /** @hidden */
  98911. _depthStencilTextureArray: Nullable<WebGLTexture>;
  98912. /** @hidden */
  98913. _lodTextureHigh: Nullable<BaseTexture>;
  98914. /** @hidden */
  98915. _lodTextureMid: Nullable<BaseTexture>;
  98916. /** @hidden */
  98917. _lodTextureLow: Nullable<BaseTexture>;
  98918. /** @hidden */
  98919. _isRGBD: boolean;
  98920. /** @hidden */
  98921. _linearSpecularLOD: boolean;
  98922. /** @hidden */
  98923. _irradianceTexture: Nullable<BaseTexture>;
  98924. /** @hidden */
  98925. _webGLTexture: Nullable<WebGLTexture>;
  98926. /** @hidden */
  98927. _references: number;
  98928. private _engine;
  98929. /**
  98930. * Gets the Engine the texture belongs to.
  98931. * @returns The babylon engine
  98932. */
  98933. getEngine(): ThinEngine;
  98934. /**
  98935. * Gets the data source type of the texture
  98936. */
  98937. readonly source: InternalTextureSource;
  98938. /**
  98939. * Creates a new InternalTexture
  98940. * @param engine defines the engine to use
  98941. * @param source defines the type of data that will be used
  98942. * @param delayAllocation if the texture allocation should be delayed (default: false)
  98943. */
  98944. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  98945. /**
  98946. * Increments the number of references (ie. the number of Texture that point to it)
  98947. */
  98948. incrementReferences(): void;
  98949. /**
  98950. * Change the size of the texture (not the size of the content)
  98951. * @param width defines the new width
  98952. * @param height defines the new height
  98953. * @param depth defines the new depth (1 by default)
  98954. */
  98955. updateSize(width: int, height: int, depth?: int): void;
  98956. /** @hidden */
  98957. _rebuild(): void;
  98958. /** @hidden */
  98959. _swapAndDie(target: InternalTexture): void;
  98960. /**
  98961. * Dispose the current allocated resources
  98962. */
  98963. dispose(): void;
  98964. }
  98965. }
  98966. declare module BABYLON {
  98967. /**
  98968. * Class used to work with sound analyzer using fast fourier transform (FFT)
  98969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98970. */
  98971. export class Analyser {
  98972. /**
  98973. * Gets or sets the smoothing
  98974. * @ignorenaming
  98975. */
  98976. SMOOTHING: number;
  98977. /**
  98978. * Gets or sets the FFT table size
  98979. * @ignorenaming
  98980. */
  98981. FFT_SIZE: number;
  98982. /**
  98983. * Gets or sets the bar graph amplitude
  98984. * @ignorenaming
  98985. */
  98986. BARGRAPHAMPLITUDE: number;
  98987. /**
  98988. * Gets or sets the position of the debug canvas
  98989. * @ignorenaming
  98990. */
  98991. DEBUGCANVASPOS: {
  98992. x: number;
  98993. y: number;
  98994. };
  98995. /**
  98996. * Gets or sets the debug canvas size
  98997. * @ignorenaming
  98998. */
  98999. DEBUGCANVASSIZE: {
  99000. width: number;
  99001. height: number;
  99002. };
  99003. private _byteFreqs;
  99004. private _byteTime;
  99005. private _floatFreqs;
  99006. private _webAudioAnalyser;
  99007. private _debugCanvas;
  99008. private _debugCanvasContext;
  99009. private _scene;
  99010. private _registerFunc;
  99011. private _audioEngine;
  99012. /**
  99013. * Creates a new analyser
  99014. * @param scene defines hosting scene
  99015. */
  99016. constructor(scene: Scene);
  99017. /**
  99018. * Get the number of data values you will have to play with for the visualization
  99019. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  99020. * @returns a number
  99021. */
  99022. getFrequencyBinCount(): number;
  99023. /**
  99024. * Gets the current frequency data as a byte array
  99025. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99026. * @returns a Uint8Array
  99027. */
  99028. getByteFrequencyData(): Uint8Array;
  99029. /**
  99030. * Gets the current waveform as a byte array
  99031. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  99032. * @returns a Uint8Array
  99033. */
  99034. getByteTimeDomainData(): Uint8Array;
  99035. /**
  99036. * Gets the current frequency data as a float array
  99037. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99038. * @returns a Float32Array
  99039. */
  99040. getFloatFrequencyData(): Float32Array;
  99041. /**
  99042. * Renders the debug canvas
  99043. */
  99044. drawDebugCanvas(): void;
  99045. /**
  99046. * Stops rendering the debug canvas and removes it
  99047. */
  99048. stopDebugCanvas(): void;
  99049. /**
  99050. * Connects two audio nodes
  99051. * @param inputAudioNode defines first node to connect
  99052. * @param outputAudioNode defines second node to connect
  99053. */
  99054. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  99055. /**
  99056. * Releases all associated resources
  99057. */
  99058. dispose(): void;
  99059. }
  99060. }
  99061. declare module BABYLON {
  99062. /**
  99063. * This represents an audio engine and it is responsible
  99064. * to play, synchronize and analyse sounds throughout the application.
  99065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99066. */
  99067. export interface IAudioEngine extends IDisposable {
  99068. /**
  99069. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99070. */
  99071. readonly canUseWebAudio: boolean;
  99072. /**
  99073. * Gets the current AudioContext if available.
  99074. */
  99075. readonly audioContext: Nullable<AudioContext>;
  99076. /**
  99077. * The master gain node defines the global audio volume of your audio engine.
  99078. */
  99079. readonly masterGain: GainNode;
  99080. /**
  99081. * Gets whether or not mp3 are supported by your browser.
  99082. */
  99083. readonly isMP3supported: boolean;
  99084. /**
  99085. * Gets whether or not ogg are supported by your browser.
  99086. */
  99087. readonly isOGGsupported: boolean;
  99088. /**
  99089. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99090. * @ignoreNaming
  99091. */
  99092. WarnedWebAudioUnsupported: boolean;
  99093. /**
  99094. * Defines if the audio engine relies on a custom unlocked button.
  99095. * In this case, the embedded button will not be displayed.
  99096. */
  99097. useCustomUnlockedButton: boolean;
  99098. /**
  99099. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  99100. */
  99101. readonly unlocked: boolean;
  99102. /**
  99103. * Event raised when audio has been unlocked on the browser.
  99104. */
  99105. onAudioUnlockedObservable: Observable<AudioEngine>;
  99106. /**
  99107. * Event raised when audio has been locked on the browser.
  99108. */
  99109. onAudioLockedObservable: Observable<AudioEngine>;
  99110. /**
  99111. * Flags the audio engine in Locked state.
  99112. * This happens due to new browser policies preventing audio to autoplay.
  99113. */
  99114. lock(): void;
  99115. /**
  99116. * Unlocks the audio engine once a user action has been done on the dom.
  99117. * This is helpful to resume play once browser policies have been satisfied.
  99118. */
  99119. unlock(): void;
  99120. }
  99121. /**
  99122. * This represents the default audio engine used in babylon.
  99123. * It is responsible to play, synchronize and analyse sounds throughout the application.
  99124. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99125. */
  99126. export class AudioEngine implements IAudioEngine {
  99127. private _audioContext;
  99128. private _audioContextInitialized;
  99129. private _muteButton;
  99130. private _hostElement;
  99131. /**
  99132. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99133. */
  99134. canUseWebAudio: boolean;
  99135. /**
  99136. * The master gain node defines the global audio volume of your audio engine.
  99137. */
  99138. masterGain: GainNode;
  99139. /**
  99140. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99141. * @ignoreNaming
  99142. */
  99143. WarnedWebAudioUnsupported: boolean;
  99144. /**
  99145. * Gets whether or not mp3 are supported by your browser.
  99146. */
  99147. isMP3supported: boolean;
  99148. /**
  99149. * Gets whether or not ogg are supported by your browser.
  99150. */
  99151. isOGGsupported: boolean;
  99152. /**
  99153. * Gets whether audio has been unlocked on the device.
  99154. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  99155. * a user interaction has happened.
  99156. */
  99157. unlocked: boolean;
  99158. /**
  99159. * Defines if the audio engine relies on a custom unlocked button.
  99160. * In this case, the embedded button will not be displayed.
  99161. */
  99162. useCustomUnlockedButton: boolean;
  99163. /**
  99164. * Event raised when audio has been unlocked on the browser.
  99165. */
  99166. onAudioUnlockedObservable: Observable<AudioEngine>;
  99167. /**
  99168. * Event raised when audio has been locked on the browser.
  99169. */
  99170. onAudioLockedObservable: Observable<AudioEngine>;
  99171. /**
  99172. * Gets the current AudioContext if available.
  99173. */
  99174. readonly audioContext: Nullable<AudioContext>;
  99175. private _connectedAnalyser;
  99176. /**
  99177. * Instantiates a new audio engine.
  99178. *
  99179. * There should be only one per page as some browsers restrict the number
  99180. * of audio contexts you can create.
  99181. * @param hostElement defines the host element where to display the mute icon if necessary
  99182. */
  99183. constructor(hostElement?: Nullable<HTMLElement>);
  99184. /**
  99185. * Flags the audio engine in Locked state.
  99186. * This happens due to new browser policies preventing audio to autoplay.
  99187. */
  99188. lock(): void;
  99189. /**
  99190. * Unlocks the audio engine once a user action has been done on the dom.
  99191. * This is helpful to resume play once browser policies have been satisfied.
  99192. */
  99193. unlock(): void;
  99194. private _resumeAudioContext;
  99195. private _initializeAudioContext;
  99196. private _tryToRun;
  99197. private _triggerRunningState;
  99198. private _triggerSuspendedState;
  99199. private _displayMuteButton;
  99200. private _moveButtonToTopLeft;
  99201. private _onResize;
  99202. private _hideMuteButton;
  99203. /**
  99204. * Destroy and release the resources associated with the audio ccontext.
  99205. */
  99206. dispose(): void;
  99207. /**
  99208. * Gets the global volume sets on the master gain.
  99209. * @returns the global volume if set or -1 otherwise
  99210. */
  99211. getGlobalVolume(): number;
  99212. /**
  99213. * Sets the global volume of your experience (sets on the master gain).
  99214. * @param newVolume Defines the new global volume of the application
  99215. */
  99216. setGlobalVolume(newVolume: number): void;
  99217. /**
  99218. * Connect the audio engine to an audio analyser allowing some amazing
  99219. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99221. * @param analyser The analyser to connect to the engine
  99222. */
  99223. connectToAnalyser(analyser: Analyser): void;
  99224. }
  99225. }
  99226. declare module BABYLON {
  99227. /**
  99228. * Interface used to present a loading screen while loading a scene
  99229. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99230. */
  99231. export interface ILoadingScreen {
  99232. /**
  99233. * Function called to display the loading screen
  99234. */
  99235. displayLoadingUI: () => void;
  99236. /**
  99237. * Function called to hide the loading screen
  99238. */
  99239. hideLoadingUI: () => void;
  99240. /**
  99241. * Gets or sets the color to use for the background
  99242. */
  99243. loadingUIBackgroundColor: string;
  99244. /**
  99245. * Gets or sets the text to display while loading
  99246. */
  99247. loadingUIText: string;
  99248. }
  99249. /**
  99250. * Class used for the default loading screen
  99251. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99252. */
  99253. export class DefaultLoadingScreen implements ILoadingScreen {
  99254. private _renderingCanvas;
  99255. private _loadingText;
  99256. private _loadingDivBackgroundColor;
  99257. private _loadingDiv;
  99258. private _loadingTextDiv;
  99259. /** Gets or sets the logo url to use for the default loading screen */
  99260. static DefaultLogoUrl: string;
  99261. /** Gets or sets the spinner url to use for the default loading screen */
  99262. static DefaultSpinnerUrl: string;
  99263. /**
  99264. * Creates a new default loading screen
  99265. * @param _renderingCanvas defines the canvas used to render the scene
  99266. * @param _loadingText defines the default text to display
  99267. * @param _loadingDivBackgroundColor defines the default background color
  99268. */
  99269. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  99270. /**
  99271. * Function called to display the loading screen
  99272. */
  99273. displayLoadingUI(): void;
  99274. /**
  99275. * Function called to hide the loading screen
  99276. */
  99277. hideLoadingUI(): void;
  99278. /**
  99279. * Gets or sets the text to display while loading
  99280. */
  99281. loadingUIText: string;
  99282. /**
  99283. * Gets or sets the color to use for the background
  99284. */
  99285. loadingUIBackgroundColor: string;
  99286. private _resizeLoadingUI;
  99287. }
  99288. }
  99289. declare module BABYLON {
  99290. /**
  99291. * Interface for any object that can request an animation frame
  99292. */
  99293. export interface ICustomAnimationFrameRequester {
  99294. /**
  99295. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  99296. */
  99297. renderFunction?: Function;
  99298. /**
  99299. * Called to request the next frame to render to
  99300. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  99301. */
  99302. requestAnimationFrame: Function;
  99303. /**
  99304. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  99305. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  99306. */
  99307. requestID?: number;
  99308. }
  99309. }
  99310. declare module BABYLON {
  99311. /**
  99312. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99313. */
  99314. export class PerformanceMonitor {
  99315. private _enabled;
  99316. private _rollingFrameTime;
  99317. private _lastFrameTimeMs;
  99318. /**
  99319. * constructor
  99320. * @param frameSampleSize The number of samples required to saturate the sliding window
  99321. */
  99322. constructor(frameSampleSize?: number);
  99323. /**
  99324. * Samples current frame
  99325. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99326. */
  99327. sampleFrame(timeMs?: number): void;
  99328. /**
  99329. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99330. */
  99331. readonly averageFrameTime: number;
  99332. /**
  99333. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99334. */
  99335. readonly averageFrameTimeVariance: number;
  99336. /**
  99337. * Returns the frame time of the most recent frame
  99338. */
  99339. readonly instantaneousFrameTime: number;
  99340. /**
  99341. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99342. */
  99343. readonly averageFPS: number;
  99344. /**
  99345. * Returns the average framerate in frames per second using the most recent frame time
  99346. */
  99347. readonly instantaneousFPS: number;
  99348. /**
  99349. * Returns true if enough samples have been taken to completely fill the sliding window
  99350. */
  99351. readonly isSaturated: boolean;
  99352. /**
  99353. * Enables contributions to the sliding window sample set
  99354. */
  99355. enable(): void;
  99356. /**
  99357. * Disables contributions to the sliding window sample set
  99358. * Samples will not be interpolated over the disabled period
  99359. */
  99360. disable(): void;
  99361. /**
  99362. * Returns true if sampling is enabled
  99363. */
  99364. readonly isEnabled: boolean;
  99365. /**
  99366. * Resets performance monitor
  99367. */
  99368. reset(): void;
  99369. }
  99370. /**
  99371. * RollingAverage
  99372. *
  99373. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99374. */
  99375. export class RollingAverage {
  99376. /**
  99377. * Current average
  99378. */
  99379. average: number;
  99380. /**
  99381. * Current variance
  99382. */
  99383. variance: number;
  99384. protected _samples: Array<number>;
  99385. protected _sampleCount: number;
  99386. protected _pos: number;
  99387. protected _m2: number;
  99388. /**
  99389. * constructor
  99390. * @param length The number of samples required to saturate the sliding window
  99391. */
  99392. constructor(length: number);
  99393. /**
  99394. * Adds a sample to the sample set
  99395. * @param v The sample value
  99396. */
  99397. add(v: number): void;
  99398. /**
  99399. * Returns previously added values or null if outside of history or outside the sliding window domain
  99400. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99401. * @return Value previously recorded with add() or null if outside of range
  99402. */
  99403. history(i: number): number;
  99404. /**
  99405. * Returns true if enough samples have been taken to completely fill the sliding window
  99406. * @return true if sample-set saturated
  99407. */
  99408. isSaturated(): boolean;
  99409. /**
  99410. * Resets the rolling average (equivalent to 0 samples taken so far)
  99411. */
  99412. reset(): void;
  99413. /**
  99414. * Wraps a value around the sample range boundaries
  99415. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99416. * @return Wrapped position in sample range
  99417. */
  99418. protected _wrapPosition(i: number): number;
  99419. }
  99420. }
  99421. declare module BABYLON {
  99422. /**
  99423. * This class is used to track a performance counter which is number based.
  99424. * The user has access to many properties which give statistics of different nature.
  99425. *
  99426. * The implementer can track two kinds of Performance Counter: time and count.
  99427. * 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.
  99428. * 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.
  99429. */
  99430. export class PerfCounter {
  99431. /**
  99432. * Gets or sets a global boolean to turn on and off all the counters
  99433. */
  99434. static Enabled: boolean;
  99435. /**
  99436. * Returns the smallest value ever
  99437. */
  99438. readonly min: number;
  99439. /**
  99440. * Returns the biggest value ever
  99441. */
  99442. readonly max: number;
  99443. /**
  99444. * Returns the average value since the performance counter is running
  99445. */
  99446. readonly average: number;
  99447. /**
  99448. * Returns the average value of the last second the counter was monitored
  99449. */
  99450. readonly lastSecAverage: number;
  99451. /**
  99452. * Returns the current value
  99453. */
  99454. readonly current: number;
  99455. /**
  99456. * Gets the accumulated total
  99457. */
  99458. readonly total: number;
  99459. /**
  99460. * Gets the total value count
  99461. */
  99462. readonly count: number;
  99463. /**
  99464. * Creates a new counter
  99465. */
  99466. constructor();
  99467. /**
  99468. * Call this method to start monitoring a new frame.
  99469. * 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.
  99470. */
  99471. fetchNewFrame(): void;
  99472. /**
  99473. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99474. * @param newCount the count value to add to the monitored count
  99475. * @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.
  99476. */
  99477. addCount(newCount: number, fetchResult: boolean): void;
  99478. /**
  99479. * Start monitoring this performance counter
  99480. */
  99481. beginMonitoring(): void;
  99482. /**
  99483. * Compute the time lapsed since the previous beginMonitoring() call.
  99484. * @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
  99485. */
  99486. endMonitoring(newFrame?: boolean): void;
  99487. private _fetchResult;
  99488. private _startMonitoringTime;
  99489. private _min;
  99490. private _max;
  99491. private _average;
  99492. private _current;
  99493. private _totalValueCount;
  99494. private _totalAccumulated;
  99495. private _lastSecAverage;
  99496. private _lastSecAccumulated;
  99497. private _lastSecTime;
  99498. private _lastSecValueCount;
  99499. }
  99500. }
  99501. declare module BABYLON {
  99502. /**
  99503. * Defines the interface used by display changed events
  99504. */
  99505. export interface IDisplayChangedEventArgs {
  99506. /** Gets the vrDisplay object (if any) */
  99507. vrDisplay: Nullable<any>;
  99508. /** Gets a boolean indicating if webVR is supported */
  99509. vrSupported: boolean;
  99510. }
  99511. /**
  99512. * Defines the interface used by objects containing a viewport (like a camera)
  99513. */
  99514. interface IViewportOwnerLike {
  99515. /**
  99516. * Gets or sets the viewport
  99517. */
  99518. viewport: IViewportLike;
  99519. }
  99520. /**
  99521. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  99522. */
  99523. export class Engine extends ThinEngine {
  99524. /** Defines that alpha blending is disabled */
  99525. static readonly ALPHA_DISABLE: number;
  99526. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  99527. static readonly ALPHA_ADD: number;
  99528. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  99529. static readonly ALPHA_COMBINE: number;
  99530. /** Defines that alpha blending to DEST - SRC * DEST */
  99531. static readonly ALPHA_SUBTRACT: number;
  99532. /** Defines that alpha blending to SRC * DEST */
  99533. static readonly ALPHA_MULTIPLY: number;
  99534. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  99535. static readonly ALPHA_MAXIMIZED: number;
  99536. /** Defines that alpha blending to SRC + DEST */
  99537. static readonly ALPHA_ONEONE: number;
  99538. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  99539. static readonly ALPHA_PREMULTIPLIED: number;
  99540. /**
  99541. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  99542. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  99543. */
  99544. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  99545. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  99546. static readonly ALPHA_INTERPOLATE: number;
  99547. /**
  99548. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  99549. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  99550. */
  99551. static readonly ALPHA_SCREENMODE: number;
  99552. /** Defines that the ressource is not delayed*/
  99553. static readonly DELAYLOADSTATE_NONE: number;
  99554. /** Defines that the ressource was successfully delay loaded */
  99555. static readonly DELAYLOADSTATE_LOADED: number;
  99556. /** Defines that the ressource is currently delay loading */
  99557. static readonly DELAYLOADSTATE_LOADING: number;
  99558. /** Defines that the ressource is delayed and has not started loading */
  99559. static readonly DELAYLOADSTATE_NOTLOADED: number;
  99560. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  99561. static readonly NEVER: number;
  99562. /** 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 */
  99563. static readonly ALWAYS: number;
  99564. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  99565. static readonly LESS: number;
  99566. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  99567. static readonly EQUAL: number;
  99568. /** 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 */
  99569. static readonly LEQUAL: number;
  99570. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  99571. static readonly GREATER: number;
  99572. /** 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 */
  99573. static readonly GEQUAL: number;
  99574. /** 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 */
  99575. static readonly NOTEQUAL: number;
  99576. /** Passed to stencilOperation to specify that stencil value must be kept */
  99577. static readonly KEEP: number;
  99578. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99579. static readonly REPLACE: number;
  99580. /** Passed to stencilOperation to specify that stencil value must be incremented */
  99581. static readonly INCR: number;
  99582. /** Passed to stencilOperation to specify that stencil value must be decremented */
  99583. static readonly DECR: number;
  99584. /** Passed to stencilOperation to specify that stencil value must be inverted */
  99585. static readonly INVERT: number;
  99586. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  99587. static readonly INCR_WRAP: number;
  99588. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  99589. static readonly DECR_WRAP: number;
  99590. /** Texture is not repeating outside of 0..1 UVs */
  99591. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  99592. /** Texture is repeating outside of 0..1 UVs */
  99593. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  99594. /** Texture is repeating and mirrored */
  99595. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  99596. /** ALPHA */
  99597. static readonly TEXTUREFORMAT_ALPHA: number;
  99598. /** LUMINANCE */
  99599. static readonly TEXTUREFORMAT_LUMINANCE: number;
  99600. /** LUMINANCE_ALPHA */
  99601. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  99602. /** RGB */
  99603. static readonly TEXTUREFORMAT_RGB: number;
  99604. /** RGBA */
  99605. static readonly TEXTUREFORMAT_RGBA: number;
  99606. /** RED */
  99607. static readonly TEXTUREFORMAT_RED: number;
  99608. /** RED (2nd reference) */
  99609. static readonly TEXTUREFORMAT_R: number;
  99610. /** RG */
  99611. static readonly TEXTUREFORMAT_RG: number;
  99612. /** RED_INTEGER */
  99613. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  99614. /** RED_INTEGER (2nd reference) */
  99615. static readonly TEXTUREFORMAT_R_INTEGER: number;
  99616. /** RG_INTEGER */
  99617. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  99618. /** RGB_INTEGER */
  99619. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  99620. /** RGBA_INTEGER */
  99621. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  99622. /** UNSIGNED_BYTE */
  99623. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  99624. /** UNSIGNED_BYTE (2nd reference) */
  99625. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  99626. /** FLOAT */
  99627. static readonly TEXTURETYPE_FLOAT: number;
  99628. /** HALF_FLOAT */
  99629. static readonly TEXTURETYPE_HALF_FLOAT: number;
  99630. /** BYTE */
  99631. static readonly TEXTURETYPE_BYTE: number;
  99632. /** SHORT */
  99633. static readonly TEXTURETYPE_SHORT: number;
  99634. /** UNSIGNED_SHORT */
  99635. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  99636. /** INT */
  99637. static readonly TEXTURETYPE_INT: number;
  99638. /** UNSIGNED_INT */
  99639. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  99640. /** UNSIGNED_SHORT_4_4_4_4 */
  99641. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  99642. /** UNSIGNED_SHORT_5_5_5_1 */
  99643. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  99644. /** UNSIGNED_SHORT_5_6_5 */
  99645. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  99646. /** UNSIGNED_INT_2_10_10_10_REV */
  99647. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  99648. /** UNSIGNED_INT_24_8 */
  99649. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  99650. /** UNSIGNED_INT_10F_11F_11F_REV */
  99651. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  99652. /** UNSIGNED_INT_5_9_9_9_REV */
  99653. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  99654. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  99655. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  99656. /** nearest is mag = nearest and min = nearest and mip = linear */
  99657. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  99658. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99659. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  99660. /** Trilinear is mag = linear and min = linear and mip = linear */
  99661. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  99662. /** nearest is mag = nearest and min = nearest and mip = linear */
  99663. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  99664. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99665. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  99666. /** Trilinear is mag = linear and min = linear and mip = linear */
  99667. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  99668. /** mag = nearest and min = nearest and mip = nearest */
  99669. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  99670. /** mag = nearest and min = linear and mip = nearest */
  99671. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  99672. /** mag = nearest and min = linear and mip = linear */
  99673. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  99674. /** mag = nearest and min = linear and mip = none */
  99675. static readonly TEXTURE_NEAREST_LINEAR: number;
  99676. /** mag = nearest and min = nearest and mip = none */
  99677. static readonly TEXTURE_NEAREST_NEAREST: number;
  99678. /** mag = linear and min = nearest and mip = nearest */
  99679. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  99680. /** mag = linear and min = nearest and mip = linear */
  99681. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  99682. /** mag = linear and min = linear and mip = none */
  99683. static readonly TEXTURE_LINEAR_LINEAR: number;
  99684. /** mag = linear and min = nearest and mip = none */
  99685. static readonly TEXTURE_LINEAR_NEAREST: number;
  99686. /** Explicit coordinates mode */
  99687. static readonly TEXTURE_EXPLICIT_MODE: number;
  99688. /** Spherical coordinates mode */
  99689. static readonly TEXTURE_SPHERICAL_MODE: number;
  99690. /** Planar coordinates mode */
  99691. static readonly TEXTURE_PLANAR_MODE: number;
  99692. /** Cubic coordinates mode */
  99693. static readonly TEXTURE_CUBIC_MODE: number;
  99694. /** Projection coordinates mode */
  99695. static readonly TEXTURE_PROJECTION_MODE: number;
  99696. /** Skybox coordinates mode */
  99697. static readonly TEXTURE_SKYBOX_MODE: number;
  99698. /** Inverse Cubic coordinates mode */
  99699. static readonly TEXTURE_INVCUBIC_MODE: number;
  99700. /** Equirectangular coordinates mode */
  99701. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  99702. /** Equirectangular Fixed coordinates mode */
  99703. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  99704. /** Equirectangular Fixed Mirrored coordinates mode */
  99705. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99706. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  99707. static readonly SCALEMODE_FLOOR: number;
  99708. /** Defines that texture rescaling will look for the nearest power of 2 size */
  99709. static readonly SCALEMODE_NEAREST: number;
  99710. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  99711. static readonly SCALEMODE_CEILING: number;
  99712. /**
  99713. * Returns the current npm package of the sdk
  99714. */
  99715. static readonly NpmPackage: string;
  99716. /**
  99717. * Returns the current version of the framework
  99718. */
  99719. static readonly Version: string;
  99720. /** Gets the list of created engines */
  99721. static readonly Instances: Engine[];
  99722. /**
  99723. * Gets the latest created engine
  99724. */
  99725. static readonly LastCreatedEngine: Nullable<Engine>;
  99726. /**
  99727. * Gets the latest created scene
  99728. */
  99729. static readonly LastCreatedScene: Nullable<Scene>;
  99730. /**
  99731. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  99732. * @param flag defines which part of the materials must be marked as dirty
  99733. * @param predicate defines a predicate used to filter which materials should be affected
  99734. */
  99735. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99736. /**
  99737. * Method called to create the default loading screen.
  99738. * This can be overriden in your own app.
  99739. * @param canvas The rendering canvas element
  99740. * @returns The loading screen
  99741. */
  99742. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  99743. /**
  99744. * Method called to create the default rescale post process on each engine.
  99745. */
  99746. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  99747. /**
  99748. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  99749. **/
  99750. enableOfflineSupport: boolean;
  99751. /**
  99752. * 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)
  99753. **/
  99754. disableManifestCheck: boolean;
  99755. /**
  99756. * Gets the list of created scenes
  99757. */
  99758. scenes: Scene[];
  99759. /**
  99760. * Event raised when a new scene is created
  99761. */
  99762. onNewSceneAddedObservable: Observable<Scene>;
  99763. /**
  99764. * Gets the list of created postprocesses
  99765. */
  99766. postProcesses: PostProcess[];
  99767. /**
  99768. * Gets a boolean indicating if the pointer is currently locked
  99769. */
  99770. isPointerLock: boolean;
  99771. /**
  99772. * Observable event triggered each time the rendering canvas is resized
  99773. */
  99774. onResizeObservable: Observable<Engine>;
  99775. /**
  99776. * Observable event triggered each time the canvas loses focus
  99777. */
  99778. onCanvasBlurObservable: Observable<Engine>;
  99779. /**
  99780. * Observable event triggered each time the canvas gains focus
  99781. */
  99782. onCanvasFocusObservable: Observable<Engine>;
  99783. /**
  99784. * Observable event triggered each time the canvas receives pointerout event
  99785. */
  99786. onCanvasPointerOutObservable: Observable<PointerEvent>;
  99787. /**
  99788. * Observable raised when the engine begins a new frame
  99789. */
  99790. onBeginFrameObservable: Observable<Engine>;
  99791. /**
  99792. * If set, will be used to request the next animation frame for the render loop
  99793. */
  99794. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  99795. /**
  99796. * Observable raised when the engine ends the current frame
  99797. */
  99798. onEndFrameObservable: Observable<Engine>;
  99799. /**
  99800. * Observable raised when the engine is about to compile a shader
  99801. */
  99802. onBeforeShaderCompilationObservable: Observable<Engine>;
  99803. /**
  99804. * Observable raised when the engine has jsut compiled a shader
  99805. */
  99806. onAfterShaderCompilationObservable: Observable<Engine>;
  99807. /**
  99808. * Gets the audio engine
  99809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99810. * @ignorenaming
  99811. */
  99812. static audioEngine: IAudioEngine;
  99813. /**
  99814. * Default AudioEngine factory responsible of creating the Audio Engine.
  99815. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  99816. */
  99817. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  99818. /**
  99819. * Default offline support factory responsible of creating a tool used to store data locally.
  99820. * By default, this will create a Database object if the workload has been embedded.
  99821. */
  99822. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  99823. private _loadingScreen;
  99824. private _pointerLockRequested;
  99825. private _dummyFramebuffer;
  99826. private _rescalePostProcess;
  99827. /** @hidden */
  99828. protected _alphaMode: number;
  99829. /** @hidden */
  99830. protected _alphaEquation: number;
  99831. private _deterministicLockstep;
  99832. private _lockstepMaxSteps;
  99833. protected readonly _supportsHardwareTextureRescaling: boolean;
  99834. private _fps;
  99835. private _deltaTime;
  99836. /** @hidden */
  99837. _drawCalls: PerfCounter;
  99838. /**
  99839. * Turn this value on if you want to pause FPS computation when in background
  99840. */
  99841. disablePerformanceMonitorInBackground: boolean;
  99842. private _performanceMonitor;
  99843. /**
  99844. * Gets the performance monitor attached to this engine
  99845. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99846. */
  99847. readonly performanceMonitor: PerformanceMonitor;
  99848. private _onFocus;
  99849. private _onBlur;
  99850. private _onCanvasPointerOut;
  99851. private _onCanvasBlur;
  99852. private _onCanvasFocus;
  99853. private _onFullscreenChange;
  99854. private _onPointerLockChange;
  99855. /**
  99856. * Gets the HTML element used to attach event listeners
  99857. * @returns a HTML element
  99858. */
  99859. getInputElement(): Nullable<HTMLElement>;
  99860. /**
  99861. * Creates a new engine
  99862. * @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
  99863. * @param antialias defines enable antialiasing (default: false)
  99864. * @param options defines further options to be sent to the getContext() function
  99865. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99866. */
  99867. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99868. /**
  99869. * Gets current aspect ratio
  99870. * @param viewportOwner defines the camera to use to get the aspect ratio
  99871. * @param useScreen defines if screen size must be used (or the current render target if any)
  99872. * @returns a number defining the aspect ratio
  99873. */
  99874. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  99875. /**
  99876. * Gets current screen aspect ratio
  99877. * @returns a number defining the aspect ratio
  99878. */
  99879. getScreenAspectRatio(): number;
  99880. /**
  99881. * Gets host document
  99882. * @returns the host document object
  99883. */
  99884. getHostDocument(): Document;
  99885. /**
  99886. * Gets the client rect of the HTML canvas attached with the current webGL context
  99887. * @returns a client rectanglee
  99888. */
  99889. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  99890. /**
  99891. * Gets the client rect of the HTML element used for events
  99892. * @returns a client rectanglee
  99893. */
  99894. getInputElementClientRect(): Nullable<ClientRect>;
  99895. /**
  99896. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  99897. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99898. * @returns true if engine is in deterministic lock step mode
  99899. */
  99900. isDeterministicLockStep(): boolean;
  99901. /**
  99902. * Gets the max steps when engine is running in deterministic lock step
  99903. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99904. * @returns the max steps
  99905. */
  99906. getLockstepMaxSteps(): number;
  99907. /**
  99908. * Force the mipmap generation for the given render target texture
  99909. * @param texture defines the render target texture to use
  99910. */
  99911. generateMipMapsForCubemap(texture: InternalTexture): void;
  99912. /** States */
  99913. /**
  99914. * Set various states to the webGL context
  99915. * @param culling defines backface culling state
  99916. * @param zOffset defines the value to apply to zOffset (0 by default)
  99917. * @param force defines if states must be applied even if cache is up to date
  99918. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  99919. */
  99920. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99921. /**
  99922. * Set the z offset to apply to current rendering
  99923. * @param value defines the offset to apply
  99924. */
  99925. setZOffset(value: number): void;
  99926. /**
  99927. * Gets the current value of the zOffset
  99928. * @returns the current zOffset state
  99929. */
  99930. getZOffset(): number;
  99931. /**
  99932. * Enable or disable depth buffering
  99933. * @param enable defines the state to set
  99934. */
  99935. setDepthBuffer(enable: boolean): void;
  99936. /**
  99937. * Gets a boolean indicating if depth writing is enabled
  99938. * @returns the current depth writing state
  99939. */
  99940. getDepthWrite(): boolean;
  99941. /**
  99942. * Enable or disable depth writing
  99943. * @param enable defines the state to set
  99944. */
  99945. setDepthWrite(enable: boolean): void;
  99946. /**
  99947. * Enable or disable color writing
  99948. * @param enable defines the state to set
  99949. */
  99950. setColorWrite(enable: boolean): void;
  99951. /**
  99952. * Gets a boolean indicating if color writing is enabled
  99953. * @returns the current color writing state
  99954. */
  99955. getColorWrite(): boolean;
  99956. /**
  99957. * Sets alpha constants used by some alpha blending modes
  99958. * @param r defines the red component
  99959. * @param g defines the green component
  99960. * @param b defines the blue component
  99961. * @param a defines the alpha component
  99962. */
  99963. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  99964. /**
  99965. * Sets the current alpha mode
  99966. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  99967. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  99968. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99969. */
  99970. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99971. /**
  99972. * Gets the current alpha mode
  99973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99974. * @returns the current alpha mode
  99975. */
  99976. getAlphaMode(): number;
  99977. /**
  99978. * Sets the current alpha equation
  99979. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  99980. */
  99981. setAlphaEquation(equation: number): void;
  99982. /**
  99983. * Gets the current alpha equation.
  99984. * @returns the current alpha equation
  99985. */
  99986. getAlphaEquation(): number;
  99987. /**
  99988. * Gets a boolean indicating if stencil buffer is enabled
  99989. * @returns the current stencil buffer state
  99990. */
  99991. getStencilBuffer(): boolean;
  99992. /**
  99993. * Enable or disable the stencil buffer
  99994. * @param enable defines if the stencil buffer must be enabled or disabled
  99995. */
  99996. setStencilBuffer(enable: boolean): void;
  99997. /**
  99998. * Gets the current stencil mask
  99999. * @returns a number defining the new stencil mask to use
  100000. */
  100001. getStencilMask(): number;
  100002. /**
  100003. * Sets the current stencil mask
  100004. * @param mask defines the new stencil mask to use
  100005. */
  100006. setStencilMask(mask: number): void;
  100007. /**
  100008. * Gets the current stencil function
  100009. * @returns a number defining the stencil function to use
  100010. */
  100011. getStencilFunction(): number;
  100012. /**
  100013. * Gets the current stencil reference value
  100014. * @returns a number defining the stencil reference value to use
  100015. */
  100016. getStencilFunctionReference(): number;
  100017. /**
  100018. * Gets the current stencil mask
  100019. * @returns a number defining the stencil mask to use
  100020. */
  100021. getStencilFunctionMask(): number;
  100022. /**
  100023. * Sets the current stencil function
  100024. * @param stencilFunc defines the new stencil function to use
  100025. */
  100026. setStencilFunction(stencilFunc: number): void;
  100027. /**
  100028. * Sets the current stencil reference
  100029. * @param reference defines the new stencil reference to use
  100030. */
  100031. setStencilFunctionReference(reference: number): void;
  100032. /**
  100033. * Sets the current stencil mask
  100034. * @param mask defines the new stencil mask to use
  100035. */
  100036. setStencilFunctionMask(mask: number): void;
  100037. /**
  100038. * Gets the current stencil operation when stencil fails
  100039. * @returns a number defining stencil operation to use when stencil fails
  100040. */
  100041. getStencilOperationFail(): number;
  100042. /**
  100043. * Gets the current stencil operation when depth fails
  100044. * @returns a number defining stencil operation to use when depth fails
  100045. */
  100046. getStencilOperationDepthFail(): number;
  100047. /**
  100048. * Gets the current stencil operation when stencil passes
  100049. * @returns a number defining stencil operation to use when stencil passes
  100050. */
  100051. getStencilOperationPass(): number;
  100052. /**
  100053. * Sets the stencil operation to use when stencil fails
  100054. * @param operation defines the stencil operation to use when stencil fails
  100055. */
  100056. setStencilOperationFail(operation: number): void;
  100057. /**
  100058. * Sets the stencil operation to use when depth fails
  100059. * @param operation defines the stencil operation to use when depth fails
  100060. */
  100061. setStencilOperationDepthFail(operation: number): void;
  100062. /**
  100063. * Sets the stencil operation to use when stencil passes
  100064. * @param operation defines the stencil operation to use when stencil passes
  100065. */
  100066. setStencilOperationPass(operation: number): void;
  100067. /**
  100068. * Sets a boolean indicating if the dithering state is enabled or disabled
  100069. * @param value defines the dithering state
  100070. */
  100071. setDitheringState(value: boolean): void;
  100072. /**
  100073. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  100074. * @param value defines the rasterizer state
  100075. */
  100076. setRasterizerState(value: boolean): void;
  100077. /**
  100078. * Gets the current depth function
  100079. * @returns a number defining the depth function
  100080. */
  100081. getDepthFunction(): Nullable<number>;
  100082. /**
  100083. * Sets the current depth function
  100084. * @param depthFunc defines the function to use
  100085. */
  100086. setDepthFunction(depthFunc: number): void;
  100087. /**
  100088. * Sets the current depth function to GREATER
  100089. */
  100090. setDepthFunctionToGreater(): void;
  100091. /**
  100092. * Sets the current depth function to GEQUAL
  100093. */
  100094. setDepthFunctionToGreaterOrEqual(): void;
  100095. /**
  100096. * Sets the current depth function to LESS
  100097. */
  100098. setDepthFunctionToLess(): void;
  100099. /**
  100100. * Sets the current depth function to LEQUAL
  100101. */
  100102. setDepthFunctionToLessOrEqual(): void;
  100103. private _cachedStencilBuffer;
  100104. private _cachedStencilFunction;
  100105. private _cachedStencilMask;
  100106. private _cachedStencilOperationPass;
  100107. private _cachedStencilOperationFail;
  100108. private _cachedStencilOperationDepthFail;
  100109. private _cachedStencilReference;
  100110. /**
  100111. * Caches the the state of the stencil buffer
  100112. */
  100113. cacheStencilState(): void;
  100114. /**
  100115. * Restores the state of the stencil buffer
  100116. */
  100117. restoreStencilState(): void;
  100118. /**
  100119. * Directly set the WebGL Viewport
  100120. * @param x defines the x coordinate of the viewport (in screen space)
  100121. * @param y defines the y coordinate of the viewport (in screen space)
  100122. * @param width defines the width of the viewport (in screen space)
  100123. * @param height defines the height of the viewport (in screen space)
  100124. * @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
  100125. */
  100126. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  100127. /**
  100128. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  100129. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100130. * @param y defines the y-coordinate of the corner of the clear rectangle
  100131. * @param width defines the width of the clear rectangle
  100132. * @param height defines the height of the clear rectangle
  100133. * @param clearColor defines the clear color
  100134. */
  100135. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  100136. /**
  100137. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  100138. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100139. * @param y defines the y-coordinate of the corner of the clear rectangle
  100140. * @param width defines the width of the clear rectangle
  100141. * @param height defines the height of the clear rectangle
  100142. */
  100143. enableScissor(x: number, y: number, width: number, height: number): void;
  100144. /**
  100145. * Disable previously set scissor test rectangle
  100146. */
  100147. disableScissor(): void;
  100148. protected _reportDrawCall(): void;
  100149. /**
  100150. * Initializes a webVR display and starts listening to display change events
  100151. * The onVRDisplayChangedObservable will be notified upon these changes
  100152. * @returns The onVRDisplayChangedObservable
  100153. */
  100154. initWebVR(): Observable<IDisplayChangedEventArgs>;
  100155. /** @hidden */
  100156. _prepareVRComponent(): void;
  100157. /** @hidden */
  100158. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  100159. /** @hidden */
  100160. _submitVRFrame(): void;
  100161. /**
  100162. * Call this function to leave webVR mode
  100163. * Will do nothing if webVR is not supported or if there is no webVR device
  100164. * @see http://doc.babylonjs.com/how_to/webvr_camera
  100165. */
  100166. disableVR(): void;
  100167. /**
  100168. * Gets a boolean indicating that the system is in VR mode and is presenting
  100169. * @returns true if VR mode is engaged
  100170. */
  100171. isVRPresenting(): boolean;
  100172. /** @hidden */
  100173. _requestVRFrame(): void;
  100174. /** @hidden */
  100175. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100176. /**
  100177. * Gets the source code of the vertex shader associated with a specific webGL program
  100178. * @param program defines the program to use
  100179. * @returns a string containing the source code of the vertex shader associated with the program
  100180. */
  100181. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  100182. /**
  100183. * Gets the source code of the fragment shader associated with a specific webGL program
  100184. * @param program defines the program to use
  100185. * @returns a string containing the source code of the fragment shader associated with the program
  100186. */
  100187. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  100188. /**
  100189. * Reads pixels from the current frame buffer. Please note that this function can be slow
  100190. * @param x defines the x coordinate of the rectangle where pixels must be read
  100191. * @param y defines the y coordinate of the rectangle where pixels must be read
  100192. * @param width defines the width of the rectangle where pixels must be read
  100193. * @param height defines the height of the rectangle where pixels must be read
  100194. * @returns a Uint8Array containing RGBA colors
  100195. */
  100196. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  100197. /**
  100198. * Sets a depth stencil texture from a render target to the according uniform.
  100199. * @param channel The texture channel
  100200. * @param uniform The uniform to set
  100201. * @param texture The render target texture containing the depth stencil texture to apply
  100202. */
  100203. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  100204. /**
  100205. * Sets a texture to the webGL context from a postprocess
  100206. * @param channel defines the channel to use
  100207. * @param postProcess defines the source postprocess
  100208. */
  100209. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  100210. /**
  100211. * Binds the output of the passed in post process to the texture channel specified
  100212. * @param channel The channel the texture should be bound to
  100213. * @param postProcess The post process which's output should be bound
  100214. */
  100215. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  100216. /** @hidden */
  100217. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  100218. protected _rebuildBuffers(): void;
  100219. /** @hidden */
  100220. _renderFrame(): void;
  100221. _renderLoop(): void;
  100222. /** @hidden */
  100223. _renderViews(): boolean;
  100224. /**
  100225. * Toggle full screen mode
  100226. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100227. */
  100228. switchFullscreen(requestPointerLock: boolean): void;
  100229. /**
  100230. * Enters full screen mode
  100231. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100232. */
  100233. enterFullscreen(requestPointerLock: boolean): void;
  100234. /**
  100235. * Exits full screen mode
  100236. */
  100237. exitFullscreen(): void;
  100238. /**
  100239. * Enters Pointerlock mode
  100240. */
  100241. enterPointerlock(): void;
  100242. /**
  100243. * Exits Pointerlock mode
  100244. */
  100245. exitPointerlock(): void;
  100246. /**
  100247. * Begin a new frame
  100248. */
  100249. beginFrame(): void;
  100250. /**
  100251. * Enf the current frame
  100252. */
  100253. endFrame(): void;
  100254. resize(): void;
  100255. /**
  100256. * Set the compressed texture format to use, based on the formats you have, and the formats
  100257. * supported by the hardware / browser.
  100258. *
  100259. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  100260. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  100261. * to API arguments needed to compressed textures. This puts the burden on the container
  100262. * generator to house the arcane code for determining these for current & future formats.
  100263. *
  100264. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  100265. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  100266. *
  100267. * Note: The result of this call is not taken into account when a texture is base64.
  100268. *
  100269. * @param formatsAvailable defines the list of those format families you have created
  100270. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  100271. *
  100272. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  100273. * @returns The extension selected.
  100274. */
  100275. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  100276. /**
  100277. * Force a specific size of the canvas
  100278. * @param width defines the new canvas' width
  100279. * @param height defines the new canvas' height
  100280. */
  100281. setSize(width: number, height: number): void;
  100282. /**
  100283. * Updates a dynamic vertex buffer.
  100284. * @param vertexBuffer the vertex buffer to update
  100285. * @param data the data used to update the vertex buffer
  100286. * @param byteOffset the byte offset of the data
  100287. * @param byteLength the byte length of the data
  100288. */
  100289. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100290. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100291. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100292. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100293. _releaseTexture(texture: InternalTexture): void;
  100294. /**
  100295. * @hidden
  100296. * Rescales a texture
  100297. * @param source input texutre
  100298. * @param destination destination texture
  100299. * @param scene scene to use to render the resize
  100300. * @param internalFormat format to use when resizing
  100301. * @param onComplete callback to be called when resize has completed
  100302. */
  100303. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100304. /**
  100305. * Gets the current framerate
  100306. * @returns a number representing the framerate
  100307. */
  100308. getFps(): number;
  100309. /**
  100310. * Gets the time spent between current and previous frame
  100311. * @returns a number representing the delta time in ms
  100312. */
  100313. getDeltaTime(): number;
  100314. private _measureFps;
  100315. /** @hidden */
  100316. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  100317. /**
  100318. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  100319. * @param renderTarget The render target to set the frame buffer for
  100320. */
  100321. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  100322. /**
  100323. * Update a dynamic index buffer
  100324. * @param indexBuffer defines the target index buffer
  100325. * @param indices defines the data to update
  100326. * @param offset defines the offset in the target index buffer where update should start
  100327. */
  100328. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100329. /**
  100330. * Updates the sample count of a render target texture
  100331. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  100332. * @param texture defines the texture to update
  100333. * @param samples defines the sample count to set
  100334. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  100335. */
  100336. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  100337. /**
  100338. * Updates a depth texture Comparison Mode and Function.
  100339. * If the comparison Function is equal to 0, the mode will be set to none.
  100340. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  100341. * @param texture The texture to set the comparison function for
  100342. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  100343. */
  100344. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  100345. /**
  100346. * Creates a webGL buffer to use with instanciation
  100347. * @param capacity defines the size of the buffer
  100348. * @returns the webGL buffer
  100349. */
  100350. createInstancesBuffer(capacity: number): DataBuffer;
  100351. /**
  100352. * Delete a webGL buffer used with instanciation
  100353. * @param buffer defines the webGL buffer to delete
  100354. */
  100355. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  100356. /** @hidden */
  100357. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  100358. dispose(): void;
  100359. private _disableTouchAction;
  100360. /**
  100361. * Display the loading screen
  100362. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100363. */
  100364. displayLoadingUI(): void;
  100365. /**
  100366. * Hide the loading screen
  100367. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100368. */
  100369. hideLoadingUI(): void;
  100370. /**
  100371. * Gets the current loading screen object
  100372. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100373. */
  100374. /**
  100375. * Sets the current loading screen object
  100376. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100377. */
  100378. loadingScreen: ILoadingScreen;
  100379. /**
  100380. * Sets the current loading screen text
  100381. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100382. */
  100383. loadingUIText: string;
  100384. /**
  100385. * Sets the current loading screen background color
  100386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100387. */
  100388. loadingUIBackgroundColor: string;
  100389. /** Pointerlock and fullscreen */
  100390. /**
  100391. * Ask the browser to promote the current element to pointerlock mode
  100392. * @param element defines the DOM element to promote
  100393. */
  100394. static _RequestPointerlock(element: HTMLElement): void;
  100395. /**
  100396. * Asks the browser to exit pointerlock mode
  100397. */
  100398. static _ExitPointerlock(): void;
  100399. /**
  100400. * Ask the browser to promote the current element to fullscreen rendering mode
  100401. * @param element defines the DOM element to promote
  100402. */
  100403. static _RequestFullscreen(element: HTMLElement): void;
  100404. /**
  100405. * Asks the browser to exit fullscreen mode
  100406. */
  100407. static _ExitFullscreen(): void;
  100408. }
  100409. }
  100410. declare module BABYLON {
  100411. /**
  100412. * The engine store class is responsible to hold all the instances of Engine and Scene created
  100413. * during the life time of the application.
  100414. */
  100415. export class EngineStore {
  100416. /** Gets the list of created engines */
  100417. static Instances: Engine[];
  100418. /** @hidden */
  100419. static _LastCreatedScene: Nullable<Scene>;
  100420. /**
  100421. * Gets the latest created engine
  100422. */
  100423. static readonly LastCreatedEngine: Nullable<Engine>;
  100424. /**
  100425. * Gets the latest created scene
  100426. */
  100427. static readonly LastCreatedScene: Nullable<Scene>;
  100428. /**
  100429. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100430. * @ignorenaming
  100431. */
  100432. static UseFallbackTexture: boolean;
  100433. /**
  100434. * Texture content used if a texture cannot loaded
  100435. * @ignorenaming
  100436. */
  100437. static FallbackTexture: string;
  100438. }
  100439. }
  100440. declare module BABYLON {
  100441. /**
  100442. * Helper class that provides a small promise polyfill
  100443. */
  100444. export class PromisePolyfill {
  100445. /**
  100446. * Static function used to check if the polyfill is required
  100447. * If this is the case then the function will inject the polyfill to window.Promise
  100448. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100449. */
  100450. static Apply(force?: boolean): void;
  100451. }
  100452. }
  100453. declare module BABYLON {
  100454. /**
  100455. * Interface for screenshot methods with describe argument called `size` as object with options
  100456. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  100457. */
  100458. export interface IScreenshotSize {
  100459. /**
  100460. * number in pixels for canvas height
  100461. */
  100462. height?: number;
  100463. /**
  100464. * multiplier allowing render at a higher or lower resolution
  100465. * If value is defined then height and width will be ignored and taken from camera
  100466. */
  100467. precision?: number;
  100468. /**
  100469. * number in pixels for canvas width
  100470. */
  100471. width?: number;
  100472. }
  100473. }
  100474. declare module BABYLON {
  100475. interface IColor4Like {
  100476. r: float;
  100477. g: float;
  100478. b: float;
  100479. a: float;
  100480. }
  100481. /**
  100482. * Class containing a set of static utilities functions
  100483. */
  100484. export class Tools {
  100485. /**
  100486. * Gets or sets the base URL to use to load assets
  100487. */
  100488. static BaseUrl: string;
  100489. /**
  100490. * Enable/Disable Custom HTTP Request Headers globally.
  100491. * default = false
  100492. * @see CustomRequestHeaders
  100493. */
  100494. static UseCustomRequestHeaders: boolean;
  100495. /**
  100496. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  100497. * i.e. when loading files, where the server/service expects an Authorization header
  100498. */
  100499. static CustomRequestHeaders: {
  100500. [key: string]: string;
  100501. };
  100502. /**
  100503. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  100504. */
  100505. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  100506. /**
  100507. * Default behaviour for cors in the application.
  100508. * It can be a string if the expected behavior is identical in the entire app.
  100509. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  100510. */
  100511. static CorsBehavior: string | ((url: string | string[]) => string);
  100512. /**
  100513. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100514. * @ignorenaming
  100515. */
  100516. static UseFallbackTexture: boolean;
  100517. /**
  100518. * Use this object to register external classes like custom textures or material
  100519. * to allow the laoders to instantiate them
  100520. */
  100521. static RegisteredExternalClasses: {
  100522. [key: string]: Object;
  100523. };
  100524. /**
  100525. * Texture content used if a texture cannot loaded
  100526. * @ignorenaming
  100527. */
  100528. static fallbackTexture: string;
  100529. /**
  100530. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100531. * @param u defines the coordinate on X axis
  100532. * @param v defines the coordinate on Y axis
  100533. * @param width defines the width of the source data
  100534. * @param height defines the height of the source data
  100535. * @param pixels defines the source byte array
  100536. * @param color defines the output color
  100537. */
  100538. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  100539. /**
  100540. * Interpolates between a and b via alpha
  100541. * @param a The lower value (returned when alpha = 0)
  100542. * @param b The upper value (returned when alpha = 1)
  100543. * @param alpha The interpolation-factor
  100544. * @return The mixed value
  100545. */
  100546. static Mix(a: number, b: number, alpha: number): number;
  100547. /**
  100548. * Tries to instantiate a new object from a given class name
  100549. * @param className defines the class name to instantiate
  100550. * @returns the new object or null if the system was not able to do the instantiation
  100551. */
  100552. static Instantiate(className: string): any;
  100553. /**
  100554. * Provides a slice function that will work even on IE
  100555. * @param data defines the array to slice
  100556. * @param start defines the start of the data (optional)
  100557. * @param end defines the end of the data (optional)
  100558. * @returns the new sliced array
  100559. */
  100560. static Slice<T>(data: T, start?: number, end?: number): T;
  100561. /**
  100562. * Polyfill for setImmediate
  100563. * @param action defines the action to execute after the current execution block
  100564. */
  100565. static SetImmediate(action: () => void): void;
  100566. /**
  100567. * Function indicating if a number is an exponent of 2
  100568. * @param value defines the value to test
  100569. * @returns true if the value is an exponent of 2
  100570. */
  100571. static IsExponentOfTwo(value: number): boolean;
  100572. private static _tmpFloatArray;
  100573. /**
  100574. * Returns the nearest 32-bit single precision float representation of a Number
  100575. * @param value A Number. If the parameter is of a different type, it will get converted
  100576. * to a number or to NaN if it cannot be converted
  100577. * @returns number
  100578. */
  100579. static FloatRound(value: number): number;
  100580. /**
  100581. * Extracts the filename from a path
  100582. * @param path defines the path to use
  100583. * @returns the filename
  100584. */
  100585. static GetFilename(path: string): string;
  100586. /**
  100587. * Extracts the "folder" part of a path (everything before the filename).
  100588. * @param uri The URI to extract the info from
  100589. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100590. * @returns The "folder" part of the path
  100591. */
  100592. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  100593. /**
  100594. * Extracts text content from a DOM element hierarchy
  100595. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  100596. */
  100597. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  100598. /**
  100599. * Convert an angle in radians to degrees
  100600. * @param angle defines the angle to convert
  100601. * @returns the angle in degrees
  100602. */
  100603. static ToDegrees(angle: number): number;
  100604. /**
  100605. * Convert an angle in degrees to radians
  100606. * @param angle defines the angle to convert
  100607. * @returns the angle in radians
  100608. */
  100609. static ToRadians(angle: number): number;
  100610. /**
  100611. * Returns an array if obj is not an array
  100612. * @param obj defines the object to evaluate as an array
  100613. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100614. * @returns either obj directly if obj is an array or a new array containing obj
  100615. */
  100616. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  100617. /**
  100618. * Gets the pointer prefix to use
  100619. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100620. */
  100621. static GetPointerPrefix(): string;
  100622. /**
  100623. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100624. * @param url define the url we are trying
  100625. * @param element define the dom element where to configure the cors policy
  100626. */
  100627. static SetCorsBehavior(url: string | string[], element: {
  100628. crossOrigin: string | null;
  100629. }): void;
  100630. /**
  100631. * Removes unwanted characters from an url
  100632. * @param url defines the url to clean
  100633. * @returns the cleaned url
  100634. */
  100635. static CleanUrl(url: string): string;
  100636. /**
  100637. * Gets or sets a function used to pre-process url before using them to load assets
  100638. */
  100639. static PreprocessUrl: (url: string) => string;
  100640. /**
  100641. * Loads an image as an HTMLImageElement.
  100642. * @param input url string, ArrayBuffer, or Blob to load
  100643. * @param onLoad callback called when the image successfully loads
  100644. * @param onError callback called when the image fails to load
  100645. * @param offlineProvider offline provider for caching
  100646. * @param mimeType optional mime type
  100647. * @returns the HTMLImageElement of the loaded image
  100648. */
  100649. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  100650. /**
  100651. * Loads a file from a url
  100652. * @param url url string, ArrayBuffer, or Blob to load
  100653. * @param onSuccess callback called when the file successfully loads
  100654. * @param onProgress callback called while file is loading (if the server supports this mode)
  100655. * @param offlineProvider defines the offline provider for caching
  100656. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100657. * @param onError callback called when the file fails to load
  100658. * @returns a file request object
  100659. */
  100660. 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;
  100661. /**
  100662. * Loads a file from a url
  100663. * @param url the file url to load
  100664. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  100665. */
  100666. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  100667. /**
  100668. * Load a script (identified by an url). When the url returns, the
  100669. * content of this file is added into a new script element, attached to the DOM (body element)
  100670. * @param scriptUrl defines the url of the script to laod
  100671. * @param onSuccess defines the callback called when the script is loaded
  100672. * @param onError defines the callback to call if an error occurs
  100673. * @param scriptId defines the id of the script element
  100674. */
  100675. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  100676. /**
  100677. * Load an asynchronous script (identified by an url). When the url returns, the
  100678. * content of this file is added into a new script element, attached to the DOM (body element)
  100679. * @param scriptUrl defines the url of the script to laod
  100680. * @param scriptId defines the id of the script element
  100681. * @returns a promise request object
  100682. */
  100683. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  100684. /**
  100685. * Loads a file from a blob
  100686. * @param fileToLoad defines the blob to use
  100687. * @param callback defines the callback to call when data is loaded
  100688. * @param progressCallback defines the callback to call during loading process
  100689. * @returns a file request object
  100690. */
  100691. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  100692. /**
  100693. * Reads a file from a File object
  100694. * @param file defines the file to load
  100695. * @param onSuccess defines the callback to call when data is loaded
  100696. * @param onProgress defines the callback to call during loading process
  100697. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100698. * @param onError defines the callback to call when an error occurs
  100699. * @returns a file request object
  100700. */
  100701. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  100702. /**
  100703. * Creates a data url from a given string content
  100704. * @param content defines the content to convert
  100705. * @returns the new data url link
  100706. */
  100707. static FileAsURL(content: string): string;
  100708. /**
  100709. * Format the given number to a specific decimal format
  100710. * @param value defines the number to format
  100711. * @param decimals defines the number of decimals to use
  100712. * @returns the formatted string
  100713. */
  100714. static Format(value: number, decimals?: number): string;
  100715. /**
  100716. * Tries to copy an object by duplicating every property
  100717. * @param source defines the source object
  100718. * @param destination defines the target object
  100719. * @param doNotCopyList defines a list of properties to avoid
  100720. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100721. */
  100722. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  100723. /**
  100724. * Gets a boolean indicating if the given object has no own property
  100725. * @param obj defines the object to test
  100726. * @returns true if object has no own property
  100727. */
  100728. static IsEmpty(obj: any): boolean;
  100729. /**
  100730. * Function used to register events at window level
  100731. * @param windowElement defines the Window object to use
  100732. * @param events defines the events to register
  100733. */
  100734. static RegisterTopRootEvents(windowElement: Window, events: {
  100735. name: string;
  100736. handler: Nullable<(e: FocusEvent) => any>;
  100737. }[]): void;
  100738. /**
  100739. * Function used to unregister events from window level
  100740. * @param windowElement defines the Window object to use
  100741. * @param events defines the events to unregister
  100742. */
  100743. static UnregisterTopRootEvents(windowElement: Window, events: {
  100744. name: string;
  100745. handler: Nullable<(e: FocusEvent) => any>;
  100746. }[]): void;
  100747. /**
  100748. * @ignore
  100749. */
  100750. static _ScreenshotCanvas: HTMLCanvasElement;
  100751. /**
  100752. * Dumps the current bound framebuffer
  100753. * @param width defines the rendering width
  100754. * @param height defines the rendering height
  100755. * @param engine defines the hosting engine
  100756. * @param successCallback defines the callback triggered once the data are available
  100757. * @param mimeType defines the mime type of the result
  100758. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  100759. */
  100760. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100761. /**
  100762. * Converts the canvas data to blob.
  100763. * This acts as a polyfill for browsers not supporting the to blob function.
  100764. * @param canvas Defines the canvas to extract the data from
  100765. * @param successCallback Defines the callback triggered once the data are available
  100766. * @param mimeType Defines the mime type of the result
  100767. */
  100768. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  100769. /**
  100770. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  100771. * @param successCallback defines the callback triggered once the data are available
  100772. * @param mimeType defines the mime type of the result
  100773. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  100774. */
  100775. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100776. /**
  100777. * Downloads a blob in the browser
  100778. * @param blob defines the blob to download
  100779. * @param fileName defines the name of the downloaded file
  100780. */
  100781. static Download(blob: Blob, fileName: string): void;
  100782. /**
  100783. * Captures a screenshot of the current rendering
  100784. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100785. * @param engine defines the rendering engine
  100786. * @param camera defines the source camera
  100787. * @param size This parameter can be set to a single number or to an object with the
  100788. * following (optional) properties: precision, width, height. If a single number is passed,
  100789. * it will be used for both width and height. If an object is passed, the screenshot size
  100790. * will be derived from the parameters. The precision property is a multiplier allowing
  100791. * rendering at a higher or lower resolution
  100792. * @param successCallback defines the callback receives a single parameter which contains the
  100793. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100794. * src parameter of an <img> to display it
  100795. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100796. * Check your browser for supported MIME types
  100797. */
  100798. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  100799. /**
  100800. * Captures a screenshot of the current rendering
  100801. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100802. * @param engine defines the rendering engine
  100803. * @param camera defines the source camera
  100804. * @param size This parameter can be set to a single number or to an object with the
  100805. * following (optional) properties: precision, width, height. If a single number is passed,
  100806. * it will be used for both width and height. If an object is passed, the screenshot size
  100807. * will be derived from the parameters. The precision property is a multiplier allowing
  100808. * rendering at a higher or lower resolution
  100809. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100810. * Check your browser for supported MIME types
  100811. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100812. * to the src parameter of an <img> to display it
  100813. */
  100814. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  100815. /**
  100816. * Generates an image screenshot from the specified camera.
  100817. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100818. * @param engine The engine to use for rendering
  100819. * @param camera The camera to use for rendering
  100820. * @param size This parameter can be set to a single number or to an object with the
  100821. * following (optional) properties: precision, width, height. If a single number is passed,
  100822. * it will be used for both width and height. If an object is passed, the screenshot size
  100823. * will be derived from the parameters. The precision property is a multiplier allowing
  100824. * rendering at a higher or lower resolution
  100825. * @param successCallback The callback receives a single parameter which contains the
  100826. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100827. * src parameter of an <img> to display it
  100828. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100829. * Check your browser for supported MIME types
  100830. * @param samples Texture samples (default: 1)
  100831. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100832. * @param fileName A name for for the downloaded file.
  100833. */
  100834. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  100835. /**
  100836. * Generates an image screenshot from the specified camera.
  100837. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100838. * @param engine The engine to use for rendering
  100839. * @param camera The camera to use for rendering
  100840. * @param size This parameter can be set to a single number or to an object with the
  100841. * following (optional) properties: precision, width, height. If a single number is passed,
  100842. * it will be used for both width and height. If an object is passed, the screenshot size
  100843. * will be derived from the parameters. The precision property is a multiplier allowing
  100844. * rendering at a higher or lower resolution
  100845. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100846. * Check your browser for supported MIME types
  100847. * @param samples Texture samples (default: 1)
  100848. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100849. * @param fileName A name for for the downloaded file.
  100850. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100851. * to the src parameter of an <img> to display it
  100852. */
  100853. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  100854. /**
  100855. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100856. * Be aware Math.random() could cause collisions, but:
  100857. * "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"
  100858. * @returns a pseudo random id
  100859. */
  100860. static RandomId(): string;
  100861. /**
  100862. * Test if the given uri is a base64 string
  100863. * @param uri The uri to test
  100864. * @return True if the uri is a base64 string or false otherwise
  100865. */
  100866. static IsBase64(uri: string): boolean;
  100867. /**
  100868. * Decode the given base64 uri.
  100869. * @param uri The uri to decode
  100870. * @return The decoded base64 data.
  100871. */
  100872. static DecodeBase64(uri: string): ArrayBuffer;
  100873. /**
  100874. * Gets the absolute url.
  100875. * @param url the input url
  100876. * @return the absolute url
  100877. */
  100878. static GetAbsoluteUrl(url: string): string;
  100879. /**
  100880. * No log
  100881. */
  100882. static readonly NoneLogLevel: number;
  100883. /**
  100884. * Only message logs
  100885. */
  100886. static readonly MessageLogLevel: number;
  100887. /**
  100888. * Only warning logs
  100889. */
  100890. static readonly WarningLogLevel: number;
  100891. /**
  100892. * Only error logs
  100893. */
  100894. static readonly ErrorLogLevel: number;
  100895. /**
  100896. * All logs
  100897. */
  100898. static readonly AllLogLevel: number;
  100899. /**
  100900. * Gets a value indicating the number of loading errors
  100901. * @ignorenaming
  100902. */
  100903. static readonly errorsCount: number;
  100904. /**
  100905. * Callback called when a new log is added
  100906. */
  100907. static OnNewCacheEntry: (entry: string) => void;
  100908. /**
  100909. * Log a message to the console
  100910. * @param message defines the message to log
  100911. */
  100912. static Log(message: string): void;
  100913. /**
  100914. * Write a warning message to the console
  100915. * @param message defines the message to log
  100916. */
  100917. static Warn(message: string): void;
  100918. /**
  100919. * Write an error message to the console
  100920. * @param message defines the message to log
  100921. */
  100922. static Error(message: string): void;
  100923. /**
  100924. * Gets current log cache (list of logs)
  100925. */
  100926. static readonly LogCache: string;
  100927. /**
  100928. * Clears the log cache
  100929. */
  100930. static ClearLogCache(): void;
  100931. /**
  100932. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  100933. */
  100934. static LogLevels: number;
  100935. /**
  100936. * Checks if the window object exists
  100937. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  100938. */
  100939. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  100940. /**
  100941. * No performance log
  100942. */
  100943. static readonly PerformanceNoneLogLevel: number;
  100944. /**
  100945. * Use user marks to log performance
  100946. */
  100947. static readonly PerformanceUserMarkLogLevel: number;
  100948. /**
  100949. * Log performance to the console
  100950. */
  100951. static readonly PerformanceConsoleLogLevel: number;
  100952. private static _performance;
  100953. /**
  100954. * Sets the current performance log level
  100955. */
  100956. static PerformanceLogLevel: number;
  100957. private static _StartPerformanceCounterDisabled;
  100958. private static _EndPerformanceCounterDisabled;
  100959. private static _StartUserMark;
  100960. private static _EndUserMark;
  100961. private static _StartPerformanceConsole;
  100962. private static _EndPerformanceConsole;
  100963. /**
  100964. * Starts a performance counter
  100965. */
  100966. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100967. /**
  100968. * Ends a specific performance coutner
  100969. */
  100970. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100971. /**
  100972. * Gets either window.performance.now() if supported or Date.now() else
  100973. */
  100974. static readonly Now: number;
  100975. /**
  100976. * This method will return the name of the class used to create the instance of the given object.
  100977. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  100978. * @param object the object to get the class name from
  100979. * @param isType defines if the object is actually a type
  100980. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  100981. */
  100982. static GetClassName(object: any, isType?: boolean): string;
  100983. /**
  100984. * Gets the first element of an array satisfying a given predicate
  100985. * @param array defines the array to browse
  100986. * @param predicate defines the predicate to use
  100987. * @returns null if not found or the element
  100988. */
  100989. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  100990. /**
  100991. * This method will return the name of the full name of the class, including its owning module (if any).
  100992. * 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).
  100993. * @param object the object to get the class name from
  100994. * @param isType defines if the object is actually a type
  100995. * @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.
  100996. * @ignorenaming
  100997. */
  100998. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  100999. /**
  101000. * Returns a promise that resolves after the given amount of time.
  101001. * @param delay Number of milliseconds to delay
  101002. * @returns Promise that resolves after the given amount of time
  101003. */
  101004. static DelayAsync(delay: number): Promise<void>;
  101005. }
  101006. /**
  101007. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  101008. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  101009. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  101010. * @param name The name of the class, case should be preserved
  101011. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  101012. */
  101013. export function className(name: string, module?: string): (target: Object) => void;
  101014. /**
  101015. * An implementation of a loop for asynchronous functions.
  101016. */
  101017. export class AsyncLoop {
  101018. /**
  101019. * Defines the number of iterations for the loop
  101020. */
  101021. iterations: number;
  101022. /**
  101023. * Defines the current index of the loop.
  101024. */
  101025. index: number;
  101026. private _done;
  101027. private _fn;
  101028. private _successCallback;
  101029. /**
  101030. * Constructor.
  101031. * @param iterations the number of iterations.
  101032. * @param func the function to run each iteration
  101033. * @param successCallback the callback that will be called upon succesful execution
  101034. * @param offset starting offset.
  101035. */
  101036. constructor(
  101037. /**
  101038. * Defines the number of iterations for the loop
  101039. */
  101040. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  101041. /**
  101042. * Execute the next iteration. Must be called after the last iteration was finished.
  101043. */
  101044. executeNext(): void;
  101045. /**
  101046. * Break the loop and run the success callback.
  101047. */
  101048. breakLoop(): void;
  101049. /**
  101050. * Create and run an async loop.
  101051. * @param iterations the number of iterations.
  101052. * @param fn the function to run each iteration
  101053. * @param successCallback the callback that will be called upon succesful execution
  101054. * @param offset starting offset.
  101055. * @returns the created async loop object
  101056. */
  101057. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  101058. /**
  101059. * A for-loop that will run a given number of iterations synchronous and the rest async.
  101060. * @param iterations total number of iterations
  101061. * @param syncedIterations number of synchronous iterations in each async iteration.
  101062. * @param fn the function to call each iteration.
  101063. * @param callback a success call back that will be called when iterating stops.
  101064. * @param breakFunction a break condition (optional)
  101065. * @param timeout timeout settings for the setTimeout function. default - 0.
  101066. * @returns the created async loop object
  101067. */
  101068. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  101069. }
  101070. }
  101071. declare module BABYLON {
  101072. /**
  101073. * This class implement a typical dictionary using a string as key and the generic type T as value.
  101074. * The underlying implementation relies on an associative array to ensure the best performances.
  101075. * The value can be anything including 'null' but except 'undefined'
  101076. */
  101077. export class StringDictionary<T> {
  101078. /**
  101079. * This will clear this dictionary and copy the content from the 'source' one.
  101080. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  101081. * @param source the dictionary to take the content from and copy to this dictionary
  101082. */
  101083. copyFrom(source: StringDictionary<T>): void;
  101084. /**
  101085. * Get a value based from its key
  101086. * @param key the given key to get the matching value from
  101087. * @return the value if found, otherwise undefined is returned
  101088. */
  101089. get(key: string): T | undefined;
  101090. /**
  101091. * Get a value from its key or add it if it doesn't exist.
  101092. * This method will ensure you that a given key/data will be present in the dictionary.
  101093. * @param key the given key to get the matching value from
  101094. * @param factory the factory that will create the value if the key is not present in the dictionary.
  101095. * The factory will only be invoked if there's no data for the given key.
  101096. * @return the value corresponding to the key.
  101097. */
  101098. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  101099. /**
  101100. * Get a value from its key if present in the dictionary otherwise add it
  101101. * @param key the key to get the value from
  101102. * @param val if there's no such key/value pair in the dictionary add it with this value
  101103. * @return the value corresponding to the key
  101104. */
  101105. getOrAdd(key: string, val: T): T;
  101106. /**
  101107. * Check if there's a given key in the dictionary
  101108. * @param key the key to check for
  101109. * @return true if the key is present, false otherwise
  101110. */
  101111. contains(key: string): boolean;
  101112. /**
  101113. * Add a new key and its corresponding value
  101114. * @param key the key to add
  101115. * @param value the value corresponding to the key
  101116. * @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
  101117. */
  101118. add(key: string, value: T): boolean;
  101119. /**
  101120. * Update a specific value associated to a key
  101121. * @param key defines the key to use
  101122. * @param value defines the value to store
  101123. * @returns true if the value was updated (or false if the key was not found)
  101124. */
  101125. set(key: string, value: T): boolean;
  101126. /**
  101127. * Get the element of the given key and remove it from the dictionary
  101128. * @param key defines the key to search
  101129. * @returns the value associated with the key or null if not found
  101130. */
  101131. getAndRemove(key: string): Nullable<T>;
  101132. /**
  101133. * Remove a key/value from the dictionary.
  101134. * @param key the key to remove
  101135. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  101136. */
  101137. remove(key: string): boolean;
  101138. /**
  101139. * Clear the whole content of the dictionary
  101140. */
  101141. clear(): void;
  101142. /**
  101143. * Gets the current count
  101144. */
  101145. readonly count: number;
  101146. /**
  101147. * Execute a callback on each key/val of the dictionary.
  101148. * Note that you can remove any element in this dictionary in the callback implementation
  101149. * @param callback the callback to execute on a given key/value pair
  101150. */
  101151. forEach(callback: (key: string, val: T) => void): void;
  101152. /**
  101153. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  101154. * If the callback returns null or undefined the method will iterate to the next key/value pair
  101155. * Note that you can remove any element in this dictionary in the callback implementation
  101156. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  101157. * @returns the first item
  101158. */
  101159. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  101160. private _count;
  101161. private _data;
  101162. }
  101163. }
  101164. declare module BABYLON {
  101165. /** @hidden */
  101166. export interface ICollisionCoordinator {
  101167. createCollider(): Collider;
  101168. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101169. init(scene: Scene): void;
  101170. }
  101171. /** @hidden */
  101172. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  101173. private _scene;
  101174. private _scaledPosition;
  101175. private _scaledVelocity;
  101176. private _finalPosition;
  101177. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101178. createCollider(): Collider;
  101179. init(scene: Scene): void;
  101180. private _collideWithWorld;
  101181. }
  101182. }
  101183. declare module BABYLON {
  101184. /**
  101185. * Class used to manage all inputs for the scene.
  101186. */
  101187. export class InputManager {
  101188. /** The distance in pixel that you have to move to prevent some events */
  101189. static DragMovementThreshold: number;
  101190. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  101191. static LongPressDelay: number;
  101192. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  101193. static DoubleClickDelay: number;
  101194. /** If you need to check double click without raising a single click at first click, enable this flag */
  101195. static ExclusiveDoubleClickMode: boolean;
  101196. private _wheelEventName;
  101197. private _onPointerMove;
  101198. private _onPointerDown;
  101199. private _onPointerUp;
  101200. private _initClickEvent;
  101201. private _initActionManager;
  101202. private _delayedSimpleClick;
  101203. private _delayedSimpleClickTimeout;
  101204. private _previousDelayedSimpleClickTimeout;
  101205. private _meshPickProceed;
  101206. private _previousButtonPressed;
  101207. private _currentPickResult;
  101208. private _previousPickResult;
  101209. private _totalPointersPressed;
  101210. private _doubleClickOccured;
  101211. private _pointerOverMesh;
  101212. private _pickedDownMesh;
  101213. private _pickedUpMesh;
  101214. private _pointerX;
  101215. private _pointerY;
  101216. private _unTranslatedPointerX;
  101217. private _unTranslatedPointerY;
  101218. private _startingPointerPosition;
  101219. private _previousStartingPointerPosition;
  101220. private _startingPointerTime;
  101221. private _previousStartingPointerTime;
  101222. private _pointerCaptures;
  101223. private _onKeyDown;
  101224. private _onKeyUp;
  101225. private _onCanvasFocusObserver;
  101226. private _onCanvasBlurObserver;
  101227. private _scene;
  101228. /**
  101229. * Creates a new InputManager
  101230. * @param scene defines the hosting scene
  101231. */
  101232. constructor(scene: Scene);
  101233. /**
  101234. * Gets the mesh that is currently under the pointer
  101235. */
  101236. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101237. /**
  101238. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  101239. */
  101240. readonly unTranslatedPointer: Vector2;
  101241. /**
  101242. * Gets or sets the current on-screen X position of the pointer
  101243. */
  101244. pointerX: number;
  101245. /**
  101246. * Gets or sets the current on-screen Y position of the pointer
  101247. */
  101248. pointerY: number;
  101249. private _updatePointerPosition;
  101250. private _processPointerMove;
  101251. private _setRayOnPointerInfo;
  101252. private _checkPrePointerObservable;
  101253. /**
  101254. * Use this method to simulate a pointer move on a mesh
  101255. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101256. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101257. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101258. */
  101259. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101260. /**
  101261. * Use this method to simulate a pointer down on a mesh
  101262. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101263. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101264. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101265. */
  101266. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101267. private _processPointerDown;
  101268. /** @hidden */
  101269. _isPointerSwiping(): boolean;
  101270. /**
  101271. * Use this method to simulate a pointer up on a mesh
  101272. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101273. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101274. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101275. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101276. */
  101277. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  101278. private _processPointerUp;
  101279. /**
  101280. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101281. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101282. * @returns true if the pointer was captured
  101283. */
  101284. isPointerCaptured(pointerId?: number): boolean;
  101285. /**
  101286. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101287. * @param attachUp defines if you want to attach events to pointerup
  101288. * @param attachDown defines if you want to attach events to pointerdown
  101289. * @param attachMove defines if you want to attach events to pointermove
  101290. */
  101291. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101292. /**
  101293. * Detaches all event handlers
  101294. */
  101295. detachControl(): void;
  101296. /**
  101297. * Force the value of meshUnderPointer
  101298. * @param mesh defines the mesh to use
  101299. */
  101300. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101301. /**
  101302. * Gets the mesh under the pointer
  101303. * @returns a Mesh or null if no mesh is under the pointer
  101304. */
  101305. getPointerOverMesh(): Nullable<AbstractMesh>;
  101306. }
  101307. }
  101308. declare module BABYLON {
  101309. /**
  101310. * Helper class used to generate session unique ID
  101311. */
  101312. export class UniqueIdGenerator {
  101313. private static _UniqueIdCounter;
  101314. /**
  101315. * Gets an unique (relatively to the current scene) Id
  101316. */
  101317. static readonly UniqueId: number;
  101318. }
  101319. }
  101320. declare module BABYLON {
  101321. /**
  101322. * This class defines the direct association between an animation and a target
  101323. */
  101324. export class TargetedAnimation {
  101325. /**
  101326. * Animation to perform
  101327. */
  101328. animation: Animation;
  101329. /**
  101330. * Target to animate
  101331. */
  101332. target: any;
  101333. /**
  101334. * Serialize the object
  101335. * @returns the JSON object representing the current entity
  101336. */
  101337. serialize(): any;
  101338. }
  101339. /**
  101340. * Use this class to create coordinated animations on multiple targets
  101341. */
  101342. export class AnimationGroup implements IDisposable {
  101343. /** The name of the animation group */
  101344. name: string;
  101345. private _scene;
  101346. private _targetedAnimations;
  101347. private _animatables;
  101348. private _from;
  101349. private _to;
  101350. private _isStarted;
  101351. private _isPaused;
  101352. private _speedRatio;
  101353. private _loopAnimation;
  101354. /**
  101355. * Gets or sets the unique id of the node
  101356. */
  101357. uniqueId: number;
  101358. /**
  101359. * This observable will notify when one animation have ended
  101360. */
  101361. onAnimationEndObservable: Observable<TargetedAnimation>;
  101362. /**
  101363. * Observer raised when one animation loops
  101364. */
  101365. onAnimationLoopObservable: Observable<TargetedAnimation>;
  101366. /**
  101367. * Observer raised when all animations have looped
  101368. */
  101369. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  101370. /**
  101371. * This observable will notify when all animations have ended.
  101372. */
  101373. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  101374. /**
  101375. * This observable will notify when all animations have paused.
  101376. */
  101377. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  101378. /**
  101379. * This observable will notify when all animations are playing.
  101380. */
  101381. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  101382. /**
  101383. * Gets the first frame
  101384. */
  101385. readonly from: number;
  101386. /**
  101387. * Gets the last frame
  101388. */
  101389. readonly to: number;
  101390. /**
  101391. * Define if the animations are started
  101392. */
  101393. readonly isStarted: boolean;
  101394. /**
  101395. * Gets a value indicating that the current group is playing
  101396. */
  101397. readonly isPlaying: boolean;
  101398. /**
  101399. * Gets or sets the speed ratio to use for all animations
  101400. */
  101401. /**
  101402. * Gets or sets the speed ratio to use for all animations
  101403. */
  101404. speedRatio: number;
  101405. /**
  101406. * Gets or sets if all animations should loop or not
  101407. */
  101408. loopAnimation: boolean;
  101409. /**
  101410. * Gets the targeted animations for this animation group
  101411. */
  101412. readonly targetedAnimations: Array<TargetedAnimation>;
  101413. /**
  101414. * returning the list of animatables controlled by this animation group.
  101415. */
  101416. readonly animatables: Array<Animatable>;
  101417. /**
  101418. * Instantiates a new Animation Group.
  101419. * This helps managing several animations at once.
  101420. * @see http://doc.babylonjs.com/how_to/group
  101421. * @param name Defines the name of the group
  101422. * @param scene Defines the scene the group belongs to
  101423. */
  101424. constructor(
  101425. /** The name of the animation group */
  101426. name: string, scene?: Nullable<Scene>);
  101427. /**
  101428. * Add an animation (with its target) in the group
  101429. * @param animation defines the animation we want to add
  101430. * @param target defines the target of the animation
  101431. * @returns the TargetedAnimation object
  101432. */
  101433. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  101434. /**
  101435. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  101436. * It can add constant keys at begin or end
  101437. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  101438. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  101439. * @returns the animation group
  101440. */
  101441. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  101442. private _animationLoopCount;
  101443. private _animationLoopFlags;
  101444. private _processLoop;
  101445. /**
  101446. * Start all animations on given targets
  101447. * @param loop defines if animations must loop
  101448. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  101449. * @param from defines the from key (optional)
  101450. * @param to defines the to key (optional)
  101451. * @returns the current animation group
  101452. */
  101453. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  101454. /**
  101455. * Pause all animations
  101456. * @returns the animation group
  101457. */
  101458. pause(): AnimationGroup;
  101459. /**
  101460. * Play all animations to initial state
  101461. * This function will start() the animations if they were not started or will restart() them if they were paused
  101462. * @param loop defines if animations must loop
  101463. * @returns the animation group
  101464. */
  101465. play(loop?: boolean): AnimationGroup;
  101466. /**
  101467. * Reset all animations to initial state
  101468. * @returns the animation group
  101469. */
  101470. reset(): AnimationGroup;
  101471. /**
  101472. * Restart animations from key 0
  101473. * @returns the animation group
  101474. */
  101475. restart(): AnimationGroup;
  101476. /**
  101477. * Stop all animations
  101478. * @returns the animation group
  101479. */
  101480. stop(): AnimationGroup;
  101481. /**
  101482. * Set animation weight for all animatables
  101483. * @param weight defines the weight to use
  101484. * @return the animationGroup
  101485. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101486. */
  101487. setWeightForAllAnimatables(weight: number): AnimationGroup;
  101488. /**
  101489. * Synchronize and normalize all animatables with a source animatable
  101490. * @param root defines the root animatable to synchronize with
  101491. * @return the animationGroup
  101492. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101493. */
  101494. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  101495. /**
  101496. * Goes to a specific frame in this animation group
  101497. * @param frame the frame number to go to
  101498. * @return the animationGroup
  101499. */
  101500. goToFrame(frame: number): AnimationGroup;
  101501. /**
  101502. * Dispose all associated resources
  101503. */
  101504. dispose(): void;
  101505. private _checkAnimationGroupEnded;
  101506. /**
  101507. * Clone the current animation group and returns a copy
  101508. * @param newName defines the name of the new group
  101509. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  101510. * @returns the new aniamtion group
  101511. */
  101512. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  101513. /**
  101514. * Serializes the animationGroup to an object
  101515. * @returns Serialized object
  101516. */
  101517. serialize(): any;
  101518. /**
  101519. * Returns a new AnimationGroup object parsed from the source provided.
  101520. * @param parsedAnimationGroup defines the source
  101521. * @param scene defines the scene that will receive the animationGroup
  101522. * @returns a new AnimationGroup
  101523. */
  101524. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  101525. /**
  101526. * Returns the string "AnimationGroup"
  101527. * @returns "AnimationGroup"
  101528. */
  101529. getClassName(): string;
  101530. /**
  101531. * Creates a detailled string about the object
  101532. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  101533. * @returns a string representing the object
  101534. */
  101535. toString(fullDetails?: boolean): string;
  101536. }
  101537. }
  101538. declare module BABYLON {
  101539. /**
  101540. * Define an interface for all classes that will hold resources
  101541. */
  101542. export interface IDisposable {
  101543. /**
  101544. * Releases all held resources
  101545. */
  101546. dispose(): void;
  101547. }
  101548. /** Interface defining initialization parameters for Scene class */
  101549. export interface SceneOptions {
  101550. /**
  101551. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  101552. * It will improve performance when the number of geometries becomes important.
  101553. */
  101554. useGeometryUniqueIdsMap?: boolean;
  101555. /**
  101556. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  101557. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101558. */
  101559. useMaterialMeshMap?: boolean;
  101560. /**
  101561. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  101562. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101563. */
  101564. useClonedMeshhMap?: boolean;
  101565. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  101566. virtual?: boolean;
  101567. }
  101568. /**
  101569. * Represents a scene to be rendered by the engine.
  101570. * @see http://doc.babylonjs.com/features/scene
  101571. */
  101572. export class Scene extends AbstractScene implements IAnimatable {
  101573. /** The fog is deactivated */
  101574. static readonly FOGMODE_NONE: number;
  101575. /** The fog density is following an exponential function */
  101576. static readonly FOGMODE_EXP: number;
  101577. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  101578. static readonly FOGMODE_EXP2: number;
  101579. /** The fog density is following a linear function. */
  101580. static readonly FOGMODE_LINEAR: number;
  101581. /**
  101582. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  101583. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101584. */
  101585. static MinDeltaTime: number;
  101586. /**
  101587. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  101588. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101589. */
  101590. static MaxDeltaTime: number;
  101591. /**
  101592. * Factory used to create the default material.
  101593. * @param name The name of the material to create
  101594. * @param scene The scene to create the material for
  101595. * @returns The default material
  101596. */
  101597. static DefaultMaterialFactory(scene: Scene): Material;
  101598. /**
  101599. * Factory used to create the a collision coordinator.
  101600. * @returns The collision coordinator
  101601. */
  101602. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  101603. /** @hidden */
  101604. _inputManager: InputManager;
  101605. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  101606. cameraToUseForPointers: Nullable<Camera>;
  101607. /** @hidden */
  101608. readonly _isScene: boolean;
  101609. /**
  101610. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  101611. */
  101612. autoClear: boolean;
  101613. /**
  101614. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  101615. */
  101616. autoClearDepthAndStencil: boolean;
  101617. /**
  101618. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  101619. */
  101620. clearColor: Color4;
  101621. /**
  101622. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  101623. */
  101624. ambientColor: Color3;
  101625. /**
  101626. * This is use to store the default BRDF lookup for PBR materials in your scene.
  101627. * It should only be one of the following (if not the default embedded one):
  101628. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101629. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  101630. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101631. * The material properties need to be setup according to the type of texture in use.
  101632. */
  101633. environmentBRDFTexture: BaseTexture;
  101634. /** @hidden */
  101635. protected _environmentTexture: Nullable<BaseTexture>;
  101636. /**
  101637. * Texture used in all pbr material as the reflection texture.
  101638. * As in the majority of the scene they are the same (exception for multi room and so on),
  101639. * this is easier to reference from here than from all the materials.
  101640. */
  101641. /**
  101642. * Texture used in all pbr material as the reflection texture.
  101643. * As in the majority of the scene they are the same (exception for multi room and so on),
  101644. * this is easier to set here than in all the materials.
  101645. */
  101646. environmentTexture: Nullable<BaseTexture>;
  101647. /** @hidden */
  101648. protected _environmentIntensity: number;
  101649. /**
  101650. * Intensity of the environment in all pbr material.
  101651. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101652. * As in the majority of the scene they are the same (exception for multi room and so on),
  101653. * this is easier to reference from here than from all the materials.
  101654. */
  101655. /**
  101656. * Intensity of the environment in all pbr material.
  101657. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101658. * As in the majority of the scene they are the same (exception for multi room and so on),
  101659. * this is easier to set here than in all the materials.
  101660. */
  101661. environmentIntensity: number;
  101662. /** @hidden */
  101663. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101664. /**
  101665. * Default image processing configuration used either in the rendering
  101666. * Forward main pass or through the imageProcessingPostProcess if present.
  101667. * As in the majority of the scene they are the same (exception for multi camera),
  101668. * this is easier to reference from here than from all the materials and post process.
  101669. *
  101670. * No setter as we it is a shared configuration, you can set the values instead.
  101671. */
  101672. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  101673. private _forceWireframe;
  101674. /**
  101675. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  101676. */
  101677. forceWireframe: boolean;
  101678. private _forcePointsCloud;
  101679. /**
  101680. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  101681. */
  101682. forcePointsCloud: boolean;
  101683. /**
  101684. * Gets or sets the active clipplane 1
  101685. */
  101686. clipPlane: Nullable<Plane>;
  101687. /**
  101688. * Gets or sets the active clipplane 2
  101689. */
  101690. clipPlane2: Nullable<Plane>;
  101691. /**
  101692. * Gets or sets the active clipplane 3
  101693. */
  101694. clipPlane3: Nullable<Plane>;
  101695. /**
  101696. * Gets or sets the active clipplane 4
  101697. */
  101698. clipPlane4: Nullable<Plane>;
  101699. /**
  101700. * Gets or sets a boolean indicating if animations are enabled
  101701. */
  101702. animationsEnabled: boolean;
  101703. private _animationPropertiesOverride;
  101704. /**
  101705. * Gets or sets the animation properties override
  101706. */
  101707. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  101708. /**
  101709. * Gets or sets a boolean indicating if a constant deltatime has to be used
  101710. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  101711. */
  101712. useConstantAnimationDeltaTime: boolean;
  101713. /**
  101714. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  101715. * Please note that it requires to run a ray cast through the scene on every frame
  101716. */
  101717. constantlyUpdateMeshUnderPointer: boolean;
  101718. /**
  101719. * Defines the HTML cursor to use when hovering over interactive elements
  101720. */
  101721. hoverCursor: string;
  101722. /**
  101723. * Defines the HTML default cursor to use (empty by default)
  101724. */
  101725. defaultCursor: string;
  101726. /**
  101727. * Defines wether cursors are handled by the scene.
  101728. */
  101729. doNotHandleCursors: boolean;
  101730. /**
  101731. * This is used to call preventDefault() on pointer down
  101732. * in order to block unwanted artifacts like system double clicks
  101733. */
  101734. preventDefaultOnPointerDown: boolean;
  101735. /**
  101736. * This is used to call preventDefault() on pointer up
  101737. * in order to block unwanted artifacts like system double clicks
  101738. */
  101739. preventDefaultOnPointerUp: boolean;
  101740. /**
  101741. * Gets or sets user defined metadata
  101742. */
  101743. metadata: any;
  101744. /**
  101745. * For internal use only. Please do not use.
  101746. */
  101747. reservedDataStore: any;
  101748. /**
  101749. * Gets the name of the plugin used to load this scene (null by default)
  101750. */
  101751. loadingPluginName: string;
  101752. /**
  101753. * Use this array to add regular expressions used to disable offline support for specific urls
  101754. */
  101755. disableOfflineSupportExceptionRules: RegExp[];
  101756. /**
  101757. * An event triggered when the scene is disposed.
  101758. */
  101759. onDisposeObservable: Observable<Scene>;
  101760. private _onDisposeObserver;
  101761. /** Sets a function to be executed when this scene is disposed. */
  101762. onDispose: () => void;
  101763. /**
  101764. * An event triggered before rendering the scene (right after animations and physics)
  101765. */
  101766. onBeforeRenderObservable: Observable<Scene>;
  101767. private _onBeforeRenderObserver;
  101768. /** Sets a function to be executed before rendering this scene */
  101769. beforeRender: Nullable<() => void>;
  101770. /**
  101771. * An event triggered after rendering the scene
  101772. */
  101773. onAfterRenderObservable: Observable<Scene>;
  101774. /**
  101775. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  101776. */
  101777. onAfterRenderCameraObservable: Observable<Camera>;
  101778. private _onAfterRenderObserver;
  101779. /** Sets a function to be executed after rendering this scene */
  101780. afterRender: Nullable<() => void>;
  101781. /**
  101782. * An event triggered before animating the scene
  101783. */
  101784. onBeforeAnimationsObservable: Observable<Scene>;
  101785. /**
  101786. * An event triggered after animations processing
  101787. */
  101788. onAfterAnimationsObservable: Observable<Scene>;
  101789. /**
  101790. * An event triggered before draw calls are ready to be sent
  101791. */
  101792. onBeforeDrawPhaseObservable: Observable<Scene>;
  101793. /**
  101794. * An event triggered after draw calls have been sent
  101795. */
  101796. onAfterDrawPhaseObservable: Observable<Scene>;
  101797. /**
  101798. * An event triggered when the scene is ready
  101799. */
  101800. onReadyObservable: Observable<Scene>;
  101801. /**
  101802. * An event triggered before rendering a camera
  101803. */
  101804. onBeforeCameraRenderObservable: Observable<Camera>;
  101805. private _onBeforeCameraRenderObserver;
  101806. /** Sets a function to be executed before rendering a camera*/
  101807. beforeCameraRender: () => void;
  101808. /**
  101809. * An event triggered after rendering a camera
  101810. */
  101811. onAfterCameraRenderObservable: Observable<Camera>;
  101812. private _onAfterCameraRenderObserver;
  101813. /** Sets a function to be executed after rendering a camera*/
  101814. afterCameraRender: () => void;
  101815. /**
  101816. * An event triggered when active meshes evaluation is about to start
  101817. */
  101818. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  101819. /**
  101820. * An event triggered when active meshes evaluation is done
  101821. */
  101822. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  101823. /**
  101824. * An event triggered when particles rendering is about to start
  101825. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101826. */
  101827. onBeforeParticlesRenderingObservable: Observable<Scene>;
  101828. /**
  101829. * An event triggered when particles rendering is done
  101830. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101831. */
  101832. onAfterParticlesRenderingObservable: Observable<Scene>;
  101833. /**
  101834. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  101835. */
  101836. onDataLoadedObservable: Observable<Scene>;
  101837. /**
  101838. * An event triggered when a camera is created
  101839. */
  101840. onNewCameraAddedObservable: Observable<Camera>;
  101841. /**
  101842. * An event triggered when a camera is removed
  101843. */
  101844. onCameraRemovedObservable: Observable<Camera>;
  101845. /**
  101846. * An event triggered when a light is created
  101847. */
  101848. onNewLightAddedObservable: Observable<Light>;
  101849. /**
  101850. * An event triggered when a light is removed
  101851. */
  101852. onLightRemovedObservable: Observable<Light>;
  101853. /**
  101854. * An event triggered when a geometry is created
  101855. */
  101856. onNewGeometryAddedObservable: Observable<Geometry>;
  101857. /**
  101858. * An event triggered when a geometry is removed
  101859. */
  101860. onGeometryRemovedObservable: Observable<Geometry>;
  101861. /**
  101862. * An event triggered when a transform node is created
  101863. */
  101864. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  101865. /**
  101866. * An event triggered when a transform node is removed
  101867. */
  101868. onTransformNodeRemovedObservable: Observable<TransformNode>;
  101869. /**
  101870. * An event triggered when a mesh is created
  101871. */
  101872. onNewMeshAddedObservable: Observable<AbstractMesh>;
  101873. /**
  101874. * An event triggered when a mesh is removed
  101875. */
  101876. onMeshRemovedObservable: Observable<AbstractMesh>;
  101877. /**
  101878. * An event triggered when a skeleton is created
  101879. */
  101880. onNewSkeletonAddedObservable: Observable<Skeleton>;
  101881. /**
  101882. * An event triggered when a skeleton is removed
  101883. */
  101884. onSkeletonRemovedObservable: Observable<Skeleton>;
  101885. /**
  101886. * An event triggered when a material is created
  101887. */
  101888. onNewMaterialAddedObservable: Observable<Material>;
  101889. /**
  101890. * An event triggered when a material is removed
  101891. */
  101892. onMaterialRemovedObservable: Observable<Material>;
  101893. /**
  101894. * An event triggered when a texture is created
  101895. */
  101896. onNewTextureAddedObservable: Observable<BaseTexture>;
  101897. /**
  101898. * An event triggered when a texture is removed
  101899. */
  101900. onTextureRemovedObservable: Observable<BaseTexture>;
  101901. /**
  101902. * An event triggered when render targets are about to be rendered
  101903. * Can happen multiple times per frame.
  101904. */
  101905. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  101906. /**
  101907. * An event triggered when render targets were rendered.
  101908. * Can happen multiple times per frame.
  101909. */
  101910. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  101911. /**
  101912. * An event triggered before calculating deterministic simulation step
  101913. */
  101914. onBeforeStepObservable: Observable<Scene>;
  101915. /**
  101916. * An event triggered after calculating deterministic simulation step
  101917. */
  101918. onAfterStepObservable: Observable<Scene>;
  101919. /**
  101920. * An event triggered when the activeCamera property is updated
  101921. */
  101922. onActiveCameraChanged: Observable<Scene>;
  101923. /**
  101924. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  101925. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101926. * 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)
  101927. */
  101928. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101929. /**
  101930. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  101931. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101932. * 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)
  101933. */
  101934. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101935. /**
  101936. * This Observable will when a mesh has been imported into the scene.
  101937. */
  101938. onMeshImportedObservable: Observable<AbstractMesh>;
  101939. /**
  101940. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  101941. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  101942. */
  101943. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  101944. /** @hidden */
  101945. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  101946. /**
  101947. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  101948. */
  101949. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  101950. /**
  101951. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  101952. */
  101953. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  101954. /**
  101955. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  101956. */
  101957. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  101958. /** Callback called when a pointer move is detected */
  101959. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101960. /** Callback called when a pointer down is detected */
  101961. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101962. /** Callback called when a pointer up is detected */
  101963. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  101964. /** Callback called when a pointer pick is detected */
  101965. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  101966. /**
  101967. * 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).
  101968. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  101969. */
  101970. onPrePointerObservable: Observable<PointerInfoPre>;
  101971. /**
  101972. * Observable event triggered each time an input event is received from the rendering canvas
  101973. */
  101974. onPointerObservable: Observable<PointerInfo>;
  101975. /**
  101976. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  101977. */
  101978. readonly unTranslatedPointer: Vector2;
  101979. /**
  101980. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  101981. */
  101982. static DragMovementThreshold: number;
  101983. /**
  101984. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  101985. */
  101986. static LongPressDelay: number;
  101987. /**
  101988. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  101989. */
  101990. static DoubleClickDelay: number;
  101991. /** If you need to check double click without raising a single click at first click, enable this flag */
  101992. static ExclusiveDoubleClickMode: boolean;
  101993. /** @hidden */
  101994. _mirroredCameraPosition: Nullable<Vector3>;
  101995. /**
  101996. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  101997. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  101998. */
  101999. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  102000. /**
  102001. * Observable event triggered each time an keyboard event is received from the hosting window
  102002. */
  102003. onKeyboardObservable: Observable<KeyboardInfo>;
  102004. private _useRightHandedSystem;
  102005. /**
  102006. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  102007. */
  102008. useRightHandedSystem: boolean;
  102009. private _timeAccumulator;
  102010. private _currentStepId;
  102011. private _currentInternalStep;
  102012. /**
  102013. * Sets the step Id used by deterministic lock step
  102014. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102015. * @param newStepId defines the step Id
  102016. */
  102017. setStepId(newStepId: number): void;
  102018. /**
  102019. * Gets the step Id used by deterministic lock step
  102020. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102021. * @returns the step Id
  102022. */
  102023. getStepId(): number;
  102024. /**
  102025. * Gets the internal step used by deterministic lock step
  102026. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102027. * @returns the internal step
  102028. */
  102029. getInternalStep(): number;
  102030. private _fogEnabled;
  102031. /**
  102032. * Gets or sets a boolean indicating if fog is enabled on this scene
  102033. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102034. * (Default is true)
  102035. */
  102036. fogEnabled: boolean;
  102037. private _fogMode;
  102038. /**
  102039. * Gets or sets the fog mode to use
  102040. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102041. * | mode | value |
  102042. * | --- | --- |
  102043. * | FOGMODE_NONE | 0 |
  102044. * | FOGMODE_EXP | 1 |
  102045. * | FOGMODE_EXP2 | 2 |
  102046. * | FOGMODE_LINEAR | 3 |
  102047. */
  102048. fogMode: number;
  102049. /**
  102050. * Gets or sets the fog color to use
  102051. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102052. * (Default is Color3(0.2, 0.2, 0.3))
  102053. */
  102054. fogColor: Color3;
  102055. /**
  102056. * Gets or sets the fog density to use
  102057. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102058. * (Default is 0.1)
  102059. */
  102060. fogDensity: number;
  102061. /**
  102062. * Gets or sets the fog start distance to use
  102063. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102064. * (Default is 0)
  102065. */
  102066. fogStart: number;
  102067. /**
  102068. * Gets or sets the fog end distance to use
  102069. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102070. * (Default is 1000)
  102071. */
  102072. fogEnd: number;
  102073. private _shadowsEnabled;
  102074. /**
  102075. * Gets or sets a boolean indicating if shadows are enabled on this scene
  102076. */
  102077. shadowsEnabled: boolean;
  102078. private _lightsEnabled;
  102079. /**
  102080. * Gets or sets a boolean indicating if lights are enabled on this scene
  102081. */
  102082. lightsEnabled: boolean;
  102083. /** All of the active cameras added to this scene. */
  102084. activeCameras: Camera[];
  102085. /** @hidden */
  102086. _activeCamera: Nullable<Camera>;
  102087. /** Gets or sets the current active camera */
  102088. activeCamera: Nullable<Camera>;
  102089. private _defaultMaterial;
  102090. /** The default material used on meshes when no material is affected */
  102091. /** The default material used on meshes when no material is affected */
  102092. defaultMaterial: Material;
  102093. private _texturesEnabled;
  102094. /**
  102095. * Gets or sets a boolean indicating if textures are enabled on this scene
  102096. */
  102097. texturesEnabled: boolean;
  102098. /**
  102099. * Gets or sets a boolean indicating if particles are enabled on this scene
  102100. */
  102101. particlesEnabled: boolean;
  102102. /**
  102103. * Gets or sets a boolean indicating if sprites are enabled on this scene
  102104. */
  102105. spritesEnabled: boolean;
  102106. private _skeletonsEnabled;
  102107. /**
  102108. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  102109. */
  102110. skeletonsEnabled: boolean;
  102111. /**
  102112. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  102113. */
  102114. lensFlaresEnabled: boolean;
  102115. /**
  102116. * Gets or sets a boolean indicating if collisions are enabled on this scene
  102117. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102118. */
  102119. collisionsEnabled: boolean;
  102120. private _collisionCoordinator;
  102121. /** @hidden */
  102122. readonly collisionCoordinator: ICollisionCoordinator;
  102123. /**
  102124. * Defines the gravity applied to this scene (used only for collisions)
  102125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102126. */
  102127. gravity: Vector3;
  102128. /**
  102129. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  102130. */
  102131. postProcessesEnabled: boolean;
  102132. /**
  102133. * The list of postprocesses added to the scene
  102134. */
  102135. postProcesses: PostProcess[];
  102136. /**
  102137. * Gets the current postprocess manager
  102138. */
  102139. postProcessManager: PostProcessManager;
  102140. /**
  102141. * Gets or sets a boolean indicating if render targets are enabled on this scene
  102142. */
  102143. renderTargetsEnabled: boolean;
  102144. /**
  102145. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  102146. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  102147. */
  102148. dumpNextRenderTargets: boolean;
  102149. /**
  102150. * The list of user defined render targets added to the scene
  102151. */
  102152. customRenderTargets: RenderTargetTexture[];
  102153. /**
  102154. * Defines if texture loading must be delayed
  102155. * If true, textures will only be loaded when they need to be rendered
  102156. */
  102157. useDelayedTextureLoading: boolean;
  102158. /**
  102159. * Gets the list of meshes imported to the scene through SceneLoader
  102160. */
  102161. importedMeshesFiles: String[];
  102162. /**
  102163. * Gets or sets a boolean indicating if probes are enabled on this scene
  102164. */
  102165. probesEnabled: boolean;
  102166. /**
  102167. * Gets or sets the current offline provider to use to store scene data
  102168. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  102169. */
  102170. offlineProvider: IOfflineProvider;
  102171. /**
  102172. * Gets or sets the action manager associated with the scene
  102173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102174. */
  102175. actionManager: AbstractActionManager;
  102176. private _meshesForIntersections;
  102177. /**
  102178. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  102179. */
  102180. proceduralTexturesEnabled: boolean;
  102181. private _engine;
  102182. private _totalVertices;
  102183. /** @hidden */
  102184. _activeIndices: PerfCounter;
  102185. /** @hidden */
  102186. _activeParticles: PerfCounter;
  102187. /** @hidden */
  102188. _activeBones: PerfCounter;
  102189. private _animationRatio;
  102190. /** @hidden */
  102191. _animationTimeLast: number;
  102192. /** @hidden */
  102193. _animationTime: number;
  102194. /**
  102195. * Gets or sets a general scale for animation speed
  102196. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  102197. */
  102198. animationTimeScale: number;
  102199. /** @hidden */
  102200. _cachedMaterial: Nullable<Material>;
  102201. /** @hidden */
  102202. _cachedEffect: Nullable<Effect>;
  102203. /** @hidden */
  102204. _cachedVisibility: Nullable<number>;
  102205. private _renderId;
  102206. private _frameId;
  102207. private _executeWhenReadyTimeoutId;
  102208. private _intermediateRendering;
  102209. private _viewUpdateFlag;
  102210. private _projectionUpdateFlag;
  102211. /** @hidden */
  102212. _toBeDisposed: Nullable<IDisposable>[];
  102213. private _activeRequests;
  102214. /** @hidden */
  102215. _pendingData: any[];
  102216. private _isDisposed;
  102217. /**
  102218. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  102219. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  102220. */
  102221. dispatchAllSubMeshesOfActiveMeshes: boolean;
  102222. private _activeMeshes;
  102223. private _processedMaterials;
  102224. private _renderTargets;
  102225. /** @hidden */
  102226. _activeParticleSystems: SmartArray<IParticleSystem>;
  102227. private _activeSkeletons;
  102228. private _softwareSkinnedMeshes;
  102229. private _renderingManager;
  102230. /** @hidden */
  102231. _activeAnimatables: Animatable[];
  102232. private _transformMatrix;
  102233. private _sceneUbo;
  102234. /** @hidden */
  102235. _viewMatrix: Matrix;
  102236. private _projectionMatrix;
  102237. /** @hidden */
  102238. _forcedViewPosition: Nullable<Vector3>;
  102239. /** @hidden */
  102240. _frustumPlanes: Plane[];
  102241. /**
  102242. * Gets the list of frustum planes (built from the active camera)
  102243. */
  102244. readonly frustumPlanes: Plane[];
  102245. /**
  102246. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  102247. * This is useful if there are more lights that the maximum simulteanous authorized
  102248. */
  102249. requireLightSorting: boolean;
  102250. /** @hidden */
  102251. readonly useMaterialMeshMap: boolean;
  102252. /** @hidden */
  102253. readonly useClonedMeshhMap: boolean;
  102254. private _externalData;
  102255. private _uid;
  102256. /**
  102257. * @hidden
  102258. * Backing store of defined scene components.
  102259. */
  102260. _components: ISceneComponent[];
  102261. /**
  102262. * @hidden
  102263. * Backing store of defined scene components.
  102264. */
  102265. _serializableComponents: ISceneSerializableComponent[];
  102266. /**
  102267. * List of components to register on the next registration step.
  102268. */
  102269. private _transientComponents;
  102270. /**
  102271. * Registers the transient components if needed.
  102272. */
  102273. private _registerTransientComponents;
  102274. /**
  102275. * @hidden
  102276. * Add a component to the scene.
  102277. * Note that the ccomponent could be registered on th next frame if this is called after
  102278. * the register component stage.
  102279. * @param component Defines the component to add to the scene
  102280. */
  102281. _addComponent(component: ISceneComponent): void;
  102282. /**
  102283. * @hidden
  102284. * Gets a component from the scene.
  102285. * @param name defines the name of the component to retrieve
  102286. * @returns the component or null if not present
  102287. */
  102288. _getComponent(name: string): Nullable<ISceneComponent>;
  102289. /**
  102290. * @hidden
  102291. * Defines the actions happening before camera updates.
  102292. */
  102293. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  102294. /**
  102295. * @hidden
  102296. * Defines the actions happening before clear the canvas.
  102297. */
  102298. _beforeClearStage: Stage<SimpleStageAction>;
  102299. /**
  102300. * @hidden
  102301. * Defines the actions when collecting render targets for the frame.
  102302. */
  102303. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102304. /**
  102305. * @hidden
  102306. * Defines the actions happening for one camera in the frame.
  102307. */
  102308. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102309. /**
  102310. * @hidden
  102311. * Defines the actions happening during the per mesh ready checks.
  102312. */
  102313. _isReadyForMeshStage: Stage<MeshStageAction>;
  102314. /**
  102315. * @hidden
  102316. * Defines the actions happening before evaluate active mesh checks.
  102317. */
  102318. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  102319. /**
  102320. * @hidden
  102321. * Defines the actions happening during the evaluate sub mesh checks.
  102322. */
  102323. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  102324. /**
  102325. * @hidden
  102326. * Defines the actions happening during the active mesh stage.
  102327. */
  102328. _activeMeshStage: Stage<ActiveMeshStageAction>;
  102329. /**
  102330. * @hidden
  102331. * Defines the actions happening during the per camera render target step.
  102332. */
  102333. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  102334. /**
  102335. * @hidden
  102336. * Defines the actions happening just before the active camera is drawing.
  102337. */
  102338. _beforeCameraDrawStage: Stage<CameraStageAction>;
  102339. /**
  102340. * @hidden
  102341. * Defines the actions happening just before a render target is drawing.
  102342. */
  102343. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102344. /**
  102345. * @hidden
  102346. * Defines the actions happening just before a rendering group is drawing.
  102347. */
  102348. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102349. /**
  102350. * @hidden
  102351. * Defines the actions happening just before a mesh is drawing.
  102352. */
  102353. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102354. /**
  102355. * @hidden
  102356. * Defines the actions happening just after a mesh has been drawn.
  102357. */
  102358. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102359. /**
  102360. * @hidden
  102361. * Defines the actions happening just after a rendering group has been drawn.
  102362. */
  102363. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102364. /**
  102365. * @hidden
  102366. * Defines the actions happening just after the active camera has been drawn.
  102367. */
  102368. _afterCameraDrawStage: Stage<CameraStageAction>;
  102369. /**
  102370. * @hidden
  102371. * Defines the actions happening just after a render target has been drawn.
  102372. */
  102373. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102374. /**
  102375. * @hidden
  102376. * Defines the actions happening just after rendering all cameras and computing intersections.
  102377. */
  102378. _afterRenderStage: Stage<SimpleStageAction>;
  102379. /**
  102380. * @hidden
  102381. * Defines the actions happening when a pointer move event happens.
  102382. */
  102383. _pointerMoveStage: Stage<PointerMoveStageAction>;
  102384. /**
  102385. * @hidden
  102386. * Defines the actions happening when a pointer down event happens.
  102387. */
  102388. _pointerDownStage: Stage<PointerUpDownStageAction>;
  102389. /**
  102390. * @hidden
  102391. * Defines the actions happening when a pointer up event happens.
  102392. */
  102393. _pointerUpStage: Stage<PointerUpDownStageAction>;
  102394. /**
  102395. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  102396. */
  102397. private geometriesByUniqueId;
  102398. /**
  102399. * Creates a new Scene
  102400. * @param engine defines the engine to use to render this scene
  102401. * @param options defines the scene options
  102402. */
  102403. constructor(engine: Engine, options?: SceneOptions);
  102404. /**
  102405. * Gets a string idenfifying the name of the class
  102406. * @returns "Scene" string
  102407. */
  102408. getClassName(): string;
  102409. private _defaultMeshCandidates;
  102410. /**
  102411. * @hidden
  102412. */
  102413. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102414. private _defaultSubMeshCandidates;
  102415. /**
  102416. * @hidden
  102417. */
  102418. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102419. /**
  102420. * Sets the default candidate providers for the scene.
  102421. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  102422. * and getCollidingSubMeshCandidates to their default function
  102423. */
  102424. setDefaultCandidateProviders(): void;
  102425. /**
  102426. * Gets the mesh that is currently under the pointer
  102427. */
  102428. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102429. /**
  102430. * Gets or sets the current on-screen X position of the pointer
  102431. */
  102432. pointerX: number;
  102433. /**
  102434. * Gets or sets the current on-screen Y position of the pointer
  102435. */
  102436. pointerY: number;
  102437. /**
  102438. * Gets the cached material (ie. the latest rendered one)
  102439. * @returns the cached material
  102440. */
  102441. getCachedMaterial(): Nullable<Material>;
  102442. /**
  102443. * Gets the cached effect (ie. the latest rendered one)
  102444. * @returns the cached effect
  102445. */
  102446. getCachedEffect(): Nullable<Effect>;
  102447. /**
  102448. * Gets the cached visibility state (ie. the latest rendered one)
  102449. * @returns the cached visibility state
  102450. */
  102451. getCachedVisibility(): Nullable<number>;
  102452. /**
  102453. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  102454. * @param material defines the current material
  102455. * @param effect defines the current effect
  102456. * @param visibility defines the current visibility state
  102457. * @returns true if one parameter is not cached
  102458. */
  102459. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  102460. /**
  102461. * Gets the engine associated with the scene
  102462. * @returns an Engine
  102463. */
  102464. getEngine(): Engine;
  102465. /**
  102466. * Gets the total number of vertices rendered per frame
  102467. * @returns the total number of vertices rendered per frame
  102468. */
  102469. getTotalVertices(): number;
  102470. /**
  102471. * Gets the performance counter for total vertices
  102472. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102473. */
  102474. readonly totalVerticesPerfCounter: PerfCounter;
  102475. /**
  102476. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  102477. * @returns the total number of active indices rendered per frame
  102478. */
  102479. getActiveIndices(): number;
  102480. /**
  102481. * Gets the performance counter for active indices
  102482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102483. */
  102484. readonly totalActiveIndicesPerfCounter: PerfCounter;
  102485. /**
  102486. * Gets the total number of active particles rendered per frame
  102487. * @returns the total number of active particles rendered per frame
  102488. */
  102489. getActiveParticles(): number;
  102490. /**
  102491. * Gets the performance counter for active particles
  102492. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102493. */
  102494. readonly activeParticlesPerfCounter: PerfCounter;
  102495. /**
  102496. * Gets the total number of active bones rendered per frame
  102497. * @returns the total number of active bones rendered per frame
  102498. */
  102499. getActiveBones(): number;
  102500. /**
  102501. * Gets the performance counter for active bones
  102502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102503. */
  102504. readonly activeBonesPerfCounter: PerfCounter;
  102505. /**
  102506. * Gets the array of active meshes
  102507. * @returns an array of AbstractMesh
  102508. */
  102509. getActiveMeshes(): SmartArray<AbstractMesh>;
  102510. /**
  102511. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  102512. * @returns a number
  102513. */
  102514. getAnimationRatio(): number;
  102515. /**
  102516. * Gets an unique Id for the current render phase
  102517. * @returns a number
  102518. */
  102519. getRenderId(): number;
  102520. /**
  102521. * Gets an unique Id for the current frame
  102522. * @returns a number
  102523. */
  102524. getFrameId(): number;
  102525. /** Call this function if you want to manually increment the render Id*/
  102526. incrementRenderId(): void;
  102527. private _createUbo;
  102528. /**
  102529. * Use this method to simulate a pointer move on a mesh
  102530. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102531. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102532. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102533. * @returns the current scene
  102534. */
  102535. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102536. /**
  102537. * Use this method to simulate a pointer down on a mesh
  102538. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102539. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102540. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102541. * @returns the current scene
  102542. */
  102543. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102544. /**
  102545. * Use this method to simulate a pointer up on a mesh
  102546. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102547. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102548. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102549. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102550. * @returns the current scene
  102551. */
  102552. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  102553. /**
  102554. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102555. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102556. * @returns true if the pointer was captured
  102557. */
  102558. isPointerCaptured(pointerId?: number): boolean;
  102559. /**
  102560. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  102561. * @param attachUp defines if you want to attach events to pointerup
  102562. * @param attachDown defines if you want to attach events to pointerdown
  102563. * @param attachMove defines if you want to attach events to pointermove
  102564. */
  102565. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  102566. /** Detaches all event handlers*/
  102567. detachControl(): void;
  102568. /**
  102569. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  102570. * Delay loaded resources are not taking in account
  102571. * @return true if all required resources are ready
  102572. */
  102573. isReady(): boolean;
  102574. /** Resets all cached information relative to material (including effect and visibility) */
  102575. resetCachedMaterial(): void;
  102576. /**
  102577. * Registers a function to be called before every frame render
  102578. * @param func defines the function to register
  102579. */
  102580. registerBeforeRender(func: () => void): void;
  102581. /**
  102582. * Unregisters a function called before every frame render
  102583. * @param func defines the function to unregister
  102584. */
  102585. unregisterBeforeRender(func: () => void): void;
  102586. /**
  102587. * Registers a function to be called after every frame render
  102588. * @param func defines the function to register
  102589. */
  102590. registerAfterRender(func: () => void): void;
  102591. /**
  102592. * Unregisters a function called after every frame render
  102593. * @param func defines the function to unregister
  102594. */
  102595. unregisterAfterRender(func: () => void): void;
  102596. private _executeOnceBeforeRender;
  102597. /**
  102598. * The provided function will run before render once and will be disposed afterwards.
  102599. * A timeout delay can be provided so that the function will be executed in N ms.
  102600. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  102601. * @param func The function to be executed.
  102602. * @param timeout optional delay in ms
  102603. */
  102604. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  102605. /** @hidden */
  102606. _addPendingData(data: any): void;
  102607. /** @hidden */
  102608. _removePendingData(data: any): void;
  102609. /**
  102610. * Returns the number of items waiting to be loaded
  102611. * @returns the number of items waiting to be loaded
  102612. */
  102613. getWaitingItemsCount(): number;
  102614. /**
  102615. * Returns a boolean indicating if the scene is still loading data
  102616. */
  102617. readonly isLoading: boolean;
  102618. /**
  102619. * Registers a function to be executed when the scene is ready
  102620. * @param {Function} func - the function to be executed
  102621. */
  102622. executeWhenReady(func: () => void): void;
  102623. /**
  102624. * Returns a promise that resolves when the scene is ready
  102625. * @returns A promise that resolves when the scene is ready
  102626. */
  102627. whenReadyAsync(): Promise<void>;
  102628. /** @hidden */
  102629. _checkIsReady(): void;
  102630. /**
  102631. * Gets all animatable attached to the scene
  102632. */
  102633. readonly animatables: Animatable[];
  102634. /**
  102635. * Resets the last animation time frame.
  102636. * Useful to override when animations start running when loading a scene for the first time.
  102637. */
  102638. resetLastAnimationTimeFrame(): void;
  102639. /**
  102640. * Gets the current view matrix
  102641. * @returns a Matrix
  102642. */
  102643. getViewMatrix(): Matrix;
  102644. /**
  102645. * Gets the current projection matrix
  102646. * @returns a Matrix
  102647. */
  102648. getProjectionMatrix(): Matrix;
  102649. /**
  102650. * Gets the current transform matrix
  102651. * @returns a Matrix made of View * Projection
  102652. */
  102653. getTransformMatrix(): Matrix;
  102654. /**
  102655. * Sets the current transform matrix
  102656. * @param viewL defines the View matrix to use
  102657. * @param projectionL defines the Projection matrix to use
  102658. * @param viewR defines the right View matrix to use (if provided)
  102659. * @param projectionR defines the right Projection matrix to use (if provided)
  102660. */
  102661. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  102662. /**
  102663. * Gets the uniform buffer used to store scene data
  102664. * @returns a UniformBuffer
  102665. */
  102666. getSceneUniformBuffer(): UniformBuffer;
  102667. /**
  102668. * Gets an unique (relatively to the current scene) Id
  102669. * @returns an unique number for the scene
  102670. */
  102671. getUniqueId(): number;
  102672. /**
  102673. * Add a mesh to the list of scene's meshes
  102674. * @param newMesh defines the mesh to add
  102675. * @param recursive if all child meshes should also be added to the scene
  102676. */
  102677. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  102678. /**
  102679. * Remove a mesh for the list of scene's meshes
  102680. * @param toRemove defines the mesh to remove
  102681. * @param recursive if all child meshes should also be removed from the scene
  102682. * @returns the index where the mesh was in the mesh list
  102683. */
  102684. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  102685. /**
  102686. * Add a transform node to the list of scene's transform nodes
  102687. * @param newTransformNode defines the transform node to add
  102688. */
  102689. addTransformNode(newTransformNode: TransformNode): void;
  102690. /**
  102691. * Remove a transform node for the list of scene's transform nodes
  102692. * @param toRemove defines the transform node to remove
  102693. * @returns the index where the transform node was in the transform node list
  102694. */
  102695. removeTransformNode(toRemove: TransformNode): number;
  102696. /**
  102697. * Remove a skeleton for the list of scene's skeletons
  102698. * @param toRemove defines the skeleton to remove
  102699. * @returns the index where the skeleton was in the skeleton list
  102700. */
  102701. removeSkeleton(toRemove: Skeleton): number;
  102702. /**
  102703. * Remove a morph target for the list of scene's morph targets
  102704. * @param toRemove defines the morph target to remove
  102705. * @returns the index where the morph target was in the morph target list
  102706. */
  102707. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  102708. /**
  102709. * Remove a light for the list of scene's lights
  102710. * @param toRemove defines the light to remove
  102711. * @returns the index where the light was in the light list
  102712. */
  102713. removeLight(toRemove: Light): number;
  102714. /**
  102715. * Remove a camera for the list of scene's cameras
  102716. * @param toRemove defines the camera to remove
  102717. * @returns the index where the camera was in the camera list
  102718. */
  102719. removeCamera(toRemove: Camera): number;
  102720. /**
  102721. * Remove a particle system for the list of scene's particle systems
  102722. * @param toRemove defines the particle system to remove
  102723. * @returns the index where the particle system was in the particle system list
  102724. */
  102725. removeParticleSystem(toRemove: IParticleSystem): number;
  102726. /**
  102727. * Remove a animation for the list of scene's animations
  102728. * @param toRemove defines the animation to remove
  102729. * @returns the index where the animation was in the animation list
  102730. */
  102731. removeAnimation(toRemove: Animation): number;
  102732. /**
  102733. * Will stop the animation of the given target
  102734. * @param target - the target
  102735. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  102736. * @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)
  102737. */
  102738. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  102739. /**
  102740. * Removes the given animation group from this scene.
  102741. * @param toRemove The animation group to remove
  102742. * @returns The index of the removed animation group
  102743. */
  102744. removeAnimationGroup(toRemove: AnimationGroup): number;
  102745. /**
  102746. * Removes the given multi-material from this scene.
  102747. * @param toRemove The multi-material to remove
  102748. * @returns The index of the removed multi-material
  102749. */
  102750. removeMultiMaterial(toRemove: MultiMaterial): number;
  102751. /**
  102752. * Removes the given material from this scene.
  102753. * @param toRemove The material to remove
  102754. * @returns The index of the removed material
  102755. */
  102756. removeMaterial(toRemove: Material): number;
  102757. /**
  102758. * Removes the given action manager from this scene.
  102759. * @param toRemove The action manager to remove
  102760. * @returns The index of the removed action manager
  102761. */
  102762. removeActionManager(toRemove: AbstractActionManager): number;
  102763. /**
  102764. * Removes the given texture from this scene.
  102765. * @param toRemove The texture to remove
  102766. * @returns The index of the removed texture
  102767. */
  102768. removeTexture(toRemove: BaseTexture): number;
  102769. /**
  102770. * Adds the given light to this scene
  102771. * @param newLight The light to add
  102772. */
  102773. addLight(newLight: Light): void;
  102774. /**
  102775. * Sorts the list list based on light priorities
  102776. */
  102777. sortLightsByPriority(): void;
  102778. /**
  102779. * Adds the given camera to this scene
  102780. * @param newCamera The camera to add
  102781. */
  102782. addCamera(newCamera: Camera): void;
  102783. /**
  102784. * Adds the given skeleton to this scene
  102785. * @param newSkeleton The skeleton to add
  102786. */
  102787. addSkeleton(newSkeleton: Skeleton): void;
  102788. /**
  102789. * Adds the given particle system to this scene
  102790. * @param newParticleSystem The particle system to add
  102791. */
  102792. addParticleSystem(newParticleSystem: IParticleSystem): void;
  102793. /**
  102794. * Adds the given animation to this scene
  102795. * @param newAnimation The animation to add
  102796. */
  102797. addAnimation(newAnimation: Animation): void;
  102798. /**
  102799. * Adds the given animation group to this scene.
  102800. * @param newAnimationGroup The animation group to add
  102801. */
  102802. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  102803. /**
  102804. * Adds the given multi-material to this scene
  102805. * @param newMultiMaterial The multi-material to add
  102806. */
  102807. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  102808. /**
  102809. * Adds the given material to this scene
  102810. * @param newMaterial The material to add
  102811. */
  102812. addMaterial(newMaterial: Material): void;
  102813. /**
  102814. * Adds the given morph target to this scene
  102815. * @param newMorphTargetManager The morph target to add
  102816. */
  102817. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  102818. /**
  102819. * Adds the given geometry to this scene
  102820. * @param newGeometry The geometry to add
  102821. */
  102822. addGeometry(newGeometry: Geometry): void;
  102823. /**
  102824. * Adds the given action manager to this scene
  102825. * @param newActionManager The action manager to add
  102826. */
  102827. addActionManager(newActionManager: AbstractActionManager): void;
  102828. /**
  102829. * Adds the given texture to this scene.
  102830. * @param newTexture The texture to add
  102831. */
  102832. addTexture(newTexture: BaseTexture): void;
  102833. /**
  102834. * Switch active camera
  102835. * @param newCamera defines the new active camera
  102836. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  102837. */
  102838. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  102839. /**
  102840. * sets the active camera of the scene using its ID
  102841. * @param id defines the camera's ID
  102842. * @return the new active camera or null if none found.
  102843. */
  102844. setActiveCameraByID(id: string): Nullable<Camera>;
  102845. /**
  102846. * sets the active camera of the scene using its name
  102847. * @param name defines the camera's name
  102848. * @returns the new active camera or null if none found.
  102849. */
  102850. setActiveCameraByName(name: string): Nullable<Camera>;
  102851. /**
  102852. * get an animation group using its name
  102853. * @param name defines the material's name
  102854. * @return the animation group or null if none found.
  102855. */
  102856. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  102857. /**
  102858. * Get a material using its unique id
  102859. * @param uniqueId defines the material's unique id
  102860. * @return the material or null if none found.
  102861. */
  102862. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  102863. /**
  102864. * get a material using its id
  102865. * @param id defines the material's ID
  102866. * @return the material or null if none found.
  102867. */
  102868. getMaterialByID(id: string): Nullable<Material>;
  102869. /**
  102870. * Gets a the last added material using a given id
  102871. * @param id defines the material's ID
  102872. * @return the last material with the given id or null if none found.
  102873. */
  102874. getLastMaterialByID(id: string): Nullable<Material>;
  102875. /**
  102876. * Gets a material using its name
  102877. * @param name defines the material's name
  102878. * @return the material or null if none found.
  102879. */
  102880. getMaterialByName(name: string): Nullable<Material>;
  102881. /**
  102882. * Get a texture using its unique id
  102883. * @param uniqueId defines the texture's unique id
  102884. * @return the texture or null if none found.
  102885. */
  102886. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  102887. /**
  102888. * Gets a camera using its id
  102889. * @param id defines the id to look for
  102890. * @returns the camera or null if not found
  102891. */
  102892. getCameraByID(id: string): Nullable<Camera>;
  102893. /**
  102894. * Gets a camera using its unique id
  102895. * @param uniqueId defines the unique id to look for
  102896. * @returns the camera or null if not found
  102897. */
  102898. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  102899. /**
  102900. * Gets a camera using its name
  102901. * @param name defines the camera's name
  102902. * @return the camera or null if none found.
  102903. */
  102904. getCameraByName(name: string): Nullable<Camera>;
  102905. /**
  102906. * Gets a bone using its id
  102907. * @param id defines the bone's id
  102908. * @return the bone or null if not found
  102909. */
  102910. getBoneByID(id: string): Nullable<Bone>;
  102911. /**
  102912. * Gets a bone using its id
  102913. * @param name defines the bone's name
  102914. * @return the bone or null if not found
  102915. */
  102916. getBoneByName(name: string): Nullable<Bone>;
  102917. /**
  102918. * Gets a light node using its name
  102919. * @param name defines the the light's name
  102920. * @return the light or null if none found.
  102921. */
  102922. getLightByName(name: string): Nullable<Light>;
  102923. /**
  102924. * Gets a light node using its id
  102925. * @param id defines the light's id
  102926. * @return the light or null if none found.
  102927. */
  102928. getLightByID(id: string): Nullable<Light>;
  102929. /**
  102930. * Gets a light node using its scene-generated unique ID
  102931. * @param uniqueId defines the light's unique id
  102932. * @return the light or null if none found.
  102933. */
  102934. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  102935. /**
  102936. * Gets a particle system by id
  102937. * @param id defines the particle system id
  102938. * @return the corresponding system or null if none found
  102939. */
  102940. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  102941. /**
  102942. * Gets a geometry using its ID
  102943. * @param id defines the geometry's id
  102944. * @return the geometry or null if none found.
  102945. */
  102946. getGeometryByID(id: string): Nullable<Geometry>;
  102947. private _getGeometryByUniqueID;
  102948. /**
  102949. * Add a new geometry to this scene
  102950. * @param geometry defines the geometry to be added to the scene.
  102951. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  102952. * @return a boolean defining if the geometry was added or not
  102953. */
  102954. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  102955. /**
  102956. * Removes an existing geometry
  102957. * @param geometry defines the geometry to be removed from the scene
  102958. * @return a boolean defining if the geometry was removed or not
  102959. */
  102960. removeGeometry(geometry: Geometry): boolean;
  102961. /**
  102962. * Gets the list of geometries attached to the scene
  102963. * @returns an array of Geometry
  102964. */
  102965. getGeometries(): Geometry[];
  102966. /**
  102967. * Gets the first added mesh found of a given ID
  102968. * @param id defines the id to search for
  102969. * @return the mesh found or null if not found at all
  102970. */
  102971. getMeshByID(id: string): Nullable<AbstractMesh>;
  102972. /**
  102973. * Gets a list of meshes using their id
  102974. * @param id defines the id to search for
  102975. * @returns a list of meshes
  102976. */
  102977. getMeshesByID(id: string): Array<AbstractMesh>;
  102978. /**
  102979. * Gets the first added transform node found of a given ID
  102980. * @param id defines the id to search for
  102981. * @return the found transform node or null if not found at all.
  102982. */
  102983. getTransformNodeByID(id: string): Nullable<TransformNode>;
  102984. /**
  102985. * Gets a transform node with its auto-generated unique id
  102986. * @param uniqueId efines the unique id to search for
  102987. * @return the found transform node or null if not found at all.
  102988. */
  102989. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  102990. /**
  102991. * Gets a list of transform nodes using their id
  102992. * @param id defines the id to search for
  102993. * @returns a list of transform nodes
  102994. */
  102995. getTransformNodesByID(id: string): Array<TransformNode>;
  102996. /**
  102997. * Gets a mesh with its auto-generated unique id
  102998. * @param uniqueId defines the unique id to search for
  102999. * @return the found mesh or null if not found at all.
  103000. */
  103001. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  103002. /**
  103003. * Gets a the last added mesh using a given id
  103004. * @param id defines the id to search for
  103005. * @return the found mesh or null if not found at all.
  103006. */
  103007. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  103008. /**
  103009. * Gets a the last added node (Mesh, Camera, Light) using a given id
  103010. * @param id defines the id to search for
  103011. * @return the found node or null if not found at all
  103012. */
  103013. getLastEntryByID(id: string): Nullable<Node>;
  103014. /**
  103015. * Gets a node (Mesh, Camera, Light) using a given id
  103016. * @param id defines the id to search for
  103017. * @return the found node or null if not found at all
  103018. */
  103019. getNodeByID(id: string): Nullable<Node>;
  103020. /**
  103021. * Gets a node (Mesh, Camera, Light) using a given name
  103022. * @param name defines the name to search for
  103023. * @return the found node or null if not found at all.
  103024. */
  103025. getNodeByName(name: string): Nullable<Node>;
  103026. /**
  103027. * Gets a mesh using a given name
  103028. * @param name defines the name to search for
  103029. * @return the found mesh or null if not found at all.
  103030. */
  103031. getMeshByName(name: string): Nullable<AbstractMesh>;
  103032. /**
  103033. * Gets a transform node using a given name
  103034. * @param name defines the name to search for
  103035. * @return the found transform node or null if not found at all.
  103036. */
  103037. getTransformNodeByName(name: string): Nullable<TransformNode>;
  103038. /**
  103039. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  103040. * @param id defines the id to search for
  103041. * @return the found skeleton or null if not found at all.
  103042. */
  103043. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  103044. /**
  103045. * Gets a skeleton using a given auto generated unique id
  103046. * @param uniqueId defines the unique id to search for
  103047. * @return the found skeleton or null if not found at all.
  103048. */
  103049. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  103050. /**
  103051. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  103052. * @param id defines the id to search for
  103053. * @return the found skeleton or null if not found at all.
  103054. */
  103055. getSkeletonById(id: string): Nullable<Skeleton>;
  103056. /**
  103057. * Gets a skeleton using a given name
  103058. * @param name defines the name to search for
  103059. * @return the found skeleton or null if not found at all.
  103060. */
  103061. getSkeletonByName(name: string): Nullable<Skeleton>;
  103062. /**
  103063. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  103064. * @param id defines the id to search for
  103065. * @return the found morph target manager or null if not found at all.
  103066. */
  103067. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  103068. /**
  103069. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  103070. * @param id defines the id to search for
  103071. * @return the found morph target or null if not found at all.
  103072. */
  103073. getMorphTargetById(id: string): Nullable<MorphTarget>;
  103074. /**
  103075. * Gets a boolean indicating if the given mesh is active
  103076. * @param mesh defines the mesh to look for
  103077. * @returns true if the mesh is in the active list
  103078. */
  103079. isActiveMesh(mesh: AbstractMesh): boolean;
  103080. /**
  103081. * Return a unique id as a string which can serve as an identifier for the scene
  103082. */
  103083. readonly uid: string;
  103084. /**
  103085. * Add an externaly attached data from its key.
  103086. * This method call will fail and return false, if such key already exists.
  103087. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  103088. * @param key the unique key that identifies the data
  103089. * @param data the data object to associate to the key for this Engine instance
  103090. * @return true if no such key were already present and the data was added successfully, false otherwise
  103091. */
  103092. addExternalData<T>(key: string, data: T): boolean;
  103093. /**
  103094. * Get an externaly attached data from its key
  103095. * @param key the unique key that identifies the data
  103096. * @return the associated data, if present (can be null), or undefined if not present
  103097. */
  103098. getExternalData<T>(key: string): Nullable<T>;
  103099. /**
  103100. * Get an externaly attached data from its key, create it using a factory if it's not already present
  103101. * @param key the unique key that identifies the data
  103102. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  103103. * @return the associated data, can be null if the factory returned null.
  103104. */
  103105. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  103106. /**
  103107. * Remove an externaly attached data from the Engine instance
  103108. * @param key the unique key that identifies the data
  103109. * @return true if the data was successfully removed, false if it doesn't exist
  103110. */
  103111. removeExternalData(key: string): boolean;
  103112. private _evaluateSubMesh;
  103113. /**
  103114. * Clear the processed materials smart array preventing retention point in material dispose.
  103115. */
  103116. freeProcessedMaterials(): void;
  103117. private _preventFreeActiveMeshesAndRenderingGroups;
  103118. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  103119. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  103120. * when disposing several meshes in a row or a hierarchy of meshes.
  103121. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  103122. */
  103123. blockfreeActiveMeshesAndRenderingGroups: boolean;
  103124. /**
  103125. * Clear the active meshes smart array preventing retention point in mesh dispose.
  103126. */
  103127. freeActiveMeshes(): void;
  103128. /**
  103129. * Clear the info related to rendering groups preventing retention points during dispose.
  103130. */
  103131. freeRenderingGroups(): void;
  103132. /** @hidden */
  103133. _isInIntermediateRendering(): boolean;
  103134. /**
  103135. * Lambda returning the list of potentially active meshes.
  103136. */
  103137. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  103138. /**
  103139. * Lambda returning the list of potentially active sub meshes.
  103140. */
  103141. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  103142. /**
  103143. * Lambda returning the list of potentially intersecting sub meshes.
  103144. */
  103145. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  103146. /**
  103147. * Lambda returning the list of potentially colliding sub meshes.
  103148. */
  103149. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  103150. private _activeMeshesFrozen;
  103151. private _skipEvaluateActiveMeshesCompletely;
  103152. /**
  103153. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  103154. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  103155. * @returns the current scene
  103156. */
  103157. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  103158. /**
  103159. * Use this function to restart evaluating active meshes on every frame
  103160. * @returns the current scene
  103161. */
  103162. unfreezeActiveMeshes(): Scene;
  103163. private _evaluateActiveMeshes;
  103164. private _activeMesh;
  103165. /**
  103166. * Update the transform matrix to update from the current active camera
  103167. * @param force defines a boolean used to force the update even if cache is up to date
  103168. */
  103169. updateTransformMatrix(force?: boolean): void;
  103170. private _bindFrameBuffer;
  103171. /** @hidden */
  103172. _allowPostProcessClearColor: boolean;
  103173. /** @hidden */
  103174. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  103175. private _processSubCameras;
  103176. private _checkIntersections;
  103177. /** @hidden */
  103178. _advancePhysicsEngineStep(step: number): void;
  103179. /**
  103180. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  103181. */
  103182. getDeterministicFrameTime: () => number;
  103183. /** @hidden */
  103184. _animate(): void;
  103185. /** Execute all animations (for a frame) */
  103186. animate(): void;
  103187. /**
  103188. * Render the scene
  103189. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  103190. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  103191. */
  103192. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  103193. /**
  103194. * Freeze all materials
  103195. * A frozen material will not be updatable but should be faster to render
  103196. */
  103197. freezeMaterials(): void;
  103198. /**
  103199. * Unfreeze all materials
  103200. * A frozen material will not be updatable but should be faster to render
  103201. */
  103202. unfreezeMaterials(): void;
  103203. /**
  103204. * Releases all held ressources
  103205. */
  103206. dispose(): void;
  103207. /**
  103208. * Gets if the scene is already disposed
  103209. */
  103210. readonly isDisposed: boolean;
  103211. /**
  103212. * Call this function to reduce memory footprint of the scene.
  103213. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  103214. */
  103215. clearCachedVertexData(): void;
  103216. /**
  103217. * This function will remove the local cached buffer data from texture.
  103218. * It will save memory but will prevent the texture from being rebuilt
  103219. */
  103220. cleanCachedTextureBuffer(): void;
  103221. /**
  103222. * Get the world extend vectors with an optional filter
  103223. *
  103224. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  103225. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  103226. */
  103227. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  103228. min: Vector3;
  103229. max: Vector3;
  103230. };
  103231. /**
  103232. * Creates a ray that can be used to pick in the scene
  103233. * @param x defines the x coordinate of the origin (on-screen)
  103234. * @param y defines the y coordinate of the origin (on-screen)
  103235. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103236. * @param camera defines the camera to use for the picking
  103237. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103238. * @returns a Ray
  103239. */
  103240. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  103241. /**
  103242. * Creates a ray that can be used to pick in the scene
  103243. * @param x defines the x coordinate of the origin (on-screen)
  103244. * @param y defines the y coordinate of the origin (on-screen)
  103245. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103246. * @param result defines the ray where to store the picking ray
  103247. * @param camera defines the camera to use for the picking
  103248. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103249. * @returns the current scene
  103250. */
  103251. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  103252. /**
  103253. * Creates a ray that can be used to pick in the scene
  103254. * @param x defines the x coordinate of the origin (on-screen)
  103255. * @param y defines the y coordinate of the origin (on-screen)
  103256. * @param camera defines the camera to use for the picking
  103257. * @returns a Ray
  103258. */
  103259. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  103260. /**
  103261. * Creates a ray that can be used to pick in the scene
  103262. * @param x defines the x coordinate of the origin (on-screen)
  103263. * @param y defines the y coordinate of the origin (on-screen)
  103264. * @param result defines the ray where to store the picking ray
  103265. * @param camera defines the camera to use for the picking
  103266. * @returns the current scene
  103267. */
  103268. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  103269. /** Launch a ray to try to pick a mesh in the scene
  103270. * @param x position on screen
  103271. * @param y position on screen
  103272. * @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
  103273. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  103274. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103275. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103276. * @returns a PickingInfo
  103277. */
  103278. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103279. /** Use the given ray to pick a mesh in the scene
  103280. * @param ray The ray to use to pick meshes
  103281. * @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
  103282. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  103283. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103284. * @returns a PickingInfo
  103285. */
  103286. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103287. /**
  103288. * Launch a ray to try to pick a mesh in the scene
  103289. * @param x X position on screen
  103290. * @param y Y position on screen
  103291. * @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
  103292. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103293. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103294. * @returns an array of PickingInfo
  103295. */
  103296. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103297. /**
  103298. * Launch a ray to try to pick a mesh in the scene
  103299. * @param ray Ray to use
  103300. * @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
  103301. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103302. * @returns an array of PickingInfo
  103303. */
  103304. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103305. /**
  103306. * Force the value of meshUnderPointer
  103307. * @param mesh defines the mesh to use
  103308. */
  103309. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103310. /**
  103311. * Gets the mesh under the pointer
  103312. * @returns a Mesh or null if no mesh is under the pointer
  103313. */
  103314. getPointerOverMesh(): Nullable<AbstractMesh>;
  103315. /** @hidden */
  103316. _rebuildGeometries(): void;
  103317. /** @hidden */
  103318. _rebuildTextures(): void;
  103319. private _getByTags;
  103320. /**
  103321. * Get a list of meshes by tags
  103322. * @param tagsQuery defines the tags query to use
  103323. * @param forEach defines a predicate used to filter results
  103324. * @returns an array of Mesh
  103325. */
  103326. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  103327. /**
  103328. * Get a list of cameras by tags
  103329. * @param tagsQuery defines the tags query to use
  103330. * @param forEach defines a predicate used to filter results
  103331. * @returns an array of Camera
  103332. */
  103333. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  103334. /**
  103335. * Get a list of lights by tags
  103336. * @param tagsQuery defines the tags query to use
  103337. * @param forEach defines a predicate used to filter results
  103338. * @returns an array of Light
  103339. */
  103340. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  103341. /**
  103342. * Get a list of materials by tags
  103343. * @param tagsQuery defines the tags query to use
  103344. * @param forEach defines a predicate used to filter results
  103345. * @returns an array of Material
  103346. */
  103347. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  103348. /**
  103349. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103350. * This allowed control for front to back rendering or reversly depending of the special needs.
  103351. *
  103352. * @param renderingGroupId The rendering group id corresponding to its index
  103353. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103354. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103355. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103356. */
  103357. 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;
  103358. /**
  103359. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103360. *
  103361. * @param renderingGroupId The rendering group id corresponding to its index
  103362. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103363. * @param depth Automatically clears depth between groups if true and autoClear is true.
  103364. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  103365. */
  103366. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  103367. /**
  103368. * Gets the current auto clear configuration for one rendering group of the rendering
  103369. * manager.
  103370. * @param index the rendering group index to get the information for
  103371. * @returns The auto clear setup for the requested rendering group
  103372. */
  103373. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  103374. private _blockMaterialDirtyMechanism;
  103375. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  103376. blockMaterialDirtyMechanism: boolean;
  103377. /**
  103378. * Will flag all materials as dirty to trigger new shader compilation
  103379. * @param flag defines the flag used to specify which material part must be marked as dirty
  103380. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  103381. */
  103382. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103383. /** @hidden */
  103384. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  103385. /** @hidden */
  103386. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103387. /** @hidden */
  103388. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  103389. /** @hidden */
  103390. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  103391. /** @hidden */
  103392. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103393. /** @hidden */
  103394. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103395. }
  103396. }
  103397. declare module BABYLON {
  103398. /**
  103399. * Set of assets to keep when moving a scene into an asset container.
  103400. */
  103401. export class KeepAssets extends AbstractScene {
  103402. }
  103403. /**
  103404. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  103405. */
  103406. export class InstantiatedEntries {
  103407. /**
  103408. * List of new root nodes (eg. nodes with no parent)
  103409. */
  103410. rootNodes: TransformNode[];
  103411. /**
  103412. * List of new skeletons
  103413. */
  103414. skeletons: Skeleton[];
  103415. /**
  103416. * List of new animation groups
  103417. */
  103418. animationGroups: AnimationGroup[];
  103419. }
  103420. /**
  103421. * Container with a set of assets that can be added or removed from a scene.
  103422. */
  103423. export class AssetContainer extends AbstractScene {
  103424. /**
  103425. * The scene the AssetContainer belongs to.
  103426. */
  103427. scene: Scene;
  103428. /**
  103429. * Instantiates an AssetContainer.
  103430. * @param scene The scene the AssetContainer belongs to.
  103431. */
  103432. constructor(scene: Scene);
  103433. /**
  103434. * Instantiate or clone all meshes and add the new ones to the scene.
  103435. * Skeletons and animation groups will all be cloned
  103436. * @param nameFunction defines an optional function used to get new names for clones
  103437. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  103438. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  103439. */
  103440. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  103441. /**
  103442. * Adds all the assets from the container to the scene.
  103443. */
  103444. addAllToScene(): void;
  103445. /**
  103446. * Removes all the assets in the container from the scene
  103447. */
  103448. removeAllFromScene(): void;
  103449. /**
  103450. * Disposes all the assets in the container
  103451. */
  103452. dispose(): void;
  103453. private _moveAssets;
  103454. /**
  103455. * Removes all the assets contained in the scene and adds them to the container.
  103456. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  103457. */
  103458. moveAllFromScene(keepAssets?: KeepAssets): void;
  103459. /**
  103460. * 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.
  103461. * @returns the root mesh
  103462. */
  103463. createRootMesh(): Mesh;
  103464. }
  103465. }
  103466. declare module BABYLON {
  103467. /**
  103468. * Defines how the parser contract is defined.
  103469. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  103470. */
  103471. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  103472. /**
  103473. * Defines how the individual parser contract is defined.
  103474. * These parser can parse an individual asset
  103475. */
  103476. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  103477. /**
  103478. * Base class of the scene acting as a container for the different elements composing a scene.
  103479. * This class is dynamically extended by the different components of the scene increasing
  103480. * flexibility and reducing coupling
  103481. */
  103482. export abstract class AbstractScene {
  103483. /**
  103484. * Stores the list of available parsers in the application.
  103485. */
  103486. private static _BabylonFileParsers;
  103487. /**
  103488. * Stores the list of available individual parsers in the application.
  103489. */
  103490. private static _IndividualBabylonFileParsers;
  103491. /**
  103492. * Adds a parser in the list of available ones
  103493. * @param name Defines the name of the parser
  103494. * @param parser Defines the parser to add
  103495. */
  103496. static AddParser(name: string, parser: BabylonFileParser): void;
  103497. /**
  103498. * Gets a general parser from the list of avaialble ones
  103499. * @param name Defines the name of the parser
  103500. * @returns the requested parser or null
  103501. */
  103502. static GetParser(name: string): Nullable<BabylonFileParser>;
  103503. /**
  103504. * Adds n individual parser in the list of available ones
  103505. * @param name Defines the name of the parser
  103506. * @param parser Defines the parser to add
  103507. */
  103508. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  103509. /**
  103510. * Gets an individual parser from the list of avaialble ones
  103511. * @param name Defines the name of the parser
  103512. * @returns the requested parser or null
  103513. */
  103514. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  103515. /**
  103516. * Parser json data and populate both a scene and its associated container object
  103517. * @param jsonData Defines the data to parse
  103518. * @param scene Defines the scene to parse the data for
  103519. * @param container Defines the container attached to the parsing sequence
  103520. * @param rootUrl Defines the root url of the data
  103521. */
  103522. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  103523. /**
  103524. * Gets the list of root nodes (ie. nodes with no parent)
  103525. */
  103526. rootNodes: Node[];
  103527. /** All of the cameras added to this scene
  103528. * @see http://doc.babylonjs.com/babylon101/cameras
  103529. */
  103530. cameras: Camera[];
  103531. /**
  103532. * All of the lights added to this scene
  103533. * @see http://doc.babylonjs.com/babylon101/lights
  103534. */
  103535. lights: Light[];
  103536. /**
  103537. * All of the (abstract) meshes added to this scene
  103538. */
  103539. meshes: AbstractMesh[];
  103540. /**
  103541. * The list of skeletons added to the scene
  103542. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103543. */
  103544. skeletons: Skeleton[];
  103545. /**
  103546. * All of the particle systems added to this scene
  103547. * @see http://doc.babylonjs.com/babylon101/particles
  103548. */
  103549. particleSystems: IParticleSystem[];
  103550. /**
  103551. * Gets a list of Animations associated with the scene
  103552. */
  103553. animations: Animation[];
  103554. /**
  103555. * All of the animation groups added to this scene
  103556. * @see http://doc.babylonjs.com/how_to/group
  103557. */
  103558. animationGroups: AnimationGroup[];
  103559. /**
  103560. * All of the multi-materials added to this scene
  103561. * @see http://doc.babylonjs.com/how_to/multi_materials
  103562. */
  103563. multiMaterials: MultiMaterial[];
  103564. /**
  103565. * All of the materials added to this scene
  103566. * In the context of a Scene, it is not supposed to be modified manually.
  103567. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  103568. * Note also that the order of the Material within the array is not significant and might change.
  103569. * @see http://doc.babylonjs.com/babylon101/materials
  103570. */
  103571. materials: Material[];
  103572. /**
  103573. * The list of morph target managers added to the scene
  103574. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  103575. */
  103576. morphTargetManagers: MorphTargetManager[];
  103577. /**
  103578. * The list of geometries used in the scene.
  103579. */
  103580. geometries: Geometry[];
  103581. /**
  103582. * All of the tranform nodes added to this scene
  103583. * In the context of a Scene, it is not supposed to be modified manually.
  103584. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  103585. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  103586. * @see http://doc.babylonjs.com/how_to/transformnode
  103587. */
  103588. transformNodes: TransformNode[];
  103589. /**
  103590. * ActionManagers available on the scene.
  103591. */
  103592. actionManagers: AbstractActionManager[];
  103593. /**
  103594. * Textures to keep.
  103595. */
  103596. textures: BaseTexture[];
  103597. /**
  103598. * Environment texture for the scene
  103599. */
  103600. environmentTexture: Nullable<BaseTexture>;
  103601. }
  103602. }
  103603. declare module BABYLON {
  103604. /**
  103605. * Interface used to define options for Sound class
  103606. */
  103607. export interface ISoundOptions {
  103608. /**
  103609. * Does the sound autoplay once loaded.
  103610. */
  103611. autoplay?: boolean;
  103612. /**
  103613. * Does the sound loop after it finishes playing once.
  103614. */
  103615. loop?: boolean;
  103616. /**
  103617. * Sound's volume
  103618. */
  103619. volume?: number;
  103620. /**
  103621. * Is it a spatial sound?
  103622. */
  103623. spatialSound?: boolean;
  103624. /**
  103625. * Maximum distance to hear that sound
  103626. */
  103627. maxDistance?: number;
  103628. /**
  103629. * Uses user defined attenuation function
  103630. */
  103631. useCustomAttenuation?: boolean;
  103632. /**
  103633. * Define the roll off factor of spatial sounds.
  103634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103635. */
  103636. rolloffFactor?: number;
  103637. /**
  103638. * Define the reference distance the sound should be heard perfectly.
  103639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103640. */
  103641. refDistance?: number;
  103642. /**
  103643. * Define the distance attenuation model the sound will follow.
  103644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103645. */
  103646. distanceModel?: string;
  103647. /**
  103648. * Defines the playback speed (1 by default)
  103649. */
  103650. playbackRate?: number;
  103651. /**
  103652. * Defines if the sound is from a streaming source
  103653. */
  103654. streaming?: boolean;
  103655. /**
  103656. * Defines an optional length (in seconds) inside the sound file
  103657. */
  103658. length?: number;
  103659. /**
  103660. * Defines an optional offset (in seconds) inside the sound file
  103661. */
  103662. offset?: number;
  103663. /**
  103664. * If true, URLs will not be required to state the audio file codec to use.
  103665. */
  103666. skipCodecCheck?: boolean;
  103667. }
  103668. /**
  103669. * Defines a sound that can be played in the application.
  103670. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  103671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103672. */
  103673. export class Sound {
  103674. /**
  103675. * The name of the sound in the scene.
  103676. */
  103677. name: string;
  103678. /**
  103679. * Does the sound autoplay once loaded.
  103680. */
  103681. autoplay: boolean;
  103682. /**
  103683. * Does the sound loop after it finishes playing once.
  103684. */
  103685. loop: boolean;
  103686. /**
  103687. * Does the sound use a custom attenuation curve to simulate the falloff
  103688. * happening when the source gets further away from the camera.
  103689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103690. */
  103691. useCustomAttenuation: boolean;
  103692. /**
  103693. * The sound track id this sound belongs to.
  103694. */
  103695. soundTrackId: number;
  103696. /**
  103697. * Is this sound currently played.
  103698. */
  103699. isPlaying: boolean;
  103700. /**
  103701. * Is this sound currently paused.
  103702. */
  103703. isPaused: boolean;
  103704. /**
  103705. * Does this sound enables spatial sound.
  103706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103707. */
  103708. spatialSound: boolean;
  103709. /**
  103710. * Define the reference distance the sound should be heard perfectly.
  103711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103712. */
  103713. refDistance: number;
  103714. /**
  103715. * Define the roll off factor of spatial sounds.
  103716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103717. */
  103718. rolloffFactor: number;
  103719. /**
  103720. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  103721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103722. */
  103723. maxDistance: number;
  103724. /**
  103725. * Define the distance attenuation model the sound will follow.
  103726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103727. */
  103728. distanceModel: string;
  103729. /**
  103730. * @hidden
  103731. * Back Compat
  103732. **/
  103733. onended: () => any;
  103734. /**
  103735. * Observable event when the current playing sound finishes.
  103736. */
  103737. onEndedObservable: Observable<Sound>;
  103738. private _panningModel;
  103739. private _playbackRate;
  103740. private _streaming;
  103741. private _startTime;
  103742. private _startOffset;
  103743. private _position;
  103744. /** @hidden */
  103745. _positionInEmitterSpace: boolean;
  103746. private _localDirection;
  103747. private _volume;
  103748. private _isReadyToPlay;
  103749. private _isDirectional;
  103750. private _readyToPlayCallback;
  103751. private _audioBuffer;
  103752. private _soundSource;
  103753. private _streamingSource;
  103754. private _soundPanner;
  103755. private _soundGain;
  103756. private _inputAudioNode;
  103757. private _outputAudioNode;
  103758. private _coneInnerAngle;
  103759. private _coneOuterAngle;
  103760. private _coneOuterGain;
  103761. private _scene;
  103762. private _connectedTransformNode;
  103763. private _customAttenuationFunction;
  103764. private _registerFunc;
  103765. private _isOutputConnected;
  103766. private _htmlAudioElement;
  103767. private _urlType;
  103768. private _length?;
  103769. private _offset?;
  103770. /** @hidden */
  103771. static _SceneComponentInitialization: (scene: Scene) => void;
  103772. /**
  103773. * Create a sound and attach it to a scene
  103774. * @param name Name of your sound
  103775. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  103776. * @param scene defines the scene the sound belongs to
  103777. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  103778. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  103779. */
  103780. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  103781. /**
  103782. * Release the sound and its associated resources
  103783. */
  103784. dispose(): void;
  103785. /**
  103786. * Gets if the sounds is ready to be played or not.
  103787. * @returns true if ready, otherwise false
  103788. */
  103789. isReady(): boolean;
  103790. private _soundLoaded;
  103791. /**
  103792. * Sets the data of the sound from an audiobuffer
  103793. * @param audioBuffer The audioBuffer containing the data
  103794. */
  103795. setAudioBuffer(audioBuffer: AudioBuffer): void;
  103796. /**
  103797. * Updates the current sounds options such as maxdistance, loop...
  103798. * @param options A JSON object containing values named as the object properties
  103799. */
  103800. updateOptions(options: ISoundOptions): void;
  103801. private _createSpatialParameters;
  103802. private _updateSpatialParameters;
  103803. /**
  103804. * Switch the panning model to HRTF:
  103805. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103807. */
  103808. switchPanningModelToHRTF(): void;
  103809. /**
  103810. * Switch the panning model to Equal Power:
  103811. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103813. */
  103814. switchPanningModelToEqualPower(): void;
  103815. private _switchPanningModel;
  103816. /**
  103817. * Connect this sound to a sound track audio node like gain...
  103818. * @param soundTrackAudioNode the sound track audio node to connect to
  103819. */
  103820. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  103821. /**
  103822. * Transform this sound into a directional source
  103823. * @param coneInnerAngle Size of the inner cone in degree
  103824. * @param coneOuterAngle Size of the outer cone in degree
  103825. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  103826. */
  103827. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  103828. /**
  103829. * Gets or sets the inner angle for the directional cone.
  103830. */
  103831. /**
  103832. * Gets or sets the inner angle for the directional cone.
  103833. */
  103834. directionalConeInnerAngle: number;
  103835. /**
  103836. * Gets or sets the outer angle for the directional cone.
  103837. */
  103838. /**
  103839. * Gets or sets the outer angle for the directional cone.
  103840. */
  103841. directionalConeOuterAngle: number;
  103842. /**
  103843. * Sets the position of the emitter if spatial sound is enabled
  103844. * @param newPosition Defines the new posisiton
  103845. */
  103846. setPosition(newPosition: Vector3): void;
  103847. /**
  103848. * Sets the local direction of the emitter if spatial sound is enabled
  103849. * @param newLocalDirection Defines the new local direction
  103850. */
  103851. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  103852. private _updateDirection;
  103853. /** @hidden */
  103854. updateDistanceFromListener(): void;
  103855. /**
  103856. * Sets a new custom attenuation function for the sound.
  103857. * @param callback Defines the function used for the attenuation
  103858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103859. */
  103860. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  103861. /**
  103862. * Play the sound
  103863. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  103864. * @param offset (optional) Start the sound at a specific time in seconds
  103865. * @param length (optional) Sound duration (in seconds)
  103866. */
  103867. play(time?: number, offset?: number, length?: number): void;
  103868. private _onended;
  103869. /**
  103870. * Stop the sound
  103871. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  103872. */
  103873. stop(time?: number): void;
  103874. /**
  103875. * Put the sound in pause
  103876. */
  103877. pause(): void;
  103878. /**
  103879. * Sets a dedicated volume for this sounds
  103880. * @param newVolume Define the new volume of the sound
  103881. * @param time Define time for gradual change to new volume
  103882. */
  103883. setVolume(newVolume: number, time?: number): void;
  103884. /**
  103885. * Set the sound play back rate
  103886. * @param newPlaybackRate Define the playback rate the sound should be played at
  103887. */
  103888. setPlaybackRate(newPlaybackRate: number): void;
  103889. /**
  103890. * Gets the volume of the sound.
  103891. * @returns the volume of the sound
  103892. */
  103893. getVolume(): number;
  103894. /**
  103895. * Attach the sound to a dedicated mesh
  103896. * @param transformNode The transform node to connect the sound with
  103897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103898. */
  103899. attachToMesh(transformNode: TransformNode): void;
  103900. /**
  103901. * Detach the sound from the previously attached mesh
  103902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103903. */
  103904. detachFromMesh(): void;
  103905. private _onRegisterAfterWorldMatrixUpdate;
  103906. /**
  103907. * Clone the current sound in the scene.
  103908. * @returns the new sound clone
  103909. */
  103910. clone(): Nullable<Sound>;
  103911. /**
  103912. * Gets the current underlying audio buffer containing the data
  103913. * @returns the audio buffer
  103914. */
  103915. getAudioBuffer(): Nullable<AudioBuffer>;
  103916. /**
  103917. * Serializes the Sound in a JSON representation
  103918. * @returns the JSON representation of the sound
  103919. */
  103920. serialize(): any;
  103921. /**
  103922. * Parse a JSON representation of a sound to innstantiate in a given scene
  103923. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  103924. * @param scene Define the scene the new parsed sound should be created in
  103925. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  103926. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  103927. * @returns the newly parsed sound
  103928. */
  103929. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  103930. }
  103931. }
  103932. declare module BABYLON {
  103933. /**
  103934. * This defines an action helpful to play a defined sound on a triggered action.
  103935. */
  103936. export class PlaySoundAction extends Action {
  103937. private _sound;
  103938. /**
  103939. * Instantiate the action
  103940. * @param triggerOptions defines the trigger options
  103941. * @param sound defines the sound to play
  103942. * @param condition defines the trigger related conditions
  103943. */
  103944. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103945. /** @hidden */
  103946. _prepare(): void;
  103947. /**
  103948. * Execute the action and play the sound.
  103949. */
  103950. execute(): void;
  103951. /**
  103952. * Serializes the actions and its related information.
  103953. * @param parent defines the object to serialize in
  103954. * @returns the serialized object
  103955. */
  103956. serialize(parent: any): any;
  103957. }
  103958. /**
  103959. * This defines an action helpful to stop a defined sound on a triggered action.
  103960. */
  103961. export class StopSoundAction extends Action {
  103962. private _sound;
  103963. /**
  103964. * Instantiate the action
  103965. * @param triggerOptions defines the trigger options
  103966. * @param sound defines the sound to stop
  103967. * @param condition defines the trigger related conditions
  103968. */
  103969. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103970. /** @hidden */
  103971. _prepare(): void;
  103972. /**
  103973. * Execute the action and stop the sound.
  103974. */
  103975. execute(): void;
  103976. /**
  103977. * Serializes the actions and its related information.
  103978. * @param parent defines the object to serialize in
  103979. * @returns the serialized object
  103980. */
  103981. serialize(parent: any): any;
  103982. }
  103983. }
  103984. declare module BABYLON {
  103985. /**
  103986. * This defines an action responsible to change the value of a property
  103987. * by interpolating between its current value and the newly set one once triggered.
  103988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103989. */
  103990. export class InterpolateValueAction extends Action {
  103991. /**
  103992. * Defines the path of the property where the value should be interpolated
  103993. */
  103994. propertyPath: string;
  103995. /**
  103996. * Defines the target value at the end of the interpolation.
  103997. */
  103998. value: any;
  103999. /**
  104000. * Defines the time it will take for the property to interpolate to the value.
  104001. */
  104002. duration: number;
  104003. /**
  104004. * Defines if the other scene animations should be stopped when the action has been triggered
  104005. */
  104006. stopOtherAnimations?: boolean;
  104007. /**
  104008. * Defines a callback raised once the interpolation animation has been done.
  104009. */
  104010. onInterpolationDone?: () => void;
  104011. /**
  104012. * Observable triggered once the interpolation animation has been done.
  104013. */
  104014. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  104015. private _target;
  104016. private _effectiveTarget;
  104017. private _property;
  104018. /**
  104019. * Instantiate the action
  104020. * @param triggerOptions defines the trigger options
  104021. * @param target defines the object containing the value to interpolate
  104022. * @param propertyPath defines the path to the property in the target object
  104023. * @param value defines the target value at the end of the interpolation
  104024. * @param duration deines the time it will take for the property to interpolate to the value.
  104025. * @param condition defines the trigger related conditions
  104026. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  104027. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  104028. */
  104029. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  104030. /** @hidden */
  104031. _prepare(): void;
  104032. /**
  104033. * Execute the action starts the value interpolation.
  104034. */
  104035. execute(): void;
  104036. /**
  104037. * Serializes the actions and its related information.
  104038. * @param parent defines the object to serialize in
  104039. * @returns the serialized object
  104040. */
  104041. serialize(parent: any): any;
  104042. }
  104043. }
  104044. declare module BABYLON {
  104045. /**
  104046. * Options allowed during the creation of a sound track.
  104047. */
  104048. export interface ISoundTrackOptions {
  104049. /**
  104050. * The volume the sound track should take during creation
  104051. */
  104052. volume?: number;
  104053. /**
  104054. * Define if the sound track is the main sound track of the scene
  104055. */
  104056. mainTrack?: boolean;
  104057. }
  104058. /**
  104059. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  104060. * It will be also used in a future release to apply effects on a specific track.
  104061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104062. */
  104063. export class SoundTrack {
  104064. /**
  104065. * The unique identifier of the sound track in the scene.
  104066. */
  104067. id: number;
  104068. /**
  104069. * The list of sounds included in the sound track.
  104070. */
  104071. soundCollection: Array<Sound>;
  104072. private _outputAudioNode;
  104073. private _scene;
  104074. private _connectedAnalyser;
  104075. private _options;
  104076. private _isInitialized;
  104077. /**
  104078. * Creates a new sound track.
  104079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104080. * @param scene Define the scene the sound track belongs to
  104081. * @param options
  104082. */
  104083. constructor(scene: Scene, options?: ISoundTrackOptions);
  104084. private _initializeSoundTrackAudioGraph;
  104085. /**
  104086. * Release the sound track and its associated resources
  104087. */
  104088. dispose(): void;
  104089. /**
  104090. * Adds a sound to this sound track
  104091. * @param sound define the cound to add
  104092. * @ignoreNaming
  104093. */
  104094. AddSound(sound: Sound): void;
  104095. /**
  104096. * Removes a sound to this sound track
  104097. * @param sound define the cound to remove
  104098. * @ignoreNaming
  104099. */
  104100. RemoveSound(sound: Sound): void;
  104101. /**
  104102. * Set a global volume for the full sound track.
  104103. * @param newVolume Define the new volume of the sound track
  104104. */
  104105. setVolume(newVolume: number): void;
  104106. /**
  104107. * Switch the panning model to HRTF:
  104108. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  104109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104110. */
  104111. switchPanningModelToHRTF(): void;
  104112. /**
  104113. * Switch the panning model to Equal Power:
  104114. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  104115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104116. */
  104117. switchPanningModelToEqualPower(): void;
  104118. /**
  104119. * Connect the sound track to an audio analyser allowing some amazing
  104120. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  104121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  104122. * @param analyser The analyser to connect to the engine
  104123. */
  104124. connectToAnalyser(analyser: Analyser): void;
  104125. }
  104126. }
  104127. declare module BABYLON {
  104128. interface AbstractScene {
  104129. /**
  104130. * The list of sounds used in the scene.
  104131. */
  104132. sounds: Nullable<Array<Sound>>;
  104133. }
  104134. interface Scene {
  104135. /**
  104136. * @hidden
  104137. * Backing field
  104138. */
  104139. _mainSoundTrack: SoundTrack;
  104140. /**
  104141. * The main sound track played by the scene.
  104142. * It cotains your primary collection of sounds.
  104143. */
  104144. mainSoundTrack: SoundTrack;
  104145. /**
  104146. * The list of sound tracks added to the scene
  104147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104148. */
  104149. soundTracks: Nullable<Array<SoundTrack>>;
  104150. /**
  104151. * Gets a sound using a given name
  104152. * @param name defines the name to search for
  104153. * @return the found sound or null if not found at all.
  104154. */
  104155. getSoundByName(name: string): Nullable<Sound>;
  104156. /**
  104157. * Gets or sets if audio support is enabled
  104158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104159. */
  104160. audioEnabled: boolean;
  104161. /**
  104162. * Gets or sets if audio will be output to headphones
  104163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104164. */
  104165. headphone: boolean;
  104166. /**
  104167. * Gets or sets custom audio listener position provider
  104168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104169. */
  104170. audioListenerPositionProvider: Nullable<() => Vector3>;
  104171. /**
  104172. * Gets or sets a refresh rate when using 3D audio positioning
  104173. */
  104174. audioPositioningRefreshRate: number;
  104175. }
  104176. /**
  104177. * Defines the sound scene component responsible to manage any sounds
  104178. * in a given scene.
  104179. */
  104180. export class AudioSceneComponent implements ISceneSerializableComponent {
  104181. /**
  104182. * The component name helpfull to identify the component in the list of scene components.
  104183. */
  104184. readonly name: string;
  104185. /**
  104186. * The scene the component belongs to.
  104187. */
  104188. scene: Scene;
  104189. private _audioEnabled;
  104190. /**
  104191. * Gets whether audio is enabled or not.
  104192. * Please use related enable/disable method to switch state.
  104193. */
  104194. readonly audioEnabled: boolean;
  104195. private _headphone;
  104196. /**
  104197. * Gets whether audio is outputing to headphone or not.
  104198. * Please use the according Switch methods to change output.
  104199. */
  104200. readonly headphone: boolean;
  104201. /**
  104202. * Gets or sets a refresh rate when using 3D audio positioning
  104203. */
  104204. audioPositioningRefreshRate: number;
  104205. private _audioListenerPositionProvider;
  104206. /**
  104207. * Gets the current audio listener position provider
  104208. */
  104209. /**
  104210. * Sets a custom listener position for all sounds in the scene
  104211. * By default, this is the position of the first active camera
  104212. */
  104213. audioListenerPositionProvider: Nullable<() => Vector3>;
  104214. /**
  104215. * Creates a new instance of the component for the given scene
  104216. * @param scene Defines the scene to register the component in
  104217. */
  104218. constructor(scene: Scene);
  104219. /**
  104220. * Registers the component in a given scene
  104221. */
  104222. register(): void;
  104223. /**
  104224. * Rebuilds the elements related to this component in case of
  104225. * context lost for instance.
  104226. */
  104227. rebuild(): void;
  104228. /**
  104229. * Serializes the component data to the specified json object
  104230. * @param serializationObject The object to serialize to
  104231. */
  104232. serialize(serializationObject: any): void;
  104233. /**
  104234. * Adds all the elements from the container to the scene
  104235. * @param container the container holding the elements
  104236. */
  104237. addFromContainer(container: AbstractScene): void;
  104238. /**
  104239. * Removes all the elements in the container from the scene
  104240. * @param container contains the elements to remove
  104241. * @param dispose if the removed element should be disposed (default: false)
  104242. */
  104243. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  104244. /**
  104245. * Disposes the component and the associated ressources.
  104246. */
  104247. dispose(): void;
  104248. /**
  104249. * Disables audio in the associated scene.
  104250. */
  104251. disableAudio(): void;
  104252. /**
  104253. * Enables audio in the associated scene.
  104254. */
  104255. enableAudio(): void;
  104256. /**
  104257. * Switch audio to headphone output.
  104258. */
  104259. switchAudioModeForHeadphones(): void;
  104260. /**
  104261. * Switch audio to normal speakers.
  104262. */
  104263. switchAudioModeForNormalSpeakers(): void;
  104264. private _cachedCameraDirection;
  104265. private _cachedCameraPosition;
  104266. private _lastCheck;
  104267. private _afterRender;
  104268. }
  104269. }
  104270. declare module BABYLON {
  104271. /**
  104272. * Wraps one or more Sound objects and selects one with random weight for playback.
  104273. */
  104274. export class WeightedSound {
  104275. /** When true a Sound will be selected and played when the current playing Sound completes. */
  104276. loop: boolean;
  104277. private _coneInnerAngle;
  104278. private _coneOuterAngle;
  104279. private _volume;
  104280. /** A Sound is currently playing. */
  104281. isPlaying: boolean;
  104282. /** A Sound is currently paused. */
  104283. isPaused: boolean;
  104284. private _sounds;
  104285. private _weights;
  104286. private _currentIndex?;
  104287. /**
  104288. * Creates a new WeightedSound from the list of sounds given.
  104289. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  104290. * @param sounds Array of Sounds that will be selected from.
  104291. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  104292. */
  104293. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  104294. /**
  104295. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  104296. */
  104297. /**
  104298. * The size of cone in degress for a directional sound in which there will be no attenuation.
  104299. */
  104300. directionalConeInnerAngle: number;
  104301. /**
  104302. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104303. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104304. */
  104305. /**
  104306. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104307. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104308. */
  104309. directionalConeOuterAngle: number;
  104310. /**
  104311. * Playback volume.
  104312. */
  104313. /**
  104314. * Playback volume.
  104315. */
  104316. volume: number;
  104317. private _onended;
  104318. /**
  104319. * Suspend playback
  104320. */
  104321. pause(): void;
  104322. /**
  104323. * Stop playback
  104324. */
  104325. stop(): void;
  104326. /**
  104327. * Start playback.
  104328. * @param startOffset Position the clip head at a specific time in seconds.
  104329. */
  104330. play(startOffset?: number): void;
  104331. }
  104332. }
  104333. declare module BABYLON {
  104334. /**
  104335. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  104336. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104337. */
  104338. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  104339. /**
  104340. * Gets the name of the behavior.
  104341. */
  104342. readonly name: string;
  104343. /**
  104344. * The easing function used by animations
  104345. */
  104346. static EasingFunction: BackEase;
  104347. /**
  104348. * The easing mode used by animations
  104349. */
  104350. static EasingMode: number;
  104351. /**
  104352. * The duration of the animation, in milliseconds
  104353. */
  104354. transitionDuration: number;
  104355. /**
  104356. * Length of the distance animated by the transition when lower radius is reached
  104357. */
  104358. lowerRadiusTransitionRange: number;
  104359. /**
  104360. * Length of the distance animated by the transition when upper radius is reached
  104361. */
  104362. upperRadiusTransitionRange: number;
  104363. private _autoTransitionRange;
  104364. /**
  104365. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104366. */
  104367. /**
  104368. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104369. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  104370. */
  104371. autoTransitionRange: boolean;
  104372. private _attachedCamera;
  104373. private _onAfterCheckInputsObserver;
  104374. private _onMeshTargetChangedObserver;
  104375. /**
  104376. * Initializes the behavior.
  104377. */
  104378. init(): void;
  104379. /**
  104380. * Attaches the behavior to its arc rotate camera.
  104381. * @param camera Defines the camera to attach the behavior to
  104382. */
  104383. attach(camera: ArcRotateCamera): void;
  104384. /**
  104385. * Detaches the behavior from its current arc rotate camera.
  104386. */
  104387. detach(): void;
  104388. private _radiusIsAnimating;
  104389. private _radiusBounceTransition;
  104390. private _animatables;
  104391. private _cachedWheelPrecision;
  104392. /**
  104393. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  104394. * @param radiusLimit The limit to check against.
  104395. * @return Bool to indicate if at limit.
  104396. */
  104397. private _isRadiusAtLimit;
  104398. /**
  104399. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  104400. * @param radiusDelta The delta by which to animate to. Can be negative.
  104401. */
  104402. private _applyBoundRadiusAnimation;
  104403. /**
  104404. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  104405. */
  104406. protected _clearAnimationLocks(): void;
  104407. /**
  104408. * Stops and removes all animations that have been applied to the camera
  104409. */
  104410. stopAllAnimations(): void;
  104411. }
  104412. }
  104413. declare module BABYLON {
  104414. /**
  104415. * 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.
  104416. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104417. */
  104418. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  104419. /**
  104420. * Gets the name of the behavior.
  104421. */
  104422. readonly name: string;
  104423. private _mode;
  104424. private _radiusScale;
  104425. private _positionScale;
  104426. private _defaultElevation;
  104427. private _elevationReturnTime;
  104428. private _elevationReturnWaitTime;
  104429. private _zoomStopsAnimation;
  104430. private _framingTime;
  104431. /**
  104432. * The easing function used by animations
  104433. */
  104434. static EasingFunction: ExponentialEase;
  104435. /**
  104436. * The easing mode used by animations
  104437. */
  104438. static EasingMode: number;
  104439. /**
  104440. * Sets the current mode used by the behavior
  104441. */
  104442. /**
  104443. * Gets current mode used by the behavior.
  104444. */
  104445. mode: number;
  104446. /**
  104447. * Sets the scale applied to the radius (1 by default)
  104448. */
  104449. /**
  104450. * Gets the scale applied to the radius
  104451. */
  104452. radiusScale: number;
  104453. /**
  104454. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104455. */
  104456. /**
  104457. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104458. */
  104459. positionScale: number;
  104460. /**
  104461. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104462. * behaviour is triggered, in radians.
  104463. */
  104464. /**
  104465. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104466. * behaviour is triggered, in radians.
  104467. */
  104468. defaultElevation: number;
  104469. /**
  104470. * Sets the time (in milliseconds) taken to return to the default beta position.
  104471. * Negative value indicates camera should not return to default.
  104472. */
  104473. /**
  104474. * Gets the time (in milliseconds) taken to return to the default beta position.
  104475. * Negative value indicates camera should not return to default.
  104476. */
  104477. elevationReturnTime: number;
  104478. /**
  104479. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104480. */
  104481. /**
  104482. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104483. */
  104484. elevationReturnWaitTime: number;
  104485. /**
  104486. * Sets the flag that indicates if user zooming should stop animation.
  104487. */
  104488. /**
  104489. * Gets the flag that indicates if user zooming should stop animation.
  104490. */
  104491. zoomStopsAnimation: boolean;
  104492. /**
  104493. * Sets the transition time when framing the mesh, in milliseconds
  104494. */
  104495. /**
  104496. * Gets the transition time when framing the mesh, in milliseconds
  104497. */
  104498. framingTime: number;
  104499. /**
  104500. * Define if the behavior should automatically change the configured
  104501. * camera limits and sensibilities.
  104502. */
  104503. autoCorrectCameraLimitsAndSensibility: boolean;
  104504. private _onPrePointerObservableObserver;
  104505. private _onAfterCheckInputsObserver;
  104506. private _onMeshTargetChangedObserver;
  104507. private _attachedCamera;
  104508. private _isPointerDown;
  104509. private _lastInteractionTime;
  104510. /**
  104511. * Initializes the behavior.
  104512. */
  104513. init(): void;
  104514. /**
  104515. * Attaches the behavior to its arc rotate camera.
  104516. * @param camera Defines the camera to attach the behavior to
  104517. */
  104518. attach(camera: ArcRotateCamera): void;
  104519. /**
  104520. * Detaches the behavior from its current arc rotate camera.
  104521. */
  104522. detach(): void;
  104523. private _animatables;
  104524. private _betaIsAnimating;
  104525. private _betaTransition;
  104526. private _radiusTransition;
  104527. private _vectorTransition;
  104528. /**
  104529. * Targets the given mesh and updates zoom level accordingly.
  104530. * @param mesh The mesh to target.
  104531. * @param radius Optional. If a cached radius position already exists, overrides default.
  104532. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104533. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104534. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104535. */
  104536. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104537. /**
  104538. * Targets the given mesh with its children and updates zoom level accordingly.
  104539. * @param mesh The mesh to target.
  104540. * @param radius Optional. If a cached radius position already exists, overrides default.
  104541. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104542. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104543. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104544. */
  104545. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104546. /**
  104547. * Targets the given meshes with their children and updates zoom level accordingly.
  104548. * @param meshes The mesh to target.
  104549. * @param radius Optional. If a cached radius position already exists, overrides default.
  104550. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104551. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104552. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104553. */
  104554. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104555. /**
  104556. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  104557. * @param minimumWorld Determines the smaller position of the bounding box extend
  104558. * @param maximumWorld Determines the bigger position of the bounding box extend
  104559. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104560. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104561. */
  104562. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104563. /**
  104564. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  104565. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  104566. * frustum width.
  104567. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  104568. * to fully enclose the mesh in the viewing frustum.
  104569. */
  104570. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  104571. /**
  104572. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  104573. * is automatically returned to its default position (expected to be above ground plane).
  104574. */
  104575. private _maintainCameraAboveGround;
  104576. /**
  104577. * Returns the frustum slope based on the canvas ratio and camera FOV
  104578. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  104579. */
  104580. private _getFrustumSlope;
  104581. /**
  104582. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  104583. */
  104584. private _clearAnimationLocks;
  104585. /**
  104586. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104587. */
  104588. private _applyUserInteraction;
  104589. /**
  104590. * Stops and removes all animations that have been applied to the camera
  104591. */
  104592. stopAllAnimations(): void;
  104593. /**
  104594. * Gets a value indicating if the user is moving the camera
  104595. */
  104596. readonly isUserIsMoving: boolean;
  104597. /**
  104598. * The camera can move all the way towards the mesh.
  104599. */
  104600. static IgnoreBoundsSizeMode: number;
  104601. /**
  104602. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  104603. */
  104604. static FitFrustumSidesMode: number;
  104605. }
  104606. }
  104607. declare module BABYLON {
  104608. /**
  104609. * Base class for Camera Pointer Inputs.
  104610. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  104611. * for example usage.
  104612. */
  104613. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  104614. /**
  104615. * Defines the camera the input is attached to.
  104616. */
  104617. abstract camera: Camera;
  104618. /**
  104619. * Whether keyboard modifier keys are pressed at time of last mouse event.
  104620. */
  104621. protected _altKey: boolean;
  104622. protected _ctrlKey: boolean;
  104623. protected _metaKey: boolean;
  104624. protected _shiftKey: boolean;
  104625. /**
  104626. * Which mouse buttons were pressed at time of last mouse event.
  104627. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  104628. */
  104629. protected _buttonsPressed: number;
  104630. /**
  104631. * Defines the buttons associated with the input to handle camera move.
  104632. */
  104633. buttons: number[];
  104634. /**
  104635. * Attach the input controls to a specific dom element to get the input from.
  104636. * @param element Defines the element the controls should be listened from
  104637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104638. */
  104639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104640. /**
  104641. * Detach the current controls from the specified dom element.
  104642. * @param element Defines the element to stop listening the inputs from
  104643. */
  104644. detachControl(element: Nullable<HTMLElement>): void;
  104645. /**
  104646. * Gets the class name of the current input.
  104647. * @returns the class name
  104648. */
  104649. getClassName(): string;
  104650. /**
  104651. * Get the friendly name associated with the input class.
  104652. * @returns the input friendly name
  104653. */
  104654. getSimpleName(): string;
  104655. /**
  104656. * Called on pointer POINTERDOUBLETAP event.
  104657. * Override this method to provide functionality on POINTERDOUBLETAP event.
  104658. */
  104659. protected onDoubleTap(type: string): void;
  104660. /**
  104661. * Called on pointer POINTERMOVE event if only a single touch is active.
  104662. * Override this method to provide functionality.
  104663. */
  104664. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104665. /**
  104666. * Called on pointer POINTERMOVE event if multiple touches are active.
  104667. * Override this method to provide functionality.
  104668. */
  104669. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104670. /**
  104671. * Called on JS contextmenu event.
  104672. * Override this method to provide functionality.
  104673. */
  104674. protected onContextMenu(evt: PointerEvent): void;
  104675. /**
  104676. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104677. * press.
  104678. * Override this method to provide functionality.
  104679. */
  104680. protected onButtonDown(evt: PointerEvent): void;
  104681. /**
  104682. * Called each time a new POINTERUP event occurs. Ie, for each button
  104683. * release.
  104684. * Override this method to provide functionality.
  104685. */
  104686. protected onButtonUp(evt: PointerEvent): void;
  104687. /**
  104688. * Called when window becomes inactive.
  104689. * Override this method to provide functionality.
  104690. */
  104691. protected onLostFocus(): void;
  104692. private _pointerInput;
  104693. private _observer;
  104694. private _onLostFocus;
  104695. private pointA;
  104696. private pointB;
  104697. }
  104698. }
  104699. declare module BABYLON {
  104700. /**
  104701. * Manage the pointers inputs to control an arc rotate camera.
  104702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104703. */
  104704. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  104705. /**
  104706. * Defines the camera the input is attached to.
  104707. */
  104708. camera: ArcRotateCamera;
  104709. /**
  104710. * Gets the class name of the current input.
  104711. * @returns the class name
  104712. */
  104713. getClassName(): string;
  104714. /**
  104715. * Defines the buttons associated with the input to handle camera move.
  104716. */
  104717. buttons: number[];
  104718. /**
  104719. * Defines the pointer angular sensibility along the X axis or how fast is
  104720. * the camera rotating.
  104721. */
  104722. angularSensibilityX: number;
  104723. /**
  104724. * Defines the pointer angular sensibility along the Y axis or how fast is
  104725. * the camera rotating.
  104726. */
  104727. angularSensibilityY: number;
  104728. /**
  104729. * Defines the pointer pinch precision or how fast is the camera zooming.
  104730. */
  104731. pinchPrecision: number;
  104732. /**
  104733. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104734. * from 0.
  104735. * It defines the percentage of current camera.radius to use as delta when
  104736. * pinch zoom is used.
  104737. */
  104738. pinchDeltaPercentage: number;
  104739. /**
  104740. * Defines the pointer panning sensibility or how fast is the camera moving.
  104741. */
  104742. panningSensibility: number;
  104743. /**
  104744. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  104745. */
  104746. multiTouchPanning: boolean;
  104747. /**
  104748. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  104749. * zoom (pinch) through multitouch.
  104750. */
  104751. multiTouchPanAndZoom: boolean;
  104752. /**
  104753. * Revers pinch action direction.
  104754. */
  104755. pinchInwards: boolean;
  104756. private _isPanClick;
  104757. private _twoFingerActivityCount;
  104758. private _isPinching;
  104759. /**
  104760. * Called on pointer POINTERMOVE event if only a single touch is active.
  104761. */
  104762. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104763. /**
  104764. * Called on pointer POINTERDOUBLETAP event.
  104765. */
  104766. protected onDoubleTap(type: string): void;
  104767. /**
  104768. * Called on pointer POINTERMOVE event if multiple touches are active.
  104769. */
  104770. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104771. /**
  104772. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104773. * press.
  104774. */
  104775. protected onButtonDown(evt: PointerEvent): void;
  104776. /**
  104777. * Called each time a new POINTERUP event occurs. Ie, for each button
  104778. * release.
  104779. */
  104780. protected onButtonUp(evt: PointerEvent): void;
  104781. /**
  104782. * Called when window becomes inactive.
  104783. */
  104784. protected onLostFocus(): void;
  104785. }
  104786. }
  104787. declare module BABYLON {
  104788. /**
  104789. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  104790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104791. */
  104792. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  104793. /**
  104794. * Defines the camera the input is attached to.
  104795. */
  104796. camera: ArcRotateCamera;
  104797. /**
  104798. * Defines the list of key codes associated with the up action (increase alpha)
  104799. */
  104800. keysUp: number[];
  104801. /**
  104802. * Defines the list of key codes associated with the down action (decrease alpha)
  104803. */
  104804. keysDown: number[];
  104805. /**
  104806. * Defines the list of key codes associated with the left action (increase beta)
  104807. */
  104808. keysLeft: number[];
  104809. /**
  104810. * Defines the list of key codes associated with the right action (decrease beta)
  104811. */
  104812. keysRight: number[];
  104813. /**
  104814. * Defines the list of key codes associated with the reset action.
  104815. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  104816. */
  104817. keysReset: number[];
  104818. /**
  104819. * Defines the panning sensibility of the inputs.
  104820. * (How fast is the camera paning)
  104821. */
  104822. panningSensibility: number;
  104823. /**
  104824. * Defines the zooming sensibility of the inputs.
  104825. * (How fast is the camera zooming)
  104826. */
  104827. zoomingSensibility: number;
  104828. /**
  104829. * Defines wether maintaining the alt key down switch the movement mode from
  104830. * orientation to zoom.
  104831. */
  104832. useAltToZoom: boolean;
  104833. /**
  104834. * Rotation speed of the camera
  104835. */
  104836. angularSpeed: number;
  104837. private _keys;
  104838. private _ctrlPressed;
  104839. private _altPressed;
  104840. private _onCanvasBlurObserver;
  104841. private _onKeyboardObserver;
  104842. private _engine;
  104843. private _scene;
  104844. /**
  104845. * Attach the input controls to a specific dom element to get the input from.
  104846. * @param element Defines the element the controls should be listened from
  104847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104848. */
  104849. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104850. /**
  104851. * Detach the current controls from the specified dom element.
  104852. * @param element Defines the element to stop listening the inputs from
  104853. */
  104854. detachControl(element: Nullable<HTMLElement>): void;
  104855. /**
  104856. * Update the current camera state depending on the inputs that have been used this frame.
  104857. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104858. */
  104859. checkInputs(): void;
  104860. /**
  104861. * Gets the class name of the current intput.
  104862. * @returns the class name
  104863. */
  104864. getClassName(): string;
  104865. /**
  104866. * Get the friendly name associated with the input class.
  104867. * @returns the input friendly name
  104868. */
  104869. getSimpleName(): string;
  104870. }
  104871. }
  104872. declare module BABYLON {
  104873. /**
  104874. * Manage the mouse wheel inputs to control an arc rotate camera.
  104875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104876. */
  104877. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  104878. /**
  104879. * Defines the camera the input is attached to.
  104880. */
  104881. camera: ArcRotateCamera;
  104882. /**
  104883. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104884. */
  104885. wheelPrecision: number;
  104886. /**
  104887. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104888. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104889. */
  104890. wheelDeltaPercentage: number;
  104891. private _wheel;
  104892. private _observer;
  104893. private computeDeltaFromMouseWheelLegacyEvent;
  104894. /**
  104895. * Attach the input controls to a specific dom element to get the input from.
  104896. * @param element Defines the element the controls should be listened from
  104897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104898. */
  104899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104900. /**
  104901. * Detach the current controls from the specified dom element.
  104902. * @param element Defines the element to stop listening the inputs from
  104903. */
  104904. detachControl(element: Nullable<HTMLElement>): void;
  104905. /**
  104906. * Gets the class name of the current intput.
  104907. * @returns the class name
  104908. */
  104909. getClassName(): string;
  104910. /**
  104911. * Get the friendly name associated with the input class.
  104912. * @returns the input friendly name
  104913. */
  104914. getSimpleName(): string;
  104915. }
  104916. }
  104917. declare module BABYLON {
  104918. /**
  104919. * Default Inputs manager for the ArcRotateCamera.
  104920. * It groups all the default supported inputs for ease of use.
  104921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104922. */
  104923. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  104924. /**
  104925. * Instantiates a new ArcRotateCameraInputsManager.
  104926. * @param camera Defines the camera the inputs belong to
  104927. */
  104928. constructor(camera: ArcRotateCamera);
  104929. /**
  104930. * Add mouse wheel input support to the input manager.
  104931. * @returns the current input manager
  104932. */
  104933. addMouseWheel(): ArcRotateCameraInputsManager;
  104934. /**
  104935. * Add pointers input support to the input manager.
  104936. * @returns the current input manager
  104937. */
  104938. addPointers(): ArcRotateCameraInputsManager;
  104939. /**
  104940. * Add keyboard input support to the input manager.
  104941. * @returns the current input manager
  104942. */
  104943. addKeyboard(): ArcRotateCameraInputsManager;
  104944. }
  104945. }
  104946. declare module BABYLON {
  104947. /**
  104948. * This represents an orbital type of camera.
  104949. *
  104950. * 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.
  104951. * 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.
  104952. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  104953. */
  104954. export class ArcRotateCamera extends TargetCamera {
  104955. /**
  104956. * Defines the rotation angle of the camera along the longitudinal axis.
  104957. */
  104958. alpha: number;
  104959. /**
  104960. * Defines the rotation angle of the camera along the latitudinal axis.
  104961. */
  104962. beta: number;
  104963. /**
  104964. * Defines the radius of the camera from it s target point.
  104965. */
  104966. radius: number;
  104967. protected _target: Vector3;
  104968. protected _targetHost: Nullable<AbstractMesh>;
  104969. /**
  104970. * Defines the target point of the camera.
  104971. * The camera looks towards it form the radius distance.
  104972. */
  104973. target: Vector3;
  104974. /**
  104975. * Define the current local position of the camera in the scene
  104976. */
  104977. position: Vector3;
  104978. protected _upVector: Vector3;
  104979. protected _upToYMatrix: Matrix;
  104980. protected _YToUpMatrix: Matrix;
  104981. /**
  104982. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  104983. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  104984. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  104985. */
  104986. upVector: Vector3;
  104987. /**
  104988. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  104989. */
  104990. setMatUp(): void;
  104991. /**
  104992. * Current inertia value on the longitudinal axis.
  104993. * The bigger this number the longer it will take for the camera to stop.
  104994. */
  104995. inertialAlphaOffset: number;
  104996. /**
  104997. * Current inertia value on the latitudinal axis.
  104998. * The bigger this number the longer it will take for the camera to stop.
  104999. */
  105000. inertialBetaOffset: number;
  105001. /**
  105002. * Current inertia value on the radius axis.
  105003. * The bigger this number the longer it will take for the camera to stop.
  105004. */
  105005. inertialRadiusOffset: number;
  105006. /**
  105007. * Minimum allowed angle on the longitudinal axis.
  105008. * This can help limiting how the Camera is able to move in the scene.
  105009. */
  105010. lowerAlphaLimit: Nullable<number>;
  105011. /**
  105012. * Maximum allowed angle on the longitudinal axis.
  105013. * This can help limiting how the Camera is able to move in the scene.
  105014. */
  105015. upperAlphaLimit: Nullable<number>;
  105016. /**
  105017. * Minimum allowed angle on the latitudinal axis.
  105018. * This can help limiting how the Camera is able to move in the scene.
  105019. */
  105020. lowerBetaLimit: number;
  105021. /**
  105022. * Maximum allowed angle on the latitudinal axis.
  105023. * This can help limiting how the Camera is able to move in the scene.
  105024. */
  105025. upperBetaLimit: number;
  105026. /**
  105027. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  105028. * This can help limiting how the Camera is able to move in the scene.
  105029. */
  105030. lowerRadiusLimit: Nullable<number>;
  105031. /**
  105032. * Maximum allowed distance of the camera to the target (The camera can not get further).
  105033. * This can help limiting how the Camera is able to move in the scene.
  105034. */
  105035. upperRadiusLimit: Nullable<number>;
  105036. /**
  105037. * Defines the current inertia value used during panning of the camera along the X axis.
  105038. */
  105039. inertialPanningX: number;
  105040. /**
  105041. * Defines the current inertia value used during panning of the camera along the Y axis.
  105042. */
  105043. inertialPanningY: number;
  105044. /**
  105045. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  105046. * Basically if your fingers moves away from more than this distance you will be considered
  105047. * in pinch mode.
  105048. */
  105049. pinchToPanMaxDistance: number;
  105050. /**
  105051. * Defines the maximum distance the camera can pan.
  105052. * This could help keeping the cammera always in your scene.
  105053. */
  105054. panningDistanceLimit: Nullable<number>;
  105055. /**
  105056. * Defines the target of the camera before paning.
  105057. */
  105058. panningOriginTarget: Vector3;
  105059. /**
  105060. * Defines the value of the inertia used during panning.
  105061. * 0 would mean stop inertia and one would mean no decelleration at all.
  105062. */
  105063. panningInertia: number;
  105064. /**
  105065. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  105066. */
  105067. angularSensibilityX: number;
  105068. /**
  105069. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  105070. */
  105071. angularSensibilityY: number;
  105072. /**
  105073. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  105074. */
  105075. pinchPrecision: number;
  105076. /**
  105077. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  105078. * It will be used instead of pinchDeltaPrecision if different from 0.
  105079. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105080. */
  105081. pinchDeltaPercentage: number;
  105082. /**
  105083. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  105084. */
  105085. panningSensibility: number;
  105086. /**
  105087. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  105088. */
  105089. keysUp: number[];
  105090. /**
  105091. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  105092. */
  105093. keysDown: number[];
  105094. /**
  105095. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  105096. */
  105097. keysLeft: number[];
  105098. /**
  105099. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  105100. */
  105101. keysRight: number[];
  105102. /**
  105103. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  105104. */
  105105. wheelPrecision: number;
  105106. /**
  105107. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  105108. * It will be used instead of pinchDeltaPrecision if different from 0.
  105109. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105110. */
  105111. wheelDeltaPercentage: number;
  105112. /**
  105113. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  105114. */
  105115. zoomOnFactor: number;
  105116. /**
  105117. * Defines a screen offset for the camera position.
  105118. */
  105119. targetScreenOffset: Vector2;
  105120. /**
  105121. * Allows the camera to be completely reversed.
  105122. * If false the camera can not arrive upside down.
  105123. */
  105124. allowUpsideDown: boolean;
  105125. /**
  105126. * Define if double tap/click is used to restore the previously saved state of the camera.
  105127. */
  105128. useInputToRestoreState: boolean;
  105129. /** @hidden */
  105130. _viewMatrix: Matrix;
  105131. /** @hidden */
  105132. _useCtrlForPanning: boolean;
  105133. /** @hidden */
  105134. _panningMouseButton: number;
  105135. /**
  105136. * Defines the input associated to the camera.
  105137. */
  105138. inputs: ArcRotateCameraInputsManager;
  105139. /** @hidden */
  105140. _reset: () => void;
  105141. /**
  105142. * Defines the allowed panning axis.
  105143. */
  105144. panningAxis: Vector3;
  105145. protected _localDirection: Vector3;
  105146. protected _transformedDirection: Vector3;
  105147. private _bouncingBehavior;
  105148. /**
  105149. * Gets the bouncing behavior of the camera if it has been enabled.
  105150. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105151. */
  105152. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  105153. /**
  105154. * Defines if the bouncing behavior of the camera is enabled on the camera.
  105155. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105156. */
  105157. useBouncingBehavior: boolean;
  105158. private _framingBehavior;
  105159. /**
  105160. * Gets the framing behavior of the camera if it has been enabled.
  105161. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105162. */
  105163. readonly framingBehavior: Nullable<FramingBehavior>;
  105164. /**
  105165. * Defines if the framing behavior of the camera is enabled on the camera.
  105166. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105167. */
  105168. useFramingBehavior: boolean;
  105169. private _autoRotationBehavior;
  105170. /**
  105171. * Gets the auto rotation behavior of the camera if it has been enabled.
  105172. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105173. */
  105174. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  105175. /**
  105176. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  105177. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105178. */
  105179. useAutoRotationBehavior: boolean;
  105180. /**
  105181. * Observable triggered when the mesh target has been changed on the camera.
  105182. */
  105183. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  105184. /**
  105185. * Event raised when the camera is colliding with a mesh.
  105186. */
  105187. onCollide: (collidedMesh: AbstractMesh) => void;
  105188. /**
  105189. * Defines whether the camera should check collision with the objects oh the scene.
  105190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  105191. */
  105192. checkCollisions: boolean;
  105193. /**
  105194. * Defines the collision radius of the camera.
  105195. * This simulates a sphere around the camera.
  105196. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105197. */
  105198. collisionRadius: Vector3;
  105199. protected _collider: Collider;
  105200. protected _previousPosition: Vector3;
  105201. protected _collisionVelocity: Vector3;
  105202. protected _newPosition: Vector3;
  105203. protected _previousAlpha: number;
  105204. protected _previousBeta: number;
  105205. protected _previousRadius: number;
  105206. protected _collisionTriggered: boolean;
  105207. protected _targetBoundingCenter: Nullable<Vector3>;
  105208. private _computationVector;
  105209. /**
  105210. * Instantiates a new ArcRotateCamera in a given scene
  105211. * @param name Defines the name of the camera
  105212. * @param alpha Defines the camera rotation along the logitudinal axis
  105213. * @param beta Defines the camera rotation along the latitudinal axis
  105214. * @param radius Defines the camera distance from its target
  105215. * @param target Defines the camera target
  105216. * @param scene Defines the scene the camera belongs to
  105217. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  105218. */
  105219. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105220. /** @hidden */
  105221. _initCache(): void;
  105222. /** @hidden */
  105223. _updateCache(ignoreParentClass?: boolean): void;
  105224. protected _getTargetPosition(): Vector3;
  105225. private _storedAlpha;
  105226. private _storedBeta;
  105227. private _storedRadius;
  105228. private _storedTarget;
  105229. private _storedTargetScreenOffset;
  105230. /**
  105231. * Stores the current state of the camera (alpha, beta, radius and target)
  105232. * @returns the camera itself
  105233. */
  105234. storeState(): Camera;
  105235. /**
  105236. * @hidden
  105237. * Restored camera state. You must call storeState() first
  105238. */
  105239. _restoreStateValues(): boolean;
  105240. /** @hidden */
  105241. _isSynchronizedViewMatrix(): boolean;
  105242. /**
  105243. * Attached controls to the current camera.
  105244. * @param element Defines the element the controls should be listened from
  105245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105246. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  105247. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  105248. */
  105249. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  105250. /**
  105251. * Detach the current controls from the camera.
  105252. * The camera will stop reacting to inputs.
  105253. * @param element Defines the element to stop listening the inputs from
  105254. */
  105255. detachControl(element: HTMLElement): void;
  105256. /** @hidden */
  105257. _checkInputs(): void;
  105258. protected _checkLimits(): void;
  105259. /**
  105260. * Rebuilds angles (alpha, beta) and radius from the give position and target
  105261. */
  105262. rebuildAnglesAndRadius(): void;
  105263. /**
  105264. * Use a position to define the current camera related information like alpha, beta and radius
  105265. * @param position Defines the position to set the camera at
  105266. */
  105267. setPosition(position: Vector3): void;
  105268. /**
  105269. * Defines the target the camera should look at.
  105270. * This will automatically adapt alpha beta and radius to fit within the new target.
  105271. * @param target Defines the new target as a Vector or a mesh
  105272. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  105273. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  105274. */
  105275. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  105276. /** @hidden */
  105277. _getViewMatrix(): Matrix;
  105278. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  105279. /**
  105280. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  105281. * @param meshes Defines the mesh to zoom on
  105282. * @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)
  105283. */
  105284. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  105285. /**
  105286. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  105287. * The target will be changed but the radius
  105288. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  105289. * @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)
  105290. */
  105291. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  105292. min: Vector3;
  105293. max: Vector3;
  105294. distance: number;
  105295. }, doNotUpdateMaxZ?: boolean): void;
  105296. /**
  105297. * @override
  105298. * Override Camera.createRigCamera
  105299. */
  105300. createRigCamera(name: string, cameraIndex: number): Camera;
  105301. /**
  105302. * @hidden
  105303. * @override
  105304. * Override Camera._updateRigCameras
  105305. */
  105306. _updateRigCameras(): void;
  105307. /**
  105308. * Destroy the camera and release the current resources hold by it.
  105309. */
  105310. dispose(): void;
  105311. /**
  105312. * Gets the current object class name.
  105313. * @return the class name
  105314. */
  105315. getClassName(): string;
  105316. }
  105317. }
  105318. declare module BABYLON {
  105319. /**
  105320. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  105321. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105322. */
  105323. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  105324. /**
  105325. * Gets the name of the behavior.
  105326. */
  105327. readonly name: string;
  105328. private _zoomStopsAnimation;
  105329. private _idleRotationSpeed;
  105330. private _idleRotationWaitTime;
  105331. private _idleRotationSpinupTime;
  105332. /**
  105333. * Sets the flag that indicates if user zooming should stop animation.
  105334. */
  105335. /**
  105336. * Gets the flag that indicates if user zooming should stop animation.
  105337. */
  105338. zoomStopsAnimation: boolean;
  105339. /**
  105340. * Sets the default speed at which the camera rotates around the model.
  105341. */
  105342. /**
  105343. * Gets the default speed at which the camera rotates around the model.
  105344. */
  105345. idleRotationSpeed: number;
  105346. /**
  105347. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  105348. */
  105349. /**
  105350. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  105351. */
  105352. idleRotationWaitTime: number;
  105353. /**
  105354. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105355. */
  105356. /**
  105357. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105358. */
  105359. idleRotationSpinupTime: number;
  105360. /**
  105361. * Gets a value indicating if the camera is currently rotating because of this behavior
  105362. */
  105363. readonly rotationInProgress: boolean;
  105364. private _onPrePointerObservableObserver;
  105365. private _onAfterCheckInputsObserver;
  105366. private _attachedCamera;
  105367. private _isPointerDown;
  105368. private _lastFrameTime;
  105369. private _lastInteractionTime;
  105370. private _cameraRotationSpeed;
  105371. /**
  105372. * Initializes the behavior.
  105373. */
  105374. init(): void;
  105375. /**
  105376. * Attaches the behavior to its arc rotate camera.
  105377. * @param camera Defines the camera to attach the behavior to
  105378. */
  105379. attach(camera: ArcRotateCamera): void;
  105380. /**
  105381. * Detaches the behavior from its current arc rotate camera.
  105382. */
  105383. detach(): void;
  105384. /**
  105385. * Returns true if user is scrolling.
  105386. * @return true if user is scrolling.
  105387. */
  105388. private _userIsZooming;
  105389. private _lastFrameRadius;
  105390. private _shouldAnimationStopForInteraction;
  105391. /**
  105392. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105393. */
  105394. private _applyUserInteraction;
  105395. private _userIsMoving;
  105396. }
  105397. }
  105398. declare module BABYLON {
  105399. /**
  105400. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  105401. */
  105402. export class AttachToBoxBehavior implements Behavior<Mesh> {
  105403. private ui;
  105404. /**
  105405. * The name of the behavior
  105406. */
  105407. name: string;
  105408. /**
  105409. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  105410. */
  105411. distanceAwayFromFace: number;
  105412. /**
  105413. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  105414. */
  105415. distanceAwayFromBottomOfFace: number;
  105416. private _faceVectors;
  105417. private _target;
  105418. private _scene;
  105419. private _onRenderObserver;
  105420. private _tmpMatrix;
  105421. private _tmpVector;
  105422. /**
  105423. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  105424. * @param ui The transform node that should be attched to the mesh
  105425. */
  105426. constructor(ui: TransformNode);
  105427. /**
  105428. * Initializes the behavior
  105429. */
  105430. init(): void;
  105431. private _closestFace;
  105432. private _zeroVector;
  105433. private _lookAtTmpMatrix;
  105434. private _lookAtToRef;
  105435. /**
  105436. * Attaches the AttachToBoxBehavior to the passed in mesh
  105437. * @param target The mesh that the specified node will be attached to
  105438. */
  105439. attach(target: Mesh): void;
  105440. /**
  105441. * Detaches the behavior from the mesh
  105442. */
  105443. detach(): void;
  105444. }
  105445. }
  105446. declare module BABYLON {
  105447. /**
  105448. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  105449. */
  105450. export class FadeInOutBehavior implements Behavior<Mesh> {
  105451. /**
  105452. * Time in milliseconds to delay before fading in (Default: 0)
  105453. */
  105454. delay: number;
  105455. /**
  105456. * Time in milliseconds for the mesh to fade in (Default: 300)
  105457. */
  105458. fadeInTime: number;
  105459. private _millisecondsPerFrame;
  105460. private _hovered;
  105461. private _hoverValue;
  105462. private _ownerNode;
  105463. /**
  105464. * Instatiates the FadeInOutBehavior
  105465. */
  105466. constructor();
  105467. /**
  105468. * The name of the behavior
  105469. */
  105470. readonly name: string;
  105471. /**
  105472. * Initializes the behavior
  105473. */
  105474. init(): void;
  105475. /**
  105476. * Attaches the fade behavior on the passed in mesh
  105477. * @param ownerNode The mesh that will be faded in/out once attached
  105478. */
  105479. attach(ownerNode: Mesh): void;
  105480. /**
  105481. * Detaches the behavior from the mesh
  105482. */
  105483. detach(): void;
  105484. /**
  105485. * Triggers the mesh to begin fading in or out
  105486. * @param value if the object should fade in or out (true to fade in)
  105487. */
  105488. fadeIn(value: boolean): void;
  105489. private _update;
  105490. private _setAllVisibility;
  105491. }
  105492. }
  105493. declare module BABYLON {
  105494. /**
  105495. * Class containing a set of static utilities functions for managing Pivots
  105496. * @hidden
  105497. */
  105498. export class PivotTools {
  105499. private static _PivotCached;
  105500. private static _OldPivotPoint;
  105501. private static _PivotTranslation;
  105502. private static _PivotTmpVector;
  105503. /** @hidden */
  105504. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  105505. /** @hidden */
  105506. static _RestorePivotPoint(mesh: AbstractMesh): void;
  105507. }
  105508. }
  105509. declare module BABYLON {
  105510. /**
  105511. * Class containing static functions to help procedurally build meshes
  105512. */
  105513. export class PlaneBuilder {
  105514. /**
  105515. * Creates a plane mesh
  105516. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105517. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105518. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105522. * @param name defines the name of the mesh
  105523. * @param options defines the options used to create the mesh
  105524. * @param scene defines the hosting scene
  105525. * @returns the plane mesh
  105526. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105527. */
  105528. static CreatePlane(name: string, options: {
  105529. size?: number;
  105530. width?: number;
  105531. height?: number;
  105532. sideOrientation?: number;
  105533. frontUVs?: Vector4;
  105534. backUVs?: Vector4;
  105535. updatable?: boolean;
  105536. sourcePlane?: Plane;
  105537. }, scene?: Nullable<Scene>): Mesh;
  105538. }
  105539. }
  105540. declare module BABYLON {
  105541. /**
  105542. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  105543. */
  105544. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  105545. private static _AnyMouseID;
  105546. /**
  105547. * Abstract mesh the behavior is set on
  105548. */
  105549. attachedNode: AbstractMesh;
  105550. private _dragPlane;
  105551. private _scene;
  105552. private _pointerObserver;
  105553. private _beforeRenderObserver;
  105554. private static _planeScene;
  105555. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  105556. /**
  105557. * 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)
  105558. */
  105559. maxDragAngle: number;
  105560. /**
  105561. * @hidden
  105562. */
  105563. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  105564. /**
  105565. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105566. */
  105567. currentDraggingPointerID: number;
  105568. /**
  105569. * The last position where the pointer hit the drag plane in world space
  105570. */
  105571. lastDragPosition: Vector3;
  105572. /**
  105573. * If the behavior is currently in a dragging state
  105574. */
  105575. dragging: boolean;
  105576. /**
  105577. * 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)
  105578. */
  105579. dragDeltaRatio: number;
  105580. /**
  105581. * If the drag plane orientation should be updated during the dragging (Default: true)
  105582. */
  105583. updateDragPlane: boolean;
  105584. private _debugMode;
  105585. private _moving;
  105586. /**
  105587. * Fires each time the attached mesh is dragged with the pointer
  105588. * * delta between last drag position and current drag position in world space
  105589. * * dragDistance along the drag axis
  105590. * * dragPlaneNormal normal of the current drag plane used during the drag
  105591. * * dragPlanePoint in world space where the drag intersects the drag plane
  105592. */
  105593. onDragObservable: Observable<{
  105594. delta: Vector3;
  105595. dragPlanePoint: Vector3;
  105596. dragPlaneNormal: Vector3;
  105597. dragDistance: number;
  105598. pointerId: number;
  105599. }>;
  105600. /**
  105601. * Fires each time a drag begins (eg. mouse down on mesh)
  105602. */
  105603. onDragStartObservable: Observable<{
  105604. dragPlanePoint: Vector3;
  105605. pointerId: number;
  105606. }>;
  105607. /**
  105608. * Fires each time a drag ends (eg. mouse release after drag)
  105609. */
  105610. onDragEndObservable: Observable<{
  105611. dragPlanePoint: Vector3;
  105612. pointerId: number;
  105613. }>;
  105614. /**
  105615. * If the attached mesh should be moved when dragged
  105616. */
  105617. moveAttached: boolean;
  105618. /**
  105619. * If the drag behavior will react to drag events (Default: true)
  105620. */
  105621. enabled: boolean;
  105622. /**
  105623. * If pointer events should start and release the drag (Default: true)
  105624. */
  105625. startAndReleaseDragOnPointerEvents: boolean;
  105626. /**
  105627. * If camera controls should be detached during the drag
  105628. */
  105629. detachCameraControls: boolean;
  105630. /**
  105631. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  105632. */
  105633. useObjectOrienationForDragging: boolean;
  105634. private _options;
  105635. /**
  105636. * Creates a pointer drag behavior that can be attached to a mesh
  105637. * @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)
  105638. */
  105639. constructor(options?: {
  105640. dragAxis?: Vector3;
  105641. dragPlaneNormal?: Vector3;
  105642. });
  105643. /**
  105644. * Predicate to determine if it is valid to move the object to a new position when it is moved
  105645. */
  105646. validateDrag: (targetPosition: Vector3) => boolean;
  105647. /**
  105648. * The name of the behavior
  105649. */
  105650. readonly name: string;
  105651. /**
  105652. * Initializes the behavior
  105653. */
  105654. init(): void;
  105655. private _tmpVector;
  105656. private _alternatePickedPoint;
  105657. private _worldDragAxis;
  105658. private _targetPosition;
  105659. private _attachedElement;
  105660. /**
  105661. * Attaches the drag behavior the passed in mesh
  105662. * @param ownerNode The mesh that will be dragged around once attached
  105663. * @param predicate Predicate to use for pick filtering
  105664. */
  105665. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  105666. /**
  105667. * Force relase the drag action by code.
  105668. */
  105669. releaseDrag(): void;
  105670. private _startDragRay;
  105671. private _lastPointerRay;
  105672. /**
  105673. * Simulates the start of a pointer drag event on the behavior
  105674. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  105675. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  105676. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  105677. */
  105678. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  105679. private _startDrag;
  105680. private _dragDelta;
  105681. private _moveDrag;
  105682. private _pickWithRayOnDragPlane;
  105683. private _pointA;
  105684. private _pointB;
  105685. private _pointC;
  105686. private _lineA;
  105687. private _lineB;
  105688. private _localAxis;
  105689. private _lookAt;
  105690. private _updateDragPlanePosition;
  105691. /**
  105692. * Detaches the behavior from the mesh
  105693. */
  105694. detach(): void;
  105695. }
  105696. }
  105697. declare module BABYLON {
  105698. /**
  105699. * A behavior that when attached to a mesh will allow the mesh to be scaled
  105700. */
  105701. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  105702. private _dragBehaviorA;
  105703. private _dragBehaviorB;
  105704. private _startDistance;
  105705. private _initialScale;
  105706. private _targetScale;
  105707. private _ownerNode;
  105708. private _sceneRenderObserver;
  105709. /**
  105710. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  105711. */
  105712. constructor();
  105713. /**
  105714. * The name of the behavior
  105715. */
  105716. readonly name: string;
  105717. /**
  105718. * Initializes the behavior
  105719. */
  105720. init(): void;
  105721. private _getCurrentDistance;
  105722. /**
  105723. * Attaches the scale behavior the passed in mesh
  105724. * @param ownerNode The mesh that will be scaled around once attached
  105725. */
  105726. attach(ownerNode: Mesh): void;
  105727. /**
  105728. * Detaches the behavior from the mesh
  105729. */
  105730. detach(): void;
  105731. }
  105732. }
  105733. declare module BABYLON {
  105734. /**
  105735. * 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
  105736. */
  105737. export class SixDofDragBehavior implements Behavior<Mesh> {
  105738. private static _virtualScene;
  105739. private _ownerNode;
  105740. private _sceneRenderObserver;
  105741. private _scene;
  105742. private _targetPosition;
  105743. private _virtualOriginMesh;
  105744. private _virtualDragMesh;
  105745. private _pointerObserver;
  105746. private _moving;
  105747. private _startingOrientation;
  105748. /**
  105749. * 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)
  105750. */
  105751. private zDragFactor;
  105752. /**
  105753. * If the object should rotate to face the drag origin
  105754. */
  105755. rotateDraggedObject: boolean;
  105756. /**
  105757. * If the behavior is currently in a dragging state
  105758. */
  105759. dragging: boolean;
  105760. /**
  105761. * 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)
  105762. */
  105763. dragDeltaRatio: number;
  105764. /**
  105765. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105766. */
  105767. currentDraggingPointerID: number;
  105768. /**
  105769. * If camera controls should be detached during the drag
  105770. */
  105771. detachCameraControls: boolean;
  105772. /**
  105773. * Fires each time a drag starts
  105774. */
  105775. onDragStartObservable: Observable<{}>;
  105776. /**
  105777. * Fires each time a drag ends (eg. mouse release after drag)
  105778. */
  105779. onDragEndObservable: Observable<{}>;
  105780. /**
  105781. * 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
  105782. */
  105783. constructor();
  105784. /**
  105785. * The name of the behavior
  105786. */
  105787. readonly name: string;
  105788. /**
  105789. * Initializes the behavior
  105790. */
  105791. init(): void;
  105792. /**
  105793. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  105794. */
  105795. private readonly _pointerCamera;
  105796. /**
  105797. * Attaches the scale behavior the passed in mesh
  105798. * @param ownerNode The mesh that will be scaled around once attached
  105799. */
  105800. attach(ownerNode: Mesh): void;
  105801. /**
  105802. * Detaches the behavior from the mesh
  105803. */
  105804. detach(): void;
  105805. }
  105806. }
  105807. declare module BABYLON {
  105808. /**
  105809. * Class used to apply inverse kinematics to bones
  105810. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  105811. */
  105812. export class BoneIKController {
  105813. private static _tmpVecs;
  105814. private static _tmpQuat;
  105815. private static _tmpMats;
  105816. /**
  105817. * Gets or sets the target mesh
  105818. */
  105819. targetMesh: AbstractMesh;
  105820. /** Gets or sets the mesh used as pole */
  105821. poleTargetMesh: AbstractMesh;
  105822. /**
  105823. * Gets or sets the bone used as pole
  105824. */
  105825. poleTargetBone: Nullable<Bone>;
  105826. /**
  105827. * Gets or sets the target position
  105828. */
  105829. targetPosition: Vector3;
  105830. /**
  105831. * Gets or sets the pole target position
  105832. */
  105833. poleTargetPosition: Vector3;
  105834. /**
  105835. * Gets or sets the pole target local offset
  105836. */
  105837. poleTargetLocalOffset: Vector3;
  105838. /**
  105839. * Gets or sets the pole angle
  105840. */
  105841. poleAngle: number;
  105842. /**
  105843. * Gets or sets the mesh associated with the controller
  105844. */
  105845. mesh: AbstractMesh;
  105846. /**
  105847. * 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)
  105848. */
  105849. slerpAmount: number;
  105850. private _bone1Quat;
  105851. private _bone1Mat;
  105852. private _bone2Ang;
  105853. private _bone1;
  105854. private _bone2;
  105855. private _bone1Length;
  105856. private _bone2Length;
  105857. private _maxAngle;
  105858. private _maxReach;
  105859. private _rightHandedSystem;
  105860. private _bendAxis;
  105861. private _slerping;
  105862. private _adjustRoll;
  105863. /**
  105864. * Gets or sets maximum allowed angle
  105865. */
  105866. maxAngle: number;
  105867. /**
  105868. * Creates a new BoneIKController
  105869. * @param mesh defines the mesh to control
  105870. * @param bone defines the bone to control
  105871. * @param options defines options to set up the controller
  105872. */
  105873. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  105874. targetMesh?: AbstractMesh;
  105875. poleTargetMesh?: AbstractMesh;
  105876. poleTargetBone?: Bone;
  105877. poleTargetLocalOffset?: Vector3;
  105878. poleAngle?: number;
  105879. bendAxis?: Vector3;
  105880. maxAngle?: number;
  105881. slerpAmount?: number;
  105882. });
  105883. private _setMaxAngle;
  105884. /**
  105885. * Force the controller to update the bones
  105886. */
  105887. update(): void;
  105888. }
  105889. }
  105890. declare module BABYLON {
  105891. /**
  105892. * Class used to make a bone look toward a point in space
  105893. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  105894. */
  105895. export class BoneLookController {
  105896. private static _tmpVecs;
  105897. private static _tmpQuat;
  105898. private static _tmpMats;
  105899. /**
  105900. * The target Vector3 that the bone will look at
  105901. */
  105902. target: Vector3;
  105903. /**
  105904. * The mesh that the bone is attached to
  105905. */
  105906. mesh: AbstractMesh;
  105907. /**
  105908. * The bone that will be looking to the target
  105909. */
  105910. bone: Bone;
  105911. /**
  105912. * The up axis of the coordinate system that is used when the bone is rotated
  105913. */
  105914. upAxis: Vector3;
  105915. /**
  105916. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  105917. */
  105918. upAxisSpace: Space;
  105919. /**
  105920. * Used to make an adjustment to the yaw of the bone
  105921. */
  105922. adjustYaw: number;
  105923. /**
  105924. * Used to make an adjustment to the pitch of the bone
  105925. */
  105926. adjustPitch: number;
  105927. /**
  105928. * Used to make an adjustment to the roll of the bone
  105929. */
  105930. adjustRoll: number;
  105931. /**
  105932. * 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)
  105933. */
  105934. slerpAmount: number;
  105935. private _minYaw;
  105936. private _maxYaw;
  105937. private _minPitch;
  105938. private _maxPitch;
  105939. private _minYawSin;
  105940. private _minYawCos;
  105941. private _maxYawSin;
  105942. private _maxYawCos;
  105943. private _midYawConstraint;
  105944. private _minPitchTan;
  105945. private _maxPitchTan;
  105946. private _boneQuat;
  105947. private _slerping;
  105948. private _transformYawPitch;
  105949. private _transformYawPitchInv;
  105950. private _firstFrameSkipped;
  105951. private _yawRange;
  105952. private _fowardAxis;
  105953. /**
  105954. * Gets or sets the minimum yaw angle that the bone can look to
  105955. */
  105956. minYaw: number;
  105957. /**
  105958. * Gets or sets the maximum yaw angle that the bone can look to
  105959. */
  105960. maxYaw: number;
  105961. /**
  105962. * Gets or sets the minimum pitch angle that the bone can look to
  105963. */
  105964. minPitch: number;
  105965. /**
  105966. * Gets or sets the maximum pitch angle that the bone can look to
  105967. */
  105968. maxPitch: number;
  105969. /**
  105970. * Create a BoneLookController
  105971. * @param mesh the mesh that the bone belongs to
  105972. * @param bone the bone that will be looking to the target
  105973. * @param target the target Vector3 to look at
  105974. * @param options optional settings:
  105975. * * maxYaw: the maximum angle the bone will yaw to
  105976. * * minYaw: the minimum angle the bone will yaw to
  105977. * * maxPitch: the maximum angle the bone will pitch to
  105978. * * minPitch: the minimum angle the bone will yaw to
  105979. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  105980. * * upAxis: the up axis of the coordinate system
  105981. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  105982. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  105983. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  105984. * * adjustYaw: used to make an adjustment to the yaw of the bone
  105985. * * adjustPitch: used to make an adjustment to the pitch of the bone
  105986. * * adjustRoll: used to make an adjustment to the roll of the bone
  105987. **/
  105988. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  105989. maxYaw?: number;
  105990. minYaw?: number;
  105991. maxPitch?: number;
  105992. minPitch?: number;
  105993. slerpAmount?: number;
  105994. upAxis?: Vector3;
  105995. upAxisSpace?: Space;
  105996. yawAxis?: Vector3;
  105997. pitchAxis?: Vector3;
  105998. adjustYaw?: number;
  105999. adjustPitch?: number;
  106000. adjustRoll?: number;
  106001. });
  106002. /**
  106003. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  106004. */
  106005. update(): void;
  106006. private _getAngleDiff;
  106007. private _getAngleBetween;
  106008. private _isAngleBetween;
  106009. }
  106010. }
  106011. declare module BABYLON {
  106012. /**
  106013. * Manage the gamepad inputs to control an arc rotate camera.
  106014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106015. */
  106016. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  106017. /**
  106018. * Defines the camera the input is attached to.
  106019. */
  106020. camera: ArcRotateCamera;
  106021. /**
  106022. * Defines the gamepad the input is gathering event from.
  106023. */
  106024. gamepad: Nullable<Gamepad>;
  106025. /**
  106026. * Defines the gamepad rotation sensiblity.
  106027. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106028. */
  106029. gamepadRotationSensibility: number;
  106030. /**
  106031. * Defines the gamepad move sensiblity.
  106032. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106033. */
  106034. gamepadMoveSensibility: number;
  106035. private _yAxisScale;
  106036. /**
  106037. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106038. */
  106039. invertYAxis: boolean;
  106040. private _onGamepadConnectedObserver;
  106041. private _onGamepadDisconnectedObserver;
  106042. /**
  106043. * Attach the input controls to a specific dom element to get the input from.
  106044. * @param element Defines the element the controls should be listened from
  106045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106046. */
  106047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106048. /**
  106049. * Detach the current controls from the specified dom element.
  106050. * @param element Defines the element to stop listening the inputs from
  106051. */
  106052. detachControl(element: Nullable<HTMLElement>): void;
  106053. /**
  106054. * Update the current camera state depending on the inputs that have been used this frame.
  106055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106056. */
  106057. checkInputs(): void;
  106058. /**
  106059. * Gets the class name of the current intput.
  106060. * @returns the class name
  106061. */
  106062. getClassName(): string;
  106063. /**
  106064. * Get the friendly name associated with the input class.
  106065. * @returns the input friendly name
  106066. */
  106067. getSimpleName(): string;
  106068. }
  106069. }
  106070. declare module BABYLON {
  106071. interface ArcRotateCameraInputsManager {
  106072. /**
  106073. * Add orientation input support to the input manager.
  106074. * @returns the current input manager
  106075. */
  106076. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  106077. }
  106078. /**
  106079. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  106080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106081. */
  106082. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  106083. /**
  106084. * Defines the camera the input is attached to.
  106085. */
  106086. camera: ArcRotateCamera;
  106087. /**
  106088. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  106089. */
  106090. alphaCorrection: number;
  106091. /**
  106092. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  106093. */
  106094. gammaCorrection: number;
  106095. private _alpha;
  106096. private _gamma;
  106097. private _dirty;
  106098. private _deviceOrientationHandler;
  106099. /**
  106100. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  106101. */
  106102. constructor();
  106103. /**
  106104. * Attach the input controls to a specific dom element to get the input from.
  106105. * @param element Defines the element the controls should be listened from
  106106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106107. */
  106108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106109. /** @hidden */
  106110. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  106111. /**
  106112. * Update the current camera state depending on the inputs that have been used this frame.
  106113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106114. */
  106115. checkInputs(): void;
  106116. /**
  106117. * Detach the current controls from the specified dom element.
  106118. * @param element Defines the element to stop listening the inputs from
  106119. */
  106120. detachControl(element: Nullable<HTMLElement>): void;
  106121. /**
  106122. * Gets the class name of the current intput.
  106123. * @returns the class name
  106124. */
  106125. getClassName(): string;
  106126. /**
  106127. * Get the friendly name associated with the input class.
  106128. * @returns the input friendly name
  106129. */
  106130. getSimpleName(): string;
  106131. }
  106132. }
  106133. declare module BABYLON {
  106134. /**
  106135. * Listen to mouse events to control the camera.
  106136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106137. */
  106138. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  106139. /**
  106140. * Defines the camera the input is attached to.
  106141. */
  106142. camera: FlyCamera;
  106143. /**
  106144. * Defines if touch is enabled. (Default is true.)
  106145. */
  106146. touchEnabled: boolean;
  106147. /**
  106148. * Defines the buttons associated with the input to handle camera rotation.
  106149. */
  106150. buttons: number[];
  106151. /**
  106152. * Assign buttons for Yaw control.
  106153. */
  106154. buttonsYaw: number[];
  106155. /**
  106156. * Assign buttons for Pitch control.
  106157. */
  106158. buttonsPitch: number[];
  106159. /**
  106160. * Assign buttons for Roll control.
  106161. */
  106162. buttonsRoll: number[];
  106163. /**
  106164. * Detect if any button is being pressed while mouse is moved.
  106165. * -1 = Mouse locked.
  106166. * 0 = Left button.
  106167. * 1 = Middle Button.
  106168. * 2 = Right Button.
  106169. */
  106170. activeButton: number;
  106171. /**
  106172. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  106173. * Higher values reduce its sensitivity.
  106174. */
  106175. angularSensibility: number;
  106176. private _mousemoveCallback;
  106177. private _observer;
  106178. private _rollObserver;
  106179. private previousPosition;
  106180. private noPreventDefault;
  106181. private element;
  106182. /**
  106183. * Listen to mouse events to control the camera.
  106184. * @param touchEnabled Define if touch is enabled. (Default is true.)
  106185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106186. */
  106187. constructor(touchEnabled?: boolean);
  106188. /**
  106189. * Attach the mouse control to the HTML DOM element.
  106190. * @param element Defines the element that listens to the input events.
  106191. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  106192. */
  106193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106194. /**
  106195. * Detach the current controls from the specified dom element.
  106196. * @param element Defines the element to stop listening the inputs from
  106197. */
  106198. detachControl(element: Nullable<HTMLElement>): void;
  106199. /**
  106200. * Gets the class name of the current input.
  106201. * @returns the class name.
  106202. */
  106203. getClassName(): string;
  106204. /**
  106205. * Get the friendly name associated with the input class.
  106206. * @returns the input's friendly name.
  106207. */
  106208. getSimpleName(): string;
  106209. private _pointerInput;
  106210. private _onMouseMove;
  106211. /**
  106212. * Rotate camera by mouse offset.
  106213. */
  106214. private rotateCamera;
  106215. }
  106216. }
  106217. declare module BABYLON {
  106218. /**
  106219. * Default Inputs manager for the FlyCamera.
  106220. * It groups all the default supported inputs for ease of use.
  106221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106222. */
  106223. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  106224. /**
  106225. * Instantiates a new FlyCameraInputsManager.
  106226. * @param camera Defines the camera the inputs belong to.
  106227. */
  106228. constructor(camera: FlyCamera);
  106229. /**
  106230. * Add keyboard input support to the input manager.
  106231. * @returns the new FlyCameraKeyboardMoveInput().
  106232. */
  106233. addKeyboard(): FlyCameraInputsManager;
  106234. /**
  106235. * Add mouse input support to the input manager.
  106236. * @param touchEnabled Enable touch screen support.
  106237. * @returns the new FlyCameraMouseInput().
  106238. */
  106239. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  106240. }
  106241. }
  106242. declare module BABYLON {
  106243. /**
  106244. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106245. * such as in a 3D Space Shooter or a Flight Simulator.
  106246. */
  106247. export class FlyCamera extends TargetCamera {
  106248. /**
  106249. * Define the collision ellipsoid of the camera.
  106250. * This is helpful for simulating a camera body, like a player's body.
  106251. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106252. */
  106253. ellipsoid: Vector3;
  106254. /**
  106255. * Define an offset for the position of the ellipsoid around the camera.
  106256. * This can be helpful if the camera is attached away from the player's body center,
  106257. * such as at its head.
  106258. */
  106259. ellipsoidOffset: Vector3;
  106260. /**
  106261. * Enable or disable collisions of the camera with the rest of the scene objects.
  106262. */
  106263. checkCollisions: boolean;
  106264. /**
  106265. * Enable or disable gravity on the camera.
  106266. */
  106267. applyGravity: boolean;
  106268. /**
  106269. * Define the current direction the camera is moving to.
  106270. */
  106271. cameraDirection: Vector3;
  106272. /**
  106273. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  106274. * This overrides and empties cameraRotation.
  106275. */
  106276. rotationQuaternion: Quaternion;
  106277. /**
  106278. * Track Roll to maintain the wanted Rolling when looking around.
  106279. */
  106280. _trackRoll: number;
  106281. /**
  106282. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  106283. */
  106284. rollCorrect: number;
  106285. /**
  106286. * Mimic a banked turn, Rolling the camera when Yawing.
  106287. * It's recommended to use rollCorrect = 10 for faster banking correction.
  106288. */
  106289. bankedTurn: boolean;
  106290. /**
  106291. * Limit in radians for how much Roll banking will add. (Default: 90°)
  106292. */
  106293. bankedTurnLimit: number;
  106294. /**
  106295. * Value of 0 disables the banked Roll.
  106296. * Value of 1 is equal to the Yaw angle in radians.
  106297. */
  106298. bankedTurnMultiplier: number;
  106299. /**
  106300. * The inputs manager loads all the input sources, such as keyboard and mouse.
  106301. */
  106302. inputs: FlyCameraInputsManager;
  106303. /**
  106304. * Gets the input sensibility for mouse input.
  106305. * Higher values reduce sensitivity.
  106306. */
  106307. /**
  106308. * Sets the input sensibility for a mouse input.
  106309. * Higher values reduce sensitivity.
  106310. */
  106311. angularSensibility: number;
  106312. /**
  106313. * Get the keys for camera movement forward.
  106314. */
  106315. /**
  106316. * Set the keys for camera movement forward.
  106317. */
  106318. keysForward: number[];
  106319. /**
  106320. * Get the keys for camera movement backward.
  106321. */
  106322. keysBackward: number[];
  106323. /**
  106324. * Get the keys for camera movement up.
  106325. */
  106326. /**
  106327. * Set the keys for camera movement up.
  106328. */
  106329. keysUp: number[];
  106330. /**
  106331. * Get the keys for camera movement down.
  106332. */
  106333. /**
  106334. * Set the keys for camera movement down.
  106335. */
  106336. keysDown: number[];
  106337. /**
  106338. * Get the keys for camera movement left.
  106339. */
  106340. /**
  106341. * Set the keys for camera movement left.
  106342. */
  106343. keysLeft: number[];
  106344. /**
  106345. * Set the keys for camera movement right.
  106346. */
  106347. /**
  106348. * Set the keys for camera movement right.
  106349. */
  106350. keysRight: number[];
  106351. /**
  106352. * Event raised when the camera collides with a mesh in the scene.
  106353. */
  106354. onCollide: (collidedMesh: AbstractMesh) => void;
  106355. private _collider;
  106356. private _needMoveForGravity;
  106357. private _oldPosition;
  106358. private _diffPosition;
  106359. private _newPosition;
  106360. /** @hidden */
  106361. _localDirection: Vector3;
  106362. /** @hidden */
  106363. _transformedDirection: Vector3;
  106364. /**
  106365. * Instantiates a FlyCamera.
  106366. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106367. * such as in a 3D Space Shooter or a Flight Simulator.
  106368. * @param name Define the name of the camera in the scene.
  106369. * @param position Define the starting position of the camera in the scene.
  106370. * @param scene Define the scene the camera belongs to.
  106371. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  106372. */
  106373. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106374. /**
  106375. * Attach a control to the HTML DOM element.
  106376. * @param element Defines the element that listens to the input events.
  106377. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  106378. */
  106379. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106380. /**
  106381. * Detach a control from the HTML DOM element.
  106382. * The camera will stop reacting to that input.
  106383. * @param element Defines the element that listens to the input events.
  106384. */
  106385. detachControl(element: HTMLElement): void;
  106386. private _collisionMask;
  106387. /**
  106388. * Get the mask that the camera ignores in collision events.
  106389. */
  106390. /**
  106391. * Set the mask that the camera ignores in collision events.
  106392. */
  106393. collisionMask: number;
  106394. /** @hidden */
  106395. _collideWithWorld(displacement: Vector3): void;
  106396. /** @hidden */
  106397. private _onCollisionPositionChange;
  106398. /** @hidden */
  106399. _checkInputs(): void;
  106400. /** @hidden */
  106401. _decideIfNeedsToMove(): boolean;
  106402. /** @hidden */
  106403. _updatePosition(): void;
  106404. /**
  106405. * Restore the Roll to its target value at the rate specified.
  106406. * @param rate - Higher means slower restoring.
  106407. * @hidden
  106408. */
  106409. restoreRoll(rate: number): void;
  106410. /**
  106411. * Destroy the camera and release the current resources held by it.
  106412. */
  106413. dispose(): void;
  106414. /**
  106415. * Get the current object class name.
  106416. * @returns the class name.
  106417. */
  106418. getClassName(): string;
  106419. }
  106420. }
  106421. declare module BABYLON {
  106422. /**
  106423. * Listen to keyboard events to control the camera.
  106424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106425. */
  106426. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  106427. /**
  106428. * Defines the camera the input is attached to.
  106429. */
  106430. camera: FlyCamera;
  106431. /**
  106432. * The list of keyboard keys used to control the forward move of the camera.
  106433. */
  106434. keysForward: number[];
  106435. /**
  106436. * The list of keyboard keys used to control the backward move of the camera.
  106437. */
  106438. keysBackward: number[];
  106439. /**
  106440. * The list of keyboard keys used to control the forward move of the camera.
  106441. */
  106442. keysUp: number[];
  106443. /**
  106444. * The list of keyboard keys used to control the backward move of the camera.
  106445. */
  106446. keysDown: number[];
  106447. /**
  106448. * The list of keyboard keys used to control the right strafe move of the camera.
  106449. */
  106450. keysRight: number[];
  106451. /**
  106452. * The list of keyboard keys used to control the left strafe move of the camera.
  106453. */
  106454. keysLeft: number[];
  106455. private _keys;
  106456. private _onCanvasBlurObserver;
  106457. private _onKeyboardObserver;
  106458. private _engine;
  106459. private _scene;
  106460. /**
  106461. * Attach the input controls to a specific dom element to get the input from.
  106462. * @param element Defines the element the controls should be listened from
  106463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106464. */
  106465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106466. /**
  106467. * Detach the current controls from the specified dom element.
  106468. * @param element Defines the element to stop listening the inputs from
  106469. */
  106470. detachControl(element: Nullable<HTMLElement>): void;
  106471. /**
  106472. * Gets the class name of the current intput.
  106473. * @returns the class name
  106474. */
  106475. getClassName(): string;
  106476. /** @hidden */
  106477. _onLostFocus(e: FocusEvent): void;
  106478. /**
  106479. * Get the friendly name associated with the input class.
  106480. * @returns the input friendly name
  106481. */
  106482. getSimpleName(): string;
  106483. /**
  106484. * Update the current camera state depending on the inputs that have been used this frame.
  106485. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106486. */
  106487. checkInputs(): void;
  106488. }
  106489. }
  106490. declare module BABYLON {
  106491. /**
  106492. * Manage the mouse wheel inputs to control a follow camera.
  106493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106494. */
  106495. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  106496. /**
  106497. * Defines the camera the input is attached to.
  106498. */
  106499. camera: FollowCamera;
  106500. /**
  106501. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  106502. */
  106503. axisControlRadius: boolean;
  106504. /**
  106505. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  106506. */
  106507. axisControlHeight: boolean;
  106508. /**
  106509. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  106510. */
  106511. axisControlRotation: boolean;
  106512. /**
  106513. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  106514. * relation to mouseWheel events.
  106515. */
  106516. wheelPrecision: number;
  106517. /**
  106518. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106519. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106520. */
  106521. wheelDeltaPercentage: number;
  106522. private _wheel;
  106523. private _observer;
  106524. /**
  106525. * Attach the input controls to a specific dom element to get the input from.
  106526. * @param element Defines the element the controls should be listened from
  106527. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106528. */
  106529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106530. /**
  106531. * Detach the current controls from the specified dom element.
  106532. * @param element Defines the element to stop listening the inputs from
  106533. */
  106534. detachControl(element: Nullable<HTMLElement>): void;
  106535. /**
  106536. * Gets the class name of the current intput.
  106537. * @returns the class name
  106538. */
  106539. getClassName(): string;
  106540. /**
  106541. * Get the friendly name associated with the input class.
  106542. * @returns the input friendly name
  106543. */
  106544. getSimpleName(): string;
  106545. }
  106546. }
  106547. declare module BABYLON {
  106548. /**
  106549. * Manage the pointers inputs to control an follow camera.
  106550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106551. */
  106552. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  106553. /**
  106554. * Defines the camera the input is attached to.
  106555. */
  106556. camera: FollowCamera;
  106557. /**
  106558. * Gets the class name of the current input.
  106559. * @returns the class name
  106560. */
  106561. getClassName(): string;
  106562. /**
  106563. * Defines the pointer angular sensibility along the X axis or how fast is
  106564. * the camera rotating.
  106565. * A negative number will reverse the axis direction.
  106566. */
  106567. angularSensibilityX: number;
  106568. /**
  106569. * Defines the pointer angular sensibility along the Y axis or how fast is
  106570. * the camera rotating.
  106571. * A negative number will reverse the axis direction.
  106572. */
  106573. angularSensibilityY: number;
  106574. /**
  106575. * Defines the pointer pinch precision or how fast is the camera zooming.
  106576. * A negative number will reverse the axis direction.
  106577. */
  106578. pinchPrecision: number;
  106579. /**
  106580. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106581. * from 0.
  106582. * It defines the percentage of current camera.radius to use as delta when
  106583. * pinch zoom is used.
  106584. */
  106585. pinchDeltaPercentage: number;
  106586. /**
  106587. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  106588. */
  106589. axisXControlRadius: boolean;
  106590. /**
  106591. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  106592. */
  106593. axisXControlHeight: boolean;
  106594. /**
  106595. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  106596. */
  106597. axisXControlRotation: boolean;
  106598. /**
  106599. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  106600. */
  106601. axisYControlRadius: boolean;
  106602. /**
  106603. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  106604. */
  106605. axisYControlHeight: boolean;
  106606. /**
  106607. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  106608. */
  106609. axisYControlRotation: boolean;
  106610. /**
  106611. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  106612. */
  106613. axisPinchControlRadius: boolean;
  106614. /**
  106615. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  106616. */
  106617. axisPinchControlHeight: boolean;
  106618. /**
  106619. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  106620. */
  106621. axisPinchControlRotation: boolean;
  106622. /**
  106623. * Log error messages if basic misconfiguration has occurred.
  106624. */
  106625. warningEnable: boolean;
  106626. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106627. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106628. private _warningCounter;
  106629. private _warning;
  106630. }
  106631. }
  106632. declare module BABYLON {
  106633. /**
  106634. * Default Inputs manager for the FollowCamera.
  106635. * It groups all the default supported inputs for ease of use.
  106636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106637. */
  106638. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  106639. /**
  106640. * Instantiates a new FollowCameraInputsManager.
  106641. * @param camera Defines the camera the inputs belong to
  106642. */
  106643. constructor(camera: FollowCamera);
  106644. /**
  106645. * Add keyboard input support to the input manager.
  106646. * @returns the current input manager
  106647. */
  106648. addKeyboard(): FollowCameraInputsManager;
  106649. /**
  106650. * Add mouse wheel input support to the input manager.
  106651. * @returns the current input manager
  106652. */
  106653. addMouseWheel(): FollowCameraInputsManager;
  106654. /**
  106655. * Add pointers input support to the input manager.
  106656. * @returns the current input manager
  106657. */
  106658. addPointers(): FollowCameraInputsManager;
  106659. /**
  106660. * Add orientation input support to the input manager.
  106661. * @returns the current input manager
  106662. */
  106663. addVRDeviceOrientation(): FollowCameraInputsManager;
  106664. }
  106665. }
  106666. declare module BABYLON {
  106667. /**
  106668. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  106669. * an arc rotate version arcFollowCamera are available.
  106670. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106671. */
  106672. export class FollowCamera extends TargetCamera {
  106673. /**
  106674. * Distance the follow camera should follow an object at
  106675. */
  106676. radius: number;
  106677. /**
  106678. * Minimum allowed distance of the camera to the axis of rotation
  106679. * (The camera can not get closer).
  106680. * This can help limiting how the Camera is able to move in the scene.
  106681. */
  106682. lowerRadiusLimit: Nullable<number>;
  106683. /**
  106684. * Maximum allowed distance of the camera to the axis of rotation
  106685. * (The camera can not get further).
  106686. * This can help limiting how the Camera is able to move in the scene.
  106687. */
  106688. upperRadiusLimit: Nullable<number>;
  106689. /**
  106690. * Define a rotation offset between the camera and the object it follows
  106691. */
  106692. rotationOffset: number;
  106693. /**
  106694. * Minimum allowed angle to camera position relative to target object.
  106695. * This can help limiting how the Camera is able to move in the scene.
  106696. */
  106697. lowerRotationOffsetLimit: Nullable<number>;
  106698. /**
  106699. * Maximum allowed angle to camera position relative to target object.
  106700. * This can help limiting how the Camera is able to move in the scene.
  106701. */
  106702. upperRotationOffsetLimit: Nullable<number>;
  106703. /**
  106704. * Define a height offset between the camera and the object it follows.
  106705. * It can help following an object from the top (like a car chaing a plane)
  106706. */
  106707. heightOffset: number;
  106708. /**
  106709. * Minimum allowed height of camera position relative to target object.
  106710. * This can help limiting how the Camera is able to move in the scene.
  106711. */
  106712. lowerHeightOffsetLimit: Nullable<number>;
  106713. /**
  106714. * Maximum allowed height of camera position relative to target object.
  106715. * This can help limiting how the Camera is able to move in the scene.
  106716. */
  106717. upperHeightOffsetLimit: Nullable<number>;
  106718. /**
  106719. * Define how fast the camera can accelerate to follow it s target.
  106720. */
  106721. cameraAcceleration: number;
  106722. /**
  106723. * Define the speed limit of the camera following an object.
  106724. */
  106725. maxCameraSpeed: number;
  106726. /**
  106727. * Define the target of the camera.
  106728. */
  106729. lockedTarget: Nullable<AbstractMesh>;
  106730. /**
  106731. * Defines the input associated with the camera.
  106732. */
  106733. inputs: FollowCameraInputsManager;
  106734. /**
  106735. * Instantiates the follow camera.
  106736. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106737. * @param name Define the name of the camera in the scene
  106738. * @param position Define the position of the camera
  106739. * @param scene Define the scene the camera belong to
  106740. * @param lockedTarget Define the target of the camera
  106741. */
  106742. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  106743. private _follow;
  106744. /**
  106745. * Attached controls to the current camera.
  106746. * @param element Defines the element the controls should be listened from
  106747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106748. */
  106749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106750. /**
  106751. * Detach the current controls from the camera.
  106752. * The camera will stop reacting to inputs.
  106753. * @param element Defines the element to stop listening the inputs from
  106754. */
  106755. detachControl(element: HTMLElement): void;
  106756. /** @hidden */
  106757. _checkInputs(): void;
  106758. private _checkLimits;
  106759. /**
  106760. * Gets the camera class name.
  106761. * @returns the class name
  106762. */
  106763. getClassName(): string;
  106764. }
  106765. /**
  106766. * Arc Rotate version of the follow camera.
  106767. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  106768. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106769. */
  106770. export class ArcFollowCamera extends TargetCamera {
  106771. /** The longitudinal angle of the camera */
  106772. alpha: number;
  106773. /** The latitudinal angle of the camera */
  106774. beta: number;
  106775. /** The radius of the camera from its target */
  106776. radius: number;
  106777. /** Define the camera target (the messh it should follow) */
  106778. target: Nullable<AbstractMesh>;
  106779. private _cartesianCoordinates;
  106780. /**
  106781. * Instantiates a new ArcFollowCamera
  106782. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106783. * @param name Define the name of the camera
  106784. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  106785. * @param beta Define the rotation angle of the camera around the elevation axis
  106786. * @param radius Define the radius of the camera from its target point
  106787. * @param target Define the target of the camera
  106788. * @param scene Define the scene the camera belongs to
  106789. */
  106790. constructor(name: string,
  106791. /** The longitudinal angle of the camera */
  106792. alpha: number,
  106793. /** The latitudinal angle of the camera */
  106794. beta: number,
  106795. /** The radius of the camera from its target */
  106796. radius: number,
  106797. /** Define the camera target (the messh it should follow) */
  106798. target: Nullable<AbstractMesh>, scene: Scene);
  106799. private _follow;
  106800. /** @hidden */
  106801. _checkInputs(): void;
  106802. /**
  106803. * Returns the class name of the object.
  106804. * It is mostly used internally for serialization purposes.
  106805. */
  106806. getClassName(): string;
  106807. }
  106808. }
  106809. declare module BABYLON {
  106810. /**
  106811. * Manage the keyboard inputs to control the movement of a follow camera.
  106812. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106813. */
  106814. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  106815. /**
  106816. * Defines the camera the input is attached to.
  106817. */
  106818. camera: FollowCamera;
  106819. /**
  106820. * Defines the list of key codes associated with the up action (increase heightOffset)
  106821. */
  106822. keysHeightOffsetIncr: number[];
  106823. /**
  106824. * Defines the list of key codes associated with the down action (decrease heightOffset)
  106825. */
  106826. keysHeightOffsetDecr: number[];
  106827. /**
  106828. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  106829. */
  106830. keysHeightOffsetModifierAlt: boolean;
  106831. /**
  106832. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  106833. */
  106834. keysHeightOffsetModifierCtrl: boolean;
  106835. /**
  106836. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  106837. */
  106838. keysHeightOffsetModifierShift: boolean;
  106839. /**
  106840. * Defines the list of key codes associated with the left action (increase rotationOffset)
  106841. */
  106842. keysRotationOffsetIncr: number[];
  106843. /**
  106844. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  106845. */
  106846. keysRotationOffsetDecr: number[];
  106847. /**
  106848. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  106849. */
  106850. keysRotationOffsetModifierAlt: boolean;
  106851. /**
  106852. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  106853. */
  106854. keysRotationOffsetModifierCtrl: boolean;
  106855. /**
  106856. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  106857. */
  106858. keysRotationOffsetModifierShift: boolean;
  106859. /**
  106860. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  106861. */
  106862. keysRadiusIncr: number[];
  106863. /**
  106864. * Defines the list of key codes associated with the zoom-out action (increase radius)
  106865. */
  106866. keysRadiusDecr: number[];
  106867. /**
  106868. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  106869. */
  106870. keysRadiusModifierAlt: boolean;
  106871. /**
  106872. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  106873. */
  106874. keysRadiusModifierCtrl: boolean;
  106875. /**
  106876. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  106877. */
  106878. keysRadiusModifierShift: boolean;
  106879. /**
  106880. * Defines the rate of change of heightOffset.
  106881. */
  106882. heightSensibility: number;
  106883. /**
  106884. * Defines the rate of change of rotationOffset.
  106885. */
  106886. rotationSensibility: number;
  106887. /**
  106888. * Defines the rate of change of radius.
  106889. */
  106890. radiusSensibility: number;
  106891. private _keys;
  106892. private _ctrlPressed;
  106893. private _altPressed;
  106894. private _shiftPressed;
  106895. private _onCanvasBlurObserver;
  106896. private _onKeyboardObserver;
  106897. private _engine;
  106898. private _scene;
  106899. /**
  106900. * Attach the input controls to a specific dom element to get the input from.
  106901. * @param element Defines the element the controls should be listened from
  106902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106903. */
  106904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106905. /**
  106906. * Detach the current controls from the specified dom element.
  106907. * @param element Defines the element to stop listening the inputs from
  106908. */
  106909. detachControl(element: Nullable<HTMLElement>): void;
  106910. /**
  106911. * Update the current camera state depending on the inputs that have been used this frame.
  106912. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106913. */
  106914. checkInputs(): void;
  106915. /**
  106916. * Gets the class name of the current input.
  106917. * @returns the class name
  106918. */
  106919. getClassName(): string;
  106920. /**
  106921. * Get the friendly name associated with the input class.
  106922. * @returns the input friendly name
  106923. */
  106924. getSimpleName(): string;
  106925. /**
  106926. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106927. * allow modification of the heightOffset value.
  106928. */
  106929. private _modifierHeightOffset;
  106930. /**
  106931. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106932. * allow modification of the rotationOffset value.
  106933. */
  106934. private _modifierRotationOffset;
  106935. /**
  106936. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106937. * allow modification of the radius value.
  106938. */
  106939. private _modifierRadius;
  106940. }
  106941. }
  106942. declare module BABYLON {
  106943. interface FreeCameraInputsManager {
  106944. /**
  106945. * @hidden
  106946. */
  106947. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  106948. /**
  106949. * Add orientation input support to the input manager.
  106950. * @returns the current input manager
  106951. */
  106952. addDeviceOrientation(): FreeCameraInputsManager;
  106953. }
  106954. /**
  106955. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  106956. * Screen rotation is taken into account.
  106957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106958. */
  106959. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  106960. private _camera;
  106961. private _screenOrientationAngle;
  106962. private _constantTranform;
  106963. private _screenQuaternion;
  106964. private _alpha;
  106965. private _beta;
  106966. private _gamma;
  106967. /**
  106968. * Can be used to detect if a device orientation sensor is availible on a device
  106969. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  106970. * @returns a promise that will resolve on orientation change
  106971. */
  106972. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  106973. /**
  106974. * @hidden
  106975. */
  106976. _onDeviceOrientationChangedObservable: Observable<void>;
  106977. /**
  106978. * Instantiates a new input
  106979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106980. */
  106981. constructor();
  106982. /**
  106983. * Define the camera controlled by the input.
  106984. */
  106985. camera: FreeCamera;
  106986. /**
  106987. * Attach the input controls to a specific dom element to get the input from.
  106988. * @param element Defines the element the controls should be listened from
  106989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106990. */
  106991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106992. private _orientationChanged;
  106993. private _deviceOrientation;
  106994. /**
  106995. * Detach the current controls from the specified dom element.
  106996. * @param element Defines the element to stop listening the inputs from
  106997. */
  106998. detachControl(element: Nullable<HTMLElement>): void;
  106999. /**
  107000. * Update the current camera state depending on the inputs that have been used this frame.
  107001. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107002. */
  107003. checkInputs(): void;
  107004. /**
  107005. * Gets the class name of the current intput.
  107006. * @returns the class name
  107007. */
  107008. getClassName(): string;
  107009. /**
  107010. * Get the friendly name associated with the input class.
  107011. * @returns the input friendly name
  107012. */
  107013. getSimpleName(): string;
  107014. }
  107015. }
  107016. declare module BABYLON {
  107017. /**
  107018. * Manage the gamepad inputs to control a free camera.
  107019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107020. */
  107021. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  107022. /**
  107023. * Define the camera the input is attached to.
  107024. */
  107025. camera: FreeCamera;
  107026. /**
  107027. * Define the Gamepad controlling the input
  107028. */
  107029. gamepad: Nullable<Gamepad>;
  107030. /**
  107031. * Defines the gamepad rotation sensiblity.
  107032. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107033. */
  107034. gamepadAngularSensibility: number;
  107035. /**
  107036. * Defines the gamepad move sensiblity.
  107037. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107038. */
  107039. gamepadMoveSensibility: number;
  107040. private _yAxisScale;
  107041. /**
  107042. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  107043. */
  107044. invertYAxis: boolean;
  107045. private _onGamepadConnectedObserver;
  107046. private _onGamepadDisconnectedObserver;
  107047. private _cameraTransform;
  107048. private _deltaTransform;
  107049. private _vector3;
  107050. private _vector2;
  107051. /**
  107052. * Attach the input controls to a specific dom element to get the input from.
  107053. * @param element Defines the element the controls should be listened from
  107054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107055. */
  107056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107057. /**
  107058. * Detach the current controls from the specified dom element.
  107059. * @param element Defines the element to stop listening the inputs from
  107060. */
  107061. detachControl(element: Nullable<HTMLElement>): void;
  107062. /**
  107063. * Update the current camera state depending on the inputs that have been used this frame.
  107064. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107065. */
  107066. checkInputs(): void;
  107067. /**
  107068. * Gets the class name of the current intput.
  107069. * @returns the class name
  107070. */
  107071. getClassName(): string;
  107072. /**
  107073. * Get the friendly name associated with the input class.
  107074. * @returns the input friendly name
  107075. */
  107076. getSimpleName(): string;
  107077. }
  107078. }
  107079. declare module BABYLON {
  107080. /**
  107081. * Defines the potential axis of a Joystick
  107082. */
  107083. export enum JoystickAxis {
  107084. /** X axis */
  107085. X = 0,
  107086. /** Y axis */
  107087. Y = 1,
  107088. /** Z axis */
  107089. Z = 2
  107090. }
  107091. /**
  107092. * Class used to define virtual joystick (used in touch mode)
  107093. */
  107094. export class VirtualJoystick {
  107095. /**
  107096. * Gets or sets a boolean indicating that left and right values must be inverted
  107097. */
  107098. reverseLeftRight: boolean;
  107099. /**
  107100. * Gets or sets a boolean indicating that up and down values must be inverted
  107101. */
  107102. reverseUpDown: boolean;
  107103. /**
  107104. * Gets the offset value for the position (ie. the change of the position value)
  107105. */
  107106. deltaPosition: Vector3;
  107107. /**
  107108. * Gets a boolean indicating if the virtual joystick was pressed
  107109. */
  107110. pressed: boolean;
  107111. /**
  107112. * Canvas the virtual joystick will render onto, default z-index of this is 5
  107113. */
  107114. static Canvas: Nullable<HTMLCanvasElement>;
  107115. private static _globalJoystickIndex;
  107116. private static vjCanvasContext;
  107117. private static vjCanvasWidth;
  107118. private static vjCanvasHeight;
  107119. private static halfWidth;
  107120. private _action;
  107121. private _axisTargetedByLeftAndRight;
  107122. private _axisTargetedByUpAndDown;
  107123. private _joystickSensibility;
  107124. private _inversedSensibility;
  107125. private _joystickPointerID;
  107126. private _joystickColor;
  107127. private _joystickPointerPos;
  107128. private _joystickPreviousPointerPos;
  107129. private _joystickPointerStartPos;
  107130. private _deltaJoystickVector;
  107131. private _leftJoystick;
  107132. private _touches;
  107133. private _onPointerDownHandlerRef;
  107134. private _onPointerMoveHandlerRef;
  107135. private _onPointerUpHandlerRef;
  107136. private _onResize;
  107137. /**
  107138. * Creates a new virtual joystick
  107139. * @param leftJoystick defines that the joystick is for left hand (false by default)
  107140. */
  107141. constructor(leftJoystick?: boolean);
  107142. /**
  107143. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  107144. * @param newJoystickSensibility defines the new sensibility
  107145. */
  107146. setJoystickSensibility(newJoystickSensibility: number): void;
  107147. private _onPointerDown;
  107148. private _onPointerMove;
  107149. private _onPointerUp;
  107150. /**
  107151. * Change the color of the virtual joystick
  107152. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  107153. */
  107154. setJoystickColor(newColor: string): void;
  107155. /**
  107156. * Defines a callback to call when the joystick is touched
  107157. * @param action defines the callback
  107158. */
  107159. setActionOnTouch(action: () => any): void;
  107160. /**
  107161. * Defines which axis you'd like to control for left & right
  107162. * @param axis defines the axis to use
  107163. */
  107164. setAxisForLeftRight(axis: JoystickAxis): void;
  107165. /**
  107166. * Defines which axis you'd like to control for up & down
  107167. * @param axis defines the axis to use
  107168. */
  107169. setAxisForUpDown(axis: JoystickAxis): void;
  107170. private _drawVirtualJoystick;
  107171. /**
  107172. * Release internal HTML canvas
  107173. */
  107174. releaseCanvas(): void;
  107175. }
  107176. }
  107177. declare module BABYLON {
  107178. interface FreeCameraInputsManager {
  107179. /**
  107180. * Add virtual joystick input support to the input manager.
  107181. * @returns the current input manager
  107182. */
  107183. addVirtualJoystick(): FreeCameraInputsManager;
  107184. }
  107185. /**
  107186. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  107187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107188. */
  107189. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  107190. /**
  107191. * Defines the camera the input is attached to.
  107192. */
  107193. camera: FreeCamera;
  107194. private _leftjoystick;
  107195. private _rightjoystick;
  107196. /**
  107197. * Gets the left stick of the virtual joystick.
  107198. * @returns The virtual Joystick
  107199. */
  107200. getLeftJoystick(): VirtualJoystick;
  107201. /**
  107202. * Gets the right stick of the virtual joystick.
  107203. * @returns The virtual Joystick
  107204. */
  107205. getRightJoystick(): VirtualJoystick;
  107206. /**
  107207. * Update the current camera state depending on the inputs that have been used this frame.
  107208. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107209. */
  107210. checkInputs(): void;
  107211. /**
  107212. * Attach the input controls to a specific dom element to get the input from.
  107213. * @param element Defines the element the controls should be listened from
  107214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107215. */
  107216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107217. /**
  107218. * Detach the current controls from the specified dom element.
  107219. * @param element Defines the element to stop listening the inputs from
  107220. */
  107221. detachControl(element: Nullable<HTMLElement>): void;
  107222. /**
  107223. * Gets the class name of the current intput.
  107224. * @returns the class name
  107225. */
  107226. getClassName(): string;
  107227. /**
  107228. * Get the friendly name associated with the input class.
  107229. * @returns the input friendly name
  107230. */
  107231. getSimpleName(): string;
  107232. }
  107233. }
  107234. declare module BABYLON {
  107235. /**
  107236. * This represents a FPS type of camera controlled by touch.
  107237. * This is like a universal camera minus the Gamepad controls.
  107238. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107239. */
  107240. export class TouchCamera extends FreeCamera {
  107241. /**
  107242. * Defines the touch sensibility for rotation.
  107243. * The higher the faster.
  107244. */
  107245. touchAngularSensibility: number;
  107246. /**
  107247. * Defines the touch sensibility for move.
  107248. * The higher the faster.
  107249. */
  107250. touchMoveSensibility: number;
  107251. /**
  107252. * Instantiates a new touch camera.
  107253. * This represents a FPS type of camera controlled by touch.
  107254. * This is like a universal camera minus the Gamepad controls.
  107255. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107256. * @param name Define the name of the camera in the scene
  107257. * @param position Define the start position of the camera in the scene
  107258. * @param scene Define the scene the camera belongs to
  107259. */
  107260. constructor(name: string, position: Vector3, scene: Scene);
  107261. /**
  107262. * Gets the current object class name.
  107263. * @return the class name
  107264. */
  107265. getClassName(): string;
  107266. /** @hidden */
  107267. _setupInputs(): void;
  107268. }
  107269. }
  107270. declare module BABYLON {
  107271. /**
  107272. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  107273. * being tilted forward or back and left or right.
  107274. */
  107275. export class DeviceOrientationCamera extends FreeCamera {
  107276. private _initialQuaternion;
  107277. private _quaternionCache;
  107278. private _tmpDragQuaternion;
  107279. private _disablePointerInputWhenUsingDeviceOrientation;
  107280. /**
  107281. * Creates a new device orientation camera
  107282. * @param name The name of the camera
  107283. * @param position The start position camera
  107284. * @param scene The scene the camera belongs to
  107285. */
  107286. constructor(name: string, position: Vector3, scene: Scene);
  107287. /**
  107288. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  107289. */
  107290. disablePointerInputWhenUsingDeviceOrientation: boolean;
  107291. private _dragFactor;
  107292. /**
  107293. * Enabled turning on the y axis when the orientation sensor is active
  107294. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  107295. */
  107296. enableHorizontalDragging(dragFactor?: number): void;
  107297. /**
  107298. * Gets the current instance class name ("DeviceOrientationCamera").
  107299. * This helps avoiding instanceof at run time.
  107300. * @returns the class name
  107301. */
  107302. getClassName(): string;
  107303. /**
  107304. * @hidden
  107305. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  107306. */
  107307. _checkInputs(): void;
  107308. /**
  107309. * Reset the camera to its default orientation on the specified axis only.
  107310. * @param axis The axis to reset
  107311. */
  107312. resetToCurrentRotation(axis?: Axis): void;
  107313. }
  107314. }
  107315. declare module BABYLON {
  107316. /**
  107317. * Defines supported buttons for XBox360 compatible gamepads
  107318. */
  107319. export enum Xbox360Button {
  107320. /** A */
  107321. A = 0,
  107322. /** B */
  107323. B = 1,
  107324. /** X */
  107325. X = 2,
  107326. /** Y */
  107327. Y = 3,
  107328. /** Start */
  107329. Start = 4,
  107330. /** Back */
  107331. Back = 5,
  107332. /** Left button */
  107333. LB = 6,
  107334. /** Right button */
  107335. RB = 7,
  107336. /** Left stick */
  107337. LeftStick = 8,
  107338. /** Right stick */
  107339. RightStick = 9
  107340. }
  107341. /** Defines values for XBox360 DPad */
  107342. export enum Xbox360Dpad {
  107343. /** Up */
  107344. Up = 0,
  107345. /** Down */
  107346. Down = 1,
  107347. /** Left */
  107348. Left = 2,
  107349. /** Right */
  107350. Right = 3
  107351. }
  107352. /**
  107353. * Defines a XBox360 gamepad
  107354. */
  107355. export class Xbox360Pad extends Gamepad {
  107356. private _leftTrigger;
  107357. private _rightTrigger;
  107358. private _onlefttriggerchanged;
  107359. private _onrighttriggerchanged;
  107360. private _onbuttondown;
  107361. private _onbuttonup;
  107362. private _ondpaddown;
  107363. private _ondpadup;
  107364. /** Observable raised when a button is pressed */
  107365. onButtonDownObservable: Observable<Xbox360Button>;
  107366. /** Observable raised when a button is released */
  107367. onButtonUpObservable: Observable<Xbox360Button>;
  107368. /** Observable raised when a pad is pressed */
  107369. onPadDownObservable: Observable<Xbox360Dpad>;
  107370. /** Observable raised when a pad is released */
  107371. onPadUpObservable: Observable<Xbox360Dpad>;
  107372. private _buttonA;
  107373. private _buttonB;
  107374. private _buttonX;
  107375. private _buttonY;
  107376. private _buttonBack;
  107377. private _buttonStart;
  107378. private _buttonLB;
  107379. private _buttonRB;
  107380. private _buttonLeftStick;
  107381. private _buttonRightStick;
  107382. private _dPadUp;
  107383. private _dPadDown;
  107384. private _dPadLeft;
  107385. private _dPadRight;
  107386. private _isXboxOnePad;
  107387. /**
  107388. * Creates a new XBox360 gamepad object
  107389. * @param id defines the id of this gamepad
  107390. * @param index defines its index
  107391. * @param gamepad defines the internal HTML gamepad object
  107392. * @param xboxOne defines if it is a XBox One gamepad
  107393. */
  107394. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  107395. /**
  107396. * Defines the callback to call when left trigger is pressed
  107397. * @param callback defines the callback to use
  107398. */
  107399. onlefttriggerchanged(callback: (value: number) => void): void;
  107400. /**
  107401. * Defines the callback to call when right trigger is pressed
  107402. * @param callback defines the callback to use
  107403. */
  107404. onrighttriggerchanged(callback: (value: number) => void): void;
  107405. /**
  107406. * Gets the left trigger value
  107407. */
  107408. /**
  107409. * Sets the left trigger value
  107410. */
  107411. leftTrigger: number;
  107412. /**
  107413. * Gets the right trigger value
  107414. */
  107415. /**
  107416. * Sets the right trigger value
  107417. */
  107418. rightTrigger: number;
  107419. /**
  107420. * Defines the callback to call when a button is pressed
  107421. * @param callback defines the callback to use
  107422. */
  107423. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  107424. /**
  107425. * Defines the callback to call when a button is released
  107426. * @param callback defines the callback to use
  107427. */
  107428. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  107429. /**
  107430. * Defines the callback to call when a pad is pressed
  107431. * @param callback defines the callback to use
  107432. */
  107433. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  107434. /**
  107435. * Defines the callback to call when a pad is released
  107436. * @param callback defines the callback to use
  107437. */
  107438. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  107439. private _setButtonValue;
  107440. private _setDPadValue;
  107441. /**
  107442. * Gets the value of the `A` button
  107443. */
  107444. /**
  107445. * Sets the value of the `A` button
  107446. */
  107447. buttonA: number;
  107448. /**
  107449. * Gets the value of the `B` button
  107450. */
  107451. /**
  107452. * Sets the value of the `B` button
  107453. */
  107454. buttonB: number;
  107455. /**
  107456. * Gets the value of the `X` button
  107457. */
  107458. /**
  107459. * Sets the value of the `X` button
  107460. */
  107461. buttonX: number;
  107462. /**
  107463. * Gets the value of the `Y` button
  107464. */
  107465. /**
  107466. * Sets the value of the `Y` button
  107467. */
  107468. buttonY: number;
  107469. /**
  107470. * Gets the value of the `Start` button
  107471. */
  107472. /**
  107473. * Sets the value of the `Start` button
  107474. */
  107475. buttonStart: number;
  107476. /**
  107477. * Gets the value of the `Back` button
  107478. */
  107479. /**
  107480. * Sets the value of the `Back` button
  107481. */
  107482. buttonBack: number;
  107483. /**
  107484. * Gets the value of the `Left` button
  107485. */
  107486. /**
  107487. * Sets the value of the `Left` button
  107488. */
  107489. buttonLB: number;
  107490. /**
  107491. * Gets the value of the `Right` button
  107492. */
  107493. /**
  107494. * Sets the value of the `Right` button
  107495. */
  107496. buttonRB: number;
  107497. /**
  107498. * Gets the value of the Left joystick
  107499. */
  107500. /**
  107501. * Sets the value of the Left joystick
  107502. */
  107503. buttonLeftStick: number;
  107504. /**
  107505. * Gets the value of the Right joystick
  107506. */
  107507. /**
  107508. * Sets the value of the Right joystick
  107509. */
  107510. buttonRightStick: number;
  107511. /**
  107512. * Gets the value of D-pad up
  107513. */
  107514. /**
  107515. * Sets the value of D-pad up
  107516. */
  107517. dPadUp: number;
  107518. /**
  107519. * Gets the value of D-pad down
  107520. */
  107521. /**
  107522. * Sets the value of D-pad down
  107523. */
  107524. dPadDown: number;
  107525. /**
  107526. * Gets the value of D-pad left
  107527. */
  107528. /**
  107529. * Sets the value of D-pad left
  107530. */
  107531. dPadLeft: number;
  107532. /**
  107533. * Gets the value of D-pad right
  107534. */
  107535. /**
  107536. * Sets the value of D-pad right
  107537. */
  107538. dPadRight: number;
  107539. /**
  107540. * Force the gamepad to synchronize with device values
  107541. */
  107542. update(): void;
  107543. /**
  107544. * Disposes the gamepad
  107545. */
  107546. dispose(): void;
  107547. }
  107548. }
  107549. declare module BABYLON {
  107550. /**
  107551. * Defines supported buttons for DualShock compatible gamepads
  107552. */
  107553. export enum DualShockButton {
  107554. /** Cross */
  107555. Cross = 0,
  107556. /** Circle */
  107557. Circle = 1,
  107558. /** Square */
  107559. Square = 2,
  107560. /** Triangle */
  107561. Triangle = 3,
  107562. /** Options */
  107563. Options = 4,
  107564. /** Share */
  107565. Share = 5,
  107566. /** L1 */
  107567. L1 = 6,
  107568. /** R1 */
  107569. R1 = 7,
  107570. /** Left stick */
  107571. LeftStick = 8,
  107572. /** Right stick */
  107573. RightStick = 9
  107574. }
  107575. /** Defines values for DualShock DPad */
  107576. export enum DualShockDpad {
  107577. /** Up */
  107578. Up = 0,
  107579. /** Down */
  107580. Down = 1,
  107581. /** Left */
  107582. Left = 2,
  107583. /** Right */
  107584. Right = 3
  107585. }
  107586. /**
  107587. * Defines a DualShock gamepad
  107588. */
  107589. export class DualShockPad extends Gamepad {
  107590. private _leftTrigger;
  107591. private _rightTrigger;
  107592. private _onlefttriggerchanged;
  107593. private _onrighttriggerchanged;
  107594. private _onbuttondown;
  107595. private _onbuttonup;
  107596. private _ondpaddown;
  107597. private _ondpadup;
  107598. /** Observable raised when a button is pressed */
  107599. onButtonDownObservable: Observable<DualShockButton>;
  107600. /** Observable raised when a button is released */
  107601. onButtonUpObservable: Observable<DualShockButton>;
  107602. /** Observable raised when a pad is pressed */
  107603. onPadDownObservable: Observable<DualShockDpad>;
  107604. /** Observable raised when a pad is released */
  107605. onPadUpObservable: Observable<DualShockDpad>;
  107606. private _buttonCross;
  107607. private _buttonCircle;
  107608. private _buttonSquare;
  107609. private _buttonTriangle;
  107610. private _buttonShare;
  107611. private _buttonOptions;
  107612. private _buttonL1;
  107613. private _buttonR1;
  107614. private _buttonLeftStick;
  107615. private _buttonRightStick;
  107616. private _dPadUp;
  107617. private _dPadDown;
  107618. private _dPadLeft;
  107619. private _dPadRight;
  107620. /**
  107621. * Creates a new DualShock gamepad object
  107622. * @param id defines the id of this gamepad
  107623. * @param index defines its index
  107624. * @param gamepad defines the internal HTML gamepad object
  107625. */
  107626. constructor(id: string, index: number, gamepad: any);
  107627. /**
  107628. * Defines the callback to call when left trigger is pressed
  107629. * @param callback defines the callback to use
  107630. */
  107631. onlefttriggerchanged(callback: (value: number) => void): void;
  107632. /**
  107633. * Defines the callback to call when right trigger is pressed
  107634. * @param callback defines the callback to use
  107635. */
  107636. onrighttriggerchanged(callback: (value: number) => void): void;
  107637. /**
  107638. * Gets the left trigger value
  107639. */
  107640. /**
  107641. * Sets the left trigger value
  107642. */
  107643. leftTrigger: number;
  107644. /**
  107645. * Gets the right trigger value
  107646. */
  107647. /**
  107648. * Sets the right trigger value
  107649. */
  107650. rightTrigger: number;
  107651. /**
  107652. * Defines the callback to call when a button is pressed
  107653. * @param callback defines the callback to use
  107654. */
  107655. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  107656. /**
  107657. * Defines the callback to call when a button is released
  107658. * @param callback defines the callback to use
  107659. */
  107660. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  107661. /**
  107662. * Defines the callback to call when a pad is pressed
  107663. * @param callback defines the callback to use
  107664. */
  107665. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  107666. /**
  107667. * Defines the callback to call when a pad is released
  107668. * @param callback defines the callback to use
  107669. */
  107670. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  107671. private _setButtonValue;
  107672. private _setDPadValue;
  107673. /**
  107674. * Gets the value of the `Cross` button
  107675. */
  107676. /**
  107677. * Sets the value of the `Cross` button
  107678. */
  107679. buttonCross: number;
  107680. /**
  107681. * Gets the value of the `Circle` button
  107682. */
  107683. /**
  107684. * Sets the value of the `Circle` button
  107685. */
  107686. buttonCircle: number;
  107687. /**
  107688. * Gets the value of the `Square` button
  107689. */
  107690. /**
  107691. * Sets the value of the `Square` button
  107692. */
  107693. buttonSquare: number;
  107694. /**
  107695. * Gets the value of the `Triangle` button
  107696. */
  107697. /**
  107698. * Sets the value of the `Triangle` button
  107699. */
  107700. buttonTriangle: number;
  107701. /**
  107702. * Gets the value of the `Options` button
  107703. */
  107704. /**
  107705. * Sets the value of the `Options` button
  107706. */
  107707. buttonOptions: number;
  107708. /**
  107709. * Gets the value of the `Share` button
  107710. */
  107711. /**
  107712. * Sets the value of the `Share` button
  107713. */
  107714. buttonShare: number;
  107715. /**
  107716. * Gets the value of the `L1` button
  107717. */
  107718. /**
  107719. * Sets the value of the `L1` button
  107720. */
  107721. buttonL1: number;
  107722. /**
  107723. * Gets the value of the `R1` button
  107724. */
  107725. /**
  107726. * Sets the value of the `R1` button
  107727. */
  107728. buttonR1: number;
  107729. /**
  107730. * Gets the value of the Left joystick
  107731. */
  107732. /**
  107733. * Sets the value of the Left joystick
  107734. */
  107735. buttonLeftStick: number;
  107736. /**
  107737. * Gets the value of the Right joystick
  107738. */
  107739. /**
  107740. * Sets the value of the Right joystick
  107741. */
  107742. buttonRightStick: number;
  107743. /**
  107744. * Gets the value of D-pad up
  107745. */
  107746. /**
  107747. * Sets the value of D-pad up
  107748. */
  107749. dPadUp: number;
  107750. /**
  107751. * Gets the value of D-pad down
  107752. */
  107753. /**
  107754. * Sets the value of D-pad down
  107755. */
  107756. dPadDown: number;
  107757. /**
  107758. * Gets the value of D-pad left
  107759. */
  107760. /**
  107761. * Sets the value of D-pad left
  107762. */
  107763. dPadLeft: number;
  107764. /**
  107765. * Gets the value of D-pad right
  107766. */
  107767. /**
  107768. * Sets the value of D-pad right
  107769. */
  107770. dPadRight: number;
  107771. /**
  107772. * Force the gamepad to synchronize with device values
  107773. */
  107774. update(): void;
  107775. /**
  107776. * Disposes the gamepad
  107777. */
  107778. dispose(): void;
  107779. }
  107780. }
  107781. declare module BABYLON {
  107782. /**
  107783. * Manager for handling gamepads
  107784. */
  107785. export class GamepadManager {
  107786. private _scene?;
  107787. private _babylonGamepads;
  107788. private _oneGamepadConnected;
  107789. /** @hidden */
  107790. _isMonitoring: boolean;
  107791. private _gamepadEventSupported;
  107792. private _gamepadSupport;
  107793. /**
  107794. * observable to be triggered when the gamepad controller has been connected
  107795. */
  107796. onGamepadConnectedObservable: Observable<Gamepad>;
  107797. /**
  107798. * observable to be triggered when the gamepad controller has been disconnected
  107799. */
  107800. onGamepadDisconnectedObservable: Observable<Gamepad>;
  107801. private _onGamepadConnectedEvent;
  107802. private _onGamepadDisconnectedEvent;
  107803. /**
  107804. * Initializes the gamepad manager
  107805. * @param _scene BabylonJS scene
  107806. */
  107807. constructor(_scene?: Scene | undefined);
  107808. /**
  107809. * The gamepads in the game pad manager
  107810. */
  107811. readonly gamepads: Gamepad[];
  107812. /**
  107813. * Get the gamepad controllers based on type
  107814. * @param type The type of gamepad controller
  107815. * @returns Nullable gamepad
  107816. */
  107817. getGamepadByType(type?: number): Nullable<Gamepad>;
  107818. /**
  107819. * Disposes the gamepad manager
  107820. */
  107821. dispose(): void;
  107822. private _addNewGamepad;
  107823. private _startMonitoringGamepads;
  107824. private _stopMonitoringGamepads;
  107825. /** @hidden */
  107826. _checkGamepadsStatus(): void;
  107827. private _updateGamepadObjects;
  107828. }
  107829. }
  107830. declare module BABYLON {
  107831. interface Scene {
  107832. /** @hidden */
  107833. _gamepadManager: Nullable<GamepadManager>;
  107834. /**
  107835. * Gets the gamepad manager associated with the scene
  107836. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  107837. */
  107838. gamepadManager: GamepadManager;
  107839. }
  107840. /**
  107841. * Interface representing a free camera inputs manager
  107842. */
  107843. interface FreeCameraInputsManager {
  107844. /**
  107845. * Adds gamepad input support to the FreeCameraInputsManager.
  107846. * @returns the FreeCameraInputsManager
  107847. */
  107848. addGamepad(): FreeCameraInputsManager;
  107849. }
  107850. /**
  107851. * Interface representing an arc rotate camera inputs manager
  107852. */
  107853. interface ArcRotateCameraInputsManager {
  107854. /**
  107855. * Adds gamepad input support to the ArcRotateCamera InputManager.
  107856. * @returns the camera inputs manager
  107857. */
  107858. addGamepad(): ArcRotateCameraInputsManager;
  107859. }
  107860. /**
  107861. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  107862. */
  107863. export class GamepadSystemSceneComponent implements ISceneComponent {
  107864. /**
  107865. * The component name helpfull to identify the component in the list of scene components.
  107866. */
  107867. readonly name: string;
  107868. /**
  107869. * The scene the component belongs to.
  107870. */
  107871. scene: Scene;
  107872. /**
  107873. * Creates a new instance of the component for the given scene
  107874. * @param scene Defines the scene to register the component in
  107875. */
  107876. constructor(scene: Scene);
  107877. /**
  107878. * Registers the component in a given scene
  107879. */
  107880. register(): void;
  107881. /**
  107882. * Rebuilds the elements related to this component in case of
  107883. * context lost for instance.
  107884. */
  107885. rebuild(): void;
  107886. /**
  107887. * Disposes the component and the associated ressources
  107888. */
  107889. dispose(): void;
  107890. private _beforeCameraUpdate;
  107891. }
  107892. }
  107893. declare module BABYLON {
  107894. /**
  107895. * 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,
  107896. * which still works and will still be found in many Playgrounds.
  107897. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107898. */
  107899. export class UniversalCamera extends TouchCamera {
  107900. /**
  107901. * Defines the gamepad rotation sensiblity.
  107902. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107903. */
  107904. gamepadAngularSensibility: number;
  107905. /**
  107906. * Defines the gamepad move sensiblity.
  107907. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107908. */
  107909. gamepadMoveSensibility: number;
  107910. /**
  107911. * 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,
  107912. * which still works and will still be found in many Playgrounds.
  107913. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107914. * @param name Define the name of the camera in the scene
  107915. * @param position Define the start position of the camera in the scene
  107916. * @param scene Define the scene the camera belongs to
  107917. */
  107918. constructor(name: string, position: Vector3, scene: Scene);
  107919. /**
  107920. * Gets the current object class name.
  107921. * @return the class name
  107922. */
  107923. getClassName(): string;
  107924. }
  107925. }
  107926. declare module BABYLON {
  107927. /**
  107928. * This represents a FPS type of camera. This is only here for back compat purpose.
  107929. * Please use the UniversalCamera instead as both are identical.
  107930. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107931. */
  107932. export class GamepadCamera extends UniversalCamera {
  107933. /**
  107934. * Instantiates a new Gamepad Camera
  107935. * This represents a FPS type of camera. This is only here for back compat purpose.
  107936. * Please use the UniversalCamera instead as both are identical.
  107937. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107938. * @param name Define the name of the camera in the scene
  107939. * @param position Define the start position of the camera in the scene
  107940. * @param scene Define the scene the camera belongs to
  107941. */
  107942. constructor(name: string, position: Vector3, scene: Scene);
  107943. /**
  107944. * Gets the current object class name.
  107945. * @return the class name
  107946. */
  107947. getClassName(): string;
  107948. }
  107949. }
  107950. declare module BABYLON {
  107951. /** @hidden */
  107952. export var passPixelShader: {
  107953. name: string;
  107954. shader: string;
  107955. };
  107956. }
  107957. declare module BABYLON {
  107958. /** @hidden */
  107959. export var passCubePixelShader: {
  107960. name: string;
  107961. shader: string;
  107962. };
  107963. }
  107964. declare module BABYLON {
  107965. /**
  107966. * PassPostProcess which produces an output the same as it's input
  107967. */
  107968. export class PassPostProcess extends PostProcess {
  107969. /**
  107970. * Creates the PassPostProcess
  107971. * @param name The name of the effect.
  107972. * @param options The required width/height ratio to downsize to before computing the render pass.
  107973. * @param camera The camera to apply the render pass to.
  107974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107975. * @param engine The engine which the post process will be applied. (default: current engine)
  107976. * @param reusable If the post process can be reused on the same frame. (default: false)
  107977. * @param textureType The type of texture to be used when performing the post processing.
  107978. * @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)
  107979. */
  107980. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107981. }
  107982. /**
  107983. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  107984. */
  107985. export class PassCubePostProcess extends PostProcess {
  107986. private _face;
  107987. /**
  107988. * Gets or sets the cube face to display.
  107989. * * 0 is +X
  107990. * * 1 is -X
  107991. * * 2 is +Y
  107992. * * 3 is -Y
  107993. * * 4 is +Z
  107994. * * 5 is -Z
  107995. */
  107996. face: number;
  107997. /**
  107998. * Creates the PassCubePostProcess
  107999. * @param name The name of the effect.
  108000. * @param options The required width/height ratio to downsize to before computing the render pass.
  108001. * @param camera The camera to apply the render pass to.
  108002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108003. * @param engine The engine which the post process will be applied. (default: current engine)
  108004. * @param reusable If the post process can be reused on the same frame. (default: false)
  108005. * @param textureType The type of texture to be used when performing the post processing.
  108006. * @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)
  108007. */
  108008. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108009. }
  108010. }
  108011. declare module BABYLON {
  108012. /** @hidden */
  108013. export var anaglyphPixelShader: {
  108014. name: string;
  108015. shader: string;
  108016. };
  108017. }
  108018. declare module BABYLON {
  108019. /**
  108020. * Postprocess used to generate anaglyphic rendering
  108021. */
  108022. export class AnaglyphPostProcess extends PostProcess {
  108023. private _passedProcess;
  108024. /**
  108025. * Creates a new AnaglyphPostProcess
  108026. * @param name defines postprocess name
  108027. * @param options defines creation options or target ratio scale
  108028. * @param rigCameras defines cameras using this postprocess
  108029. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  108030. * @param engine defines hosting engine
  108031. * @param reusable defines if the postprocess will be reused multiple times per frame
  108032. */
  108033. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  108034. }
  108035. }
  108036. declare module BABYLON {
  108037. /**
  108038. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  108039. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108040. */
  108041. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  108042. /**
  108043. * Creates a new AnaglyphArcRotateCamera
  108044. * @param name defines camera name
  108045. * @param alpha defines alpha angle (in radians)
  108046. * @param beta defines beta angle (in radians)
  108047. * @param radius defines radius
  108048. * @param target defines camera target
  108049. * @param interaxialDistance defines distance between each color axis
  108050. * @param scene defines the hosting scene
  108051. */
  108052. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  108053. /**
  108054. * Gets camera class name
  108055. * @returns AnaglyphArcRotateCamera
  108056. */
  108057. getClassName(): string;
  108058. }
  108059. }
  108060. declare module BABYLON {
  108061. /**
  108062. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  108063. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108064. */
  108065. export class AnaglyphFreeCamera extends FreeCamera {
  108066. /**
  108067. * Creates a new AnaglyphFreeCamera
  108068. * @param name defines camera name
  108069. * @param position defines initial position
  108070. * @param interaxialDistance defines distance between each color axis
  108071. * @param scene defines the hosting scene
  108072. */
  108073. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108074. /**
  108075. * Gets camera class name
  108076. * @returns AnaglyphFreeCamera
  108077. */
  108078. getClassName(): string;
  108079. }
  108080. }
  108081. declare module BABYLON {
  108082. /**
  108083. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  108084. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108085. */
  108086. export class AnaglyphGamepadCamera extends GamepadCamera {
  108087. /**
  108088. * Creates a new AnaglyphGamepadCamera
  108089. * @param name defines camera name
  108090. * @param position defines initial position
  108091. * @param interaxialDistance defines distance between each color axis
  108092. * @param scene defines the hosting scene
  108093. */
  108094. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108095. /**
  108096. * Gets camera class name
  108097. * @returns AnaglyphGamepadCamera
  108098. */
  108099. getClassName(): string;
  108100. }
  108101. }
  108102. declare module BABYLON {
  108103. /**
  108104. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  108105. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108106. */
  108107. export class AnaglyphUniversalCamera extends UniversalCamera {
  108108. /**
  108109. * Creates a new AnaglyphUniversalCamera
  108110. * @param name defines camera name
  108111. * @param position defines initial position
  108112. * @param interaxialDistance defines distance between each color axis
  108113. * @param scene defines the hosting scene
  108114. */
  108115. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108116. /**
  108117. * Gets camera class name
  108118. * @returns AnaglyphUniversalCamera
  108119. */
  108120. getClassName(): string;
  108121. }
  108122. }
  108123. declare module BABYLON {
  108124. /** @hidden */
  108125. export var stereoscopicInterlacePixelShader: {
  108126. name: string;
  108127. shader: string;
  108128. };
  108129. }
  108130. declare module BABYLON {
  108131. /**
  108132. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  108133. */
  108134. export class StereoscopicInterlacePostProcess extends PostProcess {
  108135. private _stepSize;
  108136. private _passedProcess;
  108137. /**
  108138. * Initializes a StereoscopicInterlacePostProcess
  108139. * @param name The name of the effect.
  108140. * @param rigCameras The rig cameras to be appled to the post process
  108141. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  108142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108143. * @param engine The engine which the post process will be applied. (default: current engine)
  108144. * @param reusable If the post process can be reused on the same frame. (default: false)
  108145. */
  108146. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108147. }
  108148. }
  108149. declare module BABYLON {
  108150. /**
  108151. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  108152. * @see http://doc.babylonjs.com/features/cameras
  108153. */
  108154. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  108155. /**
  108156. * Creates a new StereoscopicArcRotateCamera
  108157. * @param name defines camera name
  108158. * @param alpha defines alpha angle (in radians)
  108159. * @param beta defines beta angle (in radians)
  108160. * @param radius defines radius
  108161. * @param target defines camera target
  108162. * @param interaxialDistance defines distance between each color axis
  108163. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108164. * @param scene defines the hosting scene
  108165. */
  108166. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108167. /**
  108168. * Gets camera class name
  108169. * @returns StereoscopicArcRotateCamera
  108170. */
  108171. getClassName(): string;
  108172. }
  108173. }
  108174. declare module BABYLON {
  108175. /**
  108176. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  108177. * @see http://doc.babylonjs.com/features/cameras
  108178. */
  108179. export class StereoscopicFreeCamera extends FreeCamera {
  108180. /**
  108181. * Creates a new StereoscopicFreeCamera
  108182. * @param name defines camera name
  108183. * @param position defines initial position
  108184. * @param interaxialDistance defines distance between each color axis
  108185. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108186. * @param scene defines the hosting scene
  108187. */
  108188. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108189. /**
  108190. * Gets camera class name
  108191. * @returns StereoscopicFreeCamera
  108192. */
  108193. getClassName(): string;
  108194. }
  108195. }
  108196. declare module BABYLON {
  108197. /**
  108198. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  108199. * @see http://doc.babylonjs.com/features/cameras
  108200. */
  108201. export class StereoscopicGamepadCamera extends GamepadCamera {
  108202. /**
  108203. * Creates a new StereoscopicGamepadCamera
  108204. * @param name defines camera name
  108205. * @param position defines initial position
  108206. * @param interaxialDistance defines distance between each color axis
  108207. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108208. * @param scene defines the hosting scene
  108209. */
  108210. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108211. /**
  108212. * Gets camera class name
  108213. * @returns StereoscopicGamepadCamera
  108214. */
  108215. getClassName(): string;
  108216. }
  108217. }
  108218. declare module BABYLON {
  108219. /**
  108220. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  108221. * @see http://doc.babylonjs.com/features/cameras
  108222. */
  108223. export class StereoscopicUniversalCamera extends UniversalCamera {
  108224. /**
  108225. * Creates a new StereoscopicUniversalCamera
  108226. * @param name defines camera name
  108227. * @param position defines initial position
  108228. * @param interaxialDistance defines distance between each color axis
  108229. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108230. * @param scene defines the hosting scene
  108231. */
  108232. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108233. /**
  108234. * Gets camera class name
  108235. * @returns StereoscopicUniversalCamera
  108236. */
  108237. getClassName(): string;
  108238. }
  108239. }
  108240. declare module BABYLON {
  108241. /**
  108242. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  108243. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108244. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108245. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108246. */
  108247. export class VirtualJoysticksCamera extends FreeCamera {
  108248. /**
  108249. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  108250. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108251. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108252. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108253. * @param name Define the name of the camera in the scene
  108254. * @param position Define the start position of the camera in the scene
  108255. * @param scene Define the scene the camera belongs to
  108256. */
  108257. constructor(name: string, position: Vector3, scene: Scene);
  108258. /**
  108259. * Gets the current object class name.
  108260. * @return the class name
  108261. */
  108262. getClassName(): string;
  108263. }
  108264. }
  108265. declare module BABYLON {
  108266. /**
  108267. * This represents all the required metrics to create a VR camera.
  108268. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  108269. */
  108270. export class VRCameraMetrics {
  108271. /**
  108272. * Define the horizontal resolution off the screen.
  108273. */
  108274. hResolution: number;
  108275. /**
  108276. * Define the vertical resolution off the screen.
  108277. */
  108278. vResolution: number;
  108279. /**
  108280. * Define the horizontal screen size.
  108281. */
  108282. hScreenSize: number;
  108283. /**
  108284. * Define the vertical screen size.
  108285. */
  108286. vScreenSize: number;
  108287. /**
  108288. * Define the vertical screen center position.
  108289. */
  108290. vScreenCenter: number;
  108291. /**
  108292. * Define the distance of the eyes to the screen.
  108293. */
  108294. eyeToScreenDistance: number;
  108295. /**
  108296. * Define the distance between both lenses
  108297. */
  108298. lensSeparationDistance: number;
  108299. /**
  108300. * Define the distance between both viewer's eyes.
  108301. */
  108302. interpupillaryDistance: number;
  108303. /**
  108304. * Define the distortion factor of the VR postprocess.
  108305. * Please, touch with care.
  108306. */
  108307. distortionK: number[];
  108308. /**
  108309. * Define the chromatic aberration correction factors for the VR post process.
  108310. */
  108311. chromaAbCorrection: number[];
  108312. /**
  108313. * Define the scale factor of the post process.
  108314. * The smaller the better but the slower.
  108315. */
  108316. postProcessScaleFactor: number;
  108317. /**
  108318. * Define an offset for the lens center.
  108319. */
  108320. lensCenterOffset: number;
  108321. /**
  108322. * Define if the current vr camera should compensate the distortion of the lense or not.
  108323. */
  108324. compensateDistortion: boolean;
  108325. /**
  108326. * Defines if multiview should be enabled when rendering (Default: false)
  108327. */
  108328. multiviewEnabled: boolean;
  108329. /**
  108330. * Gets the rendering aspect ratio based on the provided resolutions.
  108331. */
  108332. readonly aspectRatio: number;
  108333. /**
  108334. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  108335. */
  108336. readonly aspectRatioFov: number;
  108337. /**
  108338. * @hidden
  108339. */
  108340. readonly leftHMatrix: Matrix;
  108341. /**
  108342. * @hidden
  108343. */
  108344. readonly rightHMatrix: Matrix;
  108345. /**
  108346. * @hidden
  108347. */
  108348. readonly leftPreViewMatrix: Matrix;
  108349. /**
  108350. * @hidden
  108351. */
  108352. readonly rightPreViewMatrix: Matrix;
  108353. /**
  108354. * Get the default VRMetrics based on the most generic setup.
  108355. * @returns the default vr metrics
  108356. */
  108357. static GetDefault(): VRCameraMetrics;
  108358. }
  108359. }
  108360. declare module BABYLON {
  108361. /** @hidden */
  108362. export var vrDistortionCorrectionPixelShader: {
  108363. name: string;
  108364. shader: string;
  108365. };
  108366. }
  108367. declare module BABYLON {
  108368. /**
  108369. * VRDistortionCorrectionPostProcess used for mobile VR
  108370. */
  108371. export class VRDistortionCorrectionPostProcess extends PostProcess {
  108372. private _isRightEye;
  108373. private _distortionFactors;
  108374. private _postProcessScaleFactor;
  108375. private _lensCenterOffset;
  108376. private _scaleIn;
  108377. private _scaleFactor;
  108378. private _lensCenter;
  108379. /**
  108380. * Initializes the VRDistortionCorrectionPostProcess
  108381. * @param name The name of the effect.
  108382. * @param camera The camera to apply the render pass to.
  108383. * @param isRightEye If this is for the right eye distortion
  108384. * @param vrMetrics All the required metrics for the VR camera
  108385. */
  108386. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  108387. }
  108388. }
  108389. declare module BABYLON {
  108390. /**
  108391. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  108392. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108393. */
  108394. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  108395. /**
  108396. * Creates a new VRDeviceOrientationArcRotateCamera
  108397. * @param name defines camera name
  108398. * @param alpha defines the camera rotation along the logitudinal axis
  108399. * @param beta defines the camera rotation along the latitudinal axis
  108400. * @param radius defines the camera distance from its target
  108401. * @param target defines the camera target
  108402. * @param scene defines the scene the camera belongs to
  108403. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108404. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108405. */
  108406. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108407. /**
  108408. * Gets camera class name
  108409. * @returns VRDeviceOrientationArcRotateCamera
  108410. */
  108411. getClassName(): string;
  108412. }
  108413. }
  108414. declare module BABYLON {
  108415. /**
  108416. * Camera used to simulate VR rendering (based on FreeCamera)
  108417. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108418. */
  108419. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  108420. /**
  108421. * Creates a new VRDeviceOrientationFreeCamera
  108422. * @param name defines camera name
  108423. * @param position defines the start position of the camera
  108424. * @param scene defines the scene the camera belongs to
  108425. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108426. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108427. */
  108428. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108429. /**
  108430. * Gets camera class name
  108431. * @returns VRDeviceOrientationFreeCamera
  108432. */
  108433. getClassName(): string;
  108434. }
  108435. }
  108436. declare module BABYLON {
  108437. /**
  108438. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  108439. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108440. */
  108441. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  108442. /**
  108443. * Creates a new VRDeviceOrientationGamepadCamera
  108444. * @param name defines camera name
  108445. * @param position defines the start position of the camera
  108446. * @param scene defines the scene the camera belongs to
  108447. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108448. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108449. */
  108450. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108451. /**
  108452. * Gets camera class name
  108453. * @returns VRDeviceOrientationGamepadCamera
  108454. */
  108455. getClassName(): string;
  108456. }
  108457. }
  108458. declare module BABYLON {
  108459. /**
  108460. * Base class of materials working in push mode in babylon JS
  108461. * @hidden
  108462. */
  108463. export class PushMaterial extends Material {
  108464. protected _activeEffect: Effect;
  108465. protected _normalMatrix: Matrix;
  108466. /**
  108467. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  108468. * This means that the material can keep using a previous shader while a new one is being compiled.
  108469. * This is mostly used when shader parallel compilation is supported (true by default)
  108470. */
  108471. allowShaderHotSwapping: boolean;
  108472. constructor(name: string, scene: Scene);
  108473. getEffect(): Effect;
  108474. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  108475. /**
  108476. * Binds the given world matrix to the active effect
  108477. *
  108478. * @param world the matrix to bind
  108479. */
  108480. bindOnlyWorldMatrix(world: Matrix): void;
  108481. /**
  108482. * Binds the given normal matrix to the active effect
  108483. *
  108484. * @param normalMatrix the matrix to bind
  108485. */
  108486. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  108487. bind(world: Matrix, mesh?: Mesh): void;
  108488. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  108489. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  108490. }
  108491. }
  108492. declare module BABYLON {
  108493. /**
  108494. * This groups all the flags used to control the materials channel.
  108495. */
  108496. export class MaterialFlags {
  108497. private static _DiffuseTextureEnabled;
  108498. /**
  108499. * Are diffuse textures enabled in the application.
  108500. */
  108501. static DiffuseTextureEnabled: boolean;
  108502. private static _AmbientTextureEnabled;
  108503. /**
  108504. * Are ambient textures enabled in the application.
  108505. */
  108506. static AmbientTextureEnabled: boolean;
  108507. private static _OpacityTextureEnabled;
  108508. /**
  108509. * Are opacity textures enabled in the application.
  108510. */
  108511. static OpacityTextureEnabled: boolean;
  108512. private static _ReflectionTextureEnabled;
  108513. /**
  108514. * Are reflection textures enabled in the application.
  108515. */
  108516. static ReflectionTextureEnabled: boolean;
  108517. private static _EmissiveTextureEnabled;
  108518. /**
  108519. * Are emissive textures enabled in the application.
  108520. */
  108521. static EmissiveTextureEnabled: boolean;
  108522. private static _SpecularTextureEnabled;
  108523. /**
  108524. * Are specular textures enabled in the application.
  108525. */
  108526. static SpecularTextureEnabled: boolean;
  108527. private static _BumpTextureEnabled;
  108528. /**
  108529. * Are bump textures enabled in the application.
  108530. */
  108531. static BumpTextureEnabled: boolean;
  108532. private static _LightmapTextureEnabled;
  108533. /**
  108534. * Are lightmap textures enabled in the application.
  108535. */
  108536. static LightmapTextureEnabled: boolean;
  108537. private static _RefractionTextureEnabled;
  108538. /**
  108539. * Are refraction textures enabled in the application.
  108540. */
  108541. static RefractionTextureEnabled: boolean;
  108542. private static _ColorGradingTextureEnabled;
  108543. /**
  108544. * Are color grading textures enabled in the application.
  108545. */
  108546. static ColorGradingTextureEnabled: boolean;
  108547. private static _FresnelEnabled;
  108548. /**
  108549. * Are fresnels enabled in the application.
  108550. */
  108551. static FresnelEnabled: boolean;
  108552. private static _ClearCoatTextureEnabled;
  108553. /**
  108554. * Are clear coat textures enabled in the application.
  108555. */
  108556. static ClearCoatTextureEnabled: boolean;
  108557. private static _ClearCoatBumpTextureEnabled;
  108558. /**
  108559. * Are clear coat bump textures enabled in the application.
  108560. */
  108561. static ClearCoatBumpTextureEnabled: boolean;
  108562. private static _ClearCoatTintTextureEnabled;
  108563. /**
  108564. * Are clear coat tint textures enabled in the application.
  108565. */
  108566. static ClearCoatTintTextureEnabled: boolean;
  108567. private static _SheenTextureEnabled;
  108568. /**
  108569. * Are sheen textures enabled in the application.
  108570. */
  108571. static SheenTextureEnabled: boolean;
  108572. private static _AnisotropicTextureEnabled;
  108573. /**
  108574. * Are anisotropic textures enabled in the application.
  108575. */
  108576. static AnisotropicTextureEnabled: boolean;
  108577. private static _ThicknessTextureEnabled;
  108578. /**
  108579. * Are thickness textures enabled in the application.
  108580. */
  108581. static ThicknessTextureEnabled: boolean;
  108582. }
  108583. }
  108584. declare module BABYLON {
  108585. /** @hidden */
  108586. export var defaultFragmentDeclaration: {
  108587. name: string;
  108588. shader: string;
  108589. };
  108590. }
  108591. declare module BABYLON {
  108592. /** @hidden */
  108593. export var defaultUboDeclaration: {
  108594. name: string;
  108595. shader: string;
  108596. };
  108597. }
  108598. declare module BABYLON {
  108599. /** @hidden */
  108600. export var lightFragmentDeclaration: {
  108601. name: string;
  108602. shader: string;
  108603. };
  108604. }
  108605. declare module BABYLON {
  108606. /** @hidden */
  108607. export var lightUboDeclaration: {
  108608. name: string;
  108609. shader: string;
  108610. };
  108611. }
  108612. declare module BABYLON {
  108613. /** @hidden */
  108614. export var lightsFragmentFunctions: {
  108615. name: string;
  108616. shader: string;
  108617. };
  108618. }
  108619. declare module BABYLON {
  108620. /** @hidden */
  108621. export var shadowsFragmentFunctions: {
  108622. name: string;
  108623. shader: string;
  108624. };
  108625. }
  108626. declare module BABYLON {
  108627. /** @hidden */
  108628. export var fresnelFunction: {
  108629. name: string;
  108630. shader: string;
  108631. };
  108632. }
  108633. declare module BABYLON {
  108634. /** @hidden */
  108635. export var reflectionFunction: {
  108636. name: string;
  108637. shader: string;
  108638. };
  108639. }
  108640. declare module BABYLON {
  108641. /** @hidden */
  108642. export var bumpFragmentFunctions: {
  108643. name: string;
  108644. shader: string;
  108645. };
  108646. }
  108647. declare module BABYLON {
  108648. /** @hidden */
  108649. export var logDepthDeclaration: {
  108650. name: string;
  108651. shader: string;
  108652. };
  108653. }
  108654. declare module BABYLON {
  108655. /** @hidden */
  108656. export var bumpFragment: {
  108657. name: string;
  108658. shader: string;
  108659. };
  108660. }
  108661. declare module BABYLON {
  108662. /** @hidden */
  108663. export var depthPrePass: {
  108664. name: string;
  108665. shader: string;
  108666. };
  108667. }
  108668. declare module BABYLON {
  108669. /** @hidden */
  108670. export var lightFragment: {
  108671. name: string;
  108672. shader: string;
  108673. };
  108674. }
  108675. declare module BABYLON {
  108676. /** @hidden */
  108677. export var logDepthFragment: {
  108678. name: string;
  108679. shader: string;
  108680. };
  108681. }
  108682. declare module BABYLON {
  108683. /** @hidden */
  108684. export var defaultPixelShader: {
  108685. name: string;
  108686. shader: string;
  108687. };
  108688. }
  108689. declare module BABYLON {
  108690. /** @hidden */
  108691. export var defaultVertexDeclaration: {
  108692. name: string;
  108693. shader: string;
  108694. };
  108695. }
  108696. declare module BABYLON {
  108697. /** @hidden */
  108698. export var bumpVertexDeclaration: {
  108699. name: string;
  108700. shader: string;
  108701. };
  108702. }
  108703. declare module BABYLON {
  108704. /** @hidden */
  108705. export var bumpVertex: {
  108706. name: string;
  108707. shader: string;
  108708. };
  108709. }
  108710. declare module BABYLON {
  108711. /** @hidden */
  108712. export var fogVertex: {
  108713. name: string;
  108714. shader: string;
  108715. };
  108716. }
  108717. declare module BABYLON {
  108718. /** @hidden */
  108719. export var shadowsVertex: {
  108720. name: string;
  108721. shader: string;
  108722. };
  108723. }
  108724. declare module BABYLON {
  108725. /** @hidden */
  108726. export var pointCloudVertex: {
  108727. name: string;
  108728. shader: string;
  108729. };
  108730. }
  108731. declare module BABYLON {
  108732. /** @hidden */
  108733. export var logDepthVertex: {
  108734. name: string;
  108735. shader: string;
  108736. };
  108737. }
  108738. declare module BABYLON {
  108739. /** @hidden */
  108740. export var defaultVertexShader: {
  108741. name: string;
  108742. shader: string;
  108743. };
  108744. }
  108745. declare module BABYLON {
  108746. /** @hidden */
  108747. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  108748. MAINUV1: boolean;
  108749. MAINUV2: boolean;
  108750. DIFFUSE: boolean;
  108751. DIFFUSEDIRECTUV: number;
  108752. AMBIENT: boolean;
  108753. AMBIENTDIRECTUV: number;
  108754. OPACITY: boolean;
  108755. OPACITYDIRECTUV: number;
  108756. OPACITYRGB: boolean;
  108757. REFLECTION: boolean;
  108758. EMISSIVE: boolean;
  108759. EMISSIVEDIRECTUV: number;
  108760. SPECULAR: boolean;
  108761. SPECULARDIRECTUV: number;
  108762. BUMP: boolean;
  108763. BUMPDIRECTUV: number;
  108764. PARALLAX: boolean;
  108765. PARALLAXOCCLUSION: boolean;
  108766. SPECULAROVERALPHA: boolean;
  108767. CLIPPLANE: boolean;
  108768. CLIPPLANE2: boolean;
  108769. CLIPPLANE3: boolean;
  108770. CLIPPLANE4: boolean;
  108771. ALPHATEST: boolean;
  108772. DEPTHPREPASS: boolean;
  108773. ALPHAFROMDIFFUSE: boolean;
  108774. POINTSIZE: boolean;
  108775. FOG: boolean;
  108776. SPECULARTERM: boolean;
  108777. DIFFUSEFRESNEL: boolean;
  108778. OPACITYFRESNEL: boolean;
  108779. REFLECTIONFRESNEL: boolean;
  108780. REFRACTIONFRESNEL: boolean;
  108781. EMISSIVEFRESNEL: boolean;
  108782. FRESNEL: boolean;
  108783. NORMAL: boolean;
  108784. UV1: boolean;
  108785. UV2: boolean;
  108786. VERTEXCOLOR: boolean;
  108787. VERTEXALPHA: boolean;
  108788. NUM_BONE_INFLUENCERS: number;
  108789. BonesPerMesh: number;
  108790. BONETEXTURE: boolean;
  108791. INSTANCES: boolean;
  108792. GLOSSINESS: boolean;
  108793. ROUGHNESS: boolean;
  108794. EMISSIVEASILLUMINATION: boolean;
  108795. LINKEMISSIVEWITHDIFFUSE: boolean;
  108796. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108797. LIGHTMAP: boolean;
  108798. LIGHTMAPDIRECTUV: number;
  108799. OBJECTSPACE_NORMALMAP: boolean;
  108800. USELIGHTMAPASSHADOWMAP: boolean;
  108801. REFLECTIONMAP_3D: boolean;
  108802. REFLECTIONMAP_SPHERICAL: boolean;
  108803. REFLECTIONMAP_PLANAR: boolean;
  108804. REFLECTIONMAP_CUBIC: boolean;
  108805. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108806. REFLECTIONMAP_PROJECTION: boolean;
  108807. REFLECTIONMAP_SKYBOX: boolean;
  108808. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108809. REFLECTIONMAP_EXPLICIT: boolean;
  108810. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108811. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108812. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108813. INVERTCUBICMAP: boolean;
  108814. LOGARITHMICDEPTH: boolean;
  108815. REFRACTION: boolean;
  108816. REFRACTIONMAP_3D: boolean;
  108817. REFLECTIONOVERALPHA: boolean;
  108818. TWOSIDEDLIGHTING: boolean;
  108819. SHADOWFLOAT: boolean;
  108820. MORPHTARGETS: boolean;
  108821. MORPHTARGETS_NORMAL: boolean;
  108822. MORPHTARGETS_TANGENT: boolean;
  108823. MORPHTARGETS_UV: boolean;
  108824. NUM_MORPH_INFLUENCERS: number;
  108825. NONUNIFORMSCALING: boolean;
  108826. PREMULTIPLYALPHA: boolean;
  108827. IMAGEPROCESSING: boolean;
  108828. VIGNETTE: boolean;
  108829. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108830. VIGNETTEBLENDMODEOPAQUE: boolean;
  108831. TONEMAPPING: boolean;
  108832. TONEMAPPING_ACES: boolean;
  108833. CONTRAST: boolean;
  108834. COLORCURVES: boolean;
  108835. COLORGRADING: boolean;
  108836. COLORGRADING3D: boolean;
  108837. SAMPLER3DGREENDEPTH: boolean;
  108838. SAMPLER3DBGRMAP: boolean;
  108839. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108840. MULTIVIEW: boolean;
  108841. /**
  108842. * If the reflection texture on this material is in linear color space
  108843. * @hidden
  108844. */
  108845. IS_REFLECTION_LINEAR: boolean;
  108846. /**
  108847. * If the refraction texture on this material is in linear color space
  108848. * @hidden
  108849. */
  108850. IS_REFRACTION_LINEAR: boolean;
  108851. EXPOSURE: boolean;
  108852. constructor();
  108853. setReflectionMode(modeToEnable: string): void;
  108854. }
  108855. /**
  108856. * This is the default material used in Babylon. It is the best trade off between quality
  108857. * and performances.
  108858. * @see http://doc.babylonjs.com/babylon101/materials
  108859. */
  108860. export class StandardMaterial extends PushMaterial {
  108861. private _diffuseTexture;
  108862. /**
  108863. * The basic texture of the material as viewed under a light.
  108864. */
  108865. diffuseTexture: Nullable<BaseTexture>;
  108866. private _ambientTexture;
  108867. /**
  108868. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108869. */
  108870. ambientTexture: Nullable<BaseTexture>;
  108871. private _opacityTexture;
  108872. /**
  108873. * Define the transparency of the material from a texture.
  108874. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108875. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108876. */
  108877. opacityTexture: Nullable<BaseTexture>;
  108878. private _reflectionTexture;
  108879. /**
  108880. * Define the texture used to display the reflection.
  108881. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108882. */
  108883. reflectionTexture: Nullable<BaseTexture>;
  108884. private _emissiveTexture;
  108885. /**
  108886. * Define texture of the material as if self lit.
  108887. * This will be mixed in the final result even in the absence of light.
  108888. */
  108889. emissiveTexture: Nullable<BaseTexture>;
  108890. private _specularTexture;
  108891. /**
  108892. * Define how the color and intensity of the highlight given by the light in the material.
  108893. */
  108894. specularTexture: Nullable<BaseTexture>;
  108895. private _bumpTexture;
  108896. /**
  108897. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108898. * 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.
  108899. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  108900. */
  108901. bumpTexture: Nullable<BaseTexture>;
  108902. private _lightmapTexture;
  108903. /**
  108904. * Complex lighting can be computationally expensive to compute at runtime.
  108905. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108906. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  108907. */
  108908. lightmapTexture: Nullable<BaseTexture>;
  108909. private _refractionTexture;
  108910. /**
  108911. * Define the texture used to display the refraction.
  108912. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108913. */
  108914. refractionTexture: Nullable<BaseTexture>;
  108915. /**
  108916. * The color of the material lit by the environmental background lighting.
  108917. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108918. */
  108919. ambientColor: Color3;
  108920. /**
  108921. * The basic color of the material as viewed under a light.
  108922. */
  108923. diffuseColor: Color3;
  108924. /**
  108925. * Define how the color and intensity of the highlight given by the light in the material.
  108926. */
  108927. specularColor: Color3;
  108928. /**
  108929. * Define the color of the material as if self lit.
  108930. * This will be mixed in the final result even in the absence of light.
  108931. */
  108932. emissiveColor: Color3;
  108933. /**
  108934. * Defines how sharp are the highlights in the material.
  108935. * The bigger the value the sharper giving a more glossy feeling to the result.
  108936. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108937. */
  108938. specularPower: number;
  108939. private _useAlphaFromDiffuseTexture;
  108940. /**
  108941. * Does the transparency come from the diffuse texture alpha channel.
  108942. */
  108943. useAlphaFromDiffuseTexture: boolean;
  108944. private _useEmissiveAsIllumination;
  108945. /**
  108946. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108947. */
  108948. useEmissiveAsIllumination: boolean;
  108949. private _linkEmissiveWithDiffuse;
  108950. /**
  108951. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108952. * the emissive level when the final color is close to one.
  108953. */
  108954. linkEmissiveWithDiffuse: boolean;
  108955. private _useSpecularOverAlpha;
  108956. /**
  108957. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108958. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108959. */
  108960. useSpecularOverAlpha: boolean;
  108961. private _useReflectionOverAlpha;
  108962. /**
  108963. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108964. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108965. */
  108966. useReflectionOverAlpha: boolean;
  108967. private _disableLighting;
  108968. /**
  108969. * Does lights from the scene impacts this material.
  108970. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108971. */
  108972. disableLighting: boolean;
  108973. private _useObjectSpaceNormalMap;
  108974. /**
  108975. * Allows using an object space normal map (instead of tangent space).
  108976. */
  108977. useObjectSpaceNormalMap: boolean;
  108978. private _useParallax;
  108979. /**
  108980. * Is parallax enabled or not.
  108981. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108982. */
  108983. useParallax: boolean;
  108984. private _useParallaxOcclusion;
  108985. /**
  108986. * Is parallax occlusion enabled or not.
  108987. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108988. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108989. */
  108990. useParallaxOcclusion: boolean;
  108991. /**
  108992. * 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.
  108993. */
  108994. parallaxScaleBias: number;
  108995. private _roughness;
  108996. /**
  108997. * Helps to define how blurry the reflections should appears in the material.
  108998. */
  108999. roughness: number;
  109000. /**
  109001. * In case of refraction, define the value of the index of refraction.
  109002. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109003. */
  109004. indexOfRefraction: number;
  109005. /**
  109006. * Invert the refraction texture alongside the y axis.
  109007. * It can be useful with procedural textures or probe for instance.
  109008. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109009. */
  109010. invertRefractionY: boolean;
  109011. /**
  109012. * Defines the alpha limits in alpha test mode.
  109013. */
  109014. alphaCutOff: number;
  109015. private _useLightmapAsShadowmap;
  109016. /**
  109017. * In case of light mapping, define whether the map contains light or shadow informations.
  109018. */
  109019. useLightmapAsShadowmap: boolean;
  109020. private _diffuseFresnelParameters;
  109021. /**
  109022. * Define the diffuse fresnel parameters of the material.
  109023. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109024. */
  109025. diffuseFresnelParameters: FresnelParameters;
  109026. private _opacityFresnelParameters;
  109027. /**
  109028. * Define the opacity fresnel parameters of the material.
  109029. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109030. */
  109031. opacityFresnelParameters: FresnelParameters;
  109032. private _reflectionFresnelParameters;
  109033. /**
  109034. * Define the reflection fresnel parameters of the material.
  109035. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109036. */
  109037. reflectionFresnelParameters: FresnelParameters;
  109038. private _refractionFresnelParameters;
  109039. /**
  109040. * Define the refraction fresnel parameters of the material.
  109041. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109042. */
  109043. refractionFresnelParameters: FresnelParameters;
  109044. private _emissiveFresnelParameters;
  109045. /**
  109046. * Define the emissive fresnel parameters of the material.
  109047. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109048. */
  109049. emissiveFresnelParameters: FresnelParameters;
  109050. private _useReflectionFresnelFromSpecular;
  109051. /**
  109052. * If true automatically deducts the fresnels values from the material specularity.
  109053. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109054. */
  109055. useReflectionFresnelFromSpecular: boolean;
  109056. private _useGlossinessFromSpecularMapAlpha;
  109057. /**
  109058. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109059. */
  109060. useGlossinessFromSpecularMapAlpha: boolean;
  109061. private _maxSimultaneousLights;
  109062. /**
  109063. * Defines the maximum number of lights that can be used in the material
  109064. */
  109065. maxSimultaneousLights: number;
  109066. private _invertNormalMapX;
  109067. /**
  109068. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109069. */
  109070. invertNormalMapX: boolean;
  109071. private _invertNormalMapY;
  109072. /**
  109073. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109074. */
  109075. invertNormalMapY: boolean;
  109076. private _twoSidedLighting;
  109077. /**
  109078. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109079. */
  109080. twoSidedLighting: boolean;
  109081. /**
  109082. * Default configuration related to image processing available in the standard Material.
  109083. */
  109084. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109085. /**
  109086. * Gets the image processing configuration used either in this material.
  109087. */
  109088. /**
  109089. * Sets the Default image processing configuration used either in the this material.
  109090. *
  109091. * If sets to null, the scene one is in use.
  109092. */
  109093. imageProcessingConfiguration: ImageProcessingConfiguration;
  109094. /**
  109095. * Keep track of the image processing observer to allow dispose and replace.
  109096. */
  109097. private _imageProcessingObserver;
  109098. /**
  109099. * Attaches a new image processing configuration to the Standard Material.
  109100. * @param configuration
  109101. */
  109102. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109103. /**
  109104. * Gets wether the color curves effect is enabled.
  109105. */
  109106. /**
  109107. * Sets wether the color curves effect is enabled.
  109108. */
  109109. cameraColorCurvesEnabled: boolean;
  109110. /**
  109111. * Gets wether the color grading effect is enabled.
  109112. */
  109113. /**
  109114. * Gets wether the color grading effect is enabled.
  109115. */
  109116. cameraColorGradingEnabled: boolean;
  109117. /**
  109118. * Gets wether tonemapping is enabled or not.
  109119. */
  109120. /**
  109121. * Sets wether tonemapping is enabled or not
  109122. */
  109123. cameraToneMappingEnabled: boolean;
  109124. /**
  109125. * The camera exposure used on this material.
  109126. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109127. * This corresponds to a photographic exposure.
  109128. */
  109129. /**
  109130. * The camera exposure used on this material.
  109131. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109132. * This corresponds to a photographic exposure.
  109133. */
  109134. cameraExposure: number;
  109135. /**
  109136. * Gets The camera contrast used on this material.
  109137. */
  109138. /**
  109139. * Sets The camera contrast used on this material.
  109140. */
  109141. cameraContrast: number;
  109142. /**
  109143. * Gets the Color Grading 2D Lookup Texture.
  109144. */
  109145. /**
  109146. * Sets the Color Grading 2D Lookup Texture.
  109147. */
  109148. cameraColorGradingTexture: Nullable<BaseTexture>;
  109149. /**
  109150. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109151. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109152. * 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;
  109153. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109154. */
  109155. /**
  109156. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109157. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109158. * 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;
  109159. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109160. */
  109161. cameraColorCurves: Nullable<ColorCurves>;
  109162. /**
  109163. * Custom callback helping to override the default shader used in the material.
  109164. */
  109165. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  109166. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109167. protected _worldViewProjectionMatrix: Matrix;
  109168. protected _globalAmbientColor: Color3;
  109169. protected _useLogarithmicDepth: boolean;
  109170. protected _rebuildInParallel: boolean;
  109171. /**
  109172. * Instantiates a new standard material.
  109173. * This is the default material used in Babylon. It is the best trade off between quality
  109174. * and performances.
  109175. * @see http://doc.babylonjs.com/babylon101/materials
  109176. * @param name Define the name of the material in the scene
  109177. * @param scene Define the scene the material belong to
  109178. */
  109179. constructor(name: string, scene: Scene);
  109180. /**
  109181. * Gets a boolean indicating that current material needs to register RTT
  109182. */
  109183. readonly hasRenderTargetTextures: boolean;
  109184. /**
  109185. * Gets the current class name of the material e.g. "StandardMaterial"
  109186. * Mainly use in serialization.
  109187. * @returns the class name
  109188. */
  109189. getClassName(): string;
  109190. /**
  109191. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109192. * You can try switching to logarithmic depth.
  109193. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109194. */
  109195. useLogarithmicDepth: boolean;
  109196. /**
  109197. * Specifies if the material will require alpha blending
  109198. * @returns a boolean specifying if alpha blending is needed
  109199. */
  109200. needAlphaBlending(): boolean;
  109201. /**
  109202. * Specifies if this material should be rendered in alpha test mode
  109203. * @returns a boolean specifying if an alpha test is needed.
  109204. */
  109205. needAlphaTesting(): boolean;
  109206. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109207. /**
  109208. * Get the texture used for alpha test purpose.
  109209. * @returns the diffuse texture in case of the standard material.
  109210. */
  109211. getAlphaTestTexture(): Nullable<BaseTexture>;
  109212. /**
  109213. * Get if the submesh is ready to be used and all its information available.
  109214. * Child classes can use it to update shaders
  109215. * @param mesh defines the mesh to check
  109216. * @param subMesh defines which submesh to check
  109217. * @param useInstances specifies that instances should be used
  109218. * @returns a boolean indicating that the submesh is ready or not
  109219. */
  109220. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109221. /**
  109222. * Builds the material UBO layouts.
  109223. * Used internally during the effect preparation.
  109224. */
  109225. buildUniformLayout(): void;
  109226. /**
  109227. * Unbinds the material from the mesh
  109228. */
  109229. unbind(): void;
  109230. /**
  109231. * Binds the submesh to this material by preparing the effect and shader to draw
  109232. * @param world defines the world transformation matrix
  109233. * @param mesh defines the mesh containing the submesh
  109234. * @param subMesh defines the submesh to bind the material to
  109235. */
  109236. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109237. /**
  109238. * Get the list of animatables in the material.
  109239. * @returns the list of animatables object used in the material
  109240. */
  109241. getAnimatables(): IAnimatable[];
  109242. /**
  109243. * Gets the active textures from the material
  109244. * @returns an array of textures
  109245. */
  109246. getActiveTextures(): BaseTexture[];
  109247. /**
  109248. * Specifies if the material uses a texture
  109249. * @param texture defines the texture to check against the material
  109250. * @returns a boolean specifying if the material uses the texture
  109251. */
  109252. hasTexture(texture: BaseTexture): boolean;
  109253. /**
  109254. * Disposes the material
  109255. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109256. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109257. */
  109258. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109259. /**
  109260. * Makes a duplicate of the material, and gives it a new name
  109261. * @param name defines the new name for the duplicated material
  109262. * @returns the cloned material
  109263. */
  109264. clone(name: string): StandardMaterial;
  109265. /**
  109266. * Serializes this material in a JSON representation
  109267. * @returns the serialized material object
  109268. */
  109269. serialize(): any;
  109270. /**
  109271. * Creates a standard material from parsed material data
  109272. * @param source defines the JSON representation of the material
  109273. * @param scene defines the hosting scene
  109274. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109275. * @returns a new standard material
  109276. */
  109277. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109278. /**
  109279. * Are diffuse textures enabled in the application.
  109280. */
  109281. static DiffuseTextureEnabled: boolean;
  109282. /**
  109283. * Are ambient textures enabled in the application.
  109284. */
  109285. static AmbientTextureEnabled: boolean;
  109286. /**
  109287. * Are opacity textures enabled in the application.
  109288. */
  109289. static OpacityTextureEnabled: boolean;
  109290. /**
  109291. * Are reflection textures enabled in the application.
  109292. */
  109293. static ReflectionTextureEnabled: boolean;
  109294. /**
  109295. * Are emissive textures enabled in the application.
  109296. */
  109297. static EmissiveTextureEnabled: boolean;
  109298. /**
  109299. * Are specular textures enabled in the application.
  109300. */
  109301. static SpecularTextureEnabled: boolean;
  109302. /**
  109303. * Are bump textures enabled in the application.
  109304. */
  109305. static BumpTextureEnabled: boolean;
  109306. /**
  109307. * Are lightmap textures enabled in the application.
  109308. */
  109309. static LightmapTextureEnabled: boolean;
  109310. /**
  109311. * Are refraction textures enabled in the application.
  109312. */
  109313. static RefractionTextureEnabled: boolean;
  109314. /**
  109315. * Are color grading textures enabled in the application.
  109316. */
  109317. static ColorGradingTextureEnabled: boolean;
  109318. /**
  109319. * Are fresnels enabled in the application.
  109320. */
  109321. static FresnelEnabled: boolean;
  109322. }
  109323. }
  109324. declare module BABYLON {
  109325. /** @hidden */
  109326. export var imageProcessingPixelShader: {
  109327. name: string;
  109328. shader: string;
  109329. };
  109330. }
  109331. declare module BABYLON {
  109332. /**
  109333. * ImageProcessingPostProcess
  109334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  109335. */
  109336. export class ImageProcessingPostProcess extends PostProcess {
  109337. /**
  109338. * Default configuration related to image processing available in the PBR Material.
  109339. */
  109340. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109341. /**
  109342. * Gets the image processing configuration used either in this material.
  109343. */
  109344. /**
  109345. * Sets the Default image processing configuration used either in the this material.
  109346. *
  109347. * If sets to null, the scene one is in use.
  109348. */
  109349. imageProcessingConfiguration: ImageProcessingConfiguration;
  109350. /**
  109351. * Keep track of the image processing observer to allow dispose and replace.
  109352. */
  109353. private _imageProcessingObserver;
  109354. /**
  109355. * Attaches a new image processing configuration to the PBR Material.
  109356. * @param configuration
  109357. */
  109358. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  109359. /**
  109360. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109361. */
  109362. /**
  109363. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109364. */
  109365. colorCurves: Nullable<ColorCurves>;
  109366. /**
  109367. * Gets wether the color curves effect is enabled.
  109368. */
  109369. /**
  109370. * Sets wether the color curves effect is enabled.
  109371. */
  109372. colorCurvesEnabled: boolean;
  109373. /**
  109374. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109375. */
  109376. /**
  109377. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109378. */
  109379. colorGradingTexture: Nullable<BaseTexture>;
  109380. /**
  109381. * Gets wether the color grading effect is enabled.
  109382. */
  109383. /**
  109384. * Gets wether the color grading effect is enabled.
  109385. */
  109386. colorGradingEnabled: boolean;
  109387. /**
  109388. * Gets exposure used in the effect.
  109389. */
  109390. /**
  109391. * Sets exposure used in the effect.
  109392. */
  109393. exposure: number;
  109394. /**
  109395. * Gets wether tonemapping is enabled or not.
  109396. */
  109397. /**
  109398. * Sets wether tonemapping is enabled or not
  109399. */
  109400. toneMappingEnabled: boolean;
  109401. /**
  109402. * Gets the type of tone mapping effect.
  109403. */
  109404. /**
  109405. * Sets the type of tone mapping effect.
  109406. */
  109407. toneMappingType: number;
  109408. /**
  109409. * Gets contrast used in the effect.
  109410. */
  109411. /**
  109412. * Sets contrast used in the effect.
  109413. */
  109414. contrast: number;
  109415. /**
  109416. * Gets Vignette stretch size.
  109417. */
  109418. /**
  109419. * Sets Vignette stretch size.
  109420. */
  109421. vignetteStretch: number;
  109422. /**
  109423. * Gets Vignette centre X Offset.
  109424. */
  109425. /**
  109426. * Sets Vignette centre X Offset.
  109427. */
  109428. vignetteCentreX: number;
  109429. /**
  109430. * Gets Vignette centre Y Offset.
  109431. */
  109432. /**
  109433. * Sets Vignette centre Y Offset.
  109434. */
  109435. vignetteCentreY: number;
  109436. /**
  109437. * Gets Vignette weight or intensity of the vignette effect.
  109438. */
  109439. /**
  109440. * Sets Vignette weight or intensity of the vignette effect.
  109441. */
  109442. vignetteWeight: number;
  109443. /**
  109444. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109445. * if vignetteEnabled is set to true.
  109446. */
  109447. /**
  109448. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109449. * if vignetteEnabled is set to true.
  109450. */
  109451. vignetteColor: Color4;
  109452. /**
  109453. * Gets Camera field of view used by the Vignette effect.
  109454. */
  109455. /**
  109456. * Sets Camera field of view used by the Vignette effect.
  109457. */
  109458. vignetteCameraFov: number;
  109459. /**
  109460. * Gets the vignette blend mode allowing different kind of effect.
  109461. */
  109462. /**
  109463. * Sets the vignette blend mode allowing different kind of effect.
  109464. */
  109465. vignetteBlendMode: number;
  109466. /**
  109467. * Gets wether the vignette effect is enabled.
  109468. */
  109469. /**
  109470. * Sets wether the vignette effect is enabled.
  109471. */
  109472. vignetteEnabled: boolean;
  109473. private _fromLinearSpace;
  109474. /**
  109475. * Gets wether the input of the processing is in Gamma or Linear Space.
  109476. */
  109477. /**
  109478. * Sets wether the input of the processing is in Gamma or Linear Space.
  109479. */
  109480. fromLinearSpace: boolean;
  109481. /**
  109482. * Defines cache preventing GC.
  109483. */
  109484. private _defines;
  109485. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  109486. /**
  109487. * "ImageProcessingPostProcess"
  109488. * @returns "ImageProcessingPostProcess"
  109489. */
  109490. getClassName(): string;
  109491. protected _updateParameters(): void;
  109492. dispose(camera?: Camera): void;
  109493. }
  109494. }
  109495. declare module BABYLON {
  109496. /**
  109497. * Class containing static functions to help procedurally build meshes
  109498. */
  109499. export class GroundBuilder {
  109500. /**
  109501. * Creates a ground mesh
  109502. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109503. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109505. * @param name defines the name of the mesh
  109506. * @param options defines the options used to create the mesh
  109507. * @param scene defines the hosting scene
  109508. * @returns the ground mesh
  109509. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109510. */
  109511. static CreateGround(name: string, options: {
  109512. width?: number;
  109513. height?: number;
  109514. subdivisions?: number;
  109515. subdivisionsX?: number;
  109516. subdivisionsY?: number;
  109517. updatable?: boolean;
  109518. }, scene: any): Mesh;
  109519. /**
  109520. * Creates a tiled ground mesh
  109521. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109522. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109523. * * 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
  109524. * * 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
  109525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109526. * @param name defines the name of the mesh
  109527. * @param options defines the options used to create the mesh
  109528. * @param scene defines the hosting scene
  109529. * @returns the tiled ground mesh
  109530. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109531. */
  109532. static CreateTiledGround(name: string, options: {
  109533. xmin: number;
  109534. zmin: number;
  109535. xmax: number;
  109536. zmax: number;
  109537. subdivisions?: {
  109538. w: number;
  109539. h: number;
  109540. };
  109541. precision?: {
  109542. w: number;
  109543. h: number;
  109544. };
  109545. updatable?: boolean;
  109546. }, scene?: Nullable<Scene>): Mesh;
  109547. /**
  109548. * Creates a ground mesh from a height map
  109549. * * The parameter `url` sets the URL of the height map image resource.
  109550. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109551. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109552. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109553. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109554. * * 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.
  109555. * * 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).
  109556. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109558. * @param name defines the name of the mesh
  109559. * @param url defines the url to the height map
  109560. * @param options defines the options used to create the mesh
  109561. * @param scene defines the hosting scene
  109562. * @returns the ground mesh
  109563. * @see https://doc.babylonjs.com/babylon101/height_map
  109564. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109565. */
  109566. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109567. width?: number;
  109568. height?: number;
  109569. subdivisions?: number;
  109570. minHeight?: number;
  109571. maxHeight?: number;
  109572. colorFilter?: Color3;
  109573. alphaFilter?: number;
  109574. updatable?: boolean;
  109575. onReady?: (mesh: GroundMesh) => void;
  109576. }, scene?: Nullable<Scene>): GroundMesh;
  109577. }
  109578. }
  109579. declare module BABYLON {
  109580. /**
  109581. * Class containing static functions to help procedurally build meshes
  109582. */
  109583. export class TorusBuilder {
  109584. /**
  109585. * Creates a torus mesh
  109586. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109587. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109588. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109592. * @param name defines the name of the mesh
  109593. * @param options defines the options used to create the mesh
  109594. * @param scene defines the hosting scene
  109595. * @returns the torus mesh
  109596. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109597. */
  109598. static CreateTorus(name: string, options: {
  109599. diameter?: number;
  109600. thickness?: number;
  109601. tessellation?: number;
  109602. updatable?: boolean;
  109603. sideOrientation?: number;
  109604. frontUVs?: Vector4;
  109605. backUVs?: Vector4;
  109606. }, scene: any): Mesh;
  109607. }
  109608. }
  109609. declare module BABYLON {
  109610. /**
  109611. * Class containing static functions to help procedurally build meshes
  109612. */
  109613. export class CylinderBuilder {
  109614. /**
  109615. * Creates a cylinder or a cone mesh
  109616. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109617. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109618. * * 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.
  109619. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109620. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109621. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109622. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109623. * * 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).
  109624. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109625. * * 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).
  109626. * * 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
  109627. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109628. * * 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
  109629. * * 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.
  109630. * * If `enclose` is false, a ring surface is one element.
  109631. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109632. * * 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
  109633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109634. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109636. * @param name defines the name of the mesh
  109637. * @param options defines the options used to create the mesh
  109638. * @param scene defines the hosting scene
  109639. * @returns the cylinder mesh
  109640. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109641. */
  109642. static CreateCylinder(name: string, options: {
  109643. height?: number;
  109644. diameterTop?: number;
  109645. diameterBottom?: number;
  109646. diameter?: number;
  109647. tessellation?: number;
  109648. subdivisions?: number;
  109649. arc?: number;
  109650. faceColors?: Color4[];
  109651. faceUV?: Vector4[];
  109652. updatable?: boolean;
  109653. hasRings?: boolean;
  109654. enclose?: boolean;
  109655. cap?: number;
  109656. sideOrientation?: number;
  109657. frontUVs?: Vector4;
  109658. backUVs?: Vector4;
  109659. }, scene: any): Mesh;
  109660. }
  109661. }
  109662. declare module BABYLON {
  109663. /**
  109664. * Options to modify the vr teleportation behavior.
  109665. */
  109666. export interface VRTeleportationOptions {
  109667. /**
  109668. * The name of the mesh which should be used as the teleportation floor. (default: null)
  109669. */
  109670. floorMeshName?: string;
  109671. /**
  109672. * A list of meshes to be used as the teleportation floor. (default: empty)
  109673. */
  109674. floorMeshes?: Mesh[];
  109675. }
  109676. /**
  109677. * Options to modify the vr experience helper's behavior.
  109678. */
  109679. export interface VRExperienceHelperOptions extends WebVROptions {
  109680. /**
  109681. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  109682. */
  109683. createDeviceOrientationCamera?: boolean;
  109684. /**
  109685. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  109686. */
  109687. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  109688. /**
  109689. * Uses the main button on the controller to toggle the laser casted. (default: true)
  109690. */
  109691. laserToggle?: boolean;
  109692. /**
  109693. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  109694. */
  109695. floorMeshes?: Mesh[];
  109696. /**
  109697. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  109698. */
  109699. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  109700. }
  109701. /**
  109702. * Event containing information after VR has been entered
  109703. */
  109704. export class OnAfterEnteringVRObservableEvent {
  109705. /**
  109706. * If entering vr was successful
  109707. */
  109708. success: boolean;
  109709. }
  109710. /**
  109711. * Helps to quickly add VR support to an existing scene.
  109712. * See http://doc.babylonjs.com/how_to/webvr_helper
  109713. */
  109714. export class VRExperienceHelper {
  109715. /** Options to modify the vr experience helper's behavior. */
  109716. webVROptions: VRExperienceHelperOptions;
  109717. private _scene;
  109718. private _position;
  109719. private _btnVR;
  109720. private _btnVRDisplayed;
  109721. private _webVRsupported;
  109722. private _webVRready;
  109723. private _webVRrequesting;
  109724. private _webVRpresenting;
  109725. private _hasEnteredVR;
  109726. private _fullscreenVRpresenting;
  109727. private _inputElement;
  109728. private _webVRCamera;
  109729. private _vrDeviceOrientationCamera;
  109730. private _deviceOrientationCamera;
  109731. private _existingCamera;
  109732. private _onKeyDown;
  109733. private _onVrDisplayPresentChange;
  109734. private _onVRDisplayChanged;
  109735. private _onVRRequestPresentStart;
  109736. private _onVRRequestPresentComplete;
  109737. /**
  109738. * 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)
  109739. */
  109740. enableGazeEvenWhenNoPointerLock: boolean;
  109741. /**
  109742. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  109743. */
  109744. exitVROnDoubleTap: boolean;
  109745. /**
  109746. * Observable raised right before entering VR.
  109747. */
  109748. onEnteringVRObservable: Observable<VRExperienceHelper>;
  109749. /**
  109750. * Observable raised when entering VR has completed.
  109751. */
  109752. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  109753. /**
  109754. * Observable raised when exiting VR.
  109755. */
  109756. onExitingVRObservable: Observable<VRExperienceHelper>;
  109757. /**
  109758. * Observable raised when controller mesh is loaded.
  109759. */
  109760. onControllerMeshLoadedObservable: Observable<WebVRController>;
  109761. /** Return this.onEnteringVRObservable
  109762. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  109763. */
  109764. readonly onEnteringVR: Observable<VRExperienceHelper>;
  109765. /** Return this.onExitingVRObservable
  109766. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  109767. */
  109768. readonly onExitingVR: Observable<VRExperienceHelper>;
  109769. /** Return this.onControllerMeshLoadedObservable
  109770. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  109771. */
  109772. readonly onControllerMeshLoaded: Observable<WebVRController>;
  109773. private _rayLength;
  109774. private _useCustomVRButton;
  109775. private _teleportationRequested;
  109776. private _teleportActive;
  109777. private _floorMeshName;
  109778. private _floorMeshesCollection;
  109779. private _rotationAllowed;
  109780. private _teleportBackwardsVector;
  109781. private _teleportationTarget;
  109782. private _isDefaultTeleportationTarget;
  109783. private _postProcessMove;
  109784. private _teleportationFillColor;
  109785. private _teleportationBorderColor;
  109786. private _rotationAngle;
  109787. private _haloCenter;
  109788. private _cameraGazer;
  109789. private _padSensibilityUp;
  109790. private _padSensibilityDown;
  109791. private _leftController;
  109792. private _rightController;
  109793. /**
  109794. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  109795. */
  109796. onNewMeshSelected: Observable<AbstractMesh>;
  109797. /**
  109798. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  109799. * This observable will provide the mesh and the controller used to select the mesh
  109800. */
  109801. onMeshSelectedWithController: Observable<{
  109802. mesh: AbstractMesh;
  109803. controller: WebVRController;
  109804. }>;
  109805. /**
  109806. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  109807. */
  109808. onNewMeshPicked: Observable<PickingInfo>;
  109809. private _circleEase;
  109810. /**
  109811. * Observable raised before camera teleportation
  109812. */
  109813. onBeforeCameraTeleport: Observable<Vector3>;
  109814. /**
  109815. * Observable raised after camera teleportation
  109816. */
  109817. onAfterCameraTeleport: Observable<Vector3>;
  109818. /**
  109819. * Observable raised when current selected mesh gets unselected
  109820. */
  109821. onSelectedMeshUnselected: Observable<AbstractMesh>;
  109822. private _raySelectionPredicate;
  109823. /**
  109824. * To be optionaly changed by user to define custom ray selection
  109825. */
  109826. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  109827. /**
  109828. * To be optionaly changed by user to define custom selection logic (after ray selection)
  109829. */
  109830. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  109831. /**
  109832. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  109833. */
  109834. teleportationEnabled: boolean;
  109835. private _defaultHeight;
  109836. private _teleportationInitialized;
  109837. private _interactionsEnabled;
  109838. private _interactionsRequested;
  109839. private _displayGaze;
  109840. private _displayLaserPointer;
  109841. /**
  109842. * The mesh used to display where the user is going to teleport.
  109843. */
  109844. /**
  109845. * Sets the mesh to be used to display where the user is going to teleport.
  109846. */
  109847. teleportationTarget: Mesh;
  109848. /**
  109849. * 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
  109850. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  109851. * See http://doc.babylonjs.com/resources/baking_transformations
  109852. */
  109853. gazeTrackerMesh: Mesh;
  109854. /**
  109855. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  109856. */
  109857. updateGazeTrackerScale: boolean;
  109858. /**
  109859. * If the gaze trackers color should be updated when selecting meshes
  109860. */
  109861. updateGazeTrackerColor: boolean;
  109862. /**
  109863. * If the controller laser color should be updated when selecting meshes
  109864. */
  109865. updateControllerLaserColor: boolean;
  109866. /**
  109867. * The gaze tracking mesh corresponding to the left controller
  109868. */
  109869. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  109870. /**
  109871. * The gaze tracking mesh corresponding to the right controller
  109872. */
  109873. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  109874. /**
  109875. * If the ray of the gaze should be displayed.
  109876. */
  109877. /**
  109878. * Sets if the ray of the gaze should be displayed.
  109879. */
  109880. displayGaze: boolean;
  109881. /**
  109882. * If the ray of the LaserPointer should be displayed.
  109883. */
  109884. /**
  109885. * Sets if the ray of the LaserPointer should be displayed.
  109886. */
  109887. displayLaserPointer: boolean;
  109888. /**
  109889. * The deviceOrientationCamera used as the camera when not in VR.
  109890. */
  109891. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  109892. /**
  109893. * Based on the current WebVR support, returns the current VR camera used.
  109894. */
  109895. readonly currentVRCamera: Nullable<Camera>;
  109896. /**
  109897. * The webVRCamera which is used when in VR.
  109898. */
  109899. readonly webVRCamera: WebVRFreeCamera;
  109900. /**
  109901. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  109902. */
  109903. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  109904. /**
  109905. * The html button that is used to trigger entering into VR.
  109906. */
  109907. readonly vrButton: Nullable<HTMLButtonElement>;
  109908. private readonly _teleportationRequestInitiated;
  109909. /**
  109910. * Defines wether or not Pointer lock should be requested when switching to
  109911. * full screen.
  109912. */
  109913. requestPointerLockOnFullScreen: boolean;
  109914. /**
  109915. * Instantiates a VRExperienceHelper.
  109916. * Helps to quickly add VR support to an existing scene.
  109917. * @param scene The scene the VRExperienceHelper belongs to.
  109918. * @param webVROptions Options to modify the vr experience helper's behavior.
  109919. */
  109920. constructor(scene: Scene,
  109921. /** Options to modify the vr experience helper's behavior. */
  109922. webVROptions?: VRExperienceHelperOptions);
  109923. private _onDefaultMeshLoaded;
  109924. private _onResize;
  109925. private _onFullscreenChange;
  109926. /**
  109927. * Gets a value indicating if we are currently in VR mode.
  109928. */
  109929. readonly isInVRMode: boolean;
  109930. private onVrDisplayPresentChange;
  109931. private onVRDisplayChanged;
  109932. private moveButtonToBottomRight;
  109933. private displayVRButton;
  109934. private updateButtonVisibility;
  109935. private _cachedAngularSensibility;
  109936. /**
  109937. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  109938. * Otherwise, will use the fullscreen API.
  109939. */
  109940. enterVR(): void;
  109941. /**
  109942. * Attempt to exit VR, or fullscreen.
  109943. */
  109944. exitVR(): void;
  109945. /**
  109946. * The position of the vr experience helper.
  109947. */
  109948. /**
  109949. * Sets the position of the vr experience helper.
  109950. */
  109951. position: Vector3;
  109952. /**
  109953. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  109954. */
  109955. enableInteractions(): void;
  109956. private readonly _noControllerIsActive;
  109957. private beforeRender;
  109958. private _isTeleportationFloor;
  109959. /**
  109960. * Adds a floor mesh to be used for teleportation.
  109961. * @param floorMesh the mesh to be used for teleportation.
  109962. */
  109963. addFloorMesh(floorMesh: Mesh): void;
  109964. /**
  109965. * Removes a floor mesh from being used for teleportation.
  109966. * @param floorMesh the mesh to be removed.
  109967. */
  109968. removeFloorMesh(floorMesh: Mesh): void;
  109969. /**
  109970. * Enables interactions and teleportation using the VR controllers and gaze.
  109971. * @param vrTeleportationOptions options to modify teleportation behavior.
  109972. */
  109973. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  109974. private _onNewGamepadConnected;
  109975. private _tryEnableInteractionOnController;
  109976. private _onNewGamepadDisconnected;
  109977. private _enableInteractionOnController;
  109978. private _checkTeleportWithRay;
  109979. private _checkRotate;
  109980. private _checkTeleportBackwards;
  109981. private _enableTeleportationOnController;
  109982. private _createTeleportationCircles;
  109983. private _displayTeleportationTarget;
  109984. private _hideTeleportationTarget;
  109985. private _rotateCamera;
  109986. private _moveTeleportationSelectorTo;
  109987. private _workingVector;
  109988. private _workingQuaternion;
  109989. private _workingMatrix;
  109990. /**
  109991. * Teleports the users feet to the desired location
  109992. * @param location The location where the user's feet should be placed
  109993. */
  109994. teleportCamera(location: Vector3): void;
  109995. private _convertNormalToDirectionOfRay;
  109996. private _castRayAndSelectObject;
  109997. private _notifySelectedMeshUnselected;
  109998. /**
  109999. * Sets the color of the laser ray from the vr controllers.
  110000. * @param color new color for the ray.
  110001. */
  110002. changeLaserColor(color: Color3): void;
  110003. /**
  110004. * Sets the color of the ray from the vr headsets gaze.
  110005. * @param color new color for the ray.
  110006. */
  110007. changeGazeColor(color: Color3): void;
  110008. /**
  110009. * Exits VR and disposes of the vr experience helper
  110010. */
  110011. dispose(): void;
  110012. /**
  110013. * Gets the name of the VRExperienceHelper class
  110014. * @returns "VRExperienceHelper"
  110015. */
  110016. getClassName(): string;
  110017. }
  110018. }
  110019. declare module BABYLON {
  110020. /**
  110021. * States of the webXR experience
  110022. */
  110023. export enum WebXRState {
  110024. /**
  110025. * Transitioning to being in XR mode
  110026. */
  110027. ENTERING_XR = 0,
  110028. /**
  110029. * Transitioning to non XR mode
  110030. */
  110031. EXITING_XR = 1,
  110032. /**
  110033. * In XR mode and presenting
  110034. */
  110035. IN_XR = 2,
  110036. /**
  110037. * Not entered XR mode
  110038. */
  110039. NOT_IN_XR = 3
  110040. }
  110041. /**
  110042. * Abstraction of the XR render target
  110043. */
  110044. export interface WebXRRenderTarget extends IDisposable {
  110045. /**
  110046. * xrpresent context of the canvas which can be used to display/mirror xr content
  110047. */
  110048. canvasContext: WebGLRenderingContext;
  110049. /**
  110050. * xr layer for the canvas
  110051. */
  110052. xrLayer: Nullable<XRWebGLLayer>;
  110053. /**
  110054. * Initializes the xr layer for the session
  110055. * @param xrSession xr session
  110056. * @returns a promise that will resolve once the XR Layer has been created
  110057. */
  110058. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110059. }
  110060. }
  110061. declare module BABYLON {
  110062. /**
  110063. * COnfiguration object for WebXR output canvas
  110064. */
  110065. export class WebXRManagedOutputCanvasOptions {
  110066. /**
  110067. * Options for this XR Layer output
  110068. */
  110069. canvasOptions: XRWebGLLayerOptions;
  110070. /**
  110071. * CSS styling for a newly created canvas (if not provided)
  110072. */
  110073. newCanvasCssStyle?: string;
  110074. /**
  110075. * Get the default values of the configuration object
  110076. * @returns default values of this configuration object
  110077. */
  110078. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  110079. }
  110080. /**
  110081. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110082. */
  110083. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110084. private configuration;
  110085. private _engine;
  110086. private _canvas;
  110087. /**
  110088. * xrpresent context of the canvas which can be used to display/mirror xr content
  110089. */
  110090. canvasContext: WebGLRenderingContext;
  110091. /**
  110092. * xr layer for the canvas
  110093. */
  110094. xrLayer: Nullable<XRWebGLLayer>;
  110095. /**
  110096. * Initializes the xr layer for the session
  110097. * @param xrSession xr session
  110098. * @returns a promise that will resolve once the XR Layer has been created
  110099. */
  110100. initializeXRLayerAsync(xrSession: any): any;
  110101. /**
  110102. * Initializes the canvas to be added/removed upon entering/exiting xr
  110103. * @param engine the Babylon engine
  110104. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110105. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110106. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  110107. */
  110108. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  110109. /**
  110110. * Disposes of the object
  110111. */
  110112. dispose(): void;
  110113. private _setManagedOutputCanvas;
  110114. private _addCanvas;
  110115. private _removeCanvas;
  110116. }
  110117. }
  110118. declare module BABYLON {
  110119. /**
  110120. * Manages an XRSession to work with Babylon's engine
  110121. * @see https://doc.babylonjs.com/how_to/webxr
  110122. */
  110123. export class WebXRSessionManager implements IDisposable {
  110124. private scene;
  110125. /**
  110126. * Fires every time a new xrFrame arrives which can be used to update the camera
  110127. */
  110128. onXRFrameObservable: Observable<any>;
  110129. /**
  110130. * Fires when the xr session is ended either by the device or manually done
  110131. */
  110132. onXRSessionEnded: Observable<any>;
  110133. /**
  110134. * Underlying xr session
  110135. */
  110136. session: XRSession;
  110137. /**
  110138. * Type of reference space used when creating the session
  110139. */
  110140. referenceSpace: XRReferenceSpace;
  110141. /**
  110142. * Current XR frame
  110143. */
  110144. currentFrame: Nullable<XRFrame>;
  110145. private _xrNavigator;
  110146. private baseLayer;
  110147. private _rttProvider;
  110148. private _sessionEnded;
  110149. /**
  110150. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110151. * @param scene The scene which the session should be created for
  110152. */
  110153. constructor(scene: Scene);
  110154. /**
  110155. * Initializes the manager
  110156. * After initialization enterXR can be called to start an XR session
  110157. * @returns Promise which resolves after it is initialized
  110158. */
  110159. initializeAsync(): Promise<void>;
  110160. /**
  110161. * Initializes an xr session
  110162. * @param xrSessionMode mode to initialize
  110163. * @param optionalFeatures defines optional values to pass to the session builder
  110164. * @returns a promise which will resolve once the session has been initialized
  110165. */
  110166. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  110167. /**
  110168. * Sets the reference space on the xr session
  110169. * @param referenceSpace space to set
  110170. * @returns a promise that will resolve once the reference space has been set
  110171. */
  110172. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110173. /**
  110174. * Updates the render state of the session
  110175. * @param state state to set
  110176. * @returns a promise that resolves once the render state has been updated
  110177. */
  110178. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110179. /**
  110180. * Starts rendering to the xr layer
  110181. * @returns a promise that will resolve once rendering has started
  110182. */
  110183. startRenderingToXRAsync(): Promise<void>;
  110184. /**
  110185. * Gets the correct render target texture to be rendered this frame for this eye
  110186. * @param eye the eye for which to get the render target
  110187. * @returns the render target for the specified eye
  110188. */
  110189. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110190. /**
  110191. * Stops the xrSession and restores the renderloop
  110192. * @returns Promise which resolves after it exits XR
  110193. */
  110194. exitXRAsync(): Promise<void>;
  110195. /**
  110196. * Checks if a session would be supported for the creation options specified
  110197. * @param sessionMode session mode to check if supported eg. immersive-vr
  110198. * @returns true if supported
  110199. */
  110200. supportsSessionAsync(sessionMode: XRSessionMode): any;
  110201. /**
  110202. * Creates a WebXRRenderTarget object for the XR session
  110203. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110204. * @param options optional options to provide when creating a new render target
  110205. * @returns a WebXR render target to which the session can render
  110206. */
  110207. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  110208. /**
  110209. * @hidden
  110210. * Converts the render layer of xrSession to a render target
  110211. * @param session session to create render target for
  110212. * @param scene scene the new render target should be created for
  110213. */
  110214. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110215. /**
  110216. * Disposes of the session manager
  110217. */
  110218. dispose(): void;
  110219. }
  110220. }
  110221. declare module BABYLON {
  110222. /**
  110223. * WebXR Camera which holds the views for the xrSession
  110224. * @see https://doc.babylonjs.com/how_to/webxr
  110225. */
  110226. export class WebXRCamera extends FreeCamera {
  110227. private static _TmpMatrix;
  110228. /**
  110229. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110230. * @param name the name of the camera
  110231. * @param scene the scene to add the camera to
  110232. */
  110233. constructor(name: string, scene: Scene);
  110234. private _updateNumberOfRigCameras;
  110235. /** @hidden */
  110236. _updateForDualEyeDebugging(): void;
  110237. /**
  110238. * Updates the cameras position from the current pose information of the XR session
  110239. * @param xrSessionManager the session containing pose information
  110240. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110241. */
  110242. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110243. }
  110244. }
  110245. declare module BABYLON {
  110246. /**
  110247. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110248. * @see https://doc.babylonjs.com/how_to/webxr
  110249. */
  110250. export class WebXRExperienceHelper implements IDisposable {
  110251. private scene;
  110252. /**
  110253. * 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
  110254. */
  110255. container: AbstractMesh;
  110256. /**
  110257. * Camera used to render xr content
  110258. */
  110259. camera: WebXRCamera;
  110260. /**
  110261. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110262. */
  110263. state: WebXRState;
  110264. private _setState;
  110265. private static _TmpVector;
  110266. /**
  110267. * Fires when the state of the experience helper has changed
  110268. */
  110269. onStateChangedObservable: Observable<WebXRState>;
  110270. /** Session manager used to keep track of xr session */
  110271. sessionManager: WebXRSessionManager;
  110272. private _nonVRCamera;
  110273. private _originalSceneAutoClear;
  110274. private _supported;
  110275. /**
  110276. * Creates the experience helper
  110277. * @param scene the scene to attach the experience helper to
  110278. * @returns a promise for the experience helper
  110279. */
  110280. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110281. /**
  110282. * Creates a WebXRExperienceHelper
  110283. * @param scene The scene the helper should be created in
  110284. */
  110285. private constructor();
  110286. /**
  110287. * Exits XR mode and returns the scene to its original state
  110288. * @returns promise that resolves after xr mode has exited
  110289. */
  110290. exitXRAsync(): Promise<void>;
  110291. /**
  110292. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110293. * @param sessionMode options for the XR session
  110294. * @param referenceSpaceType frame of reference of the XR session
  110295. * @param renderTarget the output canvas that will be used to enter XR mode
  110296. * @returns promise that resolves after xr mode has entered
  110297. */
  110298. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  110299. /**
  110300. * Updates the global position of the camera by moving the camera's container
  110301. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110302. * @param position The desired global position of the camera
  110303. */
  110304. setPositionOfCameraUsingContainer(position: Vector3): void;
  110305. /**
  110306. * Rotates the xr camera by rotating the camera's container around the camera's position
  110307. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110308. * @param rotation the desired quaternion rotation to apply to the camera
  110309. */
  110310. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110311. /**
  110312. * Disposes of the experience helper
  110313. */
  110314. dispose(): void;
  110315. }
  110316. }
  110317. declare module BABYLON {
  110318. /**
  110319. * Button which can be used to enter a different mode of XR
  110320. */
  110321. export class WebXREnterExitUIButton {
  110322. /** button element */
  110323. element: HTMLElement;
  110324. /** XR initialization options for the button */
  110325. sessionMode: XRSessionMode;
  110326. /** Reference space type */
  110327. referenceSpaceType: XRReferenceSpaceType;
  110328. /**
  110329. * Creates a WebXREnterExitUIButton
  110330. * @param element button element
  110331. * @param sessionMode XR initialization session mode
  110332. * @param referenceSpaceType the type of reference space to be used
  110333. */
  110334. constructor(
  110335. /** button element */
  110336. element: HTMLElement,
  110337. /** XR initialization options for the button */
  110338. sessionMode: XRSessionMode,
  110339. /** Reference space type */
  110340. referenceSpaceType: XRReferenceSpaceType);
  110341. /**
  110342. * Overwritable function which can be used to update the button's visuals when the state changes
  110343. * @param activeButton the current active button in the UI
  110344. */
  110345. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  110346. }
  110347. /**
  110348. * Options to create the webXR UI
  110349. */
  110350. export class WebXREnterExitUIOptions {
  110351. /**
  110352. * Context to enter xr with
  110353. */
  110354. renderTarget?: Nullable<WebXRRenderTarget>;
  110355. /**
  110356. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  110357. */
  110358. customButtons?: Array<WebXREnterExitUIButton>;
  110359. }
  110360. /**
  110361. * UI to allow the user to enter/exit XR mode
  110362. */
  110363. export class WebXREnterExitUI implements IDisposable {
  110364. private scene;
  110365. private _overlay;
  110366. private _buttons;
  110367. private _activeButton;
  110368. /**
  110369. * Fired every time the active button is changed.
  110370. *
  110371. * When xr is entered via a button that launches xr that button will be the callback parameter
  110372. *
  110373. * When exiting xr the callback parameter will be null)
  110374. */
  110375. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  110376. /**
  110377. * Creates UI to allow the user to enter/exit XR mode
  110378. * @param scene the scene to add the ui to
  110379. * @param helper the xr experience helper to enter/exit xr with
  110380. * @param options options to configure the UI
  110381. * @returns the created ui
  110382. */
  110383. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  110384. private constructor();
  110385. private _updateButtons;
  110386. /**
  110387. * Disposes of the object
  110388. */
  110389. dispose(): void;
  110390. }
  110391. }
  110392. declare module BABYLON {
  110393. /**
  110394. * Represents an XR input
  110395. */
  110396. export class WebXRController {
  110397. private scene;
  110398. /** The underlying input source for the controller */
  110399. inputSource: XRInputSource;
  110400. private parentContainer;
  110401. /**
  110402. * 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
  110403. */
  110404. grip?: AbstractMesh;
  110405. /**
  110406. * Pointer which can be used to select objects or attach a visible laser to
  110407. */
  110408. pointer: AbstractMesh;
  110409. private _gamepadMode;
  110410. /**
  110411. * If available, this is the gamepad object related to this controller.
  110412. * Using this object it is possible to get click events and trackpad changes of the
  110413. * webxr controller that is currently being used.
  110414. */
  110415. gamepadController?: WebVRController;
  110416. /**
  110417. * Event that fires when the controller is removed/disposed
  110418. */
  110419. onDisposeObservable: Observable<{}>;
  110420. private _tmpMatrix;
  110421. private _tmpQuaternion;
  110422. private _tmpVector;
  110423. /**
  110424. * Creates the controller
  110425. * @see https://doc.babylonjs.com/how_to/webxr
  110426. * @param scene the scene which the controller should be associated to
  110427. * @param inputSource the underlying input source for the controller
  110428. * @param parentContainer parent that the controller meshes should be children of
  110429. */
  110430. constructor(scene: Scene,
  110431. /** The underlying input source for the controller */
  110432. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110433. /**
  110434. * Updates the controller pose based on the given XRFrame
  110435. * @param xrFrame xr frame to update the pose with
  110436. * @param referenceSpace reference space to use
  110437. */
  110438. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110439. /**
  110440. * Gets a world space ray coming from the controller
  110441. * @param result the resulting ray
  110442. */
  110443. getWorldPointerRayToRef(result: Ray): void;
  110444. /**
  110445. * Get the scene associated with this controller
  110446. * @returns the scene object
  110447. */
  110448. getScene(): Scene;
  110449. /**
  110450. * Disposes of the object
  110451. */
  110452. dispose(): void;
  110453. }
  110454. }
  110455. declare module BABYLON {
  110456. /**
  110457. * XR input used to track XR inputs such as controllers/rays
  110458. */
  110459. export class WebXRInput implements IDisposable {
  110460. /**
  110461. * Base experience the input listens to
  110462. */
  110463. baseExperience: WebXRExperienceHelper;
  110464. /**
  110465. * XR controllers being tracked
  110466. */
  110467. controllers: Array<WebXRController>;
  110468. private _frameObserver;
  110469. private _stateObserver;
  110470. /**
  110471. * Event when a controller has been connected/added
  110472. */
  110473. onControllerAddedObservable: Observable<WebXRController>;
  110474. /**
  110475. * Event when a controller has been removed/disconnected
  110476. */
  110477. onControllerRemovedObservable: Observable<WebXRController>;
  110478. /**
  110479. * Initializes the WebXRInput
  110480. * @param baseExperience experience helper which the input should be created for
  110481. */
  110482. constructor(
  110483. /**
  110484. * Base experience the input listens to
  110485. */
  110486. baseExperience: WebXRExperienceHelper);
  110487. private _onInputSourcesChange;
  110488. private _addAndRemoveControllers;
  110489. /**
  110490. * Disposes of the object
  110491. */
  110492. dispose(): void;
  110493. }
  110494. }
  110495. declare module BABYLON {
  110496. /**
  110497. * Enables teleportation
  110498. */
  110499. export class WebXRControllerTeleportation {
  110500. private _teleportationFillColor;
  110501. private _teleportationBorderColor;
  110502. private _tmpRay;
  110503. private _tmpVector;
  110504. /**
  110505. * Creates a WebXRControllerTeleportation
  110506. * @param input input manager to add teleportation to
  110507. * @param floorMeshes floormeshes which can be teleported to
  110508. */
  110509. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  110510. }
  110511. }
  110512. declare module BABYLON {
  110513. /**
  110514. * Handles pointer input automatically for the pointer of XR controllers
  110515. */
  110516. export class WebXRControllerPointerSelection {
  110517. private static _idCounter;
  110518. private _tmpRay;
  110519. /**
  110520. * Creates a WebXRControllerPointerSelection
  110521. * @param input input manager to setup pointer selection
  110522. */
  110523. constructor(input: WebXRInput);
  110524. private _convertNormalToDirectionOfRay;
  110525. private _updatePointerDistance;
  110526. }
  110527. }
  110528. declare module BABYLON {
  110529. /**
  110530. * Class used to represent data loading progression
  110531. */
  110532. export class SceneLoaderProgressEvent {
  110533. /** defines if data length to load can be evaluated */
  110534. readonly lengthComputable: boolean;
  110535. /** defines the loaded data length */
  110536. readonly loaded: number;
  110537. /** defines the data length to load */
  110538. readonly total: number;
  110539. /**
  110540. * Create a new progress event
  110541. * @param lengthComputable defines if data length to load can be evaluated
  110542. * @param loaded defines the loaded data length
  110543. * @param total defines the data length to load
  110544. */
  110545. constructor(
  110546. /** defines if data length to load can be evaluated */
  110547. lengthComputable: boolean,
  110548. /** defines the loaded data length */
  110549. loaded: number,
  110550. /** defines the data length to load */
  110551. total: number);
  110552. /**
  110553. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110554. * @param event defines the source event
  110555. * @returns a new SceneLoaderProgressEvent
  110556. */
  110557. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110558. }
  110559. /**
  110560. * Interface used by SceneLoader plugins to define supported file extensions
  110561. */
  110562. export interface ISceneLoaderPluginExtensions {
  110563. /**
  110564. * Defines the list of supported extensions
  110565. */
  110566. [extension: string]: {
  110567. isBinary: boolean;
  110568. };
  110569. }
  110570. /**
  110571. * Interface used by SceneLoader plugin factory
  110572. */
  110573. export interface ISceneLoaderPluginFactory {
  110574. /**
  110575. * Defines the name of the factory
  110576. */
  110577. name: string;
  110578. /**
  110579. * Function called to create a new plugin
  110580. * @return the new plugin
  110581. */
  110582. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110583. /**
  110584. * The callback that returns true if the data can be directly loaded.
  110585. * @param data string containing the file data
  110586. * @returns if the data can be loaded directly
  110587. */
  110588. canDirectLoad?(data: string): boolean;
  110589. }
  110590. /**
  110591. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110592. */
  110593. export interface ISceneLoaderPluginBase {
  110594. /**
  110595. * The friendly name of this plugin.
  110596. */
  110597. name: string;
  110598. /**
  110599. * The file extensions supported by this plugin.
  110600. */
  110601. extensions: string | ISceneLoaderPluginExtensions;
  110602. /**
  110603. * The callback called when loading from a url.
  110604. * @param scene scene loading this url
  110605. * @param url url to load
  110606. * @param onSuccess callback called when the file successfully loads
  110607. * @param onProgress callback called while file is loading (if the server supports this mode)
  110608. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110609. * @param onError callback called when the file fails to load
  110610. * @returns a file request object
  110611. */
  110612. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110613. /**
  110614. * The callback called when loading from a file object.
  110615. * @param scene scene loading this file
  110616. * @param file defines the file to load
  110617. * @param onSuccess defines the callback to call when data is loaded
  110618. * @param onProgress defines the callback to call during loading process
  110619. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110620. * @param onError defines the callback to call when an error occurs
  110621. * @returns a file request object
  110622. */
  110623. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110624. /**
  110625. * The callback that returns true if the data can be directly loaded.
  110626. * @param data string containing the file data
  110627. * @returns if the data can be loaded directly
  110628. */
  110629. canDirectLoad?(data: string): boolean;
  110630. /**
  110631. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  110632. * @param scene scene loading this data
  110633. * @param data string containing the data
  110634. * @returns data to pass to the plugin
  110635. */
  110636. directLoad?(scene: Scene, data: string): any;
  110637. /**
  110638. * The callback that allows custom handling of the root url based on the response url.
  110639. * @param rootUrl the original root url
  110640. * @param responseURL the response url if available
  110641. * @returns the new root url
  110642. */
  110643. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  110644. }
  110645. /**
  110646. * Interface used to define a SceneLoader plugin
  110647. */
  110648. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  110649. /**
  110650. * Import meshes into a scene.
  110651. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110652. * @param scene The scene to import into
  110653. * @param data The data to import
  110654. * @param rootUrl The root url for scene and resources
  110655. * @param meshes The meshes array to import into
  110656. * @param particleSystems The particle systems array to import into
  110657. * @param skeletons The skeletons array to import into
  110658. * @param onError The callback when import fails
  110659. * @returns True if successful or false otherwise
  110660. */
  110661. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  110662. /**
  110663. * Load into a scene.
  110664. * @param scene The scene to load into
  110665. * @param data The data to import
  110666. * @param rootUrl The root url for scene and resources
  110667. * @param onError The callback when import fails
  110668. * @returns True if successful or false otherwise
  110669. */
  110670. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  110671. /**
  110672. * Load into an asset container.
  110673. * @param scene The scene to load into
  110674. * @param data The data to import
  110675. * @param rootUrl The root url for scene and resources
  110676. * @param onError The callback when import fails
  110677. * @returns The loaded asset container
  110678. */
  110679. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  110680. }
  110681. /**
  110682. * Interface used to define an async SceneLoader plugin
  110683. */
  110684. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  110685. /**
  110686. * Import meshes into a scene.
  110687. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110688. * @param scene The scene to import into
  110689. * @param data The data to import
  110690. * @param rootUrl The root url for scene and resources
  110691. * @param onProgress The callback when the load progresses
  110692. * @param fileName Defines the name of the file to load
  110693. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  110694. */
  110695. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  110696. meshes: AbstractMesh[];
  110697. particleSystems: IParticleSystem[];
  110698. skeletons: Skeleton[];
  110699. animationGroups: AnimationGroup[];
  110700. }>;
  110701. /**
  110702. * Load into a scene.
  110703. * @param scene The scene to load into
  110704. * @param data The data to import
  110705. * @param rootUrl The root url for scene and resources
  110706. * @param onProgress The callback when the load progresses
  110707. * @param fileName Defines the name of the file to load
  110708. * @returns Nothing
  110709. */
  110710. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110711. /**
  110712. * Load into an asset container.
  110713. * @param scene The scene to load into
  110714. * @param data The data to import
  110715. * @param rootUrl The root url for scene and resources
  110716. * @param onProgress The callback when the load progresses
  110717. * @param fileName Defines the name of the file to load
  110718. * @returns The loaded asset container
  110719. */
  110720. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110721. }
  110722. /**
  110723. * Class used to load scene from various file formats using registered plugins
  110724. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110725. */
  110726. export class SceneLoader {
  110727. /**
  110728. * No logging while loading
  110729. */
  110730. static readonly NO_LOGGING: number;
  110731. /**
  110732. * Minimal logging while loading
  110733. */
  110734. static readonly MINIMAL_LOGGING: number;
  110735. /**
  110736. * Summary logging while loading
  110737. */
  110738. static readonly SUMMARY_LOGGING: number;
  110739. /**
  110740. * Detailled logging while loading
  110741. */
  110742. static readonly DETAILED_LOGGING: number;
  110743. /**
  110744. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110745. */
  110746. static ForceFullSceneLoadingForIncremental: boolean;
  110747. /**
  110748. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110749. */
  110750. static ShowLoadingScreen: boolean;
  110751. /**
  110752. * Defines the current logging level (while loading the scene)
  110753. * @ignorenaming
  110754. */
  110755. static loggingLevel: number;
  110756. /**
  110757. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110758. */
  110759. static CleanBoneMatrixWeights: boolean;
  110760. /**
  110761. * Event raised when a plugin is used to load a scene
  110762. */
  110763. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  110764. private static _registeredPlugins;
  110765. private static _getDefaultPlugin;
  110766. private static _getPluginForExtension;
  110767. private static _getPluginForDirectLoad;
  110768. private static _getPluginForFilename;
  110769. private static _getDirectLoad;
  110770. private static _loadData;
  110771. private static _getFileInfo;
  110772. /**
  110773. * Gets a plugin that can load the given extension
  110774. * @param extension defines the extension to load
  110775. * @returns a plugin or null if none works
  110776. */
  110777. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  110778. /**
  110779. * Gets a boolean indicating that the given extension can be loaded
  110780. * @param extension defines the extension to load
  110781. * @returns true if the extension is supported
  110782. */
  110783. static IsPluginForExtensionAvailable(extension: string): boolean;
  110784. /**
  110785. * Adds a new plugin to the list of registered plugins
  110786. * @param plugin defines the plugin to add
  110787. */
  110788. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  110789. /**
  110790. * Import meshes into a scene
  110791. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110792. * @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)
  110793. * @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)
  110794. * @param scene the instance of BABYLON.Scene to append to
  110795. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  110796. * @param onProgress a callback with a progress event for each file being loaded
  110797. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110798. * @param pluginExtension the extension used to determine the plugin
  110799. * @returns The loaded plugin
  110800. */
  110801. 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>;
  110802. /**
  110803. * Import meshes into a scene
  110804. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110805. * @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)
  110806. * @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)
  110807. * @param scene the instance of BABYLON.Scene to append to
  110808. * @param onProgress a callback with a progress event for each file being loaded
  110809. * @param pluginExtension the extension used to determine the plugin
  110810. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  110811. */
  110812. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  110813. meshes: AbstractMesh[];
  110814. particleSystems: IParticleSystem[];
  110815. skeletons: Skeleton[];
  110816. animationGroups: AnimationGroup[];
  110817. }>;
  110818. /**
  110819. * Load a scene
  110820. * @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)
  110821. * @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)
  110822. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110823. * @param onSuccess a callback with the scene when import succeeds
  110824. * @param onProgress a callback with a progress event for each file being loaded
  110825. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110826. * @param pluginExtension the extension used to determine the plugin
  110827. * @returns The loaded plugin
  110828. */
  110829. 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>;
  110830. /**
  110831. * Load a scene
  110832. * @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)
  110833. * @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)
  110834. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110835. * @param onProgress a callback with a progress event for each file being loaded
  110836. * @param pluginExtension the extension used to determine the plugin
  110837. * @returns The loaded scene
  110838. */
  110839. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110840. /**
  110841. * Append a scene
  110842. * @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)
  110843. * @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)
  110844. * @param scene is the instance of BABYLON.Scene to append to
  110845. * @param onSuccess a callback with the scene when import succeeds
  110846. * @param onProgress a callback with a progress event for each file being loaded
  110847. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110848. * @param pluginExtension the extension used to determine the plugin
  110849. * @returns The loaded plugin
  110850. */
  110851. 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>;
  110852. /**
  110853. * Append a scene
  110854. * @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)
  110855. * @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)
  110856. * @param scene is the instance of BABYLON.Scene to append to
  110857. * @param onProgress a callback with a progress event for each file being loaded
  110858. * @param pluginExtension the extension used to determine the plugin
  110859. * @returns The given scene
  110860. */
  110861. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110862. /**
  110863. * Load a scene into an asset container
  110864. * @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)
  110865. * @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)
  110866. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110867. * @param onSuccess a callback with the scene when import succeeds
  110868. * @param onProgress a callback with a progress event for each file being loaded
  110869. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110870. * @param pluginExtension the extension used to determine the plugin
  110871. * @returns The loaded plugin
  110872. */
  110873. 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>;
  110874. /**
  110875. * Load a scene into an asset container
  110876. * @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)
  110877. * @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)
  110878. * @param scene is the instance of Scene to append to
  110879. * @param onProgress a callback with a progress event for each file being loaded
  110880. * @param pluginExtension the extension used to determine the plugin
  110881. * @returns The loaded asset container
  110882. */
  110883. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  110884. }
  110885. }
  110886. declare module BABYLON {
  110887. /**
  110888. * Generic Controller
  110889. */
  110890. export class GenericController extends WebVRController {
  110891. /**
  110892. * Base Url for the controller model.
  110893. */
  110894. static readonly MODEL_BASE_URL: string;
  110895. /**
  110896. * File name for the controller model.
  110897. */
  110898. static readonly MODEL_FILENAME: string;
  110899. /**
  110900. * Creates a new GenericController from a gamepad
  110901. * @param vrGamepad the gamepad that the controller should be created from
  110902. */
  110903. constructor(vrGamepad: any);
  110904. /**
  110905. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110906. * @param scene scene in which to add meshes
  110907. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110908. */
  110909. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110910. /**
  110911. * Called once for each button that changed state since the last frame
  110912. * @param buttonIdx Which button index changed
  110913. * @param state New state of the button
  110914. * @param changes Which properties on the state changed since last frame
  110915. */
  110916. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110917. }
  110918. }
  110919. declare module BABYLON {
  110920. /**
  110921. * Defines the WindowsMotionController object that the state of the windows motion controller
  110922. */
  110923. export class WindowsMotionController extends WebVRController {
  110924. /**
  110925. * The base url used to load the left and right controller models
  110926. */
  110927. static MODEL_BASE_URL: string;
  110928. /**
  110929. * The name of the left controller model file
  110930. */
  110931. static MODEL_LEFT_FILENAME: string;
  110932. /**
  110933. * The name of the right controller model file
  110934. */
  110935. static MODEL_RIGHT_FILENAME: string;
  110936. /**
  110937. * The controller name prefix for this controller type
  110938. */
  110939. static readonly GAMEPAD_ID_PREFIX: string;
  110940. /**
  110941. * The controller id pattern for this controller type
  110942. */
  110943. private static readonly GAMEPAD_ID_PATTERN;
  110944. private _loadedMeshInfo;
  110945. private readonly _mapping;
  110946. /**
  110947. * Fired when the trackpad on this controller is clicked
  110948. */
  110949. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  110950. /**
  110951. * Fired when the trackpad on this controller is modified
  110952. */
  110953. onTrackpadValuesChangedObservable: Observable<StickValues>;
  110954. /**
  110955. * The current x and y values of this controller's trackpad
  110956. */
  110957. trackpad: StickValues;
  110958. /**
  110959. * Creates a new WindowsMotionController from a gamepad
  110960. * @param vrGamepad the gamepad that the controller should be created from
  110961. */
  110962. constructor(vrGamepad: any);
  110963. /**
  110964. * Fired when the trigger on this controller is modified
  110965. */
  110966. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110967. /**
  110968. * Fired when the menu button on this controller is modified
  110969. */
  110970. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110971. /**
  110972. * Fired when the grip button on this controller is modified
  110973. */
  110974. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110975. /**
  110976. * Fired when the thumbstick button on this controller is modified
  110977. */
  110978. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110979. /**
  110980. * Fired when the touchpad button on this controller is modified
  110981. */
  110982. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110983. /**
  110984. * Fired when the touchpad values on this controller are modified
  110985. */
  110986. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  110987. private _updateTrackpad;
  110988. /**
  110989. * Called once per frame by the engine.
  110990. */
  110991. update(): void;
  110992. /**
  110993. * Called once for each button that changed state since the last frame
  110994. * @param buttonIdx Which button index changed
  110995. * @param state New state of the button
  110996. * @param changes Which properties on the state changed since last frame
  110997. */
  110998. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110999. /**
  111000. * Moves the buttons on the controller mesh based on their current state
  111001. * @param buttonName the name of the button to move
  111002. * @param buttonValue the value of the button which determines the buttons new position
  111003. */
  111004. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  111005. /**
  111006. * Moves the axis on the controller mesh based on its current state
  111007. * @param axis the index of the axis
  111008. * @param axisValue the value of the axis which determines the meshes new position
  111009. * @hidden
  111010. */
  111011. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  111012. /**
  111013. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111014. * @param scene scene in which to add meshes
  111015. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111016. */
  111017. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  111018. /**
  111019. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  111020. * can be transformed by button presses and axes values, based on this._mapping.
  111021. *
  111022. * @param scene scene in which the meshes exist
  111023. * @param meshes list of meshes that make up the controller model to process
  111024. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  111025. */
  111026. private processModel;
  111027. private createMeshInfo;
  111028. /**
  111029. * Gets the ray of the controller in the direction the controller is pointing
  111030. * @param length the length the resulting ray should be
  111031. * @returns a ray in the direction the controller is pointing
  111032. */
  111033. getForwardRay(length?: number): Ray;
  111034. /**
  111035. * Disposes of the controller
  111036. */
  111037. dispose(): void;
  111038. }
  111039. }
  111040. declare module BABYLON {
  111041. /**
  111042. * Oculus Touch Controller
  111043. */
  111044. export class OculusTouchController extends WebVRController {
  111045. /**
  111046. * Base Url for the controller model.
  111047. */
  111048. static MODEL_BASE_URL: string;
  111049. /**
  111050. * File name for the left controller model.
  111051. */
  111052. static MODEL_LEFT_FILENAME: string;
  111053. /**
  111054. * File name for the right controller model.
  111055. */
  111056. static MODEL_RIGHT_FILENAME: string;
  111057. /**
  111058. * Base Url for the Quest controller model.
  111059. */
  111060. static QUEST_MODEL_BASE_URL: string;
  111061. /**
  111062. * @hidden
  111063. * If the controllers are running on a device that needs the updated Quest controller models
  111064. */
  111065. static _IsQuest: boolean;
  111066. /**
  111067. * Fired when the secondary trigger on this controller is modified
  111068. */
  111069. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111070. /**
  111071. * Fired when the thumb rest on this controller is modified
  111072. */
  111073. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111074. /**
  111075. * Creates a new OculusTouchController from a gamepad
  111076. * @param vrGamepad the gamepad that the controller should be created from
  111077. */
  111078. constructor(vrGamepad: any);
  111079. /**
  111080. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111081. * @param scene scene in which to add meshes
  111082. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111083. */
  111084. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111085. /**
  111086. * Fired when the A button on this controller is modified
  111087. */
  111088. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111089. /**
  111090. * Fired when the B button on this controller is modified
  111091. */
  111092. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111093. /**
  111094. * Fired when the X button on this controller is modified
  111095. */
  111096. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111097. /**
  111098. * Fired when the Y button on this controller is modified
  111099. */
  111100. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111101. /**
  111102. * Called once for each button that changed state since the last frame
  111103. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111104. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111105. * 2) secondary trigger (same)
  111106. * 3) A (right) X (left), touch, pressed = value
  111107. * 4) B / Y
  111108. * 5) thumb rest
  111109. * @param buttonIdx Which button index changed
  111110. * @param state New state of the button
  111111. * @param changes Which properties on the state changed since last frame
  111112. */
  111113. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111114. }
  111115. }
  111116. declare module BABYLON {
  111117. /**
  111118. * Vive Controller
  111119. */
  111120. export class ViveController extends WebVRController {
  111121. /**
  111122. * Base Url for the controller model.
  111123. */
  111124. static MODEL_BASE_URL: string;
  111125. /**
  111126. * File name for the controller model.
  111127. */
  111128. static MODEL_FILENAME: string;
  111129. /**
  111130. * Creates a new ViveController from a gamepad
  111131. * @param vrGamepad the gamepad that the controller should be created from
  111132. */
  111133. constructor(vrGamepad: any);
  111134. /**
  111135. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111136. * @param scene scene in which to add meshes
  111137. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111138. */
  111139. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111140. /**
  111141. * Fired when the left button on this controller is modified
  111142. */
  111143. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111144. /**
  111145. * Fired when the right button on this controller is modified
  111146. */
  111147. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111148. /**
  111149. * Fired when the menu button on this controller is modified
  111150. */
  111151. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111152. /**
  111153. * Called once for each button that changed state since the last frame
  111154. * Vive mapping:
  111155. * 0: touchpad
  111156. * 1: trigger
  111157. * 2: left AND right buttons
  111158. * 3: menu button
  111159. * @param buttonIdx Which button index changed
  111160. * @param state New state of the button
  111161. * @param changes Which properties on the state changed since last frame
  111162. */
  111163. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111164. }
  111165. }
  111166. declare module BABYLON {
  111167. /**
  111168. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111169. */
  111170. export class WebXRControllerModelLoader {
  111171. /**
  111172. * Creates the WebXRControllerModelLoader
  111173. * @param input xr input that creates the controllers
  111174. */
  111175. constructor(input: WebXRInput);
  111176. }
  111177. }
  111178. declare module BABYLON {
  111179. /**
  111180. * Options for the default xr helper
  111181. */
  111182. export class WebXRDefaultExperienceOptions {
  111183. /**
  111184. * Floor meshes that should be used for teleporting
  111185. */
  111186. floorMeshes: Array<AbstractMesh>;
  111187. /**
  111188. * Enable or disable default UI to enter XR
  111189. */
  111190. disableDefaultUI: boolean;
  111191. /**
  111192. * optional configuration for the output canvas
  111193. */
  111194. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  111195. }
  111196. /**
  111197. * Default experience which provides a similar setup to the previous webVRExperience
  111198. */
  111199. export class WebXRDefaultExperience {
  111200. /**
  111201. * Base experience
  111202. */
  111203. baseExperience: WebXRExperienceHelper;
  111204. /**
  111205. * Input experience extension
  111206. */
  111207. input: WebXRInput;
  111208. /**
  111209. * Loads the controller models
  111210. */
  111211. controllerModelLoader: WebXRControllerModelLoader;
  111212. /**
  111213. * Enables laser pointer and selection
  111214. */
  111215. pointerSelection: WebXRControllerPointerSelection;
  111216. /**
  111217. * Enables teleportation
  111218. */
  111219. teleportation: WebXRControllerTeleportation;
  111220. /**
  111221. * Enables ui for enetering/exiting xr
  111222. */
  111223. enterExitUI: WebXREnterExitUI;
  111224. /**
  111225. * Default target xr should render to
  111226. */
  111227. renderTarget: WebXRRenderTarget;
  111228. /**
  111229. * Creates the default xr experience
  111230. * @param scene scene
  111231. * @param options options for basic configuration
  111232. * @returns resulting WebXRDefaultExperience
  111233. */
  111234. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111235. private constructor();
  111236. /**
  111237. * DIsposes of the experience helper
  111238. */
  111239. dispose(): void;
  111240. }
  111241. }
  111242. declare module BABYLON {
  111243. /**
  111244. * Contains an array of blocks representing the octree
  111245. */
  111246. export interface IOctreeContainer<T> {
  111247. /**
  111248. * Blocks within the octree
  111249. */
  111250. blocks: Array<OctreeBlock<T>>;
  111251. }
  111252. /**
  111253. * Class used to store a cell in an octree
  111254. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111255. */
  111256. export class OctreeBlock<T> {
  111257. /**
  111258. * Gets the content of the current block
  111259. */
  111260. entries: T[];
  111261. /**
  111262. * Gets the list of block children
  111263. */
  111264. blocks: Array<OctreeBlock<T>>;
  111265. private _depth;
  111266. private _maxDepth;
  111267. private _capacity;
  111268. private _minPoint;
  111269. private _maxPoint;
  111270. private _boundingVectors;
  111271. private _creationFunc;
  111272. /**
  111273. * Creates a new block
  111274. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  111275. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  111276. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111277. * @param depth defines the current depth of this block in the octree
  111278. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  111279. * @param creationFunc defines a callback to call when an element is added to the block
  111280. */
  111281. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  111282. /**
  111283. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111284. */
  111285. readonly capacity: number;
  111286. /**
  111287. * Gets the minimum vector (in world space) of the block's bounding box
  111288. */
  111289. readonly minPoint: Vector3;
  111290. /**
  111291. * Gets the maximum vector (in world space) of the block's bounding box
  111292. */
  111293. readonly maxPoint: Vector3;
  111294. /**
  111295. * Add a new element to this block
  111296. * @param entry defines the element to add
  111297. */
  111298. addEntry(entry: T): void;
  111299. /**
  111300. * Remove an element from this block
  111301. * @param entry defines the element to remove
  111302. */
  111303. removeEntry(entry: T): void;
  111304. /**
  111305. * Add an array of elements to this block
  111306. * @param entries defines the array of elements to add
  111307. */
  111308. addEntries(entries: T[]): void;
  111309. /**
  111310. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  111311. * @param frustumPlanes defines the frustum planes to test
  111312. * @param selection defines the array to store current content if selection is positive
  111313. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111314. */
  111315. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111316. /**
  111317. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  111318. * @param sphereCenter defines the bounding sphere center
  111319. * @param sphereRadius defines the bounding sphere radius
  111320. * @param selection defines the array to store current content if selection is positive
  111321. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111322. */
  111323. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111324. /**
  111325. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  111326. * @param ray defines the ray to test with
  111327. * @param selection defines the array to store current content if selection is positive
  111328. */
  111329. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  111330. /**
  111331. * Subdivide the content into child blocks (this block will then be empty)
  111332. */
  111333. createInnerBlocks(): void;
  111334. /**
  111335. * @hidden
  111336. */
  111337. 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;
  111338. }
  111339. }
  111340. declare module BABYLON {
  111341. /**
  111342. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  111343. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111344. */
  111345. export class Octree<T> {
  111346. /** 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.) */
  111347. maxDepth: number;
  111348. /**
  111349. * Blocks within the octree containing objects
  111350. */
  111351. blocks: Array<OctreeBlock<T>>;
  111352. /**
  111353. * Content stored in the octree
  111354. */
  111355. dynamicContent: T[];
  111356. private _maxBlockCapacity;
  111357. private _selectionContent;
  111358. private _creationFunc;
  111359. /**
  111360. * Creates a octree
  111361. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111362. * @param creationFunc function to be used to instatiate the octree
  111363. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  111364. * @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.)
  111365. */
  111366. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  111367. /** 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.) */
  111368. maxDepth?: number);
  111369. /**
  111370. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  111371. * @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);
  111372. * @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);
  111373. * @param entries meshes to be added to the octree blocks
  111374. */
  111375. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  111376. /**
  111377. * Adds a mesh to the octree
  111378. * @param entry Mesh to add to the octree
  111379. */
  111380. addMesh(entry: T): void;
  111381. /**
  111382. * Remove an element from the octree
  111383. * @param entry defines the element to remove
  111384. */
  111385. removeMesh(entry: T): void;
  111386. /**
  111387. * Selects an array of meshes within the frustum
  111388. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  111389. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  111390. * @returns array of meshes within the frustum
  111391. */
  111392. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  111393. /**
  111394. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  111395. * @param sphereCenter defines the bounding sphere center
  111396. * @param sphereRadius defines the bounding sphere radius
  111397. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111398. * @returns an array of objects that intersect the sphere
  111399. */
  111400. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  111401. /**
  111402. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  111403. * @param ray defines the ray to test with
  111404. * @returns array of intersected objects
  111405. */
  111406. intersectsRay(ray: Ray): SmartArray<T>;
  111407. /**
  111408. * Adds a mesh into the octree block if it intersects the block
  111409. */
  111410. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  111411. /**
  111412. * Adds a submesh into the octree block if it intersects the block
  111413. */
  111414. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  111415. }
  111416. }
  111417. declare module BABYLON {
  111418. interface Scene {
  111419. /**
  111420. * @hidden
  111421. * Backing Filed
  111422. */
  111423. _selectionOctree: Octree<AbstractMesh>;
  111424. /**
  111425. * Gets the octree used to boost mesh selection (picking)
  111426. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111427. */
  111428. selectionOctree: Octree<AbstractMesh>;
  111429. /**
  111430. * Creates or updates the octree used to boost selection (picking)
  111431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111432. * @param maxCapacity defines the maximum capacity per leaf
  111433. * @param maxDepth defines the maximum depth of the octree
  111434. * @returns an octree of AbstractMesh
  111435. */
  111436. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  111437. }
  111438. interface AbstractMesh {
  111439. /**
  111440. * @hidden
  111441. * Backing Field
  111442. */
  111443. _submeshesOctree: Octree<SubMesh>;
  111444. /**
  111445. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  111446. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111447. * @param maxCapacity defines the maximum size of each block (64 by default)
  111448. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  111449. * @returns the new octree
  111450. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  111451. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111452. */
  111453. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  111454. }
  111455. /**
  111456. * Defines the octree scene component responsible to manage any octrees
  111457. * in a given scene.
  111458. */
  111459. export class OctreeSceneComponent {
  111460. /**
  111461. * The component name help to identify the component in the list of scene components.
  111462. */
  111463. readonly name: string;
  111464. /**
  111465. * The scene the component belongs to.
  111466. */
  111467. scene: Scene;
  111468. /**
  111469. * Indicates if the meshes have been checked to make sure they are isEnabled()
  111470. */
  111471. readonly checksIsEnabled: boolean;
  111472. /**
  111473. * Creates a new instance of the component for the given scene
  111474. * @param scene Defines the scene to register the component in
  111475. */
  111476. constructor(scene: Scene);
  111477. /**
  111478. * Registers the component in a given scene
  111479. */
  111480. register(): void;
  111481. /**
  111482. * Return the list of active meshes
  111483. * @returns the list of active meshes
  111484. */
  111485. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  111486. /**
  111487. * Return the list of active sub meshes
  111488. * @param mesh The mesh to get the candidates sub meshes from
  111489. * @returns the list of active sub meshes
  111490. */
  111491. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  111492. private _tempRay;
  111493. /**
  111494. * Return the list of sub meshes intersecting with a given local ray
  111495. * @param mesh defines the mesh to find the submesh for
  111496. * @param localRay defines the ray in local space
  111497. * @returns the list of intersecting sub meshes
  111498. */
  111499. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  111500. /**
  111501. * Return the list of sub meshes colliding with a collider
  111502. * @param mesh defines the mesh to find the submesh for
  111503. * @param collider defines the collider to evaluate the collision against
  111504. * @returns the list of colliding sub meshes
  111505. */
  111506. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  111507. /**
  111508. * Rebuilds the elements related to this component in case of
  111509. * context lost for instance.
  111510. */
  111511. rebuild(): void;
  111512. /**
  111513. * Disposes the component and the associated ressources.
  111514. */
  111515. dispose(): void;
  111516. }
  111517. }
  111518. declare module BABYLON {
  111519. /**
  111520. * Renders a layer on top of an existing scene
  111521. */
  111522. export class UtilityLayerRenderer implements IDisposable {
  111523. /** the original scene that will be rendered on top of */
  111524. originalScene: Scene;
  111525. private _pointerCaptures;
  111526. private _lastPointerEvents;
  111527. private static _DefaultUtilityLayer;
  111528. private static _DefaultKeepDepthUtilityLayer;
  111529. private _sharedGizmoLight;
  111530. private _renderCamera;
  111531. /**
  111532. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  111533. * @returns the camera that is used when rendering the utility layer
  111534. */
  111535. getRenderCamera(): Nullable<Camera>;
  111536. /**
  111537. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  111538. * @param cam the camera that should be used when rendering the utility layer
  111539. */
  111540. setRenderCamera(cam: Nullable<Camera>): void;
  111541. /**
  111542. * @hidden
  111543. * Light which used by gizmos to get light shading
  111544. */
  111545. _getSharedGizmoLight(): HemisphericLight;
  111546. /**
  111547. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  111548. */
  111549. pickUtilitySceneFirst: boolean;
  111550. /**
  111551. * 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)
  111552. */
  111553. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  111554. /**
  111555. * 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)
  111556. */
  111557. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  111558. /**
  111559. * The scene that is rendered on top of the original scene
  111560. */
  111561. utilityLayerScene: Scene;
  111562. /**
  111563. * If the utility layer should automatically be rendered on top of existing scene
  111564. */
  111565. shouldRender: boolean;
  111566. /**
  111567. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  111568. */
  111569. onlyCheckPointerDownEvents: boolean;
  111570. /**
  111571. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  111572. */
  111573. processAllEvents: boolean;
  111574. /**
  111575. * Observable raised when the pointer move from the utility layer scene to the main scene
  111576. */
  111577. onPointerOutObservable: Observable<number>;
  111578. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  111579. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  111580. private _afterRenderObserver;
  111581. private _sceneDisposeObserver;
  111582. private _originalPointerObserver;
  111583. /**
  111584. * Instantiates a UtilityLayerRenderer
  111585. * @param originalScene the original scene that will be rendered on top of
  111586. * @param handleEvents boolean indicating if the utility layer should handle events
  111587. */
  111588. constructor(
  111589. /** the original scene that will be rendered on top of */
  111590. originalScene: Scene, handleEvents?: boolean);
  111591. private _notifyObservers;
  111592. /**
  111593. * Renders the utility layers scene on top of the original scene
  111594. */
  111595. render(): void;
  111596. /**
  111597. * Disposes of the renderer
  111598. */
  111599. dispose(): void;
  111600. private _updateCamera;
  111601. }
  111602. }
  111603. declare module BABYLON {
  111604. /**
  111605. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  111606. */
  111607. export class Gizmo implements IDisposable {
  111608. /** The utility layer the gizmo will be added to */
  111609. gizmoLayer: UtilityLayerRenderer;
  111610. /**
  111611. * The root mesh of the gizmo
  111612. */
  111613. _rootMesh: Mesh;
  111614. private _attachedMesh;
  111615. /**
  111616. * Ratio for the scale of the gizmo (Default: 1)
  111617. */
  111618. scaleRatio: number;
  111619. /**
  111620. * If a custom mesh has been set (Default: false)
  111621. */
  111622. protected _customMeshSet: boolean;
  111623. /**
  111624. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  111625. * * When set, interactions will be enabled
  111626. */
  111627. attachedMesh: Nullable<AbstractMesh>;
  111628. /**
  111629. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111630. * @param mesh The mesh to replace the default mesh of the gizmo
  111631. */
  111632. setCustomMesh(mesh: Mesh): void;
  111633. /**
  111634. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  111635. */
  111636. updateGizmoRotationToMatchAttachedMesh: boolean;
  111637. /**
  111638. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  111639. */
  111640. updateGizmoPositionToMatchAttachedMesh: boolean;
  111641. /**
  111642. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  111643. */
  111644. updateScale: boolean;
  111645. protected _interactionsEnabled: boolean;
  111646. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111647. private _beforeRenderObserver;
  111648. private _tempVector;
  111649. /**
  111650. * Creates a gizmo
  111651. * @param gizmoLayer The utility layer the gizmo will be added to
  111652. */
  111653. constructor(
  111654. /** The utility layer the gizmo will be added to */
  111655. gizmoLayer?: UtilityLayerRenderer);
  111656. /**
  111657. * Updates the gizmo to match the attached mesh's position/rotation
  111658. */
  111659. protected _update(): void;
  111660. /**
  111661. * Disposes of the gizmo
  111662. */
  111663. dispose(): void;
  111664. }
  111665. }
  111666. declare module BABYLON {
  111667. /**
  111668. * Single plane drag gizmo
  111669. */
  111670. export class PlaneDragGizmo extends Gizmo {
  111671. /**
  111672. * Drag behavior responsible for the gizmos dragging interactions
  111673. */
  111674. dragBehavior: PointerDragBehavior;
  111675. private _pointerObserver;
  111676. /**
  111677. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111678. */
  111679. snapDistance: number;
  111680. /**
  111681. * Event that fires each time the gizmo snaps to a new location.
  111682. * * snapDistance is the the change in distance
  111683. */
  111684. onSnapObservable: Observable<{
  111685. snapDistance: number;
  111686. }>;
  111687. private _plane;
  111688. private _coloredMaterial;
  111689. private _hoverMaterial;
  111690. private _isEnabled;
  111691. private _parent;
  111692. /** @hidden */
  111693. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  111694. /** @hidden */
  111695. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111696. /**
  111697. * Creates a PlaneDragGizmo
  111698. * @param gizmoLayer The utility layer the gizmo will be added to
  111699. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  111700. * @param color The color of the gizmo
  111701. */
  111702. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111703. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111704. /**
  111705. * If the gizmo is enabled
  111706. */
  111707. isEnabled: boolean;
  111708. /**
  111709. * Disposes of the gizmo
  111710. */
  111711. dispose(): void;
  111712. }
  111713. }
  111714. declare module BABYLON {
  111715. /**
  111716. * Gizmo that enables dragging a mesh along 3 axis
  111717. */
  111718. export class PositionGizmo extends Gizmo {
  111719. /**
  111720. * Internal gizmo used for interactions on the x axis
  111721. */
  111722. xGizmo: AxisDragGizmo;
  111723. /**
  111724. * Internal gizmo used for interactions on the y axis
  111725. */
  111726. yGizmo: AxisDragGizmo;
  111727. /**
  111728. * Internal gizmo used for interactions on the z axis
  111729. */
  111730. zGizmo: AxisDragGizmo;
  111731. /**
  111732. * Internal gizmo used for interactions on the yz plane
  111733. */
  111734. xPlaneGizmo: PlaneDragGizmo;
  111735. /**
  111736. * Internal gizmo used for interactions on the xz plane
  111737. */
  111738. yPlaneGizmo: PlaneDragGizmo;
  111739. /**
  111740. * Internal gizmo used for interactions on the xy plane
  111741. */
  111742. zPlaneGizmo: PlaneDragGizmo;
  111743. /**
  111744. * private variables
  111745. */
  111746. private _meshAttached;
  111747. private _updateGizmoRotationToMatchAttachedMesh;
  111748. private _snapDistance;
  111749. private _scaleRatio;
  111750. /** Fires an event when any of it's sub gizmos are dragged */
  111751. onDragStartObservable: Observable<unknown>;
  111752. /** Fires an event when any of it's sub gizmos are released from dragging */
  111753. onDragEndObservable: Observable<unknown>;
  111754. /**
  111755. * If set to true, planar drag is enabled
  111756. */
  111757. private _planarGizmoEnabled;
  111758. attachedMesh: Nullable<AbstractMesh>;
  111759. /**
  111760. * Creates a PositionGizmo
  111761. * @param gizmoLayer The utility layer the gizmo will be added to
  111762. */
  111763. constructor(gizmoLayer?: UtilityLayerRenderer);
  111764. /**
  111765. * If the planar drag gizmo is enabled
  111766. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  111767. */
  111768. planarGizmoEnabled: boolean;
  111769. updateGizmoRotationToMatchAttachedMesh: boolean;
  111770. /**
  111771. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111772. */
  111773. snapDistance: number;
  111774. /**
  111775. * Ratio for the scale of the gizmo (Default: 1)
  111776. */
  111777. scaleRatio: number;
  111778. /**
  111779. * Disposes of the gizmo
  111780. */
  111781. dispose(): void;
  111782. /**
  111783. * CustomMeshes are not supported by this gizmo
  111784. * @param mesh The mesh to replace the default mesh of the gizmo
  111785. */
  111786. setCustomMesh(mesh: Mesh): void;
  111787. }
  111788. }
  111789. declare module BABYLON {
  111790. /**
  111791. * Single axis drag gizmo
  111792. */
  111793. export class AxisDragGizmo extends Gizmo {
  111794. /**
  111795. * Drag behavior responsible for the gizmos dragging interactions
  111796. */
  111797. dragBehavior: PointerDragBehavior;
  111798. private _pointerObserver;
  111799. /**
  111800. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111801. */
  111802. snapDistance: number;
  111803. /**
  111804. * Event that fires each time the gizmo snaps to a new location.
  111805. * * snapDistance is the the change in distance
  111806. */
  111807. onSnapObservable: Observable<{
  111808. snapDistance: number;
  111809. }>;
  111810. private _isEnabled;
  111811. private _parent;
  111812. private _arrow;
  111813. private _coloredMaterial;
  111814. private _hoverMaterial;
  111815. /** @hidden */
  111816. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  111817. /** @hidden */
  111818. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111819. /**
  111820. * Creates an AxisDragGizmo
  111821. * @param gizmoLayer The utility layer the gizmo will be added to
  111822. * @param dragAxis The axis which the gizmo will be able to drag on
  111823. * @param color The color of the gizmo
  111824. */
  111825. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111826. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111827. /**
  111828. * If the gizmo is enabled
  111829. */
  111830. isEnabled: boolean;
  111831. /**
  111832. * Disposes of the gizmo
  111833. */
  111834. dispose(): void;
  111835. }
  111836. }
  111837. declare module BABYLON.Debug {
  111838. /**
  111839. * The Axes viewer will show 3 axes in a specific point in space
  111840. */
  111841. export class AxesViewer {
  111842. private _xAxis;
  111843. private _yAxis;
  111844. private _zAxis;
  111845. private _scaleLinesFactor;
  111846. private _instanced;
  111847. /**
  111848. * Gets the hosting scene
  111849. */
  111850. scene: Scene;
  111851. /**
  111852. * Gets or sets a number used to scale line length
  111853. */
  111854. scaleLines: number;
  111855. /** Gets the node hierarchy used to render x-axis */
  111856. readonly xAxis: TransformNode;
  111857. /** Gets the node hierarchy used to render y-axis */
  111858. readonly yAxis: TransformNode;
  111859. /** Gets the node hierarchy used to render z-axis */
  111860. readonly zAxis: TransformNode;
  111861. /**
  111862. * Creates a new AxesViewer
  111863. * @param scene defines the hosting scene
  111864. * @param scaleLines defines a number used to scale line length (1 by default)
  111865. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  111866. * @param xAxis defines the node hierarchy used to render the x-axis
  111867. * @param yAxis defines the node hierarchy used to render the y-axis
  111868. * @param zAxis defines the node hierarchy used to render the z-axis
  111869. */
  111870. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  111871. /**
  111872. * Force the viewer to update
  111873. * @param position defines the position of the viewer
  111874. * @param xaxis defines the x axis of the viewer
  111875. * @param yaxis defines the y axis of the viewer
  111876. * @param zaxis defines the z axis of the viewer
  111877. */
  111878. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  111879. /**
  111880. * Creates an instance of this axes viewer.
  111881. * @returns a new axes viewer with instanced meshes
  111882. */
  111883. createInstance(): AxesViewer;
  111884. /** Releases resources */
  111885. dispose(): void;
  111886. private static _SetRenderingGroupId;
  111887. }
  111888. }
  111889. declare module BABYLON.Debug {
  111890. /**
  111891. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  111892. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  111893. */
  111894. export class BoneAxesViewer extends AxesViewer {
  111895. /**
  111896. * Gets or sets the target mesh where to display the axes viewer
  111897. */
  111898. mesh: Nullable<Mesh>;
  111899. /**
  111900. * Gets or sets the target bone where to display the axes viewer
  111901. */
  111902. bone: Nullable<Bone>;
  111903. /** Gets current position */
  111904. pos: Vector3;
  111905. /** Gets direction of X axis */
  111906. xaxis: Vector3;
  111907. /** Gets direction of Y axis */
  111908. yaxis: Vector3;
  111909. /** Gets direction of Z axis */
  111910. zaxis: Vector3;
  111911. /**
  111912. * Creates a new BoneAxesViewer
  111913. * @param scene defines the hosting scene
  111914. * @param bone defines the target bone
  111915. * @param mesh defines the target mesh
  111916. * @param scaleLines defines a scaling factor for line length (1 by default)
  111917. */
  111918. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  111919. /**
  111920. * Force the viewer to update
  111921. */
  111922. update(): void;
  111923. /** Releases resources */
  111924. dispose(): void;
  111925. }
  111926. }
  111927. declare module BABYLON {
  111928. /**
  111929. * Interface used to define scene explorer extensibility option
  111930. */
  111931. export interface IExplorerExtensibilityOption {
  111932. /**
  111933. * Define the option label
  111934. */
  111935. label: string;
  111936. /**
  111937. * Defines the action to execute on click
  111938. */
  111939. action: (entity: any) => void;
  111940. }
  111941. /**
  111942. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  111943. */
  111944. export interface IExplorerExtensibilityGroup {
  111945. /**
  111946. * Defines a predicate to test if a given type mut be extended
  111947. */
  111948. predicate: (entity: any) => boolean;
  111949. /**
  111950. * Gets the list of options added to a type
  111951. */
  111952. entries: IExplorerExtensibilityOption[];
  111953. }
  111954. /**
  111955. * Interface used to define the options to use to create the Inspector
  111956. */
  111957. export interface IInspectorOptions {
  111958. /**
  111959. * Display in overlay mode (default: false)
  111960. */
  111961. overlay?: boolean;
  111962. /**
  111963. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  111964. */
  111965. globalRoot?: HTMLElement;
  111966. /**
  111967. * Display the Scene explorer
  111968. */
  111969. showExplorer?: boolean;
  111970. /**
  111971. * Display the property inspector
  111972. */
  111973. showInspector?: boolean;
  111974. /**
  111975. * Display in embed mode (both panes on the right)
  111976. */
  111977. embedMode?: boolean;
  111978. /**
  111979. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  111980. */
  111981. handleResize?: boolean;
  111982. /**
  111983. * Allow the panes to popup (default: true)
  111984. */
  111985. enablePopup?: boolean;
  111986. /**
  111987. * Allow the panes to be closed by users (default: true)
  111988. */
  111989. enableClose?: boolean;
  111990. /**
  111991. * Optional list of extensibility entries
  111992. */
  111993. explorerExtensibility?: IExplorerExtensibilityGroup[];
  111994. /**
  111995. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  111996. */
  111997. inspectorURL?: string;
  111998. }
  111999. interface Scene {
  112000. /**
  112001. * @hidden
  112002. * Backing field
  112003. */
  112004. _debugLayer: DebugLayer;
  112005. /**
  112006. * Gets the debug layer (aka Inspector) associated with the scene
  112007. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112008. */
  112009. debugLayer: DebugLayer;
  112010. }
  112011. /**
  112012. * The debug layer (aka Inspector) is the go to tool in order to better understand
  112013. * what is happening in your scene
  112014. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112015. */
  112016. export class DebugLayer {
  112017. /**
  112018. * Define the url to get the inspector script from.
  112019. * By default it uses the babylonjs CDN.
  112020. * @ignoreNaming
  112021. */
  112022. static InspectorURL: string;
  112023. private _scene;
  112024. private BJSINSPECTOR;
  112025. private _onPropertyChangedObservable?;
  112026. /**
  112027. * Observable triggered when a property is changed through the inspector.
  112028. */
  112029. readonly onPropertyChangedObservable: any;
  112030. /**
  112031. * Instantiates a new debug layer.
  112032. * The debug layer (aka Inspector) is the go to tool in order to better understand
  112033. * what is happening in your scene
  112034. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112035. * @param scene Defines the scene to inspect
  112036. */
  112037. constructor(scene: Scene);
  112038. /** Creates the inspector window. */
  112039. private _createInspector;
  112040. /**
  112041. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  112042. * @param entity defines the entity to select
  112043. * @param lineContainerTitle defines the specific block to highlight
  112044. */
  112045. select(entity: any, lineContainerTitle?: string): void;
  112046. /** Get the inspector from bundle or global */
  112047. private _getGlobalInspector;
  112048. /**
  112049. * Get if the inspector is visible or not.
  112050. * @returns true if visible otherwise, false
  112051. */
  112052. isVisible(): boolean;
  112053. /**
  112054. * Hide the inspector and close its window.
  112055. */
  112056. hide(): void;
  112057. /**
  112058. * Launch the debugLayer.
  112059. * @param config Define the configuration of the inspector
  112060. * @return a promise fulfilled when the debug layer is visible
  112061. */
  112062. show(config?: IInspectorOptions): Promise<DebugLayer>;
  112063. }
  112064. }
  112065. declare module BABYLON {
  112066. /**
  112067. * Class containing static functions to help procedurally build meshes
  112068. */
  112069. export class BoxBuilder {
  112070. /**
  112071. * Creates a box mesh
  112072. * * The parameter `size` sets the size (float) of each box side (default 1)
  112073. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  112074. * * 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)
  112075. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  112076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112079. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  112080. * @param name defines the name of the mesh
  112081. * @param options defines the options used to create the mesh
  112082. * @param scene defines the hosting scene
  112083. * @returns the box mesh
  112084. */
  112085. static CreateBox(name: string, options: {
  112086. size?: number;
  112087. width?: number;
  112088. height?: number;
  112089. depth?: number;
  112090. faceUV?: Vector4[];
  112091. faceColors?: Color4[];
  112092. sideOrientation?: number;
  112093. frontUVs?: Vector4;
  112094. backUVs?: Vector4;
  112095. wrap?: boolean;
  112096. topBaseAt?: number;
  112097. bottomBaseAt?: number;
  112098. updatable?: boolean;
  112099. }, scene?: Nullable<Scene>): Mesh;
  112100. }
  112101. }
  112102. declare module BABYLON {
  112103. /**
  112104. * Class containing static functions to help procedurally build meshes
  112105. */
  112106. export class SphereBuilder {
  112107. /**
  112108. * Creates a sphere mesh
  112109. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  112110. * * 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`)
  112111. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  112112. * * 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
  112113. * * 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)
  112114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112117. * @param name defines the name of the mesh
  112118. * @param options defines the options used to create the mesh
  112119. * @param scene defines the hosting scene
  112120. * @returns the sphere mesh
  112121. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  112122. */
  112123. static CreateSphere(name: string, options: {
  112124. segments?: number;
  112125. diameter?: number;
  112126. diameterX?: number;
  112127. diameterY?: number;
  112128. diameterZ?: number;
  112129. arc?: number;
  112130. slice?: number;
  112131. sideOrientation?: number;
  112132. frontUVs?: Vector4;
  112133. backUVs?: Vector4;
  112134. updatable?: boolean;
  112135. }, scene?: Nullable<Scene>): Mesh;
  112136. }
  112137. }
  112138. declare module BABYLON.Debug {
  112139. /**
  112140. * Used to show the physics impostor around the specific mesh
  112141. */
  112142. export class PhysicsViewer {
  112143. /** @hidden */
  112144. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  112145. /** @hidden */
  112146. protected _meshes: Array<Nullable<AbstractMesh>>;
  112147. /** @hidden */
  112148. protected _scene: Nullable<Scene>;
  112149. /** @hidden */
  112150. protected _numMeshes: number;
  112151. /** @hidden */
  112152. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  112153. private _renderFunction;
  112154. private _utilityLayer;
  112155. private _debugBoxMesh;
  112156. private _debugSphereMesh;
  112157. private _debugCylinderMesh;
  112158. private _debugMaterial;
  112159. private _debugMeshMeshes;
  112160. /**
  112161. * Creates a new PhysicsViewer
  112162. * @param scene defines the hosting scene
  112163. */
  112164. constructor(scene: Scene);
  112165. /** @hidden */
  112166. protected _updateDebugMeshes(): void;
  112167. /**
  112168. * Renders a specified physic impostor
  112169. * @param impostor defines the impostor to render
  112170. * @param targetMesh defines the mesh represented by the impostor
  112171. * @returns the new debug mesh used to render the impostor
  112172. */
  112173. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  112174. /**
  112175. * Hides a specified physic impostor
  112176. * @param impostor defines the impostor to hide
  112177. */
  112178. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  112179. private _getDebugMaterial;
  112180. private _getDebugBoxMesh;
  112181. private _getDebugSphereMesh;
  112182. private _getDebugCylinderMesh;
  112183. private _getDebugMeshMesh;
  112184. private _getDebugMesh;
  112185. /** Releases all resources */
  112186. dispose(): void;
  112187. }
  112188. }
  112189. declare module BABYLON {
  112190. /**
  112191. * Class containing static functions to help procedurally build meshes
  112192. */
  112193. export class LinesBuilder {
  112194. /**
  112195. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  112196. * * 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
  112197. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  112198. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  112199. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  112200. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  112201. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  112202. * * 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
  112203. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  112204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  112206. * @param name defines the name of the new line system
  112207. * @param options defines the options used to create the line system
  112208. * @param scene defines the hosting scene
  112209. * @returns a new line system mesh
  112210. */
  112211. static CreateLineSystem(name: string, options: {
  112212. lines: Vector3[][];
  112213. updatable?: boolean;
  112214. instance?: Nullable<LinesMesh>;
  112215. colors?: Nullable<Color4[][]>;
  112216. useVertexAlpha?: boolean;
  112217. }, scene: Nullable<Scene>): LinesMesh;
  112218. /**
  112219. * Creates a line mesh
  112220. * 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
  112221. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112222. * * The parameter `points` is an array successive Vector3
  112223. * * 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
  112224. * * The optional parameter `colors` is an array of successive Color4, one per line point
  112225. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  112226. * * When updating an instance, remember that only point positions can change, not the number of points
  112227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  112229. * @param name defines the name of the new line system
  112230. * @param options defines the options used to create the line system
  112231. * @param scene defines the hosting scene
  112232. * @returns a new line mesh
  112233. */
  112234. static CreateLines(name: string, options: {
  112235. points: Vector3[];
  112236. updatable?: boolean;
  112237. instance?: Nullable<LinesMesh>;
  112238. colors?: Color4[];
  112239. useVertexAlpha?: boolean;
  112240. }, scene?: Nullable<Scene>): LinesMesh;
  112241. /**
  112242. * Creates a dashed line mesh
  112243. * * 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
  112244. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112245. * * The parameter `points` is an array successive Vector3
  112246. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  112247. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  112248. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  112249. * * 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
  112250. * * When updating an instance, remember that only point positions can change, not the number of points
  112251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112252. * @param name defines the name of the mesh
  112253. * @param options defines the options used to create the mesh
  112254. * @param scene defines the hosting scene
  112255. * @returns the dashed line mesh
  112256. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  112257. */
  112258. static CreateDashedLines(name: string, options: {
  112259. points: Vector3[];
  112260. dashSize?: number;
  112261. gapSize?: number;
  112262. dashNb?: number;
  112263. updatable?: boolean;
  112264. instance?: LinesMesh;
  112265. }, scene?: Nullable<Scene>): LinesMesh;
  112266. }
  112267. }
  112268. declare module BABYLON {
  112269. /**
  112270. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112271. * in order to better appreciate the issue one might have.
  112272. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112273. */
  112274. export class RayHelper {
  112275. /**
  112276. * Defines the ray we are currently tryin to visualize.
  112277. */
  112278. ray: Nullable<Ray>;
  112279. private _renderPoints;
  112280. private _renderLine;
  112281. private _renderFunction;
  112282. private _scene;
  112283. private _updateToMeshFunction;
  112284. private _attachedToMesh;
  112285. private _meshSpaceDirection;
  112286. private _meshSpaceOrigin;
  112287. /**
  112288. * Helper function to create a colored helper in a scene in one line.
  112289. * @param ray Defines the ray we are currently tryin to visualize
  112290. * @param scene Defines the scene the ray is used in
  112291. * @param color Defines the color we want to see the ray in
  112292. * @returns The newly created ray helper.
  112293. */
  112294. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  112295. /**
  112296. * Instantiate a new ray helper.
  112297. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112298. * in order to better appreciate the issue one might have.
  112299. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112300. * @param ray Defines the ray we are currently tryin to visualize
  112301. */
  112302. constructor(ray: Ray);
  112303. /**
  112304. * Shows the ray we are willing to debug.
  112305. * @param scene Defines the scene the ray needs to be rendered in
  112306. * @param color Defines the color the ray needs to be rendered in
  112307. */
  112308. show(scene: Scene, color?: Color3): void;
  112309. /**
  112310. * Hides the ray we are debugging.
  112311. */
  112312. hide(): void;
  112313. private _render;
  112314. /**
  112315. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  112316. * @param mesh Defines the mesh we want the helper attached to
  112317. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  112318. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  112319. * @param length Defines the length of the ray
  112320. */
  112321. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  112322. /**
  112323. * Detach the ray helper from the mesh it has previously been attached to.
  112324. */
  112325. detachFromMesh(): void;
  112326. private _updateToMesh;
  112327. /**
  112328. * Dispose the helper and release its associated resources.
  112329. */
  112330. dispose(): void;
  112331. }
  112332. }
  112333. declare module BABYLON.Debug {
  112334. /**
  112335. * Class used to render a debug view of a given skeleton
  112336. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  112337. */
  112338. export class SkeletonViewer {
  112339. /** defines the skeleton to render */
  112340. skeleton: Skeleton;
  112341. /** defines the mesh attached to the skeleton */
  112342. mesh: AbstractMesh;
  112343. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112344. autoUpdateBonesMatrices: boolean;
  112345. /** defines the rendering group id to use with the viewer */
  112346. renderingGroupId: number;
  112347. /** Gets or sets the color used to render the skeleton */
  112348. color: Color3;
  112349. private _scene;
  112350. private _debugLines;
  112351. private _debugMesh;
  112352. private _isEnabled;
  112353. private _renderFunction;
  112354. private _utilityLayer;
  112355. /**
  112356. * Returns the mesh used to render the bones
  112357. */
  112358. readonly debugMesh: Nullable<LinesMesh>;
  112359. /**
  112360. * Creates a new SkeletonViewer
  112361. * @param skeleton defines the skeleton to render
  112362. * @param mesh defines the mesh attached to the skeleton
  112363. * @param scene defines the hosting scene
  112364. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  112365. * @param renderingGroupId defines the rendering group id to use with the viewer
  112366. */
  112367. constructor(
  112368. /** defines the skeleton to render */
  112369. skeleton: Skeleton,
  112370. /** defines the mesh attached to the skeleton */
  112371. mesh: AbstractMesh, scene: Scene,
  112372. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112373. autoUpdateBonesMatrices?: boolean,
  112374. /** defines the rendering group id to use with the viewer */
  112375. renderingGroupId?: number);
  112376. /** Gets or sets a boolean indicating if the viewer is enabled */
  112377. isEnabled: boolean;
  112378. private _getBonePosition;
  112379. private _getLinesForBonesWithLength;
  112380. private _getLinesForBonesNoLength;
  112381. /** Update the viewer to sync with current skeleton state */
  112382. update(): void;
  112383. /** Release associated resources */
  112384. dispose(): void;
  112385. }
  112386. }
  112387. declare module BABYLON {
  112388. /**
  112389. * Options to create the null engine
  112390. */
  112391. export class NullEngineOptions {
  112392. /**
  112393. * Render width (Default: 512)
  112394. */
  112395. renderWidth: number;
  112396. /**
  112397. * Render height (Default: 256)
  112398. */
  112399. renderHeight: number;
  112400. /**
  112401. * Texture size (Default: 512)
  112402. */
  112403. textureSize: number;
  112404. /**
  112405. * If delta time between frames should be constant
  112406. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112407. */
  112408. deterministicLockstep: boolean;
  112409. /**
  112410. * Maximum about of steps between frames (Default: 4)
  112411. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112412. */
  112413. lockstepMaxSteps: number;
  112414. }
  112415. /**
  112416. * The null engine class provides support for headless version of babylon.js.
  112417. * This can be used in server side scenario or for testing purposes
  112418. */
  112419. export class NullEngine extends Engine {
  112420. private _options;
  112421. /**
  112422. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  112423. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112424. * @returns true if engine is in deterministic lock step mode
  112425. */
  112426. isDeterministicLockStep(): boolean;
  112427. /**
  112428. * Gets the max steps when engine is running in deterministic lock step
  112429. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112430. * @returns the max steps
  112431. */
  112432. getLockstepMaxSteps(): number;
  112433. /**
  112434. * Gets the current hardware scaling level.
  112435. * By default the hardware scaling level is computed from the window device ratio.
  112436. * 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.
  112437. * @returns a number indicating the current hardware scaling level
  112438. */
  112439. getHardwareScalingLevel(): number;
  112440. constructor(options?: NullEngineOptions);
  112441. /**
  112442. * Creates a vertex buffer
  112443. * @param vertices the data for the vertex buffer
  112444. * @returns the new WebGL static buffer
  112445. */
  112446. createVertexBuffer(vertices: FloatArray): DataBuffer;
  112447. /**
  112448. * Creates a new index buffer
  112449. * @param indices defines the content of the index buffer
  112450. * @param updatable defines if the index buffer must be updatable
  112451. * @returns a new webGL buffer
  112452. */
  112453. createIndexBuffer(indices: IndicesArray): DataBuffer;
  112454. /**
  112455. * Clear the current render buffer or the current render target (if any is set up)
  112456. * @param color defines the color to use
  112457. * @param backBuffer defines if the back buffer must be cleared
  112458. * @param depth defines if the depth buffer must be cleared
  112459. * @param stencil defines if the stencil buffer must be cleared
  112460. */
  112461. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112462. /**
  112463. * Gets the current render width
  112464. * @param useScreen defines if screen size must be used (or the current render target if any)
  112465. * @returns a number defining the current render width
  112466. */
  112467. getRenderWidth(useScreen?: boolean): number;
  112468. /**
  112469. * Gets the current render height
  112470. * @param useScreen defines if screen size must be used (or the current render target if any)
  112471. * @returns a number defining the current render height
  112472. */
  112473. getRenderHeight(useScreen?: boolean): number;
  112474. /**
  112475. * Set the WebGL's viewport
  112476. * @param viewport defines the viewport element to be used
  112477. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112478. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112479. */
  112480. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112481. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  112482. /**
  112483. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112484. * @param pipelineContext defines the pipeline context to use
  112485. * @param uniformsNames defines the list of uniform names
  112486. * @returns an array of webGL uniform locations
  112487. */
  112488. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112489. /**
  112490. * Gets the lsit of active attributes for a given webGL program
  112491. * @param pipelineContext defines the pipeline context to use
  112492. * @param attributesNames defines the list of attribute names to get
  112493. * @returns an array of indices indicating the offset of each attribute
  112494. */
  112495. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112496. /**
  112497. * Binds an effect to the webGL context
  112498. * @param effect defines the effect to bind
  112499. */
  112500. bindSamplers(effect: Effect): void;
  112501. /**
  112502. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112503. * @param effect defines the effect to activate
  112504. */
  112505. enableEffect(effect: Effect): void;
  112506. /**
  112507. * Set various states to the webGL context
  112508. * @param culling defines backface culling state
  112509. * @param zOffset defines the value to apply to zOffset (0 by default)
  112510. * @param force defines if states must be applied even if cache is up to date
  112511. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  112512. */
  112513. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112514. /**
  112515. * Set the value of an uniform to an array of int32
  112516. * @param uniform defines the webGL uniform location where to store the value
  112517. * @param array defines the array of int32 to store
  112518. */
  112519. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112520. /**
  112521. * Set the value of an uniform to an array of int32 (stored as vec2)
  112522. * @param uniform defines the webGL uniform location where to store the value
  112523. * @param array defines the array of int32 to store
  112524. */
  112525. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112526. /**
  112527. * Set the value of an uniform to an array of int32 (stored as vec3)
  112528. * @param uniform defines the webGL uniform location where to store the value
  112529. * @param array defines the array of int32 to store
  112530. */
  112531. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112532. /**
  112533. * Set the value of an uniform to an array of int32 (stored as vec4)
  112534. * @param uniform defines the webGL uniform location where to store the value
  112535. * @param array defines the array of int32 to store
  112536. */
  112537. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112538. /**
  112539. * Set the value of an uniform to an array of float32
  112540. * @param uniform defines the webGL uniform location where to store the value
  112541. * @param array defines the array of float32 to store
  112542. */
  112543. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112544. /**
  112545. * Set the value of an uniform to an array of float32 (stored as vec2)
  112546. * @param uniform defines the webGL uniform location where to store the value
  112547. * @param array defines the array of float32 to store
  112548. */
  112549. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112550. /**
  112551. * Set the value of an uniform to an array of float32 (stored as vec3)
  112552. * @param uniform defines the webGL uniform location where to store the value
  112553. * @param array defines the array of float32 to store
  112554. */
  112555. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112556. /**
  112557. * Set the value of an uniform to an array of float32 (stored as vec4)
  112558. * @param uniform defines the webGL uniform location where to store the value
  112559. * @param array defines the array of float32 to store
  112560. */
  112561. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112562. /**
  112563. * Set the value of an uniform to an array of number
  112564. * @param uniform defines the webGL uniform location where to store the value
  112565. * @param array defines the array of number to store
  112566. */
  112567. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112568. /**
  112569. * Set the value of an uniform to an array of number (stored as vec2)
  112570. * @param uniform defines the webGL uniform location where to store the value
  112571. * @param array defines the array of number to store
  112572. */
  112573. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112574. /**
  112575. * Set the value of an uniform to an array of number (stored as vec3)
  112576. * @param uniform defines the webGL uniform location where to store the value
  112577. * @param array defines the array of number to store
  112578. */
  112579. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112580. /**
  112581. * Set the value of an uniform to an array of number (stored as vec4)
  112582. * @param uniform defines the webGL uniform location where to store the value
  112583. * @param array defines the array of number to store
  112584. */
  112585. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112586. /**
  112587. * Set the value of an uniform to an array of float32 (stored as matrices)
  112588. * @param uniform defines the webGL uniform location where to store the value
  112589. * @param matrices defines the array of float32 to store
  112590. */
  112591. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112592. /**
  112593. * Set the value of an uniform to a matrix (3x3)
  112594. * @param uniform defines the webGL uniform location where to store the value
  112595. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112596. */
  112597. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112598. /**
  112599. * Set the value of an uniform to a matrix (2x2)
  112600. * @param uniform defines the webGL uniform location where to store the value
  112601. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112602. */
  112603. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112604. /**
  112605. * Set the value of an uniform to a number (float)
  112606. * @param uniform defines the webGL uniform location where to store the value
  112607. * @param value defines the float number to store
  112608. */
  112609. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112610. /**
  112611. * Set the value of an uniform to a vec2
  112612. * @param uniform defines the webGL uniform location where to store the value
  112613. * @param x defines the 1st component of the value
  112614. * @param y defines the 2nd component of the value
  112615. */
  112616. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112617. /**
  112618. * Set the value of an uniform to a vec3
  112619. * @param uniform defines the webGL uniform location where to store the value
  112620. * @param x defines the 1st component of the value
  112621. * @param y defines the 2nd component of the value
  112622. * @param z defines the 3rd component of the value
  112623. */
  112624. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112625. /**
  112626. * Set the value of an uniform to a boolean
  112627. * @param uniform defines the webGL uniform location where to store the value
  112628. * @param bool defines the boolean to store
  112629. */
  112630. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112631. /**
  112632. * Set the value of an uniform to a vec4
  112633. * @param uniform defines the webGL uniform location where to store the value
  112634. * @param x defines the 1st component of the value
  112635. * @param y defines the 2nd component of the value
  112636. * @param z defines the 3rd component of the value
  112637. * @param w defines the 4th component of the value
  112638. */
  112639. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112640. /**
  112641. * Sets the current alpha mode
  112642. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  112643. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112644. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112645. */
  112646. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112647. /**
  112648. * Bind webGl buffers directly to the webGL context
  112649. * @param vertexBuffers defines the vertex buffer to bind
  112650. * @param indexBuffer defines the index buffer to bind
  112651. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112652. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112653. * @param effect defines the effect associated with the vertex buffer
  112654. */
  112655. bindBuffers(vertexBuffers: {
  112656. [key: string]: VertexBuffer;
  112657. }, indexBuffer: DataBuffer, effect: Effect): void;
  112658. /**
  112659. * Force the entire cache to be cleared
  112660. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112661. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112662. */
  112663. wipeCaches(bruteForce?: boolean): void;
  112664. /**
  112665. * Send a draw order
  112666. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112667. * @param indexStart defines the starting index
  112668. * @param indexCount defines the number of index to draw
  112669. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112670. */
  112671. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112672. /**
  112673. * Draw a list of indexed primitives
  112674. * @param fillMode defines the primitive to use
  112675. * @param indexStart defines the starting index
  112676. * @param indexCount defines the number of index to draw
  112677. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112678. */
  112679. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112680. /**
  112681. * Draw a list of unindexed primitives
  112682. * @param fillMode defines the primitive to use
  112683. * @param verticesStart defines the index of first vertex to draw
  112684. * @param verticesCount defines the count of vertices to draw
  112685. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112686. */
  112687. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112688. /** @hidden */
  112689. _createTexture(): WebGLTexture;
  112690. /** @hidden */
  112691. _releaseTexture(texture: InternalTexture): void;
  112692. /**
  112693. * Usually called from Texture.ts.
  112694. * Passed information to create a WebGLTexture
  112695. * @param urlArg defines a value which contains one of the following:
  112696. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112697. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112698. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112700. * @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)
  112701. * @param scene needed for loading to the correct scene
  112702. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112703. * @param onLoad optional callback to be called upon successful completion
  112704. * @param onError optional callback to be called upon failure
  112705. * @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
  112706. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112707. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112708. * @param forcedExtension defines the extension to use to pick the right loader
  112709. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  112710. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112711. */
  112712. 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;
  112713. /**
  112714. * Creates a new render target texture
  112715. * @param size defines the size of the texture
  112716. * @param options defines the options used to create the texture
  112717. * @returns a new render target texture stored in an InternalTexture
  112718. */
  112719. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112720. /**
  112721. * Update the sampling mode of a given texture
  112722. * @param samplingMode defines the required sampling mode
  112723. * @param texture defines the texture to update
  112724. */
  112725. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112726. /**
  112727. * Binds the frame buffer to the specified texture.
  112728. * @param texture The texture to render to or null for the default canvas
  112729. * @param faceIndex The face of the texture to render to in case of cube texture
  112730. * @param requiredWidth The width of the target to render to
  112731. * @param requiredHeight The height of the target to render to
  112732. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112733. * @param depthStencilTexture The depth stencil texture to use to render
  112734. * @param lodLevel defines le lod level to bind to the frame buffer
  112735. */
  112736. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112737. /**
  112738. * Unbind the current render target texture from the webGL context
  112739. * @param texture defines the render target texture to unbind
  112740. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112741. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112742. */
  112743. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112744. /**
  112745. * Creates a dynamic vertex buffer
  112746. * @param vertices the data for the dynamic vertex buffer
  112747. * @returns the new WebGL dynamic buffer
  112748. */
  112749. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  112750. /**
  112751. * Update the content of a dynamic texture
  112752. * @param texture defines the texture to update
  112753. * @param canvas defines the canvas containing the source
  112754. * @param invertY defines if data must be stored with Y axis inverted
  112755. * @param premulAlpha defines if alpha is stored as premultiplied
  112756. * @param format defines the format of the data
  112757. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112758. */
  112759. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  112760. /**
  112761. * Gets a boolean indicating if all created effects are ready
  112762. * @returns true if all effects are ready
  112763. */
  112764. areAllEffectsReady(): boolean;
  112765. /**
  112766. * @hidden
  112767. * Get the current error code of the webGL context
  112768. * @returns the error code
  112769. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112770. */
  112771. getError(): number;
  112772. /** @hidden */
  112773. _getUnpackAlignement(): number;
  112774. /** @hidden */
  112775. _unpackFlipY(value: boolean): void;
  112776. /**
  112777. * Update a dynamic index buffer
  112778. * @param indexBuffer defines the target index buffer
  112779. * @param indices defines the data to update
  112780. * @param offset defines the offset in the target index buffer where update should start
  112781. */
  112782. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  112783. /**
  112784. * Updates a dynamic vertex buffer.
  112785. * @param vertexBuffer the vertex buffer to update
  112786. * @param vertices the data used to update the vertex buffer
  112787. * @param byteOffset the byte offset of the data (optional)
  112788. * @param byteLength the byte length of the data (optional)
  112789. */
  112790. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  112791. /** @hidden */
  112792. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  112793. /** @hidden */
  112794. _bindTexture(channel: number, texture: InternalTexture): void;
  112795. protected _deleteBuffer(buffer: WebGLBuffer): void;
  112796. /**
  112797. * 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
  112798. */
  112799. releaseEffects(): void;
  112800. displayLoadingUI(): void;
  112801. hideLoadingUI(): void;
  112802. /** @hidden */
  112803. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112804. /** @hidden */
  112805. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112806. /** @hidden */
  112807. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112808. /** @hidden */
  112809. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112810. }
  112811. }
  112812. declare module BABYLON {
  112813. /** @hidden */
  112814. export class _OcclusionDataStorage {
  112815. /** @hidden */
  112816. occlusionInternalRetryCounter: number;
  112817. /** @hidden */
  112818. isOcclusionQueryInProgress: boolean;
  112819. /** @hidden */
  112820. isOccluded: boolean;
  112821. /** @hidden */
  112822. occlusionRetryCount: number;
  112823. /** @hidden */
  112824. occlusionType: number;
  112825. /** @hidden */
  112826. occlusionQueryAlgorithmType: number;
  112827. }
  112828. interface Engine {
  112829. /**
  112830. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  112831. * @return the new query
  112832. */
  112833. createQuery(): WebGLQuery;
  112834. /**
  112835. * Delete and release a webGL query
  112836. * @param query defines the query to delete
  112837. * @return the current engine
  112838. */
  112839. deleteQuery(query: WebGLQuery): Engine;
  112840. /**
  112841. * Check if a given query has resolved and got its value
  112842. * @param query defines the query to check
  112843. * @returns true if the query got its value
  112844. */
  112845. isQueryResultAvailable(query: WebGLQuery): boolean;
  112846. /**
  112847. * Gets the value of a given query
  112848. * @param query defines the query to check
  112849. * @returns the value of the query
  112850. */
  112851. getQueryResult(query: WebGLQuery): number;
  112852. /**
  112853. * Initiates an occlusion query
  112854. * @param algorithmType defines the algorithm to use
  112855. * @param query defines the query to use
  112856. * @returns the current engine
  112857. * @see http://doc.babylonjs.com/features/occlusionquery
  112858. */
  112859. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  112860. /**
  112861. * Ends an occlusion query
  112862. * @see http://doc.babylonjs.com/features/occlusionquery
  112863. * @param algorithmType defines the algorithm to use
  112864. * @returns the current engine
  112865. */
  112866. endOcclusionQuery(algorithmType: number): Engine;
  112867. /**
  112868. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  112869. * Please note that only one query can be issued at a time
  112870. * @returns a time token used to track the time span
  112871. */
  112872. startTimeQuery(): Nullable<_TimeToken>;
  112873. /**
  112874. * Ends a time query
  112875. * @param token defines the token used to measure the time span
  112876. * @returns the time spent (in ns)
  112877. */
  112878. endTimeQuery(token: _TimeToken): int;
  112879. /** @hidden */
  112880. _currentNonTimestampToken: Nullable<_TimeToken>;
  112881. /** @hidden */
  112882. _createTimeQuery(): WebGLQuery;
  112883. /** @hidden */
  112884. _deleteTimeQuery(query: WebGLQuery): void;
  112885. /** @hidden */
  112886. _getGlAlgorithmType(algorithmType: number): number;
  112887. /** @hidden */
  112888. _getTimeQueryResult(query: WebGLQuery): any;
  112889. /** @hidden */
  112890. _getTimeQueryAvailability(query: WebGLQuery): any;
  112891. }
  112892. interface AbstractMesh {
  112893. /**
  112894. * Backing filed
  112895. * @hidden
  112896. */
  112897. __occlusionDataStorage: _OcclusionDataStorage;
  112898. /**
  112899. * Access property
  112900. * @hidden
  112901. */
  112902. _occlusionDataStorage: _OcclusionDataStorage;
  112903. /**
  112904. * 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.
  112905. * The default value is -1 which means don't break the query and wait till the result
  112906. * @see http://doc.babylonjs.com/features/occlusionquery
  112907. */
  112908. occlusionRetryCount: number;
  112909. /**
  112910. * 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:
  112911. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  112912. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  112913. * * 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.
  112914. * @see http://doc.babylonjs.com/features/occlusionquery
  112915. */
  112916. occlusionType: number;
  112917. /**
  112918. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  112919. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  112920. * * 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.
  112921. * @see http://doc.babylonjs.com/features/occlusionquery
  112922. */
  112923. occlusionQueryAlgorithmType: number;
  112924. /**
  112925. * 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
  112926. * @see http://doc.babylonjs.com/features/occlusionquery
  112927. */
  112928. isOccluded: boolean;
  112929. /**
  112930. * Flag to check the progress status of the query
  112931. * @see http://doc.babylonjs.com/features/occlusionquery
  112932. */
  112933. isOcclusionQueryInProgress: boolean;
  112934. }
  112935. }
  112936. declare module BABYLON {
  112937. /** @hidden */
  112938. export var _forceTransformFeedbackToBundle: boolean;
  112939. interface Engine {
  112940. /**
  112941. * Creates a webGL transform feedback object
  112942. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  112943. * @returns the webGL transform feedback object
  112944. */
  112945. createTransformFeedback(): WebGLTransformFeedback;
  112946. /**
  112947. * Delete a webGL transform feedback object
  112948. * @param value defines the webGL transform feedback object to delete
  112949. */
  112950. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  112951. /**
  112952. * Bind a webGL transform feedback object to the webgl context
  112953. * @param value defines the webGL transform feedback object to bind
  112954. */
  112955. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  112956. /**
  112957. * Begins a transform feedback operation
  112958. * @param usePoints defines if points or triangles must be used
  112959. */
  112960. beginTransformFeedback(usePoints: boolean): void;
  112961. /**
  112962. * Ends a transform feedback operation
  112963. */
  112964. endTransformFeedback(): void;
  112965. /**
  112966. * Specify the varyings to use with transform feedback
  112967. * @param program defines the associated webGL program
  112968. * @param value defines the list of strings representing the varying names
  112969. */
  112970. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  112971. /**
  112972. * Bind a webGL buffer for a transform feedback operation
  112973. * @param value defines the webGL buffer to bind
  112974. */
  112975. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  112976. }
  112977. }
  112978. declare module BABYLON {
  112979. /**
  112980. * Creation options of the multi render target texture.
  112981. */
  112982. export interface IMultiRenderTargetOptions {
  112983. /**
  112984. * Define if the texture needs to create mip maps after render.
  112985. */
  112986. generateMipMaps?: boolean;
  112987. /**
  112988. * Define the types of all the draw buffers we want to create
  112989. */
  112990. types?: number[];
  112991. /**
  112992. * Define the sampling modes of all the draw buffers we want to create
  112993. */
  112994. samplingModes?: number[];
  112995. /**
  112996. * Define if a depth buffer is required
  112997. */
  112998. generateDepthBuffer?: boolean;
  112999. /**
  113000. * Define if a stencil buffer is required
  113001. */
  113002. generateStencilBuffer?: boolean;
  113003. /**
  113004. * Define if a depth texture is required instead of a depth buffer
  113005. */
  113006. generateDepthTexture?: boolean;
  113007. /**
  113008. * Define the number of desired draw buffers
  113009. */
  113010. textureCount?: number;
  113011. /**
  113012. * Define if aspect ratio should be adapted to the texture or stay the scene one
  113013. */
  113014. doNotChangeAspectRatio?: boolean;
  113015. /**
  113016. * Define the default type of the buffers we are creating
  113017. */
  113018. defaultType?: number;
  113019. }
  113020. /**
  113021. * A multi render target, like a render target provides the ability to render to a texture.
  113022. * Unlike the render target, it can render to several draw buffers in one draw.
  113023. * This is specially interesting in deferred rendering or for any effects requiring more than
  113024. * just one color from a single pass.
  113025. */
  113026. export class MultiRenderTarget extends RenderTargetTexture {
  113027. private _internalTextures;
  113028. private _textures;
  113029. private _multiRenderTargetOptions;
  113030. /**
  113031. * Get if draw buffers are currently supported by the used hardware and browser.
  113032. */
  113033. readonly isSupported: boolean;
  113034. /**
  113035. * Get the list of textures generated by the multi render target.
  113036. */
  113037. readonly textures: Texture[];
  113038. /**
  113039. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  113040. */
  113041. readonly depthTexture: Texture;
  113042. /**
  113043. * Set the wrapping mode on U of all the textures we are rendering to.
  113044. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  113045. */
  113046. wrapU: number;
  113047. /**
  113048. * Set the wrapping mode on V of all the textures we are rendering to.
  113049. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  113050. */
  113051. wrapV: number;
  113052. /**
  113053. * Instantiate a new multi render target texture.
  113054. * A multi render target, like a render target provides the ability to render to a texture.
  113055. * Unlike the render target, it can render to several draw buffers in one draw.
  113056. * This is specially interesting in deferred rendering or for any effects requiring more than
  113057. * just one color from a single pass.
  113058. * @param name Define the name of the texture
  113059. * @param size Define the size of the buffers to render to
  113060. * @param count Define the number of target we are rendering into
  113061. * @param scene Define the scene the texture belongs to
  113062. * @param options Define the options used to create the multi render target
  113063. */
  113064. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  113065. /** @hidden */
  113066. _rebuild(): void;
  113067. private _createInternalTextures;
  113068. private _createTextures;
  113069. /**
  113070. * Define the number of samples used if MSAA is enabled.
  113071. */
  113072. samples: number;
  113073. /**
  113074. * Resize all the textures in the multi render target.
  113075. * Be carrefull as it will recreate all the data in the new texture.
  113076. * @param size Define the new size
  113077. */
  113078. resize(size: any): void;
  113079. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  113080. /**
  113081. * Dispose the render targets and their associated resources
  113082. */
  113083. dispose(): void;
  113084. /**
  113085. * Release all the underlying texture used as draw buffers.
  113086. */
  113087. releaseInternalTextures(): void;
  113088. }
  113089. }
  113090. declare module BABYLON {
  113091. interface ThinEngine {
  113092. /**
  113093. * Unbind a list of render target textures from the webGL context
  113094. * This is used only when drawBuffer extension or webGL2 are active
  113095. * @param textures defines the render target textures to unbind
  113096. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113097. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113098. */
  113099. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  113100. /**
  113101. * Create a multi render target texture
  113102. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  113103. * @param size defines the size of the texture
  113104. * @param options defines the creation options
  113105. * @returns the cube texture as an InternalTexture
  113106. */
  113107. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  113108. /**
  113109. * Update the sample count for a given multiple render target texture
  113110. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  113111. * @param textures defines the textures to update
  113112. * @param samples defines the sample count to set
  113113. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  113114. */
  113115. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  113116. }
  113117. }
  113118. declare module BABYLON {
  113119. /**
  113120. * Class used to define an additional view for the engine
  113121. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113122. */
  113123. export class EngineView {
  113124. /** Defines the canvas where to render the view */
  113125. target: HTMLCanvasElement;
  113126. /** Defines an optional camera used to render the view (will use active camera else) */
  113127. camera?: Camera;
  113128. }
  113129. interface Engine {
  113130. /**
  113131. * Gets or sets the HTML element to use for attaching events
  113132. */
  113133. inputElement: Nullable<HTMLElement>;
  113134. /**
  113135. * Gets the current engine view
  113136. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113137. */
  113138. activeView: Nullable<EngineView>;
  113139. /** Gets or sets the list of views */
  113140. views: EngineView[];
  113141. /**
  113142. * Register a new child canvas
  113143. * @param canvas defines the canvas to register
  113144. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  113145. * @returns the associated view
  113146. */
  113147. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  113148. /**
  113149. * Remove a registered child canvas
  113150. * @param canvas defines the canvas to remove
  113151. * @returns the current engine
  113152. */
  113153. unRegisterView(canvas: HTMLCanvasElement): Engine;
  113154. }
  113155. }
  113156. declare module BABYLON {
  113157. /**
  113158. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  113159. */
  113160. export interface CubeMapInfo {
  113161. /**
  113162. * The pixel array for the front face.
  113163. * This is stored in format, left to right, up to down format.
  113164. */
  113165. front: Nullable<ArrayBufferView>;
  113166. /**
  113167. * The pixel array for the back face.
  113168. * This is stored in format, left to right, up to down format.
  113169. */
  113170. back: Nullable<ArrayBufferView>;
  113171. /**
  113172. * The pixel array for the left face.
  113173. * This is stored in format, left to right, up to down format.
  113174. */
  113175. left: Nullable<ArrayBufferView>;
  113176. /**
  113177. * The pixel array for the right face.
  113178. * This is stored in format, left to right, up to down format.
  113179. */
  113180. right: Nullable<ArrayBufferView>;
  113181. /**
  113182. * The pixel array for the up face.
  113183. * This is stored in format, left to right, up to down format.
  113184. */
  113185. up: Nullable<ArrayBufferView>;
  113186. /**
  113187. * The pixel array for the down face.
  113188. * This is stored in format, left to right, up to down format.
  113189. */
  113190. down: Nullable<ArrayBufferView>;
  113191. /**
  113192. * The size of the cubemap stored.
  113193. *
  113194. * Each faces will be size * size pixels.
  113195. */
  113196. size: number;
  113197. /**
  113198. * The format of the texture.
  113199. *
  113200. * RGBA, RGB.
  113201. */
  113202. format: number;
  113203. /**
  113204. * The type of the texture data.
  113205. *
  113206. * UNSIGNED_INT, FLOAT.
  113207. */
  113208. type: number;
  113209. /**
  113210. * Specifies whether the texture is in gamma space.
  113211. */
  113212. gammaSpace: boolean;
  113213. }
  113214. /**
  113215. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  113216. */
  113217. export class PanoramaToCubeMapTools {
  113218. private static FACE_FRONT;
  113219. private static FACE_BACK;
  113220. private static FACE_RIGHT;
  113221. private static FACE_LEFT;
  113222. private static FACE_DOWN;
  113223. private static FACE_UP;
  113224. /**
  113225. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  113226. *
  113227. * @param float32Array The source data.
  113228. * @param inputWidth The width of the input panorama.
  113229. * @param inputHeight The height of the input panorama.
  113230. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  113231. * @return The cubemap data
  113232. */
  113233. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  113234. private static CreateCubemapTexture;
  113235. private static CalcProjectionSpherical;
  113236. }
  113237. }
  113238. declare module BABYLON {
  113239. /**
  113240. * Helper class dealing with the extraction of spherical polynomial dataArray
  113241. * from a cube map.
  113242. */
  113243. export class CubeMapToSphericalPolynomialTools {
  113244. private static FileFaces;
  113245. /**
  113246. * Converts a texture to the according Spherical Polynomial data.
  113247. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113248. *
  113249. * @param texture The texture to extract the information from.
  113250. * @return The Spherical Polynomial data.
  113251. */
  113252. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  113253. /**
  113254. * Converts a cubemap to the according Spherical Polynomial data.
  113255. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113256. *
  113257. * @param cubeInfo The Cube map to extract the information from.
  113258. * @return The Spherical Polynomial data.
  113259. */
  113260. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  113261. }
  113262. }
  113263. declare module BABYLON {
  113264. interface BaseTexture {
  113265. /**
  113266. * Get the polynomial representation of the texture data.
  113267. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  113268. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  113269. */
  113270. sphericalPolynomial: Nullable<SphericalPolynomial>;
  113271. }
  113272. }
  113273. declare module BABYLON {
  113274. /** @hidden */
  113275. export var rgbdEncodePixelShader: {
  113276. name: string;
  113277. shader: string;
  113278. };
  113279. }
  113280. declare module BABYLON {
  113281. /** @hidden */
  113282. export var rgbdDecodePixelShader: {
  113283. name: string;
  113284. shader: string;
  113285. };
  113286. }
  113287. declare module BABYLON {
  113288. /**
  113289. * Raw texture data and descriptor sufficient for WebGL texture upload
  113290. */
  113291. export interface EnvironmentTextureInfo {
  113292. /**
  113293. * Version of the environment map
  113294. */
  113295. version: number;
  113296. /**
  113297. * Width of image
  113298. */
  113299. width: number;
  113300. /**
  113301. * Irradiance information stored in the file.
  113302. */
  113303. irradiance: any;
  113304. /**
  113305. * Specular information stored in the file.
  113306. */
  113307. specular: any;
  113308. }
  113309. /**
  113310. * Defines One Image in the file. It requires only the position in the file
  113311. * as well as the length.
  113312. */
  113313. interface BufferImageData {
  113314. /**
  113315. * Length of the image data.
  113316. */
  113317. length: number;
  113318. /**
  113319. * Position of the data from the null terminator delimiting the end of the JSON.
  113320. */
  113321. position: number;
  113322. }
  113323. /**
  113324. * Defines the specular data enclosed in the file.
  113325. * This corresponds to the version 1 of the data.
  113326. */
  113327. export interface EnvironmentTextureSpecularInfoV1 {
  113328. /**
  113329. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  113330. */
  113331. specularDataPosition?: number;
  113332. /**
  113333. * This contains all the images data needed to reconstruct the cubemap.
  113334. */
  113335. mipmaps: Array<BufferImageData>;
  113336. /**
  113337. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  113338. */
  113339. lodGenerationScale: number;
  113340. }
  113341. /**
  113342. * Sets of helpers addressing the serialization and deserialization of environment texture
  113343. * stored in a BabylonJS env file.
  113344. * Those files are usually stored as .env files.
  113345. */
  113346. export class EnvironmentTextureTools {
  113347. /**
  113348. * Magic number identifying the env file.
  113349. */
  113350. private static _MagicBytes;
  113351. /**
  113352. * Gets the environment info from an env file.
  113353. * @param data The array buffer containing the .env bytes.
  113354. * @returns the environment file info (the json header) if successfully parsed.
  113355. */
  113356. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  113357. /**
  113358. * Creates an environment texture from a loaded cube texture.
  113359. * @param texture defines the cube texture to convert in env file
  113360. * @return a promise containing the environment data if succesfull.
  113361. */
  113362. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  113363. /**
  113364. * Creates a JSON representation of the spherical data.
  113365. * @param texture defines the texture containing the polynomials
  113366. * @return the JSON representation of the spherical info
  113367. */
  113368. private static _CreateEnvTextureIrradiance;
  113369. /**
  113370. * Creates the ArrayBufferViews used for initializing environment texture image data.
  113371. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  113372. * @param info parameters that determine what views will be created for accessing the underlying buffer
  113373. * @return the views described by info providing access to the underlying buffer
  113374. */
  113375. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  113376. /**
  113377. * Uploads the texture info contained in the env file to the GPU.
  113378. * @param texture defines the internal texture to upload to
  113379. * @param arrayBuffer defines the buffer cotaining the data to load
  113380. * @param info defines the texture info retrieved through the GetEnvInfo method
  113381. * @returns a promise
  113382. */
  113383. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  113384. private static _OnImageReadyAsync;
  113385. /**
  113386. * Uploads the levels of image data to the GPU.
  113387. * @param texture defines the internal texture to upload to
  113388. * @param imageData defines the array buffer views of image data [mipmap][face]
  113389. * @returns a promise
  113390. */
  113391. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  113392. /**
  113393. * Uploads spherical polynomials information to the texture.
  113394. * @param texture defines the texture we are trying to upload the information to
  113395. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  113396. */
  113397. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  113398. /** @hidden */
  113399. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113400. }
  113401. }
  113402. declare module BABYLON {
  113403. /**
  113404. * Contains position and normal vectors for a vertex
  113405. */
  113406. export class PositionNormalVertex {
  113407. /** the position of the vertex (defaut: 0,0,0) */
  113408. position: Vector3;
  113409. /** the normal of the vertex (defaut: 0,1,0) */
  113410. normal: Vector3;
  113411. /**
  113412. * Creates a PositionNormalVertex
  113413. * @param position the position of the vertex (defaut: 0,0,0)
  113414. * @param normal the normal of the vertex (defaut: 0,1,0)
  113415. */
  113416. constructor(
  113417. /** the position of the vertex (defaut: 0,0,0) */
  113418. position?: Vector3,
  113419. /** the normal of the vertex (defaut: 0,1,0) */
  113420. normal?: Vector3);
  113421. /**
  113422. * Clones the PositionNormalVertex
  113423. * @returns the cloned PositionNormalVertex
  113424. */
  113425. clone(): PositionNormalVertex;
  113426. }
  113427. /**
  113428. * Contains position, normal and uv vectors for a vertex
  113429. */
  113430. export class PositionNormalTextureVertex {
  113431. /** the position of the vertex (defaut: 0,0,0) */
  113432. position: Vector3;
  113433. /** the normal of the vertex (defaut: 0,1,0) */
  113434. normal: Vector3;
  113435. /** the uv of the vertex (default: 0,0) */
  113436. uv: Vector2;
  113437. /**
  113438. * Creates a PositionNormalTextureVertex
  113439. * @param position the position of the vertex (defaut: 0,0,0)
  113440. * @param normal the normal of the vertex (defaut: 0,1,0)
  113441. * @param uv the uv of the vertex (default: 0,0)
  113442. */
  113443. constructor(
  113444. /** the position of the vertex (defaut: 0,0,0) */
  113445. position?: Vector3,
  113446. /** the normal of the vertex (defaut: 0,1,0) */
  113447. normal?: Vector3,
  113448. /** the uv of the vertex (default: 0,0) */
  113449. uv?: Vector2);
  113450. /**
  113451. * Clones the PositionNormalTextureVertex
  113452. * @returns the cloned PositionNormalTextureVertex
  113453. */
  113454. clone(): PositionNormalTextureVertex;
  113455. }
  113456. }
  113457. declare module BABYLON {
  113458. /** @hidden */
  113459. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  113460. private _genericAttributeLocation;
  113461. private _varyingLocationCount;
  113462. private _varyingLocationMap;
  113463. private _replacements;
  113464. private _textureCount;
  113465. private _uniforms;
  113466. lineProcessor(line: string): string;
  113467. attributeProcessor(attribute: string): string;
  113468. varyingProcessor(varying: string, isFragment: boolean): string;
  113469. uniformProcessor(uniform: string): string;
  113470. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  113471. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113472. }
  113473. }
  113474. declare module BABYLON {
  113475. /**
  113476. * Container for accessors for natively-stored mesh data buffers.
  113477. */
  113478. class NativeDataBuffer extends DataBuffer {
  113479. /**
  113480. * Accessor value used to identify/retrieve a natively-stored index buffer.
  113481. */
  113482. nativeIndexBuffer?: any;
  113483. /**
  113484. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  113485. */
  113486. nativeVertexBuffer?: any;
  113487. }
  113488. /** @hidden */
  113489. class NativeTexture extends InternalTexture {
  113490. getInternalTexture(): InternalTexture;
  113491. getViewCount(): number;
  113492. }
  113493. /** @hidden */
  113494. export class NativeEngine extends Engine {
  113495. private readonly _native;
  113496. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  113497. private readonly INVALID_HANDLE;
  113498. getHardwareScalingLevel(): number;
  113499. constructor();
  113500. /**
  113501. * Can be used to override the current requestAnimationFrame requester.
  113502. * @hidden
  113503. */
  113504. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113505. /**
  113506. * Override default engine behavior.
  113507. * @param color
  113508. * @param backBuffer
  113509. * @param depth
  113510. * @param stencil
  113511. */
  113512. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113513. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113514. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  113515. createVertexBuffer(data: DataArray): NativeDataBuffer;
  113516. recordVertexArrayObject(vertexBuffers: {
  113517. [key: string]: VertexBuffer;
  113518. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113519. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113520. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113521. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113522. /**
  113523. * Draw a list of indexed primitives
  113524. * @param fillMode defines the primitive to use
  113525. * @param indexStart defines the starting index
  113526. * @param indexCount defines the number of index to draw
  113527. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113528. */
  113529. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113530. /**
  113531. * Draw a list of unindexed primitives
  113532. * @param fillMode defines the primitive to use
  113533. * @param verticesStart defines the index of first vertex to draw
  113534. * @param verticesCount defines the count of vertices to draw
  113535. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113536. */
  113537. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113538. createPipelineContext(): IPipelineContext;
  113539. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113540. /** @hidden */
  113541. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113542. /** @hidden */
  113543. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113544. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113545. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113546. protected _setProgram(program: WebGLProgram): void;
  113547. _releaseEffect(effect: Effect): void;
  113548. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113549. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  113550. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  113551. bindSamplers(effect: Effect): void;
  113552. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  113553. getRenderWidth(useScreen?: boolean): number;
  113554. getRenderHeight(useScreen?: boolean): number;
  113555. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  113556. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113557. /**
  113558. * Set the z offset to apply to current rendering
  113559. * @param value defines the offset to apply
  113560. */
  113561. setZOffset(value: number): void;
  113562. /**
  113563. * Gets the current value of the zOffset
  113564. * @returns the current zOffset state
  113565. */
  113566. getZOffset(): number;
  113567. /**
  113568. * Enable or disable depth buffering
  113569. * @param enable defines the state to set
  113570. */
  113571. setDepthBuffer(enable: boolean): void;
  113572. /**
  113573. * Gets a boolean indicating if depth writing is enabled
  113574. * @returns the current depth writing state
  113575. */
  113576. getDepthWrite(): boolean;
  113577. /**
  113578. * Enable or disable depth writing
  113579. * @param enable defines the state to set
  113580. */
  113581. setDepthWrite(enable: boolean): void;
  113582. /**
  113583. * Enable or disable color writing
  113584. * @param enable defines the state to set
  113585. */
  113586. setColorWrite(enable: boolean): void;
  113587. /**
  113588. * Gets a boolean indicating if color writing is enabled
  113589. * @returns the current color writing state
  113590. */
  113591. getColorWrite(): boolean;
  113592. /**
  113593. * Sets alpha constants used by some alpha blending modes
  113594. * @param r defines the red component
  113595. * @param g defines the green component
  113596. * @param b defines the blue component
  113597. * @param a defines the alpha component
  113598. */
  113599. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113600. /**
  113601. * Sets the current alpha mode
  113602. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  113603. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113604. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113605. */
  113606. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113607. /**
  113608. * Gets the current alpha mode
  113609. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113610. * @returns the current alpha mode
  113611. */
  113612. getAlphaMode(): number;
  113613. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113614. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113615. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113616. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113617. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113618. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113619. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113620. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113621. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113622. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113623. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113624. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113625. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113626. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113627. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113628. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113629. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113630. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113631. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113632. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113633. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  113634. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  113635. wipeCaches(bruteForce?: boolean): void;
  113636. _createTexture(): WebGLTexture;
  113637. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113638. /**
  113639. * Usually called from BABYLON.Texture.ts.
  113640. * Passed information to create a WebGLTexture
  113641. * @param urlArg defines a value which contains one of the following:
  113642. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113643. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113644. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113645. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113646. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  113647. * @param scene needed for loading to the correct scene
  113648. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  113649. * @param onLoad optional callback to be called upon successful completion
  113650. * @param onError optional callback to be called upon failure
  113651. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  113652. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113653. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113654. * @param forcedExtension defines the extension to use to pick the right loader
  113655. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113656. */
  113657. 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;
  113658. /**
  113659. * Creates a cube texture
  113660. * @param rootUrl defines the url where the files to load is located
  113661. * @param scene defines the current scene
  113662. * @param files defines the list of files to load (1 per face)
  113663. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  113664. * @param onLoad defines an optional callback raised when the texture is loaded
  113665. * @param onError defines an optional callback raised if there is an issue to load the texture
  113666. * @param format defines the format of the data
  113667. * @param forcedExtension defines the extension to use to pick the right loader
  113668. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  113669. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113670. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113671. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  113672. * @returns the cube texture as an InternalTexture
  113673. */
  113674. 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;
  113675. private _getSamplingFilter;
  113676. private static _GetNativeTextureFormat;
  113677. createRenderTargetTexture(size: number | {
  113678. width: number;
  113679. height: number;
  113680. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  113681. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113682. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113683. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113684. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113685. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113686. /**
  113687. * Updates a dynamic vertex buffer.
  113688. * @param vertexBuffer the vertex buffer to update
  113689. * @param data the data used to update the vertex buffer
  113690. * @param byteOffset the byte offset of the data (optional)
  113691. * @param byteLength the byte length of the data (optional)
  113692. */
  113693. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113694. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113695. private _updateAnisotropicLevel;
  113696. private _getAddressMode;
  113697. /** @hidden */
  113698. _bindTexture(channel: number, texture: InternalTexture): void;
  113699. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  113700. releaseEffects(): void;
  113701. /** @hidden */
  113702. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113703. /** @hidden */
  113704. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113705. /** @hidden */
  113706. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113707. /** @hidden */
  113708. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113709. }
  113710. }
  113711. declare module BABYLON {
  113712. /**
  113713. * Gather the list of clipboard event types as constants.
  113714. */
  113715. export class ClipboardEventTypes {
  113716. /**
  113717. * The clipboard event is fired when a copy command is active (pressed).
  113718. */
  113719. static readonly COPY: number;
  113720. /**
  113721. * The clipboard event is fired when a cut command is active (pressed).
  113722. */
  113723. static readonly CUT: number;
  113724. /**
  113725. * The clipboard event is fired when a paste command is active (pressed).
  113726. */
  113727. static readonly PASTE: number;
  113728. }
  113729. /**
  113730. * This class is used to store clipboard related info for the onClipboardObservable event.
  113731. */
  113732. export class ClipboardInfo {
  113733. /**
  113734. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113735. */
  113736. type: number;
  113737. /**
  113738. * Defines the related dom event
  113739. */
  113740. event: ClipboardEvent;
  113741. /**
  113742. *Creates an instance of ClipboardInfo.
  113743. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  113744. * @param event Defines the related dom event
  113745. */
  113746. constructor(
  113747. /**
  113748. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113749. */
  113750. type: number,
  113751. /**
  113752. * Defines the related dom event
  113753. */
  113754. event: ClipboardEvent);
  113755. /**
  113756. * Get the clipboard event's type from the keycode.
  113757. * @param keyCode Defines the keyCode for the current keyboard event.
  113758. * @return {number}
  113759. */
  113760. static GetTypeFromCharacter(keyCode: number): number;
  113761. }
  113762. }
  113763. declare module BABYLON {
  113764. /**
  113765. * Google Daydream controller
  113766. */
  113767. export class DaydreamController extends WebVRController {
  113768. /**
  113769. * Base Url for the controller model.
  113770. */
  113771. static MODEL_BASE_URL: string;
  113772. /**
  113773. * File name for the controller model.
  113774. */
  113775. static MODEL_FILENAME: string;
  113776. /**
  113777. * Gamepad Id prefix used to identify Daydream Controller.
  113778. */
  113779. static readonly GAMEPAD_ID_PREFIX: string;
  113780. /**
  113781. * Creates a new DaydreamController from a gamepad
  113782. * @param vrGamepad the gamepad that the controller should be created from
  113783. */
  113784. constructor(vrGamepad: any);
  113785. /**
  113786. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113787. * @param scene scene in which to add meshes
  113788. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113789. */
  113790. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113791. /**
  113792. * Called once for each button that changed state since the last frame
  113793. * @param buttonIdx Which button index changed
  113794. * @param state New state of the button
  113795. * @param changes Which properties on the state changed since last frame
  113796. */
  113797. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113798. }
  113799. }
  113800. declare module BABYLON {
  113801. /**
  113802. * Gear VR Controller
  113803. */
  113804. export class GearVRController extends WebVRController {
  113805. /**
  113806. * Base Url for the controller model.
  113807. */
  113808. static MODEL_BASE_URL: string;
  113809. /**
  113810. * File name for the controller model.
  113811. */
  113812. static MODEL_FILENAME: string;
  113813. /**
  113814. * Gamepad Id prefix used to identify this controller.
  113815. */
  113816. static readonly GAMEPAD_ID_PREFIX: string;
  113817. private readonly _buttonIndexToObservableNameMap;
  113818. /**
  113819. * Creates a new GearVRController from a gamepad
  113820. * @param vrGamepad the gamepad that the controller should be created from
  113821. */
  113822. constructor(vrGamepad: any);
  113823. /**
  113824. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113825. * @param scene scene in which to add meshes
  113826. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113827. */
  113828. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113829. /**
  113830. * Called once for each button that changed state since the last frame
  113831. * @param buttonIdx Which button index changed
  113832. * @param state New state of the button
  113833. * @param changes Which properties on the state changed since last frame
  113834. */
  113835. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113836. }
  113837. }
  113838. declare module BABYLON {
  113839. /**
  113840. * Class containing static functions to help procedurally build meshes
  113841. */
  113842. export class PolyhedronBuilder {
  113843. /**
  113844. * Creates a polyhedron mesh
  113845. * * 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
  113846. * * The parameter `size` (positive float, default 1) sets the polygon size
  113847. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  113848. * * 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`
  113849. * * 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
  113850. * * 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)`)
  113851. * * 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
  113852. * * 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
  113853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113856. * @param name defines the name of the mesh
  113857. * @param options defines the options used to create the mesh
  113858. * @param scene defines the hosting scene
  113859. * @returns the polyhedron mesh
  113860. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  113861. */
  113862. static CreatePolyhedron(name: string, options: {
  113863. type?: number;
  113864. size?: number;
  113865. sizeX?: number;
  113866. sizeY?: number;
  113867. sizeZ?: number;
  113868. custom?: any;
  113869. faceUV?: Vector4[];
  113870. faceColors?: Color4[];
  113871. flat?: boolean;
  113872. updatable?: boolean;
  113873. sideOrientation?: number;
  113874. frontUVs?: Vector4;
  113875. backUVs?: Vector4;
  113876. }, scene?: Nullable<Scene>): Mesh;
  113877. }
  113878. }
  113879. declare module BABYLON {
  113880. /**
  113881. * Gizmo that enables scaling a mesh along 3 axis
  113882. */
  113883. export class ScaleGizmo extends Gizmo {
  113884. /**
  113885. * Internal gizmo used for interactions on the x axis
  113886. */
  113887. xGizmo: AxisScaleGizmo;
  113888. /**
  113889. * Internal gizmo used for interactions on the y axis
  113890. */
  113891. yGizmo: AxisScaleGizmo;
  113892. /**
  113893. * Internal gizmo used for interactions on the z axis
  113894. */
  113895. zGizmo: AxisScaleGizmo;
  113896. /**
  113897. * Internal gizmo used to scale all axis equally
  113898. */
  113899. uniformScaleGizmo: AxisScaleGizmo;
  113900. private _meshAttached;
  113901. private _updateGizmoRotationToMatchAttachedMesh;
  113902. private _snapDistance;
  113903. private _scaleRatio;
  113904. private _uniformScalingMesh;
  113905. private _octahedron;
  113906. /** Fires an event when any of it's sub gizmos are dragged */
  113907. onDragStartObservable: Observable<unknown>;
  113908. /** Fires an event when any of it's sub gizmos are released from dragging */
  113909. onDragEndObservable: Observable<unknown>;
  113910. attachedMesh: Nullable<AbstractMesh>;
  113911. /**
  113912. * Creates a ScaleGizmo
  113913. * @param gizmoLayer The utility layer the gizmo will be added to
  113914. */
  113915. constructor(gizmoLayer?: UtilityLayerRenderer);
  113916. updateGizmoRotationToMatchAttachedMesh: boolean;
  113917. /**
  113918. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113919. */
  113920. snapDistance: number;
  113921. /**
  113922. * Ratio for the scale of the gizmo (Default: 1)
  113923. */
  113924. scaleRatio: number;
  113925. /**
  113926. * Disposes of the gizmo
  113927. */
  113928. dispose(): void;
  113929. }
  113930. }
  113931. declare module BABYLON {
  113932. /**
  113933. * Single axis scale gizmo
  113934. */
  113935. export class AxisScaleGizmo extends Gizmo {
  113936. /**
  113937. * Drag behavior responsible for the gizmos dragging interactions
  113938. */
  113939. dragBehavior: PointerDragBehavior;
  113940. private _pointerObserver;
  113941. /**
  113942. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113943. */
  113944. snapDistance: number;
  113945. /**
  113946. * Event that fires each time the gizmo snaps to a new location.
  113947. * * snapDistance is the the change in distance
  113948. */
  113949. onSnapObservable: Observable<{
  113950. snapDistance: number;
  113951. }>;
  113952. /**
  113953. * If the scaling operation should be done on all axis (default: false)
  113954. */
  113955. uniformScaling: boolean;
  113956. private _isEnabled;
  113957. private _parent;
  113958. private _arrow;
  113959. private _coloredMaterial;
  113960. private _hoverMaterial;
  113961. /**
  113962. * Creates an AxisScaleGizmo
  113963. * @param gizmoLayer The utility layer the gizmo will be added to
  113964. * @param dragAxis The axis which the gizmo will be able to scale on
  113965. * @param color The color of the gizmo
  113966. */
  113967. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  113968. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113969. /**
  113970. * If the gizmo is enabled
  113971. */
  113972. isEnabled: boolean;
  113973. /**
  113974. * Disposes of the gizmo
  113975. */
  113976. dispose(): void;
  113977. /**
  113978. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113979. * @param mesh The mesh to replace the default mesh of the gizmo
  113980. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  113981. */
  113982. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  113983. }
  113984. }
  113985. declare module BABYLON {
  113986. /**
  113987. * Bounding box gizmo
  113988. */
  113989. export class BoundingBoxGizmo extends Gizmo {
  113990. private _lineBoundingBox;
  113991. private _rotateSpheresParent;
  113992. private _scaleBoxesParent;
  113993. private _boundingDimensions;
  113994. private _renderObserver;
  113995. private _pointerObserver;
  113996. private _scaleDragSpeed;
  113997. private _tmpQuaternion;
  113998. private _tmpVector;
  113999. private _tmpRotationMatrix;
  114000. /**
  114001. * 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)
  114002. */
  114003. ignoreChildren: boolean;
  114004. /**
  114005. * 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)
  114006. */
  114007. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  114008. /**
  114009. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  114010. */
  114011. rotationSphereSize: number;
  114012. /**
  114013. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  114014. */
  114015. scaleBoxSize: number;
  114016. /**
  114017. * 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)
  114018. */
  114019. fixedDragMeshScreenSize: boolean;
  114020. /**
  114021. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  114022. */
  114023. fixedDragMeshScreenSizeDistanceFactor: number;
  114024. /**
  114025. * Fired when a rotation sphere or scale box is dragged
  114026. */
  114027. onDragStartObservable: Observable<{}>;
  114028. /**
  114029. * Fired when a scale box is dragged
  114030. */
  114031. onScaleBoxDragObservable: Observable<{}>;
  114032. /**
  114033. * Fired when a scale box drag is ended
  114034. */
  114035. onScaleBoxDragEndObservable: Observable<{}>;
  114036. /**
  114037. * Fired when a rotation sphere is dragged
  114038. */
  114039. onRotationSphereDragObservable: Observable<{}>;
  114040. /**
  114041. * Fired when a rotation sphere drag is ended
  114042. */
  114043. onRotationSphereDragEndObservable: Observable<{}>;
  114044. /**
  114045. * 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)
  114046. */
  114047. scalePivot: Nullable<Vector3>;
  114048. /**
  114049. * Mesh used as a pivot to rotate the attached mesh
  114050. */
  114051. private _anchorMesh;
  114052. private _existingMeshScale;
  114053. private _dragMesh;
  114054. private pointerDragBehavior;
  114055. private coloredMaterial;
  114056. private hoverColoredMaterial;
  114057. /**
  114058. * Sets the color of the bounding box gizmo
  114059. * @param color the color to set
  114060. */
  114061. setColor(color: Color3): void;
  114062. /**
  114063. * Creates an BoundingBoxGizmo
  114064. * @param gizmoLayer The utility layer the gizmo will be added to
  114065. * @param color The color of the gizmo
  114066. */
  114067. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  114068. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114069. private _selectNode;
  114070. /**
  114071. * Updates the bounding box information for the Gizmo
  114072. */
  114073. updateBoundingBox(): void;
  114074. private _updateRotationSpheres;
  114075. private _updateScaleBoxes;
  114076. /**
  114077. * Enables rotation on the specified axis and disables rotation on the others
  114078. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  114079. */
  114080. setEnabledRotationAxis(axis: string): void;
  114081. /**
  114082. * Enables/disables scaling
  114083. * @param enable if scaling should be enabled
  114084. */
  114085. setEnabledScaling(enable: boolean): void;
  114086. private _updateDummy;
  114087. /**
  114088. * Enables a pointer drag behavior on the bounding box of the gizmo
  114089. */
  114090. enableDragBehavior(): void;
  114091. /**
  114092. * Disposes of the gizmo
  114093. */
  114094. dispose(): void;
  114095. /**
  114096. * 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)
  114097. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  114098. * @returns the bounding box mesh with the passed in mesh as a child
  114099. */
  114100. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  114101. /**
  114102. * CustomMeshes are not supported by this gizmo
  114103. * @param mesh The mesh to replace the default mesh of the gizmo
  114104. */
  114105. setCustomMesh(mesh: Mesh): void;
  114106. }
  114107. }
  114108. declare module BABYLON {
  114109. /**
  114110. * Single plane rotation gizmo
  114111. */
  114112. export class PlaneRotationGizmo extends Gizmo {
  114113. /**
  114114. * Drag behavior responsible for the gizmos dragging interactions
  114115. */
  114116. dragBehavior: PointerDragBehavior;
  114117. private _pointerObserver;
  114118. /**
  114119. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  114120. */
  114121. snapDistance: number;
  114122. /**
  114123. * Event that fires each time the gizmo snaps to a new location.
  114124. * * snapDistance is the the change in distance
  114125. */
  114126. onSnapObservable: Observable<{
  114127. snapDistance: number;
  114128. }>;
  114129. private _isEnabled;
  114130. private _parent;
  114131. /**
  114132. * Creates a PlaneRotationGizmo
  114133. * @param gizmoLayer The utility layer the gizmo will be added to
  114134. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  114135. * @param color The color of the gizmo
  114136. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114137. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114138. */
  114139. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  114140. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114141. /**
  114142. * If the gizmo is enabled
  114143. */
  114144. isEnabled: boolean;
  114145. /**
  114146. * Disposes of the gizmo
  114147. */
  114148. dispose(): void;
  114149. }
  114150. }
  114151. declare module BABYLON {
  114152. /**
  114153. * Gizmo that enables rotating a mesh along 3 axis
  114154. */
  114155. export class RotationGizmo extends Gizmo {
  114156. /**
  114157. * Internal gizmo used for interactions on the x axis
  114158. */
  114159. xGizmo: PlaneRotationGizmo;
  114160. /**
  114161. * Internal gizmo used for interactions on the y axis
  114162. */
  114163. yGizmo: PlaneRotationGizmo;
  114164. /**
  114165. * Internal gizmo used for interactions on the z axis
  114166. */
  114167. zGizmo: PlaneRotationGizmo;
  114168. /** Fires an event when any of it's sub gizmos are dragged */
  114169. onDragStartObservable: Observable<unknown>;
  114170. /** Fires an event when any of it's sub gizmos are released from dragging */
  114171. onDragEndObservable: Observable<unknown>;
  114172. private _meshAttached;
  114173. attachedMesh: Nullable<AbstractMesh>;
  114174. /**
  114175. * Creates a RotationGizmo
  114176. * @param gizmoLayer The utility layer the gizmo will be added to
  114177. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114178. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114179. */
  114180. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  114181. updateGizmoRotationToMatchAttachedMesh: boolean;
  114182. /**
  114183. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114184. */
  114185. snapDistance: number;
  114186. /**
  114187. * Ratio for the scale of the gizmo (Default: 1)
  114188. */
  114189. scaleRatio: number;
  114190. /**
  114191. * Disposes of the gizmo
  114192. */
  114193. dispose(): void;
  114194. /**
  114195. * CustomMeshes are not supported by this gizmo
  114196. * @param mesh The mesh to replace the default mesh of the gizmo
  114197. */
  114198. setCustomMesh(mesh: Mesh): void;
  114199. }
  114200. }
  114201. declare module BABYLON {
  114202. /**
  114203. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  114204. */
  114205. export class GizmoManager implements IDisposable {
  114206. private scene;
  114207. /**
  114208. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  114209. */
  114210. gizmos: {
  114211. positionGizmo: Nullable<PositionGizmo>;
  114212. rotationGizmo: Nullable<RotationGizmo>;
  114213. scaleGizmo: Nullable<ScaleGizmo>;
  114214. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  114215. };
  114216. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  114217. clearGizmoOnEmptyPointerEvent: boolean;
  114218. /** Fires an event when the manager is attached to a mesh */
  114219. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  114220. private _gizmosEnabled;
  114221. private _pointerObserver;
  114222. private _attachedMesh;
  114223. private _boundingBoxColor;
  114224. private _defaultUtilityLayer;
  114225. private _defaultKeepDepthUtilityLayer;
  114226. /**
  114227. * When bounding box gizmo is enabled, this can be used to track drag/end events
  114228. */
  114229. boundingBoxDragBehavior: SixDofDragBehavior;
  114230. /**
  114231. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  114232. */
  114233. attachableMeshes: Nullable<Array<AbstractMesh>>;
  114234. /**
  114235. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  114236. */
  114237. usePointerToAttachGizmos: boolean;
  114238. /**
  114239. * Utility layer that the bounding box gizmo belongs to
  114240. */
  114241. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  114242. /**
  114243. * Utility layer that all gizmos besides bounding box belong to
  114244. */
  114245. readonly utilityLayer: UtilityLayerRenderer;
  114246. /**
  114247. * Instatiates a gizmo manager
  114248. * @param scene the scene to overlay the gizmos on top of
  114249. */
  114250. constructor(scene: Scene);
  114251. /**
  114252. * Attaches a set of gizmos to the specified mesh
  114253. * @param mesh The mesh the gizmo's should be attached to
  114254. */
  114255. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114256. /**
  114257. * If the position gizmo is enabled
  114258. */
  114259. positionGizmoEnabled: boolean;
  114260. /**
  114261. * If the rotation gizmo is enabled
  114262. */
  114263. rotationGizmoEnabled: boolean;
  114264. /**
  114265. * If the scale gizmo is enabled
  114266. */
  114267. scaleGizmoEnabled: boolean;
  114268. /**
  114269. * If the boundingBox gizmo is enabled
  114270. */
  114271. boundingBoxGizmoEnabled: boolean;
  114272. /**
  114273. * Disposes of the gizmo manager
  114274. */
  114275. dispose(): void;
  114276. }
  114277. }
  114278. declare module BABYLON {
  114279. /**
  114280. * A directional light is defined by a direction (what a surprise!).
  114281. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  114282. * 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.
  114283. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114284. */
  114285. export class DirectionalLight extends ShadowLight {
  114286. private _shadowFrustumSize;
  114287. /**
  114288. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  114289. */
  114290. /**
  114291. * Specifies a fix frustum size for the shadow generation.
  114292. */
  114293. shadowFrustumSize: number;
  114294. private _shadowOrthoScale;
  114295. /**
  114296. * Gets the shadow projection scale against the optimal computed one.
  114297. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114298. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114299. */
  114300. /**
  114301. * Sets the shadow projection scale against the optimal computed one.
  114302. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114303. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114304. */
  114305. shadowOrthoScale: number;
  114306. /**
  114307. * Automatically compute the projection matrix to best fit (including all the casters)
  114308. * on each frame.
  114309. */
  114310. autoUpdateExtends: boolean;
  114311. private _orthoLeft;
  114312. private _orthoRight;
  114313. private _orthoTop;
  114314. private _orthoBottom;
  114315. /**
  114316. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  114317. * The directional light is emitted from everywhere in the given direction.
  114318. * It can cast shadows.
  114319. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114320. * @param name The friendly name of the light
  114321. * @param direction The direction of the light
  114322. * @param scene The scene the light belongs to
  114323. */
  114324. constructor(name: string, direction: Vector3, scene: Scene);
  114325. /**
  114326. * Returns the string "DirectionalLight".
  114327. * @return The class name
  114328. */
  114329. getClassName(): string;
  114330. /**
  114331. * Returns the integer 1.
  114332. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114333. */
  114334. getTypeID(): number;
  114335. /**
  114336. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  114337. * Returns the DirectionalLight Shadow projection matrix.
  114338. */
  114339. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114340. /**
  114341. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  114342. * Returns the DirectionalLight Shadow projection matrix.
  114343. */
  114344. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  114345. /**
  114346. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  114347. * Returns the DirectionalLight Shadow projection matrix.
  114348. */
  114349. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114350. protected _buildUniformLayout(): void;
  114351. /**
  114352. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  114353. * @param effect The effect to update
  114354. * @param lightIndex The index of the light in the effect to update
  114355. * @returns The directional light
  114356. */
  114357. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  114358. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  114359. /**
  114360. * Gets the minZ used for shadow according to both the scene and the light.
  114361. *
  114362. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114363. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114364. * @param activeCamera The camera we are returning the min for
  114365. * @returns the depth min z
  114366. */
  114367. getDepthMinZ(activeCamera: Camera): number;
  114368. /**
  114369. * Gets the maxZ used for shadow according to both the scene and the light.
  114370. *
  114371. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114372. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114373. * @param activeCamera The camera we are returning the max for
  114374. * @returns the depth max z
  114375. */
  114376. getDepthMaxZ(activeCamera: Camera): number;
  114377. /**
  114378. * Prepares the list of defines specific to the light type.
  114379. * @param defines the list of defines
  114380. * @param lightIndex defines the index of the light for the effect
  114381. */
  114382. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114383. }
  114384. }
  114385. declare module BABYLON {
  114386. /**
  114387. * Class containing static functions to help procedurally build meshes
  114388. */
  114389. export class HemisphereBuilder {
  114390. /**
  114391. * Creates a hemisphere mesh
  114392. * @param name defines the name of the mesh
  114393. * @param options defines the options used to create the mesh
  114394. * @param scene defines the hosting scene
  114395. * @returns the hemisphere mesh
  114396. */
  114397. static CreateHemisphere(name: string, options: {
  114398. segments?: number;
  114399. diameter?: number;
  114400. sideOrientation?: number;
  114401. }, scene: any): Mesh;
  114402. }
  114403. }
  114404. declare module BABYLON {
  114405. /**
  114406. * A spot light is defined by a position, a direction, an angle, and an exponent.
  114407. * These values define a cone of light starting from the position, emitting toward the direction.
  114408. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  114409. * and the exponent defines the speed of the decay of the light with distance (reach).
  114410. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114411. */
  114412. export class SpotLight extends ShadowLight {
  114413. private _angle;
  114414. private _innerAngle;
  114415. private _cosHalfAngle;
  114416. private _lightAngleScale;
  114417. private _lightAngleOffset;
  114418. /**
  114419. * Gets the cone angle of the spot light in Radians.
  114420. */
  114421. /**
  114422. * Sets the cone angle of the spot light in Radians.
  114423. */
  114424. angle: number;
  114425. /**
  114426. * Only used in gltf falloff mode, this defines the angle where
  114427. * the directional falloff will start before cutting at angle which could be seen
  114428. * as outer angle.
  114429. */
  114430. /**
  114431. * Only used in gltf falloff mode, this defines the angle where
  114432. * the directional falloff will start before cutting at angle which could be seen
  114433. * as outer angle.
  114434. */
  114435. innerAngle: number;
  114436. private _shadowAngleScale;
  114437. /**
  114438. * Allows scaling the angle of the light for shadow generation only.
  114439. */
  114440. /**
  114441. * Allows scaling the angle of the light for shadow generation only.
  114442. */
  114443. shadowAngleScale: number;
  114444. /**
  114445. * The light decay speed with the distance from the emission spot.
  114446. */
  114447. exponent: number;
  114448. private _projectionTextureMatrix;
  114449. /**
  114450. * Allows reading the projecton texture
  114451. */
  114452. readonly projectionTextureMatrix: Matrix;
  114453. protected _projectionTextureLightNear: number;
  114454. /**
  114455. * Gets the near clip of the Spotlight for texture projection.
  114456. */
  114457. /**
  114458. * Sets the near clip of the Spotlight for texture projection.
  114459. */
  114460. projectionTextureLightNear: number;
  114461. protected _projectionTextureLightFar: number;
  114462. /**
  114463. * Gets the far clip of the Spotlight for texture projection.
  114464. */
  114465. /**
  114466. * Sets the far clip of the Spotlight for texture projection.
  114467. */
  114468. projectionTextureLightFar: number;
  114469. protected _projectionTextureUpDirection: Vector3;
  114470. /**
  114471. * Gets the Up vector of the Spotlight for texture projection.
  114472. */
  114473. /**
  114474. * Sets the Up vector of the Spotlight for texture projection.
  114475. */
  114476. projectionTextureUpDirection: Vector3;
  114477. private _projectionTexture;
  114478. /**
  114479. * Gets the projection texture of the light.
  114480. */
  114481. /**
  114482. * Sets the projection texture of the light.
  114483. */
  114484. projectionTexture: Nullable<BaseTexture>;
  114485. private _projectionTextureViewLightDirty;
  114486. private _projectionTextureProjectionLightDirty;
  114487. private _projectionTextureDirty;
  114488. private _projectionTextureViewTargetVector;
  114489. private _projectionTextureViewLightMatrix;
  114490. private _projectionTextureProjectionLightMatrix;
  114491. private _projectionTextureScalingMatrix;
  114492. /**
  114493. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  114494. * It can cast shadows.
  114495. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114496. * @param name The light friendly name
  114497. * @param position The position of the spot light in the scene
  114498. * @param direction The direction of the light in the scene
  114499. * @param angle The cone angle of the light in Radians
  114500. * @param exponent The light decay speed with the distance from the emission spot
  114501. * @param scene The scene the lights belongs to
  114502. */
  114503. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  114504. /**
  114505. * Returns the string "SpotLight".
  114506. * @returns the class name
  114507. */
  114508. getClassName(): string;
  114509. /**
  114510. * Returns the integer 2.
  114511. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114512. */
  114513. getTypeID(): number;
  114514. /**
  114515. * Overrides the direction setter to recompute the projection texture view light Matrix.
  114516. */
  114517. protected _setDirection(value: Vector3): void;
  114518. /**
  114519. * Overrides the position setter to recompute the projection texture view light Matrix.
  114520. */
  114521. protected _setPosition(value: Vector3): void;
  114522. /**
  114523. * 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.
  114524. * Returns the SpotLight.
  114525. */
  114526. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114527. protected _computeProjectionTextureViewLightMatrix(): void;
  114528. protected _computeProjectionTextureProjectionLightMatrix(): void;
  114529. /**
  114530. * Main function for light texture projection matrix computing.
  114531. */
  114532. protected _computeProjectionTextureMatrix(): void;
  114533. protected _buildUniformLayout(): void;
  114534. private _computeAngleValues;
  114535. /**
  114536. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  114537. * @param effect The effect to update
  114538. * @param lightIndex The index of the light in the effect to update
  114539. * @returns The spot light
  114540. */
  114541. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  114542. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  114543. /**
  114544. * Disposes the light and the associated resources.
  114545. */
  114546. dispose(): void;
  114547. /**
  114548. * Prepares the list of defines specific to the light type.
  114549. * @param defines the list of defines
  114550. * @param lightIndex defines the index of the light for the effect
  114551. */
  114552. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114553. }
  114554. }
  114555. declare module BABYLON {
  114556. /**
  114557. * Gizmo that enables viewing a light
  114558. */
  114559. export class LightGizmo extends Gizmo {
  114560. private _lightMesh;
  114561. private _material;
  114562. private cachedPosition;
  114563. private cachedForward;
  114564. /**
  114565. * Creates a LightGizmo
  114566. * @param gizmoLayer The utility layer the gizmo will be added to
  114567. */
  114568. constructor(gizmoLayer?: UtilityLayerRenderer);
  114569. private _light;
  114570. /**
  114571. * The light that the gizmo is attached to
  114572. */
  114573. light: Nullable<Light>;
  114574. /**
  114575. * Gets the material used to render the light gizmo
  114576. */
  114577. readonly material: StandardMaterial;
  114578. /**
  114579. * @hidden
  114580. * Updates the gizmo to match the attached mesh's position/rotation
  114581. */
  114582. protected _update(): void;
  114583. private static _Scale;
  114584. /**
  114585. * Creates the lines for a light mesh
  114586. */
  114587. private static _createLightLines;
  114588. /**
  114589. * Disposes of the light gizmo
  114590. */
  114591. dispose(): void;
  114592. private static _CreateHemisphericLightMesh;
  114593. private static _CreatePointLightMesh;
  114594. private static _CreateSpotLightMesh;
  114595. private static _CreateDirectionalLightMesh;
  114596. }
  114597. }
  114598. declare module BABYLON {
  114599. /** @hidden */
  114600. export var backgroundFragmentDeclaration: {
  114601. name: string;
  114602. shader: string;
  114603. };
  114604. }
  114605. declare module BABYLON {
  114606. /** @hidden */
  114607. export var backgroundUboDeclaration: {
  114608. name: string;
  114609. shader: string;
  114610. };
  114611. }
  114612. declare module BABYLON {
  114613. /** @hidden */
  114614. export var backgroundPixelShader: {
  114615. name: string;
  114616. shader: string;
  114617. };
  114618. }
  114619. declare module BABYLON {
  114620. /** @hidden */
  114621. export var backgroundVertexDeclaration: {
  114622. name: string;
  114623. shader: string;
  114624. };
  114625. }
  114626. declare module BABYLON {
  114627. /** @hidden */
  114628. export var backgroundVertexShader: {
  114629. name: string;
  114630. shader: string;
  114631. };
  114632. }
  114633. declare module BABYLON {
  114634. /**
  114635. * Background material used to create an efficient environement around your scene.
  114636. */
  114637. export class BackgroundMaterial extends PushMaterial {
  114638. /**
  114639. * Standard reflectance value at parallel view angle.
  114640. */
  114641. static StandardReflectance0: number;
  114642. /**
  114643. * Standard reflectance value at grazing angle.
  114644. */
  114645. static StandardReflectance90: number;
  114646. protected _primaryColor: Color3;
  114647. /**
  114648. * Key light Color (multiply against the environement texture)
  114649. */
  114650. primaryColor: Color3;
  114651. protected __perceptualColor: Nullable<Color3>;
  114652. /**
  114653. * Experimental Internal Use Only.
  114654. *
  114655. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  114656. * This acts as a helper to set the primary color to a more "human friendly" value.
  114657. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  114658. * output color as close as possible from the chosen value.
  114659. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  114660. * part of lighting setup.)
  114661. */
  114662. _perceptualColor: Nullable<Color3>;
  114663. protected _primaryColorShadowLevel: float;
  114664. /**
  114665. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  114666. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  114667. */
  114668. primaryColorShadowLevel: float;
  114669. protected _primaryColorHighlightLevel: float;
  114670. /**
  114671. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  114672. * The primary color is used at the level chosen to define what the white area would look.
  114673. */
  114674. primaryColorHighlightLevel: float;
  114675. protected _reflectionTexture: Nullable<BaseTexture>;
  114676. /**
  114677. * Reflection Texture used in the material.
  114678. * Should be author in a specific way for the best result (refer to the documentation).
  114679. */
  114680. reflectionTexture: Nullable<BaseTexture>;
  114681. protected _reflectionBlur: float;
  114682. /**
  114683. * Reflection Texture level of blur.
  114684. *
  114685. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  114686. * texture twice.
  114687. */
  114688. reflectionBlur: float;
  114689. protected _diffuseTexture: Nullable<BaseTexture>;
  114690. /**
  114691. * Diffuse Texture used in the material.
  114692. * Should be author in a specific way for the best result (refer to the documentation).
  114693. */
  114694. diffuseTexture: Nullable<BaseTexture>;
  114695. protected _shadowLights: Nullable<IShadowLight[]>;
  114696. /**
  114697. * Specify the list of lights casting shadow on the material.
  114698. * All scene shadow lights will be included if null.
  114699. */
  114700. shadowLights: Nullable<IShadowLight[]>;
  114701. protected _shadowLevel: float;
  114702. /**
  114703. * Helps adjusting the shadow to a softer level if required.
  114704. * 0 means black shadows and 1 means no shadows.
  114705. */
  114706. shadowLevel: float;
  114707. protected _sceneCenter: Vector3;
  114708. /**
  114709. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  114710. * It is usually zero but might be interesting to modify according to your setup.
  114711. */
  114712. sceneCenter: Vector3;
  114713. protected _opacityFresnel: boolean;
  114714. /**
  114715. * This helps specifying that the material is falling off to the sky box at grazing angle.
  114716. * This helps ensuring a nice transition when the camera goes under the ground.
  114717. */
  114718. opacityFresnel: boolean;
  114719. protected _reflectionFresnel: boolean;
  114720. /**
  114721. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  114722. * This helps adding a mirror texture on the ground.
  114723. */
  114724. reflectionFresnel: boolean;
  114725. protected _reflectionFalloffDistance: number;
  114726. /**
  114727. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  114728. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  114729. */
  114730. reflectionFalloffDistance: number;
  114731. protected _reflectionAmount: number;
  114732. /**
  114733. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  114734. */
  114735. reflectionAmount: number;
  114736. protected _reflectionReflectance0: number;
  114737. /**
  114738. * This specifies the weight of the reflection at grazing angle.
  114739. */
  114740. reflectionReflectance0: number;
  114741. protected _reflectionReflectance90: number;
  114742. /**
  114743. * This specifies the weight of the reflection at a perpendicular point of view.
  114744. */
  114745. reflectionReflectance90: number;
  114746. /**
  114747. * Sets the reflection reflectance fresnel values according to the default standard
  114748. * empirically know to work well :-)
  114749. */
  114750. reflectionStandardFresnelWeight: number;
  114751. protected _useRGBColor: boolean;
  114752. /**
  114753. * Helps to directly use the maps channels instead of their level.
  114754. */
  114755. useRGBColor: boolean;
  114756. protected _enableNoise: boolean;
  114757. /**
  114758. * This helps reducing the banding effect that could occur on the background.
  114759. */
  114760. enableNoise: boolean;
  114761. /**
  114762. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114763. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  114764. * Recommended to be keep at 1.0 except for special cases.
  114765. */
  114766. fovMultiplier: number;
  114767. private _fovMultiplier;
  114768. /**
  114769. * Enable the FOV adjustment feature controlled by fovMultiplier.
  114770. */
  114771. useEquirectangularFOV: boolean;
  114772. private _maxSimultaneousLights;
  114773. /**
  114774. * Number of Simultaneous lights allowed on the material.
  114775. */
  114776. maxSimultaneousLights: int;
  114777. /**
  114778. * Default configuration related to image processing available in the Background Material.
  114779. */
  114780. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114781. /**
  114782. * Keep track of the image processing observer to allow dispose and replace.
  114783. */
  114784. private _imageProcessingObserver;
  114785. /**
  114786. * Attaches a new image processing configuration to the PBR Material.
  114787. * @param configuration (if null the scene configuration will be use)
  114788. */
  114789. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114790. /**
  114791. * Gets the image processing configuration used either in this material.
  114792. */
  114793. /**
  114794. * Sets the Default image processing configuration used either in the this material.
  114795. *
  114796. * If sets to null, the scene one is in use.
  114797. */
  114798. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  114799. /**
  114800. * Gets wether the color curves effect is enabled.
  114801. */
  114802. /**
  114803. * Sets wether the color curves effect is enabled.
  114804. */
  114805. cameraColorCurvesEnabled: boolean;
  114806. /**
  114807. * Gets wether the color grading effect is enabled.
  114808. */
  114809. /**
  114810. * Gets wether the color grading effect is enabled.
  114811. */
  114812. cameraColorGradingEnabled: boolean;
  114813. /**
  114814. * Gets wether tonemapping is enabled or not.
  114815. */
  114816. /**
  114817. * Sets wether tonemapping is enabled or not
  114818. */
  114819. cameraToneMappingEnabled: boolean;
  114820. /**
  114821. * The camera exposure used on this material.
  114822. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114823. * This corresponds to a photographic exposure.
  114824. */
  114825. /**
  114826. * The camera exposure used on this material.
  114827. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114828. * This corresponds to a photographic exposure.
  114829. */
  114830. cameraExposure: float;
  114831. /**
  114832. * Gets The camera contrast used on this material.
  114833. */
  114834. /**
  114835. * Sets The camera contrast used on this material.
  114836. */
  114837. cameraContrast: float;
  114838. /**
  114839. * Gets the Color Grading 2D Lookup Texture.
  114840. */
  114841. /**
  114842. * Sets the Color Grading 2D Lookup Texture.
  114843. */
  114844. cameraColorGradingTexture: Nullable<BaseTexture>;
  114845. /**
  114846. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114847. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114848. * 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;
  114849. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114850. */
  114851. /**
  114852. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114853. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114854. * 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;
  114855. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114856. */
  114857. cameraColorCurves: Nullable<ColorCurves>;
  114858. /**
  114859. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  114860. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  114861. */
  114862. switchToBGR: boolean;
  114863. private _renderTargets;
  114864. private _reflectionControls;
  114865. private _white;
  114866. private _primaryShadowColor;
  114867. private _primaryHighlightColor;
  114868. /**
  114869. * Instantiates a Background Material in the given scene
  114870. * @param name The friendly name of the material
  114871. * @param scene The scene to add the material to
  114872. */
  114873. constructor(name: string, scene: Scene);
  114874. /**
  114875. * Gets a boolean indicating that current material needs to register RTT
  114876. */
  114877. readonly hasRenderTargetTextures: boolean;
  114878. /**
  114879. * The entire material has been created in order to prevent overdraw.
  114880. * @returns false
  114881. */
  114882. needAlphaTesting(): boolean;
  114883. /**
  114884. * The entire material has been created in order to prevent overdraw.
  114885. * @returns true if blending is enable
  114886. */
  114887. needAlphaBlending(): boolean;
  114888. /**
  114889. * Checks wether the material is ready to be rendered for a given mesh.
  114890. * @param mesh The mesh to render
  114891. * @param subMesh The submesh to check against
  114892. * @param useInstances Specify wether or not the material is used with instances
  114893. * @returns true if all the dependencies are ready (Textures, Effects...)
  114894. */
  114895. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114896. /**
  114897. * Compute the primary color according to the chosen perceptual color.
  114898. */
  114899. private _computePrimaryColorFromPerceptualColor;
  114900. /**
  114901. * Compute the highlights and shadow colors according to their chosen levels.
  114902. */
  114903. private _computePrimaryColors;
  114904. /**
  114905. * Build the uniform buffer used in the material.
  114906. */
  114907. buildUniformLayout(): void;
  114908. /**
  114909. * Unbind the material.
  114910. */
  114911. unbind(): void;
  114912. /**
  114913. * Bind only the world matrix to the material.
  114914. * @param world The world matrix to bind.
  114915. */
  114916. bindOnlyWorldMatrix(world: Matrix): void;
  114917. /**
  114918. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  114919. * @param world The world matrix to bind.
  114920. * @param subMesh The submesh to bind for.
  114921. */
  114922. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114923. /**
  114924. * Checks to see if a texture is used in the material.
  114925. * @param texture - Base texture to use.
  114926. * @returns - Boolean specifying if a texture is used in the material.
  114927. */
  114928. hasTexture(texture: BaseTexture): boolean;
  114929. /**
  114930. * Dispose the material.
  114931. * @param forceDisposeEffect Force disposal of the associated effect.
  114932. * @param forceDisposeTextures Force disposal of the associated textures.
  114933. */
  114934. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114935. /**
  114936. * Clones the material.
  114937. * @param name The cloned name.
  114938. * @returns The cloned material.
  114939. */
  114940. clone(name: string): BackgroundMaterial;
  114941. /**
  114942. * Serializes the current material to its JSON representation.
  114943. * @returns The JSON representation.
  114944. */
  114945. serialize(): any;
  114946. /**
  114947. * Gets the class name of the material
  114948. * @returns "BackgroundMaterial"
  114949. */
  114950. getClassName(): string;
  114951. /**
  114952. * Parse a JSON input to create back a background material.
  114953. * @param source The JSON data to parse
  114954. * @param scene The scene to create the parsed material in
  114955. * @param rootUrl The root url of the assets the material depends upon
  114956. * @returns the instantiated BackgroundMaterial.
  114957. */
  114958. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  114959. }
  114960. }
  114961. declare module BABYLON {
  114962. /**
  114963. * Represents the different options available during the creation of
  114964. * a Environment helper.
  114965. *
  114966. * This can control the default ground, skybox and image processing setup of your scene.
  114967. */
  114968. export interface IEnvironmentHelperOptions {
  114969. /**
  114970. * Specifies wether or not to create a ground.
  114971. * True by default.
  114972. */
  114973. createGround: boolean;
  114974. /**
  114975. * Specifies the ground size.
  114976. * 15 by default.
  114977. */
  114978. groundSize: number;
  114979. /**
  114980. * The texture used on the ground for the main color.
  114981. * Comes from the BabylonJS CDN by default.
  114982. *
  114983. * Remarks: Can be either a texture or a url.
  114984. */
  114985. groundTexture: string | BaseTexture;
  114986. /**
  114987. * The color mixed in the ground texture by default.
  114988. * BabylonJS clearColor by default.
  114989. */
  114990. groundColor: Color3;
  114991. /**
  114992. * Specifies the ground opacity.
  114993. * 1 by default.
  114994. */
  114995. groundOpacity: number;
  114996. /**
  114997. * Enables the ground to receive shadows.
  114998. * True by default.
  114999. */
  115000. enableGroundShadow: boolean;
  115001. /**
  115002. * Helps preventing the shadow to be fully black on the ground.
  115003. * 0.5 by default.
  115004. */
  115005. groundShadowLevel: number;
  115006. /**
  115007. * Creates a mirror texture attach to the ground.
  115008. * false by default.
  115009. */
  115010. enableGroundMirror: boolean;
  115011. /**
  115012. * Specifies the ground mirror size ratio.
  115013. * 0.3 by default as the default kernel is 64.
  115014. */
  115015. groundMirrorSizeRatio: number;
  115016. /**
  115017. * Specifies the ground mirror blur kernel size.
  115018. * 64 by default.
  115019. */
  115020. groundMirrorBlurKernel: number;
  115021. /**
  115022. * Specifies the ground mirror visibility amount.
  115023. * 1 by default
  115024. */
  115025. groundMirrorAmount: number;
  115026. /**
  115027. * Specifies the ground mirror reflectance weight.
  115028. * This uses the standard weight of the background material to setup the fresnel effect
  115029. * of the mirror.
  115030. * 1 by default.
  115031. */
  115032. groundMirrorFresnelWeight: number;
  115033. /**
  115034. * Specifies the ground mirror Falloff distance.
  115035. * This can helps reducing the size of the reflection.
  115036. * 0 by Default.
  115037. */
  115038. groundMirrorFallOffDistance: number;
  115039. /**
  115040. * Specifies the ground mirror texture type.
  115041. * Unsigned Int by Default.
  115042. */
  115043. groundMirrorTextureType: number;
  115044. /**
  115045. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  115046. * the shown objects.
  115047. */
  115048. groundYBias: number;
  115049. /**
  115050. * Specifies wether or not to create a skybox.
  115051. * True by default.
  115052. */
  115053. createSkybox: boolean;
  115054. /**
  115055. * Specifies the skybox size.
  115056. * 20 by default.
  115057. */
  115058. skyboxSize: number;
  115059. /**
  115060. * The texture used on the skybox for the main color.
  115061. * Comes from the BabylonJS CDN by default.
  115062. *
  115063. * Remarks: Can be either a texture or a url.
  115064. */
  115065. skyboxTexture: string | BaseTexture;
  115066. /**
  115067. * The color mixed in the skybox texture by default.
  115068. * BabylonJS clearColor by default.
  115069. */
  115070. skyboxColor: Color3;
  115071. /**
  115072. * The background rotation around the Y axis of the scene.
  115073. * This helps aligning the key lights of your scene with the background.
  115074. * 0 by default.
  115075. */
  115076. backgroundYRotation: number;
  115077. /**
  115078. * Compute automatically the size of the elements to best fit with the scene.
  115079. */
  115080. sizeAuto: boolean;
  115081. /**
  115082. * Default position of the rootMesh if autoSize is not true.
  115083. */
  115084. rootPosition: Vector3;
  115085. /**
  115086. * Sets up the image processing in the scene.
  115087. * true by default.
  115088. */
  115089. setupImageProcessing: boolean;
  115090. /**
  115091. * The texture used as your environment texture in the scene.
  115092. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  115093. *
  115094. * Remarks: Can be either a texture or a url.
  115095. */
  115096. environmentTexture: string | BaseTexture;
  115097. /**
  115098. * The value of the exposure to apply to the scene.
  115099. * 0.6 by default if setupImageProcessing is true.
  115100. */
  115101. cameraExposure: number;
  115102. /**
  115103. * The value of the contrast to apply to the scene.
  115104. * 1.6 by default if setupImageProcessing is true.
  115105. */
  115106. cameraContrast: number;
  115107. /**
  115108. * Specifies wether or not tonemapping should be enabled in the scene.
  115109. * true by default if setupImageProcessing is true.
  115110. */
  115111. toneMappingEnabled: boolean;
  115112. }
  115113. /**
  115114. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  115115. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  115116. * It also helps with the default setup of your imageProcessing configuration.
  115117. */
  115118. export class EnvironmentHelper {
  115119. /**
  115120. * Default ground texture URL.
  115121. */
  115122. private static _groundTextureCDNUrl;
  115123. /**
  115124. * Default skybox texture URL.
  115125. */
  115126. private static _skyboxTextureCDNUrl;
  115127. /**
  115128. * Default environment texture URL.
  115129. */
  115130. private static _environmentTextureCDNUrl;
  115131. /**
  115132. * Creates the default options for the helper.
  115133. */
  115134. private static _getDefaultOptions;
  115135. private _rootMesh;
  115136. /**
  115137. * Gets the root mesh created by the helper.
  115138. */
  115139. readonly rootMesh: Mesh;
  115140. private _skybox;
  115141. /**
  115142. * Gets the skybox created by the helper.
  115143. */
  115144. readonly skybox: Nullable<Mesh>;
  115145. private _skyboxTexture;
  115146. /**
  115147. * Gets the skybox texture created by the helper.
  115148. */
  115149. readonly skyboxTexture: Nullable<BaseTexture>;
  115150. private _skyboxMaterial;
  115151. /**
  115152. * Gets the skybox material created by the helper.
  115153. */
  115154. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  115155. private _ground;
  115156. /**
  115157. * Gets the ground mesh created by the helper.
  115158. */
  115159. readonly ground: Nullable<Mesh>;
  115160. private _groundTexture;
  115161. /**
  115162. * Gets the ground texture created by the helper.
  115163. */
  115164. readonly groundTexture: Nullable<BaseTexture>;
  115165. private _groundMirror;
  115166. /**
  115167. * Gets the ground mirror created by the helper.
  115168. */
  115169. readonly groundMirror: Nullable<MirrorTexture>;
  115170. /**
  115171. * Gets the ground mirror render list to helps pushing the meshes
  115172. * you wish in the ground reflection.
  115173. */
  115174. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  115175. private _groundMaterial;
  115176. /**
  115177. * Gets the ground material created by the helper.
  115178. */
  115179. readonly groundMaterial: Nullable<BackgroundMaterial>;
  115180. /**
  115181. * Stores the creation options.
  115182. */
  115183. private readonly _scene;
  115184. private _options;
  115185. /**
  115186. * This observable will be notified with any error during the creation of the environment,
  115187. * mainly texture creation errors.
  115188. */
  115189. onErrorObservable: Observable<{
  115190. message?: string;
  115191. exception?: any;
  115192. }>;
  115193. /**
  115194. * constructor
  115195. * @param options Defines the options we want to customize the helper
  115196. * @param scene The scene to add the material to
  115197. */
  115198. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  115199. /**
  115200. * Updates the background according to the new options
  115201. * @param options
  115202. */
  115203. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  115204. /**
  115205. * Sets the primary color of all the available elements.
  115206. * @param color the main color to affect to the ground and the background
  115207. */
  115208. setMainColor(color: Color3): void;
  115209. /**
  115210. * Setup the image processing according to the specified options.
  115211. */
  115212. private _setupImageProcessing;
  115213. /**
  115214. * Setup the environment texture according to the specified options.
  115215. */
  115216. private _setupEnvironmentTexture;
  115217. /**
  115218. * Setup the background according to the specified options.
  115219. */
  115220. private _setupBackground;
  115221. /**
  115222. * Get the scene sizes according to the setup.
  115223. */
  115224. private _getSceneSize;
  115225. /**
  115226. * Setup the ground according to the specified options.
  115227. */
  115228. private _setupGround;
  115229. /**
  115230. * Setup the ground material according to the specified options.
  115231. */
  115232. private _setupGroundMaterial;
  115233. /**
  115234. * Setup the ground diffuse texture according to the specified options.
  115235. */
  115236. private _setupGroundDiffuseTexture;
  115237. /**
  115238. * Setup the ground mirror texture according to the specified options.
  115239. */
  115240. private _setupGroundMirrorTexture;
  115241. /**
  115242. * Setup the ground to receive the mirror texture.
  115243. */
  115244. private _setupMirrorInGroundMaterial;
  115245. /**
  115246. * Setup the skybox according to the specified options.
  115247. */
  115248. private _setupSkybox;
  115249. /**
  115250. * Setup the skybox material according to the specified options.
  115251. */
  115252. private _setupSkyboxMaterial;
  115253. /**
  115254. * Setup the skybox reflection texture according to the specified options.
  115255. */
  115256. private _setupSkyboxReflectionTexture;
  115257. private _errorHandler;
  115258. /**
  115259. * Dispose all the elements created by the Helper.
  115260. */
  115261. dispose(): void;
  115262. }
  115263. }
  115264. declare module BABYLON {
  115265. /**
  115266. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  115267. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  115268. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  115269. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115270. */
  115271. export class PhotoDome extends TransformNode {
  115272. /**
  115273. * Define the image as a Monoscopic panoramic 360 image.
  115274. */
  115275. static readonly MODE_MONOSCOPIC: number;
  115276. /**
  115277. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115278. */
  115279. static readonly MODE_TOPBOTTOM: number;
  115280. /**
  115281. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115282. */
  115283. static readonly MODE_SIDEBYSIDE: number;
  115284. private _useDirectMapping;
  115285. /**
  115286. * The texture being displayed on the sphere
  115287. */
  115288. protected _photoTexture: Texture;
  115289. /**
  115290. * Gets or sets the texture being displayed on the sphere
  115291. */
  115292. photoTexture: Texture;
  115293. /**
  115294. * Observable raised when an error occured while loading the 360 image
  115295. */
  115296. onLoadErrorObservable: Observable<string>;
  115297. /**
  115298. * The skybox material
  115299. */
  115300. protected _material: BackgroundMaterial;
  115301. /**
  115302. * The surface used for the skybox
  115303. */
  115304. protected _mesh: Mesh;
  115305. /**
  115306. * Gets the mesh used for the skybox.
  115307. */
  115308. readonly mesh: Mesh;
  115309. /**
  115310. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115311. * Also see the options.resolution property.
  115312. */
  115313. fovMultiplier: number;
  115314. private _imageMode;
  115315. /**
  115316. * Gets or set the current video mode for the video. It can be:
  115317. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  115318. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115319. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115320. */
  115321. imageMode: number;
  115322. /**
  115323. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  115324. * @param name Element's name, child elements will append suffixes for their own names.
  115325. * @param urlsOfPhoto defines the url of the photo to display
  115326. * @param options defines an object containing optional or exposed sub element properties
  115327. * @param onError defines a callback called when an error occured while loading the texture
  115328. */
  115329. constructor(name: string, urlOfPhoto: string, options: {
  115330. resolution?: number;
  115331. size?: number;
  115332. useDirectMapping?: boolean;
  115333. faceForward?: boolean;
  115334. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  115335. private _onBeforeCameraRenderObserver;
  115336. private _changeImageMode;
  115337. /**
  115338. * Releases resources associated with this node.
  115339. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115340. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115341. */
  115342. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115343. }
  115344. }
  115345. declare module BABYLON {
  115346. /**
  115347. * Class used to host RGBD texture specific utilities
  115348. */
  115349. export class RGBDTextureTools {
  115350. /**
  115351. * Expand the RGBD Texture from RGBD to Half Float if possible.
  115352. * @param texture the texture to expand.
  115353. */
  115354. static ExpandRGBDTexture(texture: Texture): void;
  115355. }
  115356. }
  115357. declare module BABYLON {
  115358. /**
  115359. * Class used to host texture specific utilities
  115360. */
  115361. export class BRDFTextureTools {
  115362. /**
  115363. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  115364. * @param scene defines the hosting scene
  115365. * @returns the environment BRDF texture
  115366. */
  115367. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  115368. private static _environmentBRDFBase64Texture;
  115369. }
  115370. }
  115371. declare module BABYLON {
  115372. /**
  115373. * @hidden
  115374. */
  115375. export interface IMaterialClearCoatDefines {
  115376. CLEARCOAT: boolean;
  115377. CLEARCOAT_DEFAULTIOR: boolean;
  115378. CLEARCOAT_TEXTURE: boolean;
  115379. CLEARCOAT_TEXTUREDIRECTUV: number;
  115380. CLEARCOAT_BUMP: boolean;
  115381. CLEARCOAT_BUMPDIRECTUV: number;
  115382. CLEARCOAT_TINT: boolean;
  115383. CLEARCOAT_TINT_TEXTURE: boolean;
  115384. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115385. /** @hidden */
  115386. _areTexturesDirty: boolean;
  115387. }
  115388. /**
  115389. * Define the code related to the clear coat parameters of the pbr material.
  115390. */
  115391. export class PBRClearCoatConfiguration {
  115392. /**
  115393. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115394. * The default fits with a polyurethane material.
  115395. */
  115396. private static readonly _DefaultIndexOfRefraction;
  115397. private _isEnabled;
  115398. /**
  115399. * Defines if the clear coat is enabled in the material.
  115400. */
  115401. isEnabled: boolean;
  115402. /**
  115403. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  115404. */
  115405. intensity: number;
  115406. /**
  115407. * Defines the clear coat layer roughness.
  115408. */
  115409. roughness: number;
  115410. private _indexOfRefraction;
  115411. /**
  115412. * Defines the index of refraction of the clear coat.
  115413. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115414. * The default fits with a polyurethane material.
  115415. * Changing the default value is more performance intensive.
  115416. */
  115417. indexOfRefraction: number;
  115418. private _texture;
  115419. /**
  115420. * Stores the clear coat values in a texture.
  115421. */
  115422. texture: Nullable<BaseTexture>;
  115423. private _bumpTexture;
  115424. /**
  115425. * Define the clear coat specific bump texture.
  115426. */
  115427. bumpTexture: Nullable<BaseTexture>;
  115428. private _isTintEnabled;
  115429. /**
  115430. * Defines if the clear coat tint is enabled in the material.
  115431. */
  115432. isTintEnabled: boolean;
  115433. /**
  115434. * Defines the clear coat tint of the material.
  115435. * This is only use if tint is enabled
  115436. */
  115437. tintColor: Color3;
  115438. /**
  115439. * Defines the distance at which the tint color should be found in the
  115440. * clear coat media.
  115441. * This is only use if tint is enabled
  115442. */
  115443. tintColorAtDistance: number;
  115444. /**
  115445. * Defines the clear coat layer thickness.
  115446. * This is only use if tint is enabled
  115447. */
  115448. tintThickness: number;
  115449. private _tintTexture;
  115450. /**
  115451. * Stores the clear tint values in a texture.
  115452. * rgb is tint
  115453. * a is a thickness factor
  115454. */
  115455. tintTexture: Nullable<BaseTexture>;
  115456. /** @hidden */
  115457. private _internalMarkAllSubMeshesAsTexturesDirty;
  115458. /** @hidden */
  115459. _markAllSubMeshesAsTexturesDirty(): void;
  115460. /**
  115461. * Instantiate a new istance of clear coat configuration.
  115462. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115463. */
  115464. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115465. /**
  115466. * Gets wehter the submesh is ready to be used or not.
  115467. * @param defines the list of "defines" to update.
  115468. * @param scene defines the scene the material belongs to.
  115469. * @param engine defines the engine the material belongs to.
  115470. * @param disableBumpMap defines wether the material disables bump or not.
  115471. * @returns - boolean indicating that the submesh is ready or not.
  115472. */
  115473. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  115474. /**
  115475. * Checks to see if a texture is used in the material.
  115476. * @param defines the list of "defines" to update.
  115477. * @param scene defines the scene to the material belongs to.
  115478. */
  115479. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  115480. /**
  115481. * Binds the material data.
  115482. * @param uniformBuffer defines the Uniform buffer to fill in.
  115483. * @param scene defines the scene the material belongs to.
  115484. * @param engine defines the engine the material belongs to.
  115485. * @param disableBumpMap defines wether the material disables bump or not.
  115486. * @param isFrozen defines wether the material is frozen or not.
  115487. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115488. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115489. */
  115490. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  115491. /**
  115492. * Checks to see if a texture is used in the material.
  115493. * @param texture - Base texture to use.
  115494. * @returns - Boolean specifying if a texture is used in the material.
  115495. */
  115496. hasTexture(texture: BaseTexture): boolean;
  115497. /**
  115498. * Returns an array of the actively used textures.
  115499. * @param activeTextures Array of BaseTextures
  115500. */
  115501. getActiveTextures(activeTextures: BaseTexture[]): void;
  115502. /**
  115503. * Returns the animatable textures.
  115504. * @param animatables Array of animatable textures.
  115505. */
  115506. getAnimatables(animatables: IAnimatable[]): void;
  115507. /**
  115508. * Disposes the resources of the material.
  115509. * @param forceDisposeTextures - Forces the disposal of all textures.
  115510. */
  115511. dispose(forceDisposeTextures?: boolean): void;
  115512. /**
  115513. * Get the current class name of the texture useful for serialization or dynamic coding.
  115514. * @returns "PBRClearCoatConfiguration"
  115515. */
  115516. getClassName(): string;
  115517. /**
  115518. * Add fallbacks to the effect fallbacks list.
  115519. * @param defines defines the Base texture to use.
  115520. * @param fallbacks defines the current fallback list.
  115521. * @param currentRank defines the current fallback rank.
  115522. * @returns the new fallback rank.
  115523. */
  115524. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115525. /**
  115526. * Add the required uniforms to the current list.
  115527. * @param uniforms defines the current uniform list.
  115528. */
  115529. static AddUniforms(uniforms: string[]): void;
  115530. /**
  115531. * Add the required samplers to the current list.
  115532. * @param samplers defines the current sampler list.
  115533. */
  115534. static AddSamplers(samplers: string[]): void;
  115535. /**
  115536. * Add the required uniforms to the current buffer.
  115537. * @param uniformBuffer defines the current uniform buffer.
  115538. */
  115539. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115540. /**
  115541. * Makes a duplicate of the current configuration into another one.
  115542. * @param clearCoatConfiguration define the config where to copy the info
  115543. */
  115544. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  115545. /**
  115546. * Serializes this clear coat configuration.
  115547. * @returns - An object with the serialized config.
  115548. */
  115549. serialize(): any;
  115550. /**
  115551. * Parses a anisotropy Configuration from a serialized object.
  115552. * @param source - Serialized object.
  115553. * @param scene Defines the scene we are parsing for
  115554. * @param rootUrl Defines the rootUrl to load from
  115555. */
  115556. parse(source: any, scene: Scene, rootUrl: string): void;
  115557. }
  115558. }
  115559. declare module BABYLON {
  115560. /**
  115561. * @hidden
  115562. */
  115563. export interface IMaterialAnisotropicDefines {
  115564. ANISOTROPIC: boolean;
  115565. ANISOTROPIC_TEXTURE: boolean;
  115566. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115567. MAINUV1: boolean;
  115568. _areTexturesDirty: boolean;
  115569. _needUVs: boolean;
  115570. }
  115571. /**
  115572. * Define the code related to the anisotropic parameters of the pbr material.
  115573. */
  115574. export class PBRAnisotropicConfiguration {
  115575. private _isEnabled;
  115576. /**
  115577. * Defines if the anisotropy is enabled in the material.
  115578. */
  115579. isEnabled: boolean;
  115580. /**
  115581. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  115582. */
  115583. intensity: number;
  115584. /**
  115585. * Defines if the effect is along the tangents, bitangents or in between.
  115586. * By default, the effect is "strectching" the highlights along the tangents.
  115587. */
  115588. direction: Vector2;
  115589. private _texture;
  115590. /**
  115591. * Stores the anisotropy values in a texture.
  115592. * rg is direction (like normal from -1 to 1)
  115593. * b is a intensity
  115594. */
  115595. texture: Nullable<BaseTexture>;
  115596. /** @hidden */
  115597. private _internalMarkAllSubMeshesAsTexturesDirty;
  115598. /** @hidden */
  115599. _markAllSubMeshesAsTexturesDirty(): void;
  115600. /**
  115601. * Instantiate a new istance of anisotropy configuration.
  115602. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115603. */
  115604. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115605. /**
  115606. * Specifies that the submesh is ready to be used.
  115607. * @param defines the list of "defines" to update.
  115608. * @param scene defines the scene the material belongs to.
  115609. * @returns - boolean indicating that the submesh is ready or not.
  115610. */
  115611. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  115612. /**
  115613. * Checks to see if a texture is used in the material.
  115614. * @param defines the list of "defines" to update.
  115615. * @param mesh the mesh we are preparing the defines for.
  115616. * @param scene defines the scene the material belongs to.
  115617. */
  115618. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  115619. /**
  115620. * Binds the material data.
  115621. * @param uniformBuffer defines the Uniform buffer to fill in.
  115622. * @param scene defines the scene the material belongs to.
  115623. * @param isFrozen defines wether the material is frozen or not.
  115624. */
  115625. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115626. /**
  115627. * Checks to see if a texture is used in the material.
  115628. * @param texture - Base texture to use.
  115629. * @returns - Boolean specifying if a texture is used in the material.
  115630. */
  115631. hasTexture(texture: BaseTexture): boolean;
  115632. /**
  115633. * Returns an array of the actively used textures.
  115634. * @param activeTextures Array of BaseTextures
  115635. */
  115636. getActiveTextures(activeTextures: BaseTexture[]): void;
  115637. /**
  115638. * Returns the animatable textures.
  115639. * @param animatables Array of animatable textures.
  115640. */
  115641. getAnimatables(animatables: IAnimatable[]): void;
  115642. /**
  115643. * Disposes the resources of the material.
  115644. * @param forceDisposeTextures - Forces the disposal of all textures.
  115645. */
  115646. dispose(forceDisposeTextures?: boolean): void;
  115647. /**
  115648. * Get the current class name of the texture useful for serialization or dynamic coding.
  115649. * @returns "PBRAnisotropicConfiguration"
  115650. */
  115651. getClassName(): string;
  115652. /**
  115653. * Add fallbacks to the effect fallbacks list.
  115654. * @param defines defines the Base texture to use.
  115655. * @param fallbacks defines the current fallback list.
  115656. * @param currentRank defines the current fallback rank.
  115657. * @returns the new fallback rank.
  115658. */
  115659. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115660. /**
  115661. * Add the required uniforms to the current list.
  115662. * @param uniforms defines the current uniform list.
  115663. */
  115664. static AddUniforms(uniforms: string[]): void;
  115665. /**
  115666. * Add the required uniforms to the current buffer.
  115667. * @param uniformBuffer defines the current uniform buffer.
  115668. */
  115669. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115670. /**
  115671. * Add the required samplers to the current list.
  115672. * @param samplers defines the current sampler list.
  115673. */
  115674. static AddSamplers(samplers: string[]): void;
  115675. /**
  115676. * Makes a duplicate of the current configuration into another one.
  115677. * @param anisotropicConfiguration define the config where to copy the info
  115678. */
  115679. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  115680. /**
  115681. * Serializes this anisotropy configuration.
  115682. * @returns - An object with the serialized config.
  115683. */
  115684. serialize(): any;
  115685. /**
  115686. * Parses a anisotropy Configuration from a serialized object.
  115687. * @param source - Serialized object.
  115688. * @param scene Defines the scene we are parsing for
  115689. * @param rootUrl Defines the rootUrl to load from
  115690. */
  115691. parse(source: any, scene: Scene, rootUrl: string): void;
  115692. }
  115693. }
  115694. declare module BABYLON {
  115695. /**
  115696. * @hidden
  115697. */
  115698. export interface IMaterialBRDFDefines {
  115699. BRDF_V_HEIGHT_CORRELATED: boolean;
  115700. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115701. SPHERICAL_HARMONICS: boolean;
  115702. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115703. /** @hidden */
  115704. _areMiscDirty: boolean;
  115705. }
  115706. /**
  115707. * Define the code related to the BRDF parameters of the pbr material.
  115708. */
  115709. export class PBRBRDFConfiguration {
  115710. /**
  115711. * Default value used for the energy conservation.
  115712. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115713. */
  115714. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  115715. /**
  115716. * Default value used for the Smith Visibility Height Correlated mode.
  115717. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115718. */
  115719. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  115720. /**
  115721. * Default value used for the IBL diffuse part.
  115722. * This can help switching back to the polynomials mode globally which is a tiny bit
  115723. * less GPU intensive at the drawback of a lower quality.
  115724. */
  115725. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  115726. /**
  115727. * Default value used for activating energy conservation for the specular workflow.
  115728. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115729. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115730. */
  115731. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  115732. private _useEnergyConservation;
  115733. /**
  115734. * Defines if the material uses energy conservation.
  115735. */
  115736. useEnergyConservation: boolean;
  115737. private _useSmithVisibilityHeightCorrelated;
  115738. /**
  115739. * LEGACY Mode set to false
  115740. * Defines if the material uses height smith correlated visibility term.
  115741. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  115742. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  115743. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  115744. * Not relying on height correlated will also disable energy conservation.
  115745. */
  115746. useSmithVisibilityHeightCorrelated: boolean;
  115747. private _useSphericalHarmonics;
  115748. /**
  115749. * LEGACY Mode set to false
  115750. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  115751. * diffuse part of the IBL.
  115752. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  115753. * to the ground truth.
  115754. */
  115755. useSphericalHarmonics: boolean;
  115756. private _useSpecularGlossinessInputEnergyConservation;
  115757. /**
  115758. * Defines if the material uses energy conservation, when the specular workflow is active.
  115759. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115760. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115761. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  115762. */
  115763. useSpecularGlossinessInputEnergyConservation: boolean;
  115764. /** @hidden */
  115765. private _internalMarkAllSubMeshesAsMiscDirty;
  115766. /** @hidden */
  115767. _markAllSubMeshesAsMiscDirty(): void;
  115768. /**
  115769. * Instantiate a new istance of clear coat configuration.
  115770. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  115771. */
  115772. constructor(markAllSubMeshesAsMiscDirty: () => void);
  115773. /**
  115774. * Checks to see if a texture is used in the material.
  115775. * @param defines the list of "defines" to update.
  115776. */
  115777. prepareDefines(defines: IMaterialBRDFDefines): void;
  115778. /**
  115779. * Get the current class name of the texture useful for serialization or dynamic coding.
  115780. * @returns "PBRClearCoatConfiguration"
  115781. */
  115782. getClassName(): string;
  115783. /**
  115784. * Makes a duplicate of the current configuration into another one.
  115785. * @param brdfConfiguration define the config where to copy the info
  115786. */
  115787. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  115788. /**
  115789. * Serializes this BRDF configuration.
  115790. * @returns - An object with the serialized config.
  115791. */
  115792. serialize(): any;
  115793. /**
  115794. * Parses a anisotropy Configuration from a serialized object.
  115795. * @param source - Serialized object.
  115796. * @param scene Defines the scene we are parsing for
  115797. * @param rootUrl Defines the rootUrl to load from
  115798. */
  115799. parse(source: any, scene: Scene, rootUrl: string): void;
  115800. }
  115801. }
  115802. declare module BABYLON {
  115803. /**
  115804. * @hidden
  115805. */
  115806. export interface IMaterialSheenDefines {
  115807. SHEEN: boolean;
  115808. SHEEN_TEXTURE: boolean;
  115809. SHEEN_TEXTUREDIRECTUV: number;
  115810. SHEEN_LINKWITHALBEDO: boolean;
  115811. /** @hidden */
  115812. _areTexturesDirty: boolean;
  115813. }
  115814. /**
  115815. * Define the code related to the Sheen parameters of the pbr material.
  115816. */
  115817. export class PBRSheenConfiguration {
  115818. private _isEnabled;
  115819. /**
  115820. * Defines if the material uses sheen.
  115821. */
  115822. isEnabled: boolean;
  115823. private _linkSheenWithAlbedo;
  115824. /**
  115825. * Defines if the sheen is linked to the sheen color.
  115826. */
  115827. linkSheenWithAlbedo: boolean;
  115828. /**
  115829. * Defines the sheen intensity.
  115830. */
  115831. intensity: number;
  115832. /**
  115833. * Defines the sheen color.
  115834. */
  115835. color: Color3;
  115836. private _texture;
  115837. /**
  115838. * Stores the sheen tint values in a texture.
  115839. * rgb is tint
  115840. * a is a intensity
  115841. */
  115842. texture: Nullable<BaseTexture>;
  115843. /** @hidden */
  115844. private _internalMarkAllSubMeshesAsTexturesDirty;
  115845. /** @hidden */
  115846. _markAllSubMeshesAsTexturesDirty(): void;
  115847. /**
  115848. * Instantiate a new istance of clear coat configuration.
  115849. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115850. */
  115851. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115852. /**
  115853. * Specifies that the submesh is ready to be used.
  115854. * @param defines the list of "defines" to update.
  115855. * @param scene defines the scene the material belongs to.
  115856. * @returns - boolean indicating that the submesh is ready or not.
  115857. */
  115858. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  115859. /**
  115860. * Checks to see if a texture is used in the material.
  115861. * @param defines the list of "defines" to update.
  115862. * @param scene defines the scene the material belongs to.
  115863. */
  115864. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  115865. /**
  115866. * Binds the material data.
  115867. * @param uniformBuffer defines the Uniform buffer to fill in.
  115868. * @param scene defines the scene the material belongs to.
  115869. * @param isFrozen defines wether the material is frozen or not.
  115870. */
  115871. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115872. /**
  115873. * Checks to see if a texture is used in the material.
  115874. * @param texture - Base texture to use.
  115875. * @returns - Boolean specifying if a texture is used in the material.
  115876. */
  115877. hasTexture(texture: BaseTexture): boolean;
  115878. /**
  115879. * Returns an array of the actively used textures.
  115880. * @param activeTextures Array of BaseTextures
  115881. */
  115882. getActiveTextures(activeTextures: BaseTexture[]): void;
  115883. /**
  115884. * Returns the animatable textures.
  115885. * @param animatables Array of animatable textures.
  115886. */
  115887. getAnimatables(animatables: IAnimatable[]): void;
  115888. /**
  115889. * Disposes the resources of the material.
  115890. * @param forceDisposeTextures - Forces the disposal of all textures.
  115891. */
  115892. dispose(forceDisposeTextures?: boolean): void;
  115893. /**
  115894. * Get the current class name of the texture useful for serialization or dynamic coding.
  115895. * @returns "PBRSheenConfiguration"
  115896. */
  115897. getClassName(): string;
  115898. /**
  115899. * Add fallbacks to the effect fallbacks list.
  115900. * @param defines defines the Base texture to use.
  115901. * @param fallbacks defines the current fallback list.
  115902. * @param currentRank defines the current fallback rank.
  115903. * @returns the new fallback rank.
  115904. */
  115905. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115906. /**
  115907. * Add the required uniforms to the current list.
  115908. * @param uniforms defines the current uniform list.
  115909. */
  115910. static AddUniforms(uniforms: string[]): void;
  115911. /**
  115912. * Add the required uniforms to the current buffer.
  115913. * @param uniformBuffer defines the current uniform buffer.
  115914. */
  115915. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115916. /**
  115917. * Add the required samplers to the current list.
  115918. * @param samplers defines the current sampler list.
  115919. */
  115920. static AddSamplers(samplers: string[]): void;
  115921. /**
  115922. * Makes a duplicate of the current configuration into another one.
  115923. * @param sheenConfiguration define the config where to copy the info
  115924. */
  115925. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  115926. /**
  115927. * Serializes this BRDF configuration.
  115928. * @returns - An object with the serialized config.
  115929. */
  115930. serialize(): any;
  115931. /**
  115932. * Parses a anisotropy Configuration from a serialized object.
  115933. * @param source - Serialized object.
  115934. * @param scene Defines the scene we are parsing for
  115935. * @param rootUrl Defines the rootUrl to load from
  115936. */
  115937. parse(source: any, scene: Scene, rootUrl: string): void;
  115938. }
  115939. }
  115940. declare module BABYLON {
  115941. /**
  115942. * @hidden
  115943. */
  115944. export interface IMaterialSubSurfaceDefines {
  115945. SUBSURFACE: boolean;
  115946. SS_REFRACTION: boolean;
  115947. SS_TRANSLUCENCY: boolean;
  115948. SS_SCATERRING: boolean;
  115949. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115950. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115951. SS_REFRACTIONMAP_3D: boolean;
  115952. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115953. SS_LODINREFRACTIONALPHA: boolean;
  115954. SS_GAMMAREFRACTION: boolean;
  115955. SS_RGBDREFRACTION: boolean;
  115956. SS_LINEARSPECULARREFRACTION: boolean;
  115957. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115958. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115959. /** @hidden */
  115960. _areTexturesDirty: boolean;
  115961. }
  115962. /**
  115963. * Define the code related to the sub surface parameters of the pbr material.
  115964. */
  115965. export class PBRSubSurfaceConfiguration {
  115966. private _isRefractionEnabled;
  115967. /**
  115968. * Defines if the refraction is enabled in the material.
  115969. */
  115970. isRefractionEnabled: boolean;
  115971. private _isTranslucencyEnabled;
  115972. /**
  115973. * Defines if the translucency is enabled in the material.
  115974. */
  115975. isTranslucencyEnabled: boolean;
  115976. private _isScatteringEnabled;
  115977. /**
  115978. * Defines the refraction intensity of the material.
  115979. * The refraction when enabled replaces the Diffuse part of the material.
  115980. * The intensity helps transitionning between diffuse and refraction.
  115981. */
  115982. refractionIntensity: number;
  115983. /**
  115984. * Defines the translucency intensity of the material.
  115985. * When translucency has been enabled, this defines how much of the "translucency"
  115986. * is addded to the diffuse part of the material.
  115987. */
  115988. translucencyIntensity: number;
  115989. /**
  115990. * Defines the scattering intensity of the material.
  115991. * When scattering has been enabled, this defines how much of the "scattered light"
  115992. * is addded to the diffuse part of the material.
  115993. */
  115994. scatteringIntensity: number;
  115995. private _thicknessTexture;
  115996. /**
  115997. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  115998. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  115999. * 0 would mean minimumThickness
  116000. * 1 would mean maximumThickness
  116001. * The other channels might be use as a mask to vary the different effects intensity.
  116002. */
  116003. thicknessTexture: Nullable<BaseTexture>;
  116004. private _refractionTexture;
  116005. /**
  116006. * Defines the texture to use for refraction.
  116007. */
  116008. refractionTexture: Nullable<BaseTexture>;
  116009. private _indexOfRefraction;
  116010. /**
  116011. * Defines the index of refraction used in the material.
  116012. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  116013. */
  116014. indexOfRefraction: number;
  116015. private _invertRefractionY;
  116016. /**
  116017. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116018. */
  116019. invertRefractionY: boolean;
  116020. private _linkRefractionWithTransparency;
  116021. /**
  116022. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116023. * Materials half opaque for instance using refraction could benefit from this control.
  116024. */
  116025. linkRefractionWithTransparency: boolean;
  116026. /**
  116027. * Defines the minimum thickness stored in the thickness map.
  116028. * If no thickness map is defined, this value will be used to simulate thickness.
  116029. */
  116030. minimumThickness: number;
  116031. /**
  116032. * Defines the maximum thickness stored in the thickness map.
  116033. */
  116034. maximumThickness: number;
  116035. /**
  116036. * Defines the volume tint of the material.
  116037. * This is used for both translucency and scattering.
  116038. */
  116039. tintColor: Color3;
  116040. /**
  116041. * Defines the distance at which the tint color should be found in the media.
  116042. * This is used for refraction only.
  116043. */
  116044. tintColorAtDistance: number;
  116045. /**
  116046. * Defines how far each channel transmit through the media.
  116047. * It is defined as a color to simplify it selection.
  116048. */
  116049. diffusionDistance: Color3;
  116050. private _useMaskFromThicknessTexture;
  116051. /**
  116052. * Stores the intensity of the different subsurface effects in the thickness texture.
  116053. * * the green channel is the translucency intensity.
  116054. * * the blue channel is the scattering intensity.
  116055. * * the alpha channel is the refraction intensity.
  116056. */
  116057. useMaskFromThicknessTexture: boolean;
  116058. /** @hidden */
  116059. private _internalMarkAllSubMeshesAsTexturesDirty;
  116060. /** @hidden */
  116061. _markAllSubMeshesAsTexturesDirty(): void;
  116062. /**
  116063. * Instantiate a new istance of sub surface configuration.
  116064. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116065. */
  116066. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116067. /**
  116068. * Gets wehter the submesh is ready to be used or not.
  116069. * @param defines the list of "defines" to update.
  116070. * @param scene defines the scene the material belongs to.
  116071. * @returns - boolean indicating that the submesh is ready or not.
  116072. */
  116073. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  116074. /**
  116075. * Checks to see if a texture is used in the material.
  116076. * @param defines the list of "defines" to update.
  116077. * @param scene defines the scene to the material belongs to.
  116078. */
  116079. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  116080. /**
  116081. * Binds the material data.
  116082. * @param uniformBuffer defines the Uniform buffer to fill in.
  116083. * @param scene defines the scene the material belongs to.
  116084. * @param engine defines the engine the material belongs to.
  116085. * @param isFrozen defines wether the material is frozen or not.
  116086. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  116087. */
  116088. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  116089. /**
  116090. * Unbinds the material from the mesh.
  116091. * @param activeEffect defines the effect that should be unbound from.
  116092. * @returns true if unbound, otherwise false
  116093. */
  116094. unbind(activeEffect: Effect): boolean;
  116095. /**
  116096. * Returns the texture used for refraction or null if none is used.
  116097. * @param scene defines the scene the material belongs to.
  116098. * @returns - Refraction texture if present. If no refraction texture and refraction
  116099. * is linked with transparency, returns environment texture. Otherwise, returns null.
  116100. */
  116101. private _getRefractionTexture;
  116102. /**
  116103. * Returns true if alpha blending should be disabled.
  116104. */
  116105. readonly disableAlphaBlending: boolean;
  116106. /**
  116107. * Fills the list of render target textures.
  116108. * @param renderTargets the list of render targets to update
  116109. */
  116110. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  116111. /**
  116112. * Checks to see if a texture is used in the material.
  116113. * @param texture - Base texture to use.
  116114. * @returns - Boolean specifying if a texture is used in the material.
  116115. */
  116116. hasTexture(texture: BaseTexture): boolean;
  116117. /**
  116118. * Gets a boolean indicating that current material needs to register RTT
  116119. * @returns true if this uses a render target otherwise false.
  116120. */
  116121. hasRenderTargetTextures(): boolean;
  116122. /**
  116123. * Returns an array of the actively used textures.
  116124. * @param activeTextures Array of BaseTextures
  116125. */
  116126. getActiveTextures(activeTextures: BaseTexture[]): void;
  116127. /**
  116128. * Returns the animatable textures.
  116129. * @param animatables Array of animatable textures.
  116130. */
  116131. getAnimatables(animatables: IAnimatable[]): void;
  116132. /**
  116133. * Disposes the resources of the material.
  116134. * @param forceDisposeTextures - Forces the disposal of all textures.
  116135. */
  116136. dispose(forceDisposeTextures?: boolean): void;
  116137. /**
  116138. * Get the current class name of the texture useful for serialization or dynamic coding.
  116139. * @returns "PBRSubSurfaceConfiguration"
  116140. */
  116141. getClassName(): string;
  116142. /**
  116143. * Add fallbacks to the effect fallbacks list.
  116144. * @param defines defines the Base texture to use.
  116145. * @param fallbacks defines the current fallback list.
  116146. * @param currentRank defines the current fallback rank.
  116147. * @returns the new fallback rank.
  116148. */
  116149. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116150. /**
  116151. * Add the required uniforms to the current list.
  116152. * @param uniforms defines the current uniform list.
  116153. */
  116154. static AddUniforms(uniforms: string[]): void;
  116155. /**
  116156. * Add the required samplers to the current list.
  116157. * @param samplers defines the current sampler list.
  116158. */
  116159. static AddSamplers(samplers: string[]): void;
  116160. /**
  116161. * Add the required uniforms to the current buffer.
  116162. * @param uniformBuffer defines the current uniform buffer.
  116163. */
  116164. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116165. /**
  116166. * Makes a duplicate of the current configuration into another one.
  116167. * @param configuration define the config where to copy the info
  116168. */
  116169. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  116170. /**
  116171. * Serializes this Sub Surface configuration.
  116172. * @returns - An object with the serialized config.
  116173. */
  116174. serialize(): any;
  116175. /**
  116176. * Parses a anisotropy Configuration from a serialized object.
  116177. * @param source - Serialized object.
  116178. * @param scene Defines the scene we are parsing for
  116179. * @param rootUrl Defines the rootUrl to load from
  116180. */
  116181. parse(source: any, scene: Scene, rootUrl: string): void;
  116182. }
  116183. }
  116184. declare module BABYLON {
  116185. /** @hidden */
  116186. export var pbrFragmentDeclaration: {
  116187. name: string;
  116188. shader: string;
  116189. };
  116190. }
  116191. declare module BABYLON {
  116192. /** @hidden */
  116193. export var pbrUboDeclaration: {
  116194. name: string;
  116195. shader: string;
  116196. };
  116197. }
  116198. declare module BABYLON {
  116199. /** @hidden */
  116200. export var pbrFragmentExtraDeclaration: {
  116201. name: string;
  116202. shader: string;
  116203. };
  116204. }
  116205. declare module BABYLON {
  116206. /** @hidden */
  116207. export var pbrFragmentSamplersDeclaration: {
  116208. name: string;
  116209. shader: string;
  116210. };
  116211. }
  116212. declare module BABYLON {
  116213. /** @hidden */
  116214. export var pbrHelperFunctions: {
  116215. name: string;
  116216. shader: string;
  116217. };
  116218. }
  116219. declare module BABYLON {
  116220. /** @hidden */
  116221. export var harmonicsFunctions: {
  116222. name: string;
  116223. shader: string;
  116224. };
  116225. }
  116226. declare module BABYLON {
  116227. /** @hidden */
  116228. export var pbrDirectLightingSetupFunctions: {
  116229. name: string;
  116230. shader: string;
  116231. };
  116232. }
  116233. declare module BABYLON {
  116234. /** @hidden */
  116235. export var pbrDirectLightingFalloffFunctions: {
  116236. name: string;
  116237. shader: string;
  116238. };
  116239. }
  116240. declare module BABYLON {
  116241. /** @hidden */
  116242. export var pbrBRDFFunctions: {
  116243. name: string;
  116244. shader: string;
  116245. };
  116246. }
  116247. declare module BABYLON {
  116248. /** @hidden */
  116249. export var pbrDirectLightingFunctions: {
  116250. name: string;
  116251. shader: string;
  116252. };
  116253. }
  116254. declare module BABYLON {
  116255. /** @hidden */
  116256. export var pbrIBLFunctions: {
  116257. name: string;
  116258. shader: string;
  116259. };
  116260. }
  116261. declare module BABYLON {
  116262. /** @hidden */
  116263. export var pbrDebug: {
  116264. name: string;
  116265. shader: string;
  116266. };
  116267. }
  116268. declare module BABYLON {
  116269. /** @hidden */
  116270. export var pbrPixelShader: {
  116271. name: string;
  116272. shader: string;
  116273. };
  116274. }
  116275. declare module BABYLON {
  116276. /** @hidden */
  116277. export var pbrVertexDeclaration: {
  116278. name: string;
  116279. shader: string;
  116280. };
  116281. }
  116282. declare module BABYLON {
  116283. /** @hidden */
  116284. export var pbrVertexShader: {
  116285. name: string;
  116286. shader: string;
  116287. };
  116288. }
  116289. declare module BABYLON {
  116290. /**
  116291. * Manages the defines for the PBR Material.
  116292. * @hidden
  116293. */
  116294. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  116295. PBR: boolean;
  116296. MAINUV1: boolean;
  116297. MAINUV2: boolean;
  116298. UV1: boolean;
  116299. UV2: boolean;
  116300. ALBEDO: boolean;
  116301. ALBEDODIRECTUV: number;
  116302. VERTEXCOLOR: boolean;
  116303. AMBIENT: boolean;
  116304. AMBIENTDIRECTUV: number;
  116305. AMBIENTINGRAYSCALE: boolean;
  116306. OPACITY: boolean;
  116307. VERTEXALPHA: boolean;
  116308. OPACITYDIRECTUV: number;
  116309. OPACITYRGB: boolean;
  116310. ALPHATEST: boolean;
  116311. DEPTHPREPASS: boolean;
  116312. ALPHABLEND: boolean;
  116313. ALPHAFROMALBEDO: boolean;
  116314. ALPHATESTVALUE: string;
  116315. SPECULAROVERALPHA: boolean;
  116316. RADIANCEOVERALPHA: boolean;
  116317. ALPHAFRESNEL: boolean;
  116318. LINEARALPHAFRESNEL: boolean;
  116319. PREMULTIPLYALPHA: boolean;
  116320. EMISSIVE: boolean;
  116321. EMISSIVEDIRECTUV: number;
  116322. REFLECTIVITY: boolean;
  116323. REFLECTIVITYDIRECTUV: number;
  116324. SPECULARTERM: boolean;
  116325. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  116326. MICROSURFACEAUTOMATIC: boolean;
  116327. LODBASEDMICROSFURACE: boolean;
  116328. MICROSURFACEMAP: boolean;
  116329. MICROSURFACEMAPDIRECTUV: number;
  116330. METALLICWORKFLOW: boolean;
  116331. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  116332. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  116333. METALLNESSSTOREINMETALMAPBLUE: boolean;
  116334. AOSTOREINMETALMAPRED: boolean;
  116335. METALLICF0FACTORFROMMETALLICMAP: boolean;
  116336. ENVIRONMENTBRDF: boolean;
  116337. ENVIRONMENTBRDF_RGBD: boolean;
  116338. NORMAL: boolean;
  116339. TANGENT: boolean;
  116340. BUMP: boolean;
  116341. BUMPDIRECTUV: number;
  116342. OBJECTSPACE_NORMALMAP: boolean;
  116343. PARALLAX: boolean;
  116344. PARALLAXOCCLUSION: boolean;
  116345. NORMALXYSCALE: boolean;
  116346. LIGHTMAP: boolean;
  116347. LIGHTMAPDIRECTUV: number;
  116348. USELIGHTMAPASSHADOWMAP: boolean;
  116349. GAMMALIGHTMAP: boolean;
  116350. RGBDLIGHTMAP: boolean;
  116351. REFLECTION: boolean;
  116352. REFLECTIONMAP_3D: boolean;
  116353. REFLECTIONMAP_SPHERICAL: boolean;
  116354. REFLECTIONMAP_PLANAR: boolean;
  116355. REFLECTIONMAP_CUBIC: boolean;
  116356. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  116357. REFLECTIONMAP_PROJECTION: boolean;
  116358. REFLECTIONMAP_SKYBOX: boolean;
  116359. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  116360. REFLECTIONMAP_EXPLICIT: boolean;
  116361. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  116362. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  116363. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  116364. INVERTCUBICMAP: boolean;
  116365. USESPHERICALFROMREFLECTIONMAP: boolean;
  116366. USEIRRADIANCEMAP: boolean;
  116367. SPHERICAL_HARMONICS: boolean;
  116368. USESPHERICALINVERTEX: boolean;
  116369. REFLECTIONMAP_OPPOSITEZ: boolean;
  116370. LODINREFLECTIONALPHA: boolean;
  116371. GAMMAREFLECTION: boolean;
  116372. RGBDREFLECTION: boolean;
  116373. LINEARSPECULARREFLECTION: boolean;
  116374. RADIANCEOCCLUSION: boolean;
  116375. HORIZONOCCLUSION: boolean;
  116376. INSTANCES: boolean;
  116377. NUM_BONE_INFLUENCERS: number;
  116378. BonesPerMesh: number;
  116379. BONETEXTURE: boolean;
  116380. NONUNIFORMSCALING: boolean;
  116381. MORPHTARGETS: boolean;
  116382. MORPHTARGETS_NORMAL: boolean;
  116383. MORPHTARGETS_TANGENT: boolean;
  116384. MORPHTARGETS_UV: boolean;
  116385. NUM_MORPH_INFLUENCERS: number;
  116386. IMAGEPROCESSING: boolean;
  116387. VIGNETTE: boolean;
  116388. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116389. VIGNETTEBLENDMODEOPAQUE: boolean;
  116390. TONEMAPPING: boolean;
  116391. TONEMAPPING_ACES: boolean;
  116392. CONTRAST: boolean;
  116393. COLORCURVES: boolean;
  116394. COLORGRADING: boolean;
  116395. COLORGRADING3D: boolean;
  116396. SAMPLER3DGREENDEPTH: boolean;
  116397. SAMPLER3DBGRMAP: boolean;
  116398. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116399. EXPOSURE: boolean;
  116400. MULTIVIEW: boolean;
  116401. USEPHYSICALLIGHTFALLOFF: boolean;
  116402. USEGLTFLIGHTFALLOFF: boolean;
  116403. TWOSIDEDLIGHTING: boolean;
  116404. SHADOWFLOAT: boolean;
  116405. CLIPPLANE: boolean;
  116406. CLIPPLANE2: boolean;
  116407. CLIPPLANE3: boolean;
  116408. CLIPPLANE4: boolean;
  116409. POINTSIZE: boolean;
  116410. FOG: boolean;
  116411. LOGARITHMICDEPTH: boolean;
  116412. FORCENORMALFORWARD: boolean;
  116413. SPECULARAA: boolean;
  116414. CLEARCOAT: boolean;
  116415. CLEARCOAT_DEFAULTIOR: boolean;
  116416. CLEARCOAT_TEXTURE: boolean;
  116417. CLEARCOAT_TEXTUREDIRECTUV: number;
  116418. CLEARCOAT_BUMP: boolean;
  116419. CLEARCOAT_BUMPDIRECTUV: number;
  116420. CLEARCOAT_TINT: boolean;
  116421. CLEARCOAT_TINT_TEXTURE: boolean;
  116422. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116423. ANISOTROPIC: boolean;
  116424. ANISOTROPIC_TEXTURE: boolean;
  116425. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116426. BRDF_V_HEIGHT_CORRELATED: boolean;
  116427. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116428. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116429. SHEEN: boolean;
  116430. SHEEN_TEXTURE: boolean;
  116431. SHEEN_TEXTUREDIRECTUV: number;
  116432. SHEEN_LINKWITHALBEDO: boolean;
  116433. SUBSURFACE: boolean;
  116434. SS_REFRACTION: boolean;
  116435. SS_TRANSLUCENCY: boolean;
  116436. SS_SCATERRING: boolean;
  116437. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116438. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116439. SS_REFRACTIONMAP_3D: boolean;
  116440. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116441. SS_LODINREFRACTIONALPHA: boolean;
  116442. SS_GAMMAREFRACTION: boolean;
  116443. SS_RGBDREFRACTION: boolean;
  116444. SS_LINEARSPECULARREFRACTION: boolean;
  116445. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116446. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116447. UNLIT: boolean;
  116448. DEBUGMODE: number;
  116449. /**
  116450. * Initializes the PBR Material defines.
  116451. */
  116452. constructor();
  116453. /**
  116454. * Resets the PBR Material defines.
  116455. */
  116456. reset(): void;
  116457. }
  116458. /**
  116459. * The Physically based material base class of BJS.
  116460. *
  116461. * This offers the main features of a standard PBR material.
  116462. * For more information, please refer to the documentation :
  116463. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116464. */
  116465. export abstract class PBRBaseMaterial extends PushMaterial {
  116466. /**
  116467. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116468. */
  116469. static readonly PBRMATERIAL_OPAQUE: number;
  116470. /**
  116471. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116472. */
  116473. static readonly PBRMATERIAL_ALPHATEST: number;
  116474. /**
  116475. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116476. */
  116477. static readonly PBRMATERIAL_ALPHABLEND: number;
  116478. /**
  116479. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116480. * They are also discarded below the alpha cutoff threshold to improve performances.
  116481. */
  116482. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116483. /**
  116484. * Defines the default value of how much AO map is occluding the analytical lights
  116485. * (point spot...).
  116486. */
  116487. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116488. /**
  116489. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  116490. */
  116491. static readonly LIGHTFALLOFF_PHYSICAL: number;
  116492. /**
  116493. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  116494. * to enhance interoperability with other engines.
  116495. */
  116496. static readonly LIGHTFALLOFF_GLTF: number;
  116497. /**
  116498. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  116499. * to enhance interoperability with other materials.
  116500. */
  116501. static readonly LIGHTFALLOFF_STANDARD: number;
  116502. /**
  116503. * Intensity of the direct lights e.g. the four lights available in your scene.
  116504. * This impacts both the direct diffuse and specular highlights.
  116505. */
  116506. protected _directIntensity: number;
  116507. /**
  116508. * Intensity of the emissive part of the material.
  116509. * This helps controlling the emissive effect without modifying the emissive color.
  116510. */
  116511. protected _emissiveIntensity: number;
  116512. /**
  116513. * Intensity of the environment e.g. how much the environment will light the object
  116514. * either through harmonics for rough material or through the refelction for shiny ones.
  116515. */
  116516. protected _environmentIntensity: number;
  116517. /**
  116518. * This is a special control allowing the reduction of the specular highlights coming from the
  116519. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116520. */
  116521. protected _specularIntensity: number;
  116522. /**
  116523. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  116524. */
  116525. private _lightingInfos;
  116526. /**
  116527. * Debug Control allowing disabling the bump map on this material.
  116528. */
  116529. protected _disableBumpMap: boolean;
  116530. /**
  116531. * AKA Diffuse Texture in standard nomenclature.
  116532. */
  116533. protected _albedoTexture: Nullable<BaseTexture>;
  116534. /**
  116535. * AKA Occlusion Texture in other nomenclature.
  116536. */
  116537. protected _ambientTexture: Nullable<BaseTexture>;
  116538. /**
  116539. * AKA Occlusion Texture Intensity in other nomenclature.
  116540. */
  116541. protected _ambientTextureStrength: number;
  116542. /**
  116543. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116544. * 1 means it completely occludes it
  116545. * 0 mean it has no impact
  116546. */
  116547. protected _ambientTextureImpactOnAnalyticalLights: number;
  116548. /**
  116549. * Stores the alpha values in a texture.
  116550. */
  116551. protected _opacityTexture: Nullable<BaseTexture>;
  116552. /**
  116553. * Stores the reflection values in a texture.
  116554. */
  116555. protected _reflectionTexture: Nullable<BaseTexture>;
  116556. /**
  116557. * Stores the emissive values in a texture.
  116558. */
  116559. protected _emissiveTexture: Nullable<BaseTexture>;
  116560. /**
  116561. * AKA Specular texture in other nomenclature.
  116562. */
  116563. protected _reflectivityTexture: Nullable<BaseTexture>;
  116564. /**
  116565. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116566. */
  116567. protected _metallicTexture: Nullable<BaseTexture>;
  116568. /**
  116569. * Specifies the metallic scalar of the metallic/roughness workflow.
  116570. * Can also be used to scale the metalness values of the metallic texture.
  116571. */
  116572. protected _metallic: Nullable<number>;
  116573. /**
  116574. * Specifies the roughness scalar of the metallic/roughness workflow.
  116575. * Can also be used to scale the roughness values of the metallic texture.
  116576. */
  116577. protected _roughness: Nullable<number>;
  116578. /**
  116579. * Specifies the an F0 factor to help configuring the material F0.
  116580. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116581. * to 0.5 the previously hard coded value stays the same.
  116582. * Can also be used to scale the F0 values of the metallic texture.
  116583. */
  116584. protected _metallicF0Factor: number;
  116585. /**
  116586. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116587. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116588. * your expectation as it multiplies with the texture data.
  116589. */
  116590. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  116591. /**
  116592. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116593. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116594. */
  116595. protected _microSurfaceTexture: Nullable<BaseTexture>;
  116596. /**
  116597. * Stores surface normal data used to displace a mesh in a texture.
  116598. */
  116599. protected _bumpTexture: Nullable<BaseTexture>;
  116600. /**
  116601. * Stores the pre-calculated light information of a mesh in a texture.
  116602. */
  116603. protected _lightmapTexture: Nullable<BaseTexture>;
  116604. /**
  116605. * The color of a material in ambient lighting.
  116606. */
  116607. protected _ambientColor: Color3;
  116608. /**
  116609. * AKA Diffuse Color in other nomenclature.
  116610. */
  116611. protected _albedoColor: Color3;
  116612. /**
  116613. * AKA Specular Color in other nomenclature.
  116614. */
  116615. protected _reflectivityColor: Color3;
  116616. /**
  116617. * The color applied when light is reflected from a material.
  116618. */
  116619. protected _reflectionColor: Color3;
  116620. /**
  116621. * The color applied when light is emitted from a material.
  116622. */
  116623. protected _emissiveColor: Color3;
  116624. /**
  116625. * AKA Glossiness in other nomenclature.
  116626. */
  116627. protected _microSurface: number;
  116628. /**
  116629. * Specifies that the material will use the light map as a show map.
  116630. */
  116631. protected _useLightmapAsShadowmap: boolean;
  116632. /**
  116633. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116634. * makes the reflect vector face the model (under horizon).
  116635. */
  116636. protected _useHorizonOcclusion: boolean;
  116637. /**
  116638. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116639. * too much the area relying on ambient texture to define their ambient occlusion.
  116640. */
  116641. protected _useRadianceOcclusion: boolean;
  116642. /**
  116643. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116644. */
  116645. protected _useAlphaFromAlbedoTexture: boolean;
  116646. /**
  116647. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  116648. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116649. */
  116650. protected _useSpecularOverAlpha: boolean;
  116651. /**
  116652. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116653. */
  116654. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116655. /**
  116656. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116657. */
  116658. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  116659. /**
  116660. * Specifies if the metallic texture contains the roughness information in its green channel.
  116661. */
  116662. protected _useRoughnessFromMetallicTextureGreen: boolean;
  116663. /**
  116664. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116665. */
  116666. protected _useMetallnessFromMetallicTextureBlue: boolean;
  116667. /**
  116668. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116669. */
  116670. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  116671. /**
  116672. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116673. */
  116674. protected _useAmbientInGrayScale: boolean;
  116675. /**
  116676. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116677. * The material will try to infer what glossiness each pixel should be.
  116678. */
  116679. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  116680. /**
  116681. * Defines the falloff type used in this material.
  116682. * It by default is Physical.
  116683. */
  116684. protected _lightFalloff: number;
  116685. /**
  116686. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116687. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116688. */
  116689. protected _useRadianceOverAlpha: boolean;
  116690. /**
  116691. * Allows using an object space normal map (instead of tangent space).
  116692. */
  116693. protected _useObjectSpaceNormalMap: boolean;
  116694. /**
  116695. * Allows using the bump map in parallax mode.
  116696. */
  116697. protected _useParallax: boolean;
  116698. /**
  116699. * Allows using the bump map in parallax occlusion mode.
  116700. */
  116701. protected _useParallaxOcclusion: boolean;
  116702. /**
  116703. * Controls the scale bias of the parallax mode.
  116704. */
  116705. protected _parallaxScaleBias: number;
  116706. /**
  116707. * If sets to true, disables all the lights affecting the material.
  116708. */
  116709. protected _disableLighting: boolean;
  116710. /**
  116711. * Number of Simultaneous lights allowed on the material.
  116712. */
  116713. protected _maxSimultaneousLights: number;
  116714. /**
  116715. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116716. */
  116717. protected _invertNormalMapX: boolean;
  116718. /**
  116719. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116720. */
  116721. protected _invertNormalMapY: boolean;
  116722. /**
  116723. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116724. */
  116725. protected _twoSidedLighting: boolean;
  116726. /**
  116727. * Defines the alpha limits in alpha test mode.
  116728. */
  116729. protected _alphaCutOff: number;
  116730. /**
  116731. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116732. */
  116733. protected _forceAlphaTest: boolean;
  116734. /**
  116735. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116736. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116737. */
  116738. protected _useAlphaFresnel: boolean;
  116739. /**
  116740. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116741. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116742. */
  116743. protected _useLinearAlphaFresnel: boolean;
  116744. /**
  116745. * The transparency mode of the material.
  116746. */
  116747. protected _transparencyMode: Nullable<number>;
  116748. /**
  116749. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  116750. * from cos thetav and roughness:
  116751. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  116752. */
  116753. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  116754. /**
  116755. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116756. */
  116757. protected _forceIrradianceInFragment: boolean;
  116758. /**
  116759. * Force normal to face away from face.
  116760. */
  116761. protected _forceNormalForward: boolean;
  116762. /**
  116763. * Enables specular anti aliasing in the PBR shader.
  116764. * It will both interacts on the Geometry for analytical and IBL lighting.
  116765. * It also prefilter the roughness map based on the bump values.
  116766. */
  116767. protected _enableSpecularAntiAliasing: boolean;
  116768. /**
  116769. * Default configuration related to image processing available in the PBR Material.
  116770. */
  116771. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116772. /**
  116773. * Keep track of the image processing observer to allow dispose and replace.
  116774. */
  116775. private _imageProcessingObserver;
  116776. /**
  116777. * Attaches a new image processing configuration to the PBR Material.
  116778. * @param configuration
  116779. */
  116780. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116781. /**
  116782. * Stores the available render targets.
  116783. */
  116784. private _renderTargets;
  116785. /**
  116786. * Sets the global ambient color for the material used in lighting calculations.
  116787. */
  116788. private _globalAmbientColor;
  116789. /**
  116790. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  116791. */
  116792. private _useLogarithmicDepth;
  116793. /**
  116794. * If set to true, no lighting calculations will be applied.
  116795. */
  116796. private _unlit;
  116797. private _debugMode;
  116798. /**
  116799. * @hidden
  116800. * This is reserved for the inspector.
  116801. * Defines the material debug mode.
  116802. * It helps seeing only some components of the material while troubleshooting.
  116803. */
  116804. debugMode: number;
  116805. /**
  116806. * @hidden
  116807. * This is reserved for the inspector.
  116808. * Specify from where on screen the debug mode should start.
  116809. * The value goes from -1 (full screen) to 1 (not visible)
  116810. * It helps with side by side comparison against the final render
  116811. * This defaults to -1
  116812. */
  116813. private debugLimit;
  116814. /**
  116815. * @hidden
  116816. * This is reserved for the inspector.
  116817. * As the default viewing range might not be enough (if the ambient is really small for instance)
  116818. * You can use the factor to better multiply the final value.
  116819. */
  116820. private debugFactor;
  116821. /**
  116822. * Defines the clear coat layer parameters for the material.
  116823. */
  116824. readonly clearCoat: PBRClearCoatConfiguration;
  116825. /**
  116826. * Defines the anisotropic parameters for the material.
  116827. */
  116828. readonly anisotropy: PBRAnisotropicConfiguration;
  116829. /**
  116830. * Defines the BRDF parameters for the material.
  116831. */
  116832. readonly brdf: PBRBRDFConfiguration;
  116833. /**
  116834. * Defines the Sheen parameters for the material.
  116835. */
  116836. readonly sheen: PBRSheenConfiguration;
  116837. /**
  116838. * Defines the SubSurface parameters for the material.
  116839. */
  116840. readonly subSurface: PBRSubSurfaceConfiguration;
  116841. /**
  116842. * Custom callback helping to override the default shader used in the material.
  116843. */
  116844. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  116845. protected _rebuildInParallel: boolean;
  116846. /**
  116847. * Instantiates a new PBRMaterial instance.
  116848. *
  116849. * @param name The material name
  116850. * @param scene The scene the material will be use in.
  116851. */
  116852. constructor(name: string, scene: Scene);
  116853. /**
  116854. * Gets a boolean indicating that current material needs to register RTT
  116855. */
  116856. readonly hasRenderTargetTextures: boolean;
  116857. /**
  116858. * Gets the name of the material class.
  116859. */
  116860. getClassName(): string;
  116861. /**
  116862. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116863. */
  116864. /**
  116865. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116866. */
  116867. useLogarithmicDepth: boolean;
  116868. /**
  116869. * Gets the current transparency mode.
  116870. */
  116871. /**
  116872. * Sets the transparency mode of the material.
  116873. *
  116874. * | Value | Type | Description |
  116875. * | ----- | ----------------------------------- | ----------- |
  116876. * | 0 | OPAQUE | |
  116877. * | 1 | ALPHATEST | |
  116878. * | 2 | ALPHABLEND | |
  116879. * | 3 | ALPHATESTANDBLEND | |
  116880. *
  116881. */
  116882. transparencyMode: Nullable<number>;
  116883. /**
  116884. * Returns true if alpha blending should be disabled.
  116885. */
  116886. private readonly _disableAlphaBlending;
  116887. /**
  116888. * Specifies whether or not this material should be rendered in alpha blend mode.
  116889. */
  116890. needAlphaBlending(): boolean;
  116891. /**
  116892. * Specifies if the mesh will require alpha blending.
  116893. * @param mesh - BJS mesh.
  116894. */
  116895. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  116896. /**
  116897. * Specifies whether or not this material should be rendered in alpha test mode.
  116898. */
  116899. needAlphaTesting(): boolean;
  116900. /**
  116901. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  116902. */
  116903. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  116904. /**
  116905. * Gets the texture used for the alpha test.
  116906. */
  116907. getAlphaTestTexture(): Nullable<BaseTexture>;
  116908. /**
  116909. * Specifies that the submesh is ready to be used.
  116910. * @param mesh - BJS mesh.
  116911. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  116912. * @param useInstances - Specifies that instances should be used.
  116913. * @returns - boolean indicating that the submesh is ready or not.
  116914. */
  116915. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116916. /**
  116917. * Specifies if the material uses metallic roughness workflow.
  116918. * @returns boolean specifiying if the material uses metallic roughness workflow.
  116919. */
  116920. isMetallicWorkflow(): boolean;
  116921. private _prepareEffect;
  116922. private _prepareDefines;
  116923. /**
  116924. * Force shader compilation
  116925. */
  116926. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  116927. /**
  116928. * Initializes the uniform buffer layout for the shader.
  116929. */
  116930. buildUniformLayout(): void;
  116931. /**
  116932. * Unbinds the material from the mesh
  116933. */
  116934. unbind(): void;
  116935. /**
  116936. * Binds the submesh data.
  116937. * @param world - The world matrix.
  116938. * @param mesh - The BJS mesh.
  116939. * @param subMesh - A submesh of the BJS mesh.
  116940. */
  116941. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116942. /**
  116943. * Returns the animatable textures.
  116944. * @returns - Array of animatable textures.
  116945. */
  116946. getAnimatables(): IAnimatable[];
  116947. /**
  116948. * Returns the texture used for reflections.
  116949. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  116950. */
  116951. private _getReflectionTexture;
  116952. /**
  116953. * Returns an array of the actively used textures.
  116954. * @returns - Array of BaseTextures
  116955. */
  116956. getActiveTextures(): BaseTexture[];
  116957. /**
  116958. * Checks to see if a texture is used in the material.
  116959. * @param texture - Base texture to use.
  116960. * @returns - Boolean specifying if a texture is used in the material.
  116961. */
  116962. hasTexture(texture: BaseTexture): boolean;
  116963. /**
  116964. * Disposes the resources of the material.
  116965. * @param forceDisposeEffect - Forces the disposal of effects.
  116966. * @param forceDisposeTextures - Forces the disposal of all textures.
  116967. */
  116968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116969. }
  116970. }
  116971. declare module BABYLON {
  116972. /**
  116973. * The Physically based material of BJS.
  116974. *
  116975. * This offers the main features of a standard PBR material.
  116976. * For more information, please refer to the documentation :
  116977. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116978. */
  116979. export class PBRMaterial extends PBRBaseMaterial {
  116980. /**
  116981. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116982. */
  116983. static readonly PBRMATERIAL_OPAQUE: number;
  116984. /**
  116985. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116986. */
  116987. static readonly PBRMATERIAL_ALPHATEST: number;
  116988. /**
  116989. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116990. */
  116991. static readonly PBRMATERIAL_ALPHABLEND: number;
  116992. /**
  116993. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116994. * They are also discarded below the alpha cutoff threshold to improve performances.
  116995. */
  116996. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116997. /**
  116998. * Defines the default value of how much AO map is occluding the analytical lights
  116999. * (point spot...).
  117000. */
  117001. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117002. /**
  117003. * Intensity of the direct lights e.g. the four lights available in your scene.
  117004. * This impacts both the direct diffuse and specular highlights.
  117005. */
  117006. directIntensity: number;
  117007. /**
  117008. * Intensity of the emissive part of the material.
  117009. * This helps controlling the emissive effect without modifying the emissive color.
  117010. */
  117011. emissiveIntensity: number;
  117012. /**
  117013. * Intensity of the environment e.g. how much the environment will light the object
  117014. * either through harmonics for rough material or through the refelction for shiny ones.
  117015. */
  117016. environmentIntensity: number;
  117017. /**
  117018. * This is a special control allowing the reduction of the specular highlights coming from the
  117019. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  117020. */
  117021. specularIntensity: number;
  117022. /**
  117023. * Debug Control allowing disabling the bump map on this material.
  117024. */
  117025. disableBumpMap: boolean;
  117026. /**
  117027. * AKA Diffuse Texture in standard nomenclature.
  117028. */
  117029. albedoTexture: BaseTexture;
  117030. /**
  117031. * AKA Occlusion Texture in other nomenclature.
  117032. */
  117033. ambientTexture: BaseTexture;
  117034. /**
  117035. * AKA Occlusion Texture Intensity in other nomenclature.
  117036. */
  117037. ambientTextureStrength: number;
  117038. /**
  117039. * Defines how much the AO map is occluding the analytical lights (point spot...).
  117040. * 1 means it completely occludes it
  117041. * 0 mean it has no impact
  117042. */
  117043. ambientTextureImpactOnAnalyticalLights: number;
  117044. /**
  117045. * Stores the alpha values in a texture.
  117046. */
  117047. opacityTexture: BaseTexture;
  117048. /**
  117049. * Stores the reflection values in a texture.
  117050. */
  117051. reflectionTexture: Nullable<BaseTexture>;
  117052. /**
  117053. * Stores the emissive values in a texture.
  117054. */
  117055. emissiveTexture: BaseTexture;
  117056. /**
  117057. * AKA Specular texture in other nomenclature.
  117058. */
  117059. reflectivityTexture: BaseTexture;
  117060. /**
  117061. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117062. */
  117063. metallicTexture: BaseTexture;
  117064. /**
  117065. * Specifies the metallic scalar of the metallic/roughness workflow.
  117066. * Can also be used to scale the metalness values of the metallic texture.
  117067. */
  117068. metallic: Nullable<number>;
  117069. /**
  117070. * Specifies the roughness scalar of the metallic/roughness workflow.
  117071. * Can also be used to scale the roughness values of the metallic texture.
  117072. */
  117073. roughness: Nullable<number>;
  117074. /**
  117075. * Specifies the an F0 factor to help configuring the material F0.
  117076. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117077. * to 0.5 the previously hard coded value stays the same.
  117078. * Can also be used to scale the F0 values of the metallic texture.
  117079. */
  117080. metallicF0Factor: number;
  117081. /**
  117082. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117083. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117084. * your expectation as it multiplies with the texture data.
  117085. */
  117086. useMetallicF0FactorFromMetallicTexture: boolean;
  117087. /**
  117088. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117089. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117090. */
  117091. microSurfaceTexture: BaseTexture;
  117092. /**
  117093. * Stores surface normal data used to displace a mesh in a texture.
  117094. */
  117095. bumpTexture: BaseTexture;
  117096. /**
  117097. * Stores the pre-calculated light information of a mesh in a texture.
  117098. */
  117099. lightmapTexture: BaseTexture;
  117100. /**
  117101. * Stores the refracted light information in a texture.
  117102. */
  117103. refractionTexture: Nullable<BaseTexture>;
  117104. /**
  117105. * The color of a material in ambient lighting.
  117106. */
  117107. ambientColor: Color3;
  117108. /**
  117109. * AKA Diffuse Color in other nomenclature.
  117110. */
  117111. albedoColor: Color3;
  117112. /**
  117113. * AKA Specular Color in other nomenclature.
  117114. */
  117115. reflectivityColor: Color3;
  117116. /**
  117117. * The color reflected from the material.
  117118. */
  117119. reflectionColor: Color3;
  117120. /**
  117121. * The color emitted from the material.
  117122. */
  117123. emissiveColor: Color3;
  117124. /**
  117125. * AKA Glossiness in other nomenclature.
  117126. */
  117127. microSurface: number;
  117128. /**
  117129. * source material index of refraction (IOR)' / 'destination material IOR.
  117130. */
  117131. indexOfRefraction: number;
  117132. /**
  117133. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117134. */
  117135. invertRefractionY: boolean;
  117136. /**
  117137. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117138. * Materials half opaque for instance using refraction could benefit from this control.
  117139. */
  117140. linkRefractionWithTransparency: boolean;
  117141. /**
  117142. * If true, the light map contains occlusion information instead of lighting info.
  117143. */
  117144. useLightmapAsShadowmap: boolean;
  117145. /**
  117146. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117147. */
  117148. useAlphaFromAlbedoTexture: boolean;
  117149. /**
  117150. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117151. */
  117152. forceAlphaTest: boolean;
  117153. /**
  117154. * Defines the alpha limits in alpha test mode.
  117155. */
  117156. alphaCutOff: number;
  117157. /**
  117158. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  117159. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117160. */
  117161. useSpecularOverAlpha: boolean;
  117162. /**
  117163. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117164. */
  117165. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117166. /**
  117167. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117168. */
  117169. useRoughnessFromMetallicTextureAlpha: boolean;
  117170. /**
  117171. * Specifies if the metallic texture contains the roughness information in its green channel.
  117172. */
  117173. useRoughnessFromMetallicTextureGreen: boolean;
  117174. /**
  117175. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117176. */
  117177. useMetallnessFromMetallicTextureBlue: boolean;
  117178. /**
  117179. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117180. */
  117181. useAmbientOcclusionFromMetallicTextureRed: boolean;
  117182. /**
  117183. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117184. */
  117185. useAmbientInGrayScale: boolean;
  117186. /**
  117187. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117188. * The material will try to infer what glossiness each pixel should be.
  117189. */
  117190. useAutoMicroSurfaceFromReflectivityMap: boolean;
  117191. /**
  117192. * BJS is using an harcoded light falloff based on a manually sets up range.
  117193. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117194. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117195. */
  117196. /**
  117197. * BJS is using an harcoded light falloff based on a manually sets up range.
  117198. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117199. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117200. */
  117201. usePhysicalLightFalloff: boolean;
  117202. /**
  117203. * In order to support the falloff compatibility with gltf, a special mode has been added
  117204. * to reproduce the gltf light falloff.
  117205. */
  117206. /**
  117207. * In order to support the falloff compatibility with gltf, a special mode has been added
  117208. * to reproduce the gltf light falloff.
  117209. */
  117210. useGLTFLightFalloff: boolean;
  117211. /**
  117212. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117213. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117214. */
  117215. useRadianceOverAlpha: boolean;
  117216. /**
  117217. * Allows using an object space normal map (instead of tangent space).
  117218. */
  117219. useObjectSpaceNormalMap: boolean;
  117220. /**
  117221. * Allows using the bump map in parallax mode.
  117222. */
  117223. useParallax: boolean;
  117224. /**
  117225. * Allows using the bump map in parallax occlusion mode.
  117226. */
  117227. useParallaxOcclusion: boolean;
  117228. /**
  117229. * Controls the scale bias of the parallax mode.
  117230. */
  117231. parallaxScaleBias: number;
  117232. /**
  117233. * If sets to true, disables all the lights affecting the material.
  117234. */
  117235. disableLighting: boolean;
  117236. /**
  117237. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117238. */
  117239. forceIrradianceInFragment: boolean;
  117240. /**
  117241. * Number of Simultaneous lights allowed on the material.
  117242. */
  117243. maxSimultaneousLights: number;
  117244. /**
  117245. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117246. */
  117247. invertNormalMapX: boolean;
  117248. /**
  117249. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117250. */
  117251. invertNormalMapY: boolean;
  117252. /**
  117253. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117254. */
  117255. twoSidedLighting: boolean;
  117256. /**
  117257. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117258. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117259. */
  117260. useAlphaFresnel: boolean;
  117261. /**
  117262. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117263. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117264. */
  117265. useLinearAlphaFresnel: boolean;
  117266. /**
  117267. * Let user defines the brdf lookup texture used for IBL.
  117268. * A default 8bit version is embedded but you could point at :
  117269. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  117270. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  117271. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  117272. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  117273. */
  117274. environmentBRDFTexture: Nullable<BaseTexture>;
  117275. /**
  117276. * Force normal to face away from face.
  117277. */
  117278. forceNormalForward: boolean;
  117279. /**
  117280. * Enables specular anti aliasing in the PBR shader.
  117281. * It will both interacts on the Geometry for analytical and IBL lighting.
  117282. * It also prefilter the roughness map based on the bump values.
  117283. */
  117284. enableSpecularAntiAliasing: boolean;
  117285. /**
  117286. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117287. * makes the reflect vector face the model (under horizon).
  117288. */
  117289. useHorizonOcclusion: boolean;
  117290. /**
  117291. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117292. * too much the area relying on ambient texture to define their ambient occlusion.
  117293. */
  117294. useRadianceOcclusion: boolean;
  117295. /**
  117296. * If set to true, no lighting calculations will be applied.
  117297. */
  117298. unlit: boolean;
  117299. /**
  117300. * Gets the image processing configuration used either in this material.
  117301. */
  117302. /**
  117303. * Sets the Default image processing configuration used either in the this material.
  117304. *
  117305. * If sets to null, the scene one is in use.
  117306. */
  117307. imageProcessingConfiguration: ImageProcessingConfiguration;
  117308. /**
  117309. * Gets wether the color curves effect is enabled.
  117310. */
  117311. /**
  117312. * Sets wether the color curves effect is enabled.
  117313. */
  117314. cameraColorCurvesEnabled: boolean;
  117315. /**
  117316. * Gets wether the color grading effect is enabled.
  117317. */
  117318. /**
  117319. * Gets wether the color grading effect is enabled.
  117320. */
  117321. cameraColorGradingEnabled: boolean;
  117322. /**
  117323. * Gets wether tonemapping is enabled or not.
  117324. */
  117325. /**
  117326. * Sets wether tonemapping is enabled or not
  117327. */
  117328. cameraToneMappingEnabled: boolean;
  117329. /**
  117330. * The camera exposure used on this material.
  117331. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117332. * This corresponds to a photographic exposure.
  117333. */
  117334. /**
  117335. * The camera exposure used on this material.
  117336. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117337. * This corresponds to a photographic exposure.
  117338. */
  117339. cameraExposure: number;
  117340. /**
  117341. * Gets The camera contrast used on this material.
  117342. */
  117343. /**
  117344. * Sets The camera contrast used on this material.
  117345. */
  117346. cameraContrast: number;
  117347. /**
  117348. * Gets the Color Grading 2D Lookup Texture.
  117349. */
  117350. /**
  117351. * Sets the Color Grading 2D Lookup Texture.
  117352. */
  117353. cameraColorGradingTexture: Nullable<BaseTexture>;
  117354. /**
  117355. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117356. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117357. * 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;
  117358. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117359. */
  117360. /**
  117361. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117362. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117363. * 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;
  117364. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117365. */
  117366. cameraColorCurves: Nullable<ColorCurves>;
  117367. /**
  117368. * Instantiates a new PBRMaterial instance.
  117369. *
  117370. * @param name The material name
  117371. * @param scene The scene the material will be use in.
  117372. */
  117373. constructor(name: string, scene: Scene);
  117374. /**
  117375. * Returns the name of this material class.
  117376. */
  117377. getClassName(): string;
  117378. /**
  117379. * Makes a duplicate of the current material.
  117380. * @param name - name to use for the new material.
  117381. */
  117382. clone(name: string): PBRMaterial;
  117383. /**
  117384. * Serializes this PBR Material.
  117385. * @returns - An object with the serialized material.
  117386. */
  117387. serialize(): any;
  117388. /**
  117389. * Parses a PBR Material from a serialized object.
  117390. * @param source - Serialized object.
  117391. * @param scene - BJS scene instance.
  117392. * @param rootUrl - url for the scene object
  117393. * @returns - PBRMaterial
  117394. */
  117395. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  117396. }
  117397. }
  117398. declare module BABYLON {
  117399. /**
  117400. * Direct draw surface info
  117401. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  117402. */
  117403. export interface DDSInfo {
  117404. /**
  117405. * Width of the texture
  117406. */
  117407. width: number;
  117408. /**
  117409. * Width of the texture
  117410. */
  117411. height: number;
  117412. /**
  117413. * Number of Mipmaps for the texture
  117414. * @see https://en.wikipedia.org/wiki/Mipmap
  117415. */
  117416. mipmapCount: number;
  117417. /**
  117418. * If the textures format is a known fourCC format
  117419. * @see https://www.fourcc.org/
  117420. */
  117421. isFourCC: boolean;
  117422. /**
  117423. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  117424. */
  117425. isRGB: boolean;
  117426. /**
  117427. * If the texture is a lumincance format
  117428. */
  117429. isLuminance: boolean;
  117430. /**
  117431. * If this is a cube texture
  117432. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  117433. */
  117434. isCube: boolean;
  117435. /**
  117436. * If the texture is a compressed format eg. FOURCC_DXT1
  117437. */
  117438. isCompressed: boolean;
  117439. /**
  117440. * The dxgiFormat of the texture
  117441. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  117442. */
  117443. dxgiFormat: number;
  117444. /**
  117445. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  117446. */
  117447. textureType: number;
  117448. /**
  117449. * Sphericle polynomial created for the dds texture
  117450. */
  117451. sphericalPolynomial?: SphericalPolynomial;
  117452. }
  117453. /**
  117454. * Class used to provide DDS decompression tools
  117455. */
  117456. export class DDSTools {
  117457. /**
  117458. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  117459. */
  117460. static StoreLODInAlphaChannel: boolean;
  117461. /**
  117462. * Gets DDS information from an array buffer
  117463. * @param arrayBuffer defines the array buffer to read data from
  117464. * @returns the DDS information
  117465. */
  117466. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  117467. private static _FloatView;
  117468. private static _Int32View;
  117469. private static _ToHalfFloat;
  117470. private static _FromHalfFloat;
  117471. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  117472. private static _GetHalfFloatRGBAArrayBuffer;
  117473. private static _GetFloatRGBAArrayBuffer;
  117474. private static _GetFloatAsUIntRGBAArrayBuffer;
  117475. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  117476. private static _GetRGBAArrayBuffer;
  117477. private static _ExtractLongWordOrder;
  117478. private static _GetRGBArrayBuffer;
  117479. private static _GetLuminanceArrayBuffer;
  117480. /**
  117481. * Uploads DDS Levels to a Babylon Texture
  117482. * @hidden
  117483. */
  117484. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  117485. }
  117486. interface ThinEngine {
  117487. /**
  117488. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  117489. * @param rootUrl defines the url where the file to load is located
  117490. * @param scene defines the current scene
  117491. * @param lodScale defines scale to apply to the mip map selection
  117492. * @param lodOffset defines offset to apply to the mip map selection
  117493. * @param onLoad defines an optional callback raised when the texture is loaded
  117494. * @param onError defines an optional callback raised if there is an issue to load the texture
  117495. * @param format defines the format of the data
  117496. * @param forcedExtension defines the extension to use to pick the right loader
  117497. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  117498. * @returns the cube texture as an InternalTexture
  117499. */
  117500. 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;
  117501. }
  117502. }
  117503. declare module BABYLON {
  117504. /**
  117505. * Implementation of the DDS Texture Loader.
  117506. * @hidden
  117507. */
  117508. export class _DDSTextureLoader implements IInternalTextureLoader {
  117509. /**
  117510. * Defines wether the loader supports cascade loading the different faces.
  117511. */
  117512. readonly supportCascades: boolean;
  117513. /**
  117514. * This returns if the loader support the current file information.
  117515. * @param extension defines the file extension of the file being loaded
  117516. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117517. * @param fallback defines the fallback internal texture if any
  117518. * @param isBase64 defines whether the texture is encoded as a base64
  117519. * @param isBuffer defines whether the texture data are stored as a buffer
  117520. * @returns true if the loader can load the specified file
  117521. */
  117522. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117523. /**
  117524. * Transform the url before loading if required.
  117525. * @param rootUrl the url of the texture
  117526. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117527. * @returns the transformed texture
  117528. */
  117529. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117530. /**
  117531. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117532. * @param rootUrl the url of the texture
  117533. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117534. * @returns the fallback texture
  117535. */
  117536. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117537. /**
  117538. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117539. * @param data contains the texture data
  117540. * @param texture defines the BabylonJS internal texture
  117541. * @param createPolynomials will be true if polynomials have been requested
  117542. * @param onLoad defines the callback to trigger once the texture is ready
  117543. * @param onError defines the callback to trigger in case of error
  117544. */
  117545. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117546. /**
  117547. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117548. * @param data contains the texture data
  117549. * @param texture defines the BabylonJS internal texture
  117550. * @param callback defines the method to call once ready to upload
  117551. */
  117552. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117553. }
  117554. }
  117555. declare module BABYLON {
  117556. /**
  117557. * Implementation of the ENV Texture Loader.
  117558. * @hidden
  117559. */
  117560. export class _ENVTextureLoader implements IInternalTextureLoader {
  117561. /**
  117562. * Defines wether the loader supports cascade loading the different faces.
  117563. */
  117564. readonly supportCascades: boolean;
  117565. /**
  117566. * This returns if the loader support the current file information.
  117567. * @param extension defines the file extension of the file being loaded
  117568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117569. * @param fallback defines the fallback internal texture if any
  117570. * @param isBase64 defines whether the texture is encoded as a base64
  117571. * @param isBuffer defines whether the texture data are stored as a buffer
  117572. * @returns true if the loader can load the specified file
  117573. */
  117574. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117575. /**
  117576. * Transform the url before loading if required.
  117577. * @param rootUrl the url of the texture
  117578. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117579. * @returns the transformed texture
  117580. */
  117581. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117582. /**
  117583. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117584. * @param rootUrl the url of the texture
  117585. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117586. * @returns the fallback texture
  117587. */
  117588. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117589. /**
  117590. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117591. * @param data contains the texture data
  117592. * @param texture defines the BabylonJS internal texture
  117593. * @param createPolynomials will be true if polynomials have been requested
  117594. * @param onLoad defines the callback to trigger once the texture is ready
  117595. * @param onError defines the callback to trigger in case of error
  117596. */
  117597. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117598. /**
  117599. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117600. * @param data contains the texture data
  117601. * @param texture defines the BabylonJS internal texture
  117602. * @param callback defines the method to call once ready to upload
  117603. */
  117604. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117605. }
  117606. }
  117607. declare module BABYLON {
  117608. /**
  117609. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  117610. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  117611. */
  117612. export class KhronosTextureContainer {
  117613. /** contents of the KTX container file */
  117614. arrayBuffer: any;
  117615. private static HEADER_LEN;
  117616. private static COMPRESSED_2D;
  117617. private static COMPRESSED_3D;
  117618. private static TEX_2D;
  117619. private static TEX_3D;
  117620. /**
  117621. * Gets the openGL type
  117622. */
  117623. glType: number;
  117624. /**
  117625. * Gets the openGL type size
  117626. */
  117627. glTypeSize: number;
  117628. /**
  117629. * Gets the openGL format
  117630. */
  117631. glFormat: number;
  117632. /**
  117633. * Gets the openGL internal format
  117634. */
  117635. glInternalFormat: number;
  117636. /**
  117637. * Gets the base internal format
  117638. */
  117639. glBaseInternalFormat: number;
  117640. /**
  117641. * Gets image width in pixel
  117642. */
  117643. pixelWidth: number;
  117644. /**
  117645. * Gets image height in pixel
  117646. */
  117647. pixelHeight: number;
  117648. /**
  117649. * Gets image depth in pixels
  117650. */
  117651. pixelDepth: number;
  117652. /**
  117653. * Gets the number of array elements
  117654. */
  117655. numberOfArrayElements: number;
  117656. /**
  117657. * Gets the number of faces
  117658. */
  117659. numberOfFaces: number;
  117660. /**
  117661. * Gets the number of mipmap levels
  117662. */
  117663. numberOfMipmapLevels: number;
  117664. /**
  117665. * Gets the bytes of key value data
  117666. */
  117667. bytesOfKeyValueData: number;
  117668. /**
  117669. * Gets the load type
  117670. */
  117671. loadType: number;
  117672. /**
  117673. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  117674. */
  117675. isInvalid: boolean;
  117676. /**
  117677. * Creates a new KhronosTextureContainer
  117678. * @param arrayBuffer contents of the KTX container file
  117679. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  117680. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  117681. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  117682. */
  117683. constructor(
  117684. /** contents of the KTX container file */
  117685. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  117686. /**
  117687. * Uploads KTX content to a Babylon Texture.
  117688. * It is assumed that the texture has already been created & is currently bound
  117689. * @hidden
  117690. */
  117691. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  117692. private _upload2DCompressedLevels;
  117693. }
  117694. }
  117695. declare module BABYLON {
  117696. /**
  117697. * Implementation of the KTX Texture Loader.
  117698. * @hidden
  117699. */
  117700. export class _KTXTextureLoader implements IInternalTextureLoader {
  117701. /**
  117702. * Defines wether the loader supports cascade loading the different faces.
  117703. */
  117704. readonly supportCascades: boolean;
  117705. /**
  117706. * This returns if the loader support the current file information.
  117707. * @param extension defines the file extension of the file being loaded
  117708. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117709. * @param fallback defines the fallback internal texture if any
  117710. * @param isBase64 defines whether the texture is encoded as a base64
  117711. * @param isBuffer defines whether the texture data are stored as a buffer
  117712. * @returns true if the loader can load the specified file
  117713. */
  117714. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117715. /**
  117716. * Transform the url before loading if required.
  117717. * @param rootUrl the url of the texture
  117718. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117719. * @returns the transformed texture
  117720. */
  117721. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117722. /**
  117723. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117724. * @param rootUrl the url of the texture
  117725. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117726. * @returns the fallback texture
  117727. */
  117728. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117729. /**
  117730. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117731. * @param data contains the texture data
  117732. * @param texture defines the BabylonJS internal texture
  117733. * @param createPolynomials will be true if polynomials have been requested
  117734. * @param onLoad defines the callback to trigger once the texture is ready
  117735. * @param onError defines the callback to trigger in case of error
  117736. */
  117737. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117738. /**
  117739. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117740. * @param data contains the texture data
  117741. * @param texture defines the BabylonJS internal texture
  117742. * @param callback defines the method to call once ready to upload
  117743. */
  117744. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  117745. }
  117746. }
  117747. declare module BABYLON {
  117748. /** @hidden */
  117749. export var _forceSceneHelpersToBundle: boolean;
  117750. interface Scene {
  117751. /**
  117752. * Creates a default light for the scene.
  117753. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  117754. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  117755. */
  117756. createDefaultLight(replace?: boolean): void;
  117757. /**
  117758. * Creates a default camera for the scene.
  117759. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  117760. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117761. * @param replace has default false, when true replaces the active camera in the scene
  117762. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  117763. */
  117764. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117765. /**
  117766. * Creates a default camera and a default light.
  117767. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  117768. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117769. * @param replace has the default false, when true replaces the active camera/light in the scene
  117770. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  117771. */
  117772. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117773. /**
  117774. * Creates a new sky box
  117775. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  117776. * @param environmentTexture defines the texture to use as environment texture
  117777. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  117778. * @param scale defines the overall scale of the skybox
  117779. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  117780. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  117781. * @returns a new mesh holding the sky box
  117782. */
  117783. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  117784. /**
  117785. * Creates a new environment
  117786. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  117787. * @param options defines the options you can use to configure the environment
  117788. * @returns the new EnvironmentHelper
  117789. */
  117790. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  117791. /**
  117792. * Creates a new VREXperienceHelper
  117793. * @see http://doc.babylonjs.com/how_to/webvr_helper
  117794. * @param webVROptions defines the options used to create the new VREXperienceHelper
  117795. * @returns a new VREXperienceHelper
  117796. */
  117797. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  117798. /**
  117799. * Creates a new WebXRDefaultExperience
  117800. * @see http://doc.babylonjs.com/how_to/webxr
  117801. * @param options experience options
  117802. * @returns a promise for a new WebXRDefaultExperience
  117803. */
  117804. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117805. }
  117806. }
  117807. declare module BABYLON {
  117808. /**
  117809. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  117810. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  117811. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  117812. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117813. */
  117814. export class VideoDome extends TransformNode {
  117815. /**
  117816. * Define the video source as a Monoscopic panoramic 360 video.
  117817. */
  117818. static readonly MODE_MONOSCOPIC: number;
  117819. /**
  117820. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117821. */
  117822. static readonly MODE_TOPBOTTOM: number;
  117823. /**
  117824. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117825. */
  117826. static readonly MODE_SIDEBYSIDE: number;
  117827. private _halfDome;
  117828. private _useDirectMapping;
  117829. /**
  117830. * The video texture being displayed on the sphere
  117831. */
  117832. protected _videoTexture: VideoTexture;
  117833. /**
  117834. * Gets the video texture being displayed on the sphere
  117835. */
  117836. readonly videoTexture: VideoTexture;
  117837. /**
  117838. * The skybox material
  117839. */
  117840. protected _material: BackgroundMaterial;
  117841. /**
  117842. * The surface used for the skybox
  117843. */
  117844. protected _mesh: Mesh;
  117845. /**
  117846. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  117847. */
  117848. private _halfDomeMask;
  117849. /**
  117850. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117851. * Also see the options.resolution property.
  117852. */
  117853. fovMultiplier: number;
  117854. private _videoMode;
  117855. /**
  117856. * Gets or set the current video mode for the video. It can be:
  117857. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  117858. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117859. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117860. */
  117861. videoMode: number;
  117862. /**
  117863. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  117864. *
  117865. */
  117866. /**
  117867. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  117868. */
  117869. halfDome: boolean;
  117870. /**
  117871. * Oberserver used in Stereoscopic VR Mode.
  117872. */
  117873. private _onBeforeCameraRenderObserver;
  117874. /**
  117875. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  117876. * @param name Element's name, child elements will append suffixes for their own names.
  117877. * @param urlsOrVideo defines the url(s) or the video element to use
  117878. * @param options An object containing optional or exposed sub element properties
  117879. */
  117880. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  117881. resolution?: number;
  117882. clickToPlay?: boolean;
  117883. autoPlay?: boolean;
  117884. loop?: boolean;
  117885. size?: number;
  117886. poster?: string;
  117887. faceForward?: boolean;
  117888. useDirectMapping?: boolean;
  117889. halfDomeMode?: boolean;
  117890. }, scene: Scene);
  117891. private _changeVideoMode;
  117892. /**
  117893. * Releases resources associated with this node.
  117894. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117895. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117896. */
  117897. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117898. }
  117899. }
  117900. declare module BABYLON {
  117901. /**
  117902. * This class can be used to get instrumentation data from a Babylon engine
  117903. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117904. */
  117905. export class EngineInstrumentation implements IDisposable {
  117906. /**
  117907. * Define the instrumented engine.
  117908. */
  117909. engine: Engine;
  117910. private _captureGPUFrameTime;
  117911. private _gpuFrameTimeToken;
  117912. private _gpuFrameTime;
  117913. private _captureShaderCompilationTime;
  117914. private _shaderCompilationTime;
  117915. private _onBeginFrameObserver;
  117916. private _onEndFrameObserver;
  117917. private _onBeforeShaderCompilationObserver;
  117918. private _onAfterShaderCompilationObserver;
  117919. /**
  117920. * Gets the perf counter used for GPU frame time
  117921. */
  117922. readonly gpuFrameTimeCounter: PerfCounter;
  117923. /**
  117924. * Gets the GPU frame time capture status
  117925. */
  117926. /**
  117927. * Enable or disable the GPU frame time capture
  117928. */
  117929. captureGPUFrameTime: boolean;
  117930. /**
  117931. * Gets the perf counter used for shader compilation time
  117932. */
  117933. readonly shaderCompilationTimeCounter: PerfCounter;
  117934. /**
  117935. * Gets the shader compilation time capture status
  117936. */
  117937. /**
  117938. * Enable or disable the shader compilation time capture
  117939. */
  117940. captureShaderCompilationTime: boolean;
  117941. /**
  117942. * Instantiates a new engine instrumentation.
  117943. * This class can be used to get instrumentation data from a Babylon engine
  117944. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117945. * @param engine Defines the engine to instrument
  117946. */
  117947. constructor(
  117948. /**
  117949. * Define the instrumented engine.
  117950. */
  117951. engine: Engine);
  117952. /**
  117953. * Dispose and release associated resources.
  117954. */
  117955. dispose(): void;
  117956. }
  117957. }
  117958. declare module BABYLON {
  117959. /**
  117960. * This class can be used to get instrumentation data from a Babylon engine
  117961. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117962. */
  117963. export class SceneInstrumentation implements IDisposable {
  117964. /**
  117965. * Defines the scene to instrument
  117966. */
  117967. scene: Scene;
  117968. private _captureActiveMeshesEvaluationTime;
  117969. private _activeMeshesEvaluationTime;
  117970. private _captureRenderTargetsRenderTime;
  117971. private _renderTargetsRenderTime;
  117972. private _captureFrameTime;
  117973. private _frameTime;
  117974. private _captureRenderTime;
  117975. private _renderTime;
  117976. private _captureInterFrameTime;
  117977. private _interFrameTime;
  117978. private _captureParticlesRenderTime;
  117979. private _particlesRenderTime;
  117980. private _captureSpritesRenderTime;
  117981. private _spritesRenderTime;
  117982. private _capturePhysicsTime;
  117983. private _physicsTime;
  117984. private _captureAnimationsTime;
  117985. private _animationsTime;
  117986. private _captureCameraRenderTime;
  117987. private _cameraRenderTime;
  117988. private _onBeforeActiveMeshesEvaluationObserver;
  117989. private _onAfterActiveMeshesEvaluationObserver;
  117990. private _onBeforeRenderTargetsRenderObserver;
  117991. private _onAfterRenderTargetsRenderObserver;
  117992. private _onAfterRenderObserver;
  117993. private _onBeforeDrawPhaseObserver;
  117994. private _onAfterDrawPhaseObserver;
  117995. private _onBeforeAnimationsObserver;
  117996. private _onBeforeParticlesRenderingObserver;
  117997. private _onAfterParticlesRenderingObserver;
  117998. private _onBeforeSpritesRenderingObserver;
  117999. private _onAfterSpritesRenderingObserver;
  118000. private _onBeforePhysicsObserver;
  118001. private _onAfterPhysicsObserver;
  118002. private _onAfterAnimationsObserver;
  118003. private _onBeforeCameraRenderObserver;
  118004. private _onAfterCameraRenderObserver;
  118005. /**
  118006. * Gets the perf counter used for active meshes evaluation time
  118007. */
  118008. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  118009. /**
  118010. * Gets the active meshes evaluation time capture status
  118011. */
  118012. /**
  118013. * Enable or disable the active meshes evaluation time capture
  118014. */
  118015. captureActiveMeshesEvaluationTime: boolean;
  118016. /**
  118017. * Gets the perf counter used for render targets render time
  118018. */
  118019. readonly renderTargetsRenderTimeCounter: PerfCounter;
  118020. /**
  118021. * Gets the render targets render time capture status
  118022. */
  118023. /**
  118024. * Enable or disable the render targets render time capture
  118025. */
  118026. captureRenderTargetsRenderTime: boolean;
  118027. /**
  118028. * Gets the perf counter used for particles render time
  118029. */
  118030. readonly particlesRenderTimeCounter: PerfCounter;
  118031. /**
  118032. * Gets the particles render time capture status
  118033. */
  118034. /**
  118035. * Enable or disable the particles render time capture
  118036. */
  118037. captureParticlesRenderTime: boolean;
  118038. /**
  118039. * Gets the perf counter used for sprites render time
  118040. */
  118041. readonly spritesRenderTimeCounter: PerfCounter;
  118042. /**
  118043. * Gets the sprites render time capture status
  118044. */
  118045. /**
  118046. * Enable or disable the sprites render time capture
  118047. */
  118048. captureSpritesRenderTime: boolean;
  118049. /**
  118050. * Gets the perf counter used for physics time
  118051. */
  118052. readonly physicsTimeCounter: PerfCounter;
  118053. /**
  118054. * Gets the physics time capture status
  118055. */
  118056. /**
  118057. * Enable or disable the physics time capture
  118058. */
  118059. capturePhysicsTime: boolean;
  118060. /**
  118061. * Gets the perf counter used for animations time
  118062. */
  118063. readonly animationsTimeCounter: PerfCounter;
  118064. /**
  118065. * Gets the animations time capture status
  118066. */
  118067. /**
  118068. * Enable or disable the animations time capture
  118069. */
  118070. captureAnimationsTime: boolean;
  118071. /**
  118072. * Gets the perf counter used for frame time capture
  118073. */
  118074. readonly frameTimeCounter: PerfCounter;
  118075. /**
  118076. * Gets the frame time capture status
  118077. */
  118078. /**
  118079. * Enable or disable the frame time capture
  118080. */
  118081. captureFrameTime: boolean;
  118082. /**
  118083. * Gets the perf counter used for inter-frames time capture
  118084. */
  118085. readonly interFrameTimeCounter: PerfCounter;
  118086. /**
  118087. * Gets the inter-frames time capture status
  118088. */
  118089. /**
  118090. * Enable or disable the inter-frames time capture
  118091. */
  118092. captureInterFrameTime: boolean;
  118093. /**
  118094. * Gets the perf counter used for render time capture
  118095. */
  118096. readonly renderTimeCounter: PerfCounter;
  118097. /**
  118098. * Gets the render time capture status
  118099. */
  118100. /**
  118101. * Enable or disable the render time capture
  118102. */
  118103. captureRenderTime: boolean;
  118104. /**
  118105. * Gets the perf counter used for camera render time capture
  118106. */
  118107. readonly cameraRenderTimeCounter: PerfCounter;
  118108. /**
  118109. * Gets the camera render time capture status
  118110. */
  118111. /**
  118112. * Enable or disable the camera render time capture
  118113. */
  118114. captureCameraRenderTime: boolean;
  118115. /**
  118116. * Gets the perf counter used for draw calls
  118117. */
  118118. readonly drawCallsCounter: PerfCounter;
  118119. /**
  118120. * Instantiates a new scene instrumentation.
  118121. * This class can be used to get instrumentation data from a Babylon engine
  118122. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118123. * @param scene Defines the scene to instrument
  118124. */
  118125. constructor(
  118126. /**
  118127. * Defines the scene to instrument
  118128. */
  118129. scene: Scene);
  118130. /**
  118131. * Dispose and release associated resources.
  118132. */
  118133. dispose(): void;
  118134. }
  118135. }
  118136. declare module BABYLON {
  118137. /** @hidden */
  118138. export var glowMapGenerationPixelShader: {
  118139. name: string;
  118140. shader: string;
  118141. };
  118142. }
  118143. declare module BABYLON {
  118144. /** @hidden */
  118145. export var glowMapGenerationVertexShader: {
  118146. name: string;
  118147. shader: string;
  118148. };
  118149. }
  118150. declare module BABYLON {
  118151. /**
  118152. * Effect layer options. This helps customizing the behaviour
  118153. * of the effect layer.
  118154. */
  118155. export interface IEffectLayerOptions {
  118156. /**
  118157. * Multiplication factor apply to the canvas size to compute the render target size
  118158. * used to generated the objects (the smaller the faster).
  118159. */
  118160. mainTextureRatio: number;
  118161. /**
  118162. * Enforces a fixed size texture to ensure effect stability across devices.
  118163. */
  118164. mainTextureFixedSize?: number;
  118165. /**
  118166. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  118167. */
  118168. alphaBlendingMode: number;
  118169. /**
  118170. * The camera attached to the layer.
  118171. */
  118172. camera: Nullable<Camera>;
  118173. /**
  118174. * The rendering group to draw the layer in.
  118175. */
  118176. renderingGroupId: number;
  118177. }
  118178. /**
  118179. * The effect layer Helps adding post process effect blended with the main pass.
  118180. *
  118181. * This can be for instance use to generate glow or higlight effects on the scene.
  118182. *
  118183. * The effect layer class can not be used directly and is intented to inherited from to be
  118184. * customized per effects.
  118185. */
  118186. export abstract class EffectLayer {
  118187. private _vertexBuffers;
  118188. private _indexBuffer;
  118189. private _cachedDefines;
  118190. private _effectLayerMapGenerationEffect;
  118191. private _effectLayerOptions;
  118192. private _mergeEffect;
  118193. protected _scene: Scene;
  118194. protected _engine: Engine;
  118195. protected _maxSize: number;
  118196. protected _mainTextureDesiredSize: ISize;
  118197. protected _mainTexture: RenderTargetTexture;
  118198. protected _shouldRender: boolean;
  118199. protected _postProcesses: PostProcess[];
  118200. protected _textures: BaseTexture[];
  118201. protected _emissiveTextureAndColor: {
  118202. texture: Nullable<BaseTexture>;
  118203. color: Color4;
  118204. };
  118205. /**
  118206. * The name of the layer
  118207. */
  118208. name: string;
  118209. /**
  118210. * The clear color of the texture used to generate the glow map.
  118211. */
  118212. neutralColor: Color4;
  118213. /**
  118214. * Specifies wether the highlight layer is enabled or not.
  118215. */
  118216. isEnabled: boolean;
  118217. /**
  118218. * Gets the camera attached to the layer.
  118219. */
  118220. readonly camera: Nullable<Camera>;
  118221. /**
  118222. * Gets the rendering group id the layer should render in.
  118223. */
  118224. renderingGroupId: number;
  118225. /**
  118226. * An event triggered when the effect layer has been disposed.
  118227. */
  118228. onDisposeObservable: Observable<EffectLayer>;
  118229. /**
  118230. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  118231. */
  118232. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  118233. /**
  118234. * An event triggered when the generated texture is being merged in the scene.
  118235. */
  118236. onBeforeComposeObservable: Observable<EffectLayer>;
  118237. /**
  118238. * An event triggered when the mesh is rendered into the effect render target.
  118239. */
  118240. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  118241. /**
  118242. * An event triggered after the mesh has been rendered into the effect render target.
  118243. */
  118244. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  118245. /**
  118246. * An event triggered when the generated texture has been merged in the scene.
  118247. */
  118248. onAfterComposeObservable: Observable<EffectLayer>;
  118249. /**
  118250. * An event triggered when the efffect layer changes its size.
  118251. */
  118252. onSizeChangedObservable: Observable<EffectLayer>;
  118253. /** @hidden */
  118254. static _SceneComponentInitialization: (scene: Scene) => void;
  118255. /**
  118256. * Instantiates a new effect Layer and references it in the scene.
  118257. * @param name The name of the layer
  118258. * @param scene The scene to use the layer in
  118259. */
  118260. constructor(
  118261. /** The Friendly of the effect in the scene */
  118262. name: string, scene: Scene);
  118263. /**
  118264. * Get the effect name of the layer.
  118265. * @return The effect name
  118266. */
  118267. abstract getEffectName(): string;
  118268. /**
  118269. * Checks for the readiness of the element composing the layer.
  118270. * @param subMesh the mesh to check for
  118271. * @param useInstances specify wether or not to use instances to render the mesh
  118272. * @return true if ready otherwise, false
  118273. */
  118274. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118275. /**
  118276. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118277. * @returns true if the effect requires stencil during the main canvas render pass.
  118278. */
  118279. abstract needStencil(): boolean;
  118280. /**
  118281. * Create the merge effect. This is the shader use to blit the information back
  118282. * to the main canvas at the end of the scene rendering.
  118283. * @returns The effect containing the shader used to merge the effect on the main canvas
  118284. */
  118285. protected abstract _createMergeEffect(): Effect;
  118286. /**
  118287. * Creates the render target textures and post processes used in the effect layer.
  118288. */
  118289. protected abstract _createTextureAndPostProcesses(): void;
  118290. /**
  118291. * Implementation specific of rendering the generating effect on the main canvas.
  118292. * @param effect The effect used to render through
  118293. */
  118294. protected abstract _internalRender(effect: Effect): void;
  118295. /**
  118296. * Sets the required values for both the emissive texture and and the main color.
  118297. */
  118298. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118299. /**
  118300. * Free any resources and references associated to a mesh.
  118301. * Internal use
  118302. * @param mesh The mesh to free.
  118303. */
  118304. abstract _disposeMesh(mesh: Mesh): void;
  118305. /**
  118306. * Serializes this layer (Glow or Highlight for example)
  118307. * @returns a serialized layer object
  118308. */
  118309. abstract serialize?(): any;
  118310. /**
  118311. * Initializes the effect layer with the required options.
  118312. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  118313. */
  118314. protected _init(options: Partial<IEffectLayerOptions>): void;
  118315. /**
  118316. * Generates the index buffer of the full screen quad blending to the main canvas.
  118317. */
  118318. private _generateIndexBuffer;
  118319. /**
  118320. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  118321. */
  118322. private _generateVertexBuffer;
  118323. /**
  118324. * Sets the main texture desired size which is the closest power of two
  118325. * of the engine canvas size.
  118326. */
  118327. private _setMainTextureSize;
  118328. /**
  118329. * Creates the main texture for the effect layer.
  118330. */
  118331. protected _createMainTexture(): void;
  118332. /**
  118333. * Adds specific effects defines.
  118334. * @param defines The defines to add specifics to.
  118335. */
  118336. protected _addCustomEffectDefines(defines: string[]): void;
  118337. /**
  118338. * Checks for the readiness of the element composing the layer.
  118339. * @param subMesh the mesh to check for
  118340. * @param useInstances specify wether or not to use instances to render the mesh
  118341. * @param emissiveTexture the associated emissive texture used to generate the glow
  118342. * @return true if ready otherwise, false
  118343. */
  118344. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  118345. /**
  118346. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  118347. */
  118348. render(): void;
  118349. /**
  118350. * Determine if a given mesh will be used in the current effect.
  118351. * @param mesh mesh to test
  118352. * @returns true if the mesh will be used
  118353. */
  118354. hasMesh(mesh: AbstractMesh): boolean;
  118355. /**
  118356. * Returns true if the layer contains information to display, otherwise false.
  118357. * @returns true if the glow layer should be rendered
  118358. */
  118359. shouldRender(): boolean;
  118360. /**
  118361. * Returns true if the mesh should render, otherwise false.
  118362. * @param mesh The mesh to render
  118363. * @returns true if it should render otherwise false
  118364. */
  118365. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  118366. /**
  118367. * Returns true if the mesh can be rendered, otherwise false.
  118368. * @param mesh The mesh to render
  118369. * @param material The material used on the mesh
  118370. * @returns true if it can be rendered otherwise false
  118371. */
  118372. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118373. /**
  118374. * Returns true if the mesh should render, otherwise false.
  118375. * @param mesh The mesh to render
  118376. * @returns true if it should render otherwise false
  118377. */
  118378. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  118379. /**
  118380. * Renders the submesh passed in parameter to the generation map.
  118381. */
  118382. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  118383. /**
  118384. * Defines wether the current material of the mesh should be use to render the effect.
  118385. * @param mesh defines the current mesh to render
  118386. */
  118387. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118388. /**
  118389. * Rebuild the required buffers.
  118390. * @hidden Internal use only.
  118391. */
  118392. _rebuild(): void;
  118393. /**
  118394. * Dispose only the render target textures and post process.
  118395. */
  118396. private _disposeTextureAndPostProcesses;
  118397. /**
  118398. * Dispose the highlight layer and free resources.
  118399. */
  118400. dispose(): void;
  118401. /**
  118402. * Gets the class name of the effect layer
  118403. * @returns the string with the class name of the effect layer
  118404. */
  118405. getClassName(): string;
  118406. /**
  118407. * Creates an effect layer from parsed effect layer data
  118408. * @param parsedEffectLayer defines effect layer data
  118409. * @param scene defines the current scene
  118410. * @param rootUrl defines the root URL containing the effect layer information
  118411. * @returns a parsed effect Layer
  118412. */
  118413. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  118414. }
  118415. }
  118416. declare module BABYLON {
  118417. interface AbstractScene {
  118418. /**
  118419. * The list of effect layers (highlights/glow) added to the scene
  118420. * @see http://doc.babylonjs.com/how_to/highlight_layer
  118421. * @see http://doc.babylonjs.com/how_to/glow_layer
  118422. */
  118423. effectLayers: Array<EffectLayer>;
  118424. /**
  118425. * Removes the given effect layer from this scene.
  118426. * @param toRemove defines the effect layer to remove
  118427. * @returns the index of the removed effect layer
  118428. */
  118429. removeEffectLayer(toRemove: EffectLayer): number;
  118430. /**
  118431. * Adds the given effect layer to this scene
  118432. * @param newEffectLayer defines the effect layer to add
  118433. */
  118434. addEffectLayer(newEffectLayer: EffectLayer): void;
  118435. }
  118436. /**
  118437. * Defines the layer scene component responsible to manage any effect layers
  118438. * in a given scene.
  118439. */
  118440. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  118441. /**
  118442. * The component name helpfull to identify the component in the list of scene components.
  118443. */
  118444. readonly name: string;
  118445. /**
  118446. * The scene the component belongs to.
  118447. */
  118448. scene: Scene;
  118449. private _engine;
  118450. private _renderEffects;
  118451. private _needStencil;
  118452. private _previousStencilState;
  118453. /**
  118454. * Creates a new instance of the component for the given scene
  118455. * @param scene Defines the scene to register the component in
  118456. */
  118457. constructor(scene: Scene);
  118458. /**
  118459. * Registers the component in a given scene
  118460. */
  118461. register(): void;
  118462. /**
  118463. * Rebuilds the elements related to this component in case of
  118464. * context lost for instance.
  118465. */
  118466. rebuild(): void;
  118467. /**
  118468. * Serializes the component data to the specified json object
  118469. * @param serializationObject The object to serialize to
  118470. */
  118471. serialize(serializationObject: any): void;
  118472. /**
  118473. * Adds all the elements from the container to the scene
  118474. * @param container the container holding the elements
  118475. */
  118476. addFromContainer(container: AbstractScene): void;
  118477. /**
  118478. * Removes all the elements in the container from the scene
  118479. * @param container contains the elements to remove
  118480. * @param dispose if the removed element should be disposed (default: false)
  118481. */
  118482. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118483. /**
  118484. * Disposes the component and the associated ressources.
  118485. */
  118486. dispose(): void;
  118487. private _isReadyForMesh;
  118488. private _renderMainTexture;
  118489. private _setStencil;
  118490. private _setStencilBack;
  118491. private _draw;
  118492. private _drawCamera;
  118493. private _drawRenderingGroup;
  118494. }
  118495. }
  118496. declare module BABYLON {
  118497. /** @hidden */
  118498. export var glowMapMergePixelShader: {
  118499. name: string;
  118500. shader: string;
  118501. };
  118502. }
  118503. declare module BABYLON {
  118504. /** @hidden */
  118505. export var glowMapMergeVertexShader: {
  118506. name: string;
  118507. shader: string;
  118508. };
  118509. }
  118510. declare module BABYLON {
  118511. interface AbstractScene {
  118512. /**
  118513. * Return a the first highlight layer of the scene with a given name.
  118514. * @param name The name of the highlight layer to look for.
  118515. * @return The highlight layer if found otherwise null.
  118516. */
  118517. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  118518. }
  118519. /**
  118520. * Glow layer options. This helps customizing the behaviour
  118521. * of the glow layer.
  118522. */
  118523. export interface IGlowLayerOptions {
  118524. /**
  118525. * Multiplication factor apply to the canvas size to compute the render target size
  118526. * used to generated the glowing objects (the smaller the faster).
  118527. */
  118528. mainTextureRatio: number;
  118529. /**
  118530. * Enforces a fixed size texture to ensure resize independant blur.
  118531. */
  118532. mainTextureFixedSize?: number;
  118533. /**
  118534. * How big is the kernel of the blur texture.
  118535. */
  118536. blurKernelSize: number;
  118537. /**
  118538. * The camera attached to the layer.
  118539. */
  118540. camera: Nullable<Camera>;
  118541. /**
  118542. * Enable MSAA by chosing the number of samples.
  118543. */
  118544. mainTextureSamples?: number;
  118545. /**
  118546. * The rendering group to draw the layer in.
  118547. */
  118548. renderingGroupId: number;
  118549. }
  118550. /**
  118551. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  118552. *
  118553. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  118554. *
  118555. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  118556. */
  118557. export class GlowLayer extends EffectLayer {
  118558. /**
  118559. * Effect Name of the layer.
  118560. */
  118561. static readonly EffectName: string;
  118562. /**
  118563. * The default blur kernel size used for the glow.
  118564. */
  118565. static DefaultBlurKernelSize: number;
  118566. /**
  118567. * The default texture size ratio used for the glow.
  118568. */
  118569. static DefaultTextureRatio: number;
  118570. /**
  118571. * Sets the kernel size of the blur.
  118572. */
  118573. /**
  118574. * Gets the kernel size of the blur.
  118575. */
  118576. blurKernelSize: number;
  118577. /**
  118578. * Sets the glow intensity.
  118579. */
  118580. /**
  118581. * Gets the glow intensity.
  118582. */
  118583. intensity: number;
  118584. private _options;
  118585. private _intensity;
  118586. private _horizontalBlurPostprocess1;
  118587. private _verticalBlurPostprocess1;
  118588. private _horizontalBlurPostprocess2;
  118589. private _verticalBlurPostprocess2;
  118590. private _blurTexture1;
  118591. private _blurTexture2;
  118592. private _postProcesses1;
  118593. private _postProcesses2;
  118594. private _includedOnlyMeshes;
  118595. private _excludedMeshes;
  118596. private _meshesUsingTheirOwnMaterials;
  118597. /**
  118598. * Callback used to let the user override the color selection on a per mesh basis
  118599. */
  118600. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  118601. /**
  118602. * Callback used to let the user override the texture selection on a per mesh basis
  118603. */
  118604. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  118605. /**
  118606. * Instantiates a new glow Layer and references it to the scene.
  118607. * @param name The name of the layer
  118608. * @param scene The scene to use the layer in
  118609. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  118610. */
  118611. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  118612. /**
  118613. * Get the effect name of the layer.
  118614. * @return The effect name
  118615. */
  118616. getEffectName(): string;
  118617. /**
  118618. * Create the merge effect. This is the shader use to blit the information back
  118619. * to the main canvas at the end of the scene rendering.
  118620. */
  118621. protected _createMergeEffect(): Effect;
  118622. /**
  118623. * Creates the render target textures and post processes used in the glow layer.
  118624. */
  118625. protected _createTextureAndPostProcesses(): void;
  118626. /**
  118627. * Checks for the readiness of the element composing the layer.
  118628. * @param subMesh the mesh to check for
  118629. * @param useInstances specify wether or not to use instances to render the mesh
  118630. * @param emissiveTexture the associated emissive texture used to generate the glow
  118631. * @return true if ready otherwise, false
  118632. */
  118633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118634. /**
  118635. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118636. */
  118637. needStencil(): boolean;
  118638. /**
  118639. * Returns true if the mesh can be rendered, otherwise false.
  118640. * @param mesh The mesh to render
  118641. * @param material The material used on the mesh
  118642. * @returns true if it can be rendered otherwise false
  118643. */
  118644. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118645. /**
  118646. * Implementation specific of rendering the generating effect on the main canvas.
  118647. * @param effect The effect used to render through
  118648. */
  118649. protected _internalRender(effect: Effect): void;
  118650. /**
  118651. * Sets the required values for both the emissive texture and and the main color.
  118652. */
  118653. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118654. /**
  118655. * Returns true if the mesh should render, otherwise false.
  118656. * @param mesh The mesh to render
  118657. * @returns true if it should render otherwise false
  118658. */
  118659. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118660. /**
  118661. * Adds specific effects defines.
  118662. * @param defines The defines to add specifics to.
  118663. */
  118664. protected _addCustomEffectDefines(defines: string[]): void;
  118665. /**
  118666. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  118667. * @param mesh The mesh to exclude from the glow layer
  118668. */
  118669. addExcludedMesh(mesh: Mesh): void;
  118670. /**
  118671. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  118672. * @param mesh The mesh to remove
  118673. */
  118674. removeExcludedMesh(mesh: Mesh): void;
  118675. /**
  118676. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  118677. * @param mesh The mesh to include in the glow layer
  118678. */
  118679. addIncludedOnlyMesh(mesh: Mesh): void;
  118680. /**
  118681. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  118682. * @param mesh The mesh to remove
  118683. */
  118684. removeIncludedOnlyMesh(mesh: Mesh): void;
  118685. /**
  118686. * Determine if a given mesh will be used in the glow layer
  118687. * @param mesh The mesh to test
  118688. * @returns true if the mesh will be highlighted by the current glow layer
  118689. */
  118690. hasMesh(mesh: AbstractMesh): boolean;
  118691. /**
  118692. * Defines wether the current material of the mesh should be use to render the effect.
  118693. * @param mesh defines the current mesh to render
  118694. */
  118695. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118696. /**
  118697. * Add a mesh to be rendered through its own material and not with emissive only.
  118698. * @param mesh The mesh for which we need to use its material
  118699. */
  118700. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  118701. /**
  118702. * Remove a mesh from being rendered through its own material and not with emissive only.
  118703. * @param mesh The mesh for which we need to not use its material
  118704. */
  118705. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  118706. /**
  118707. * Free any resources and references associated to a mesh.
  118708. * Internal use
  118709. * @param mesh The mesh to free.
  118710. * @hidden
  118711. */
  118712. _disposeMesh(mesh: Mesh): void;
  118713. /**
  118714. * Gets the class name of the effect layer
  118715. * @returns the string with the class name of the effect layer
  118716. */
  118717. getClassName(): string;
  118718. /**
  118719. * Serializes this glow layer
  118720. * @returns a serialized glow layer object
  118721. */
  118722. serialize(): any;
  118723. /**
  118724. * Creates a Glow Layer from parsed glow layer data
  118725. * @param parsedGlowLayer defines glow layer data
  118726. * @param scene defines the current scene
  118727. * @param rootUrl defines the root URL containing the glow layer information
  118728. * @returns a parsed Glow Layer
  118729. */
  118730. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  118731. }
  118732. }
  118733. declare module BABYLON {
  118734. /** @hidden */
  118735. export var glowBlurPostProcessPixelShader: {
  118736. name: string;
  118737. shader: string;
  118738. };
  118739. }
  118740. declare module BABYLON {
  118741. interface AbstractScene {
  118742. /**
  118743. * Return a the first highlight layer of the scene with a given name.
  118744. * @param name The name of the highlight layer to look for.
  118745. * @return The highlight layer if found otherwise null.
  118746. */
  118747. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  118748. }
  118749. /**
  118750. * Highlight layer options. This helps customizing the behaviour
  118751. * of the highlight layer.
  118752. */
  118753. export interface IHighlightLayerOptions {
  118754. /**
  118755. * Multiplication factor apply to the canvas size to compute the render target size
  118756. * used to generated the glowing objects (the smaller the faster).
  118757. */
  118758. mainTextureRatio: number;
  118759. /**
  118760. * Enforces a fixed size texture to ensure resize independant blur.
  118761. */
  118762. mainTextureFixedSize?: number;
  118763. /**
  118764. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  118765. * of the picture to blur (the smaller the faster).
  118766. */
  118767. blurTextureSizeRatio: number;
  118768. /**
  118769. * How big in texel of the blur texture is the vertical blur.
  118770. */
  118771. blurVerticalSize: number;
  118772. /**
  118773. * How big in texel of the blur texture is the horizontal blur.
  118774. */
  118775. blurHorizontalSize: number;
  118776. /**
  118777. * Alpha blending mode used to apply the blur. Default is combine.
  118778. */
  118779. alphaBlendingMode: number;
  118780. /**
  118781. * The camera attached to the layer.
  118782. */
  118783. camera: Nullable<Camera>;
  118784. /**
  118785. * Should we display highlight as a solid stroke?
  118786. */
  118787. isStroke?: boolean;
  118788. /**
  118789. * The rendering group to draw the layer in.
  118790. */
  118791. renderingGroupId: number;
  118792. }
  118793. /**
  118794. * The highlight layer Helps adding a glow effect around a mesh.
  118795. *
  118796. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  118797. * glowy meshes to your scene.
  118798. *
  118799. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  118800. */
  118801. export class HighlightLayer extends EffectLayer {
  118802. name: string;
  118803. /**
  118804. * Effect Name of the highlight layer.
  118805. */
  118806. static readonly EffectName: string;
  118807. /**
  118808. * The neutral color used during the preparation of the glow effect.
  118809. * This is black by default as the blend operation is a blend operation.
  118810. */
  118811. static NeutralColor: Color4;
  118812. /**
  118813. * Stencil value used for glowing meshes.
  118814. */
  118815. static GlowingMeshStencilReference: number;
  118816. /**
  118817. * Stencil value used for the other meshes in the scene.
  118818. */
  118819. static NormalMeshStencilReference: number;
  118820. /**
  118821. * Specifies whether or not the inner glow is ACTIVE in the layer.
  118822. */
  118823. innerGlow: boolean;
  118824. /**
  118825. * Specifies whether or not the outer glow is ACTIVE in the layer.
  118826. */
  118827. outerGlow: boolean;
  118828. /**
  118829. * Specifies the horizontal size of the blur.
  118830. */
  118831. /**
  118832. * Gets the horizontal size of the blur.
  118833. */
  118834. blurHorizontalSize: number;
  118835. /**
  118836. * Specifies the vertical size of the blur.
  118837. */
  118838. /**
  118839. * Gets the vertical size of the blur.
  118840. */
  118841. blurVerticalSize: number;
  118842. /**
  118843. * An event triggered when the highlight layer is being blurred.
  118844. */
  118845. onBeforeBlurObservable: Observable<HighlightLayer>;
  118846. /**
  118847. * An event triggered when the highlight layer has been blurred.
  118848. */
  118849. onAfterBlurObservable: Observable<HighlightLayer>;
  118850. private _instanceGlowingMeshStencilReference;
  118851. private _options;
  118852. private _downSamplePostprocess;
  118853. private _horizontalBlurPostprocess;
  118854. private _verticalBlurPostprocess;
  118855. private _blurTexture;
  118856. private _meshes;
  118857. private _excludedMeshes;
  118858. /**
  118859. * Instantiates a new highlight Layer and references it to the scene..
  118860. * @param name The name of the layer
  118861. * @param scene The scene to use the layer in
  118862. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  118863. */
  118864. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  118865. /**
  118866. * Get the effect name of the layer.
  118867. * @return The effect name
  118868. */
  118869. getEffectName(): string;
  118870. /**
  118871. * Create the merge effect. This is the shader use to blit the information back
  118872. * to the main canvas at the end of the scene rendering.
  118873. */
  118874. protected _createMergeEffect(): Effect;
  118875. /**
  118876. * Creates the render target textures and post processes used in the highlight layer.
  118877. */
  118878. protected _createTextureAndPostProcesses(): void;
  118879. /**
  118880. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118881. */
  118882. needStencil(): boolean;
  118883. /**
  118884. * Checks for the readiness of the element composing the layer.
  118885. * @param subMesh the mesh to check for
  118886. * @param useInstances specify wether or not to use instances to render the mesh
  118887. * @param emissiveTexture the associated emissive texture used to generate the glow
  118888. * @return true if ready otherwise, false
  118889. */
  118890. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118891. /**
  118892. * Implementation specific of rendering the generating effect on the main canvas.
  118893. * @param effect The effect used to render through
  118894. */
  118895. protected _internalRender(effect: Effect): void;
  118896. /**
  118897. * Returns true if the layer contains information to display, otherwise false.
  118898. */
  118899. shouldRender(): boolean;
  118900. /**
  118901. * Returns true if the mesh should render, otherwise false.
  118902. * @param mesh The mesh to render
  118903. * @returns true if it should render otherwise false
  118904. */
  118905. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118906. /**
  118907. * Sets the required values for both the emissive texture and and the main color.
  118908. */
  118909. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118910. /**
  118911. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  118912. * @param mesh The mesh to exclude from the highlight layer
  118913. */
  118914. addExcludedMesh(mesh: Mesh): void;
  118915. /**
  118916. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  118917. * @param mesh The mesh to highlight
  118918. */
  118919. removeExcludedMesh(mesh: Mesh): void;
  118920. /**
  118921. * Determine if a given mesh will be highlighted by the current HighlightLayer
  118922. * @param mesh mesh to test
  118923. * @returns true if the mesh will be highlighted by the current HighlightLayer
  118924. */
  118925. hasMesh(mesh: AbstractMesh): boolean;
  118926. /**
  118927. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  118928. * @param mesh The mesh to highlight
  118929. * @param color The color of the highlight
  118930. * @param glowEmissiveOnly Extract the glow from the emissive texture
  118931. */
  118932. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  118933. /**
  118934. * Remove a mesh from the highlight layer in order to make it stop glowing.
  118935. * @param mesh The mesh to highlight
  118936. */
  118937. removeMesh(mesh: Mesh): void;
  118938. /**
  118939. * Force the stencil to the normal expected value for none glowing parts
  118940. */
  118941. private _defaultStencilReference;
  118942. /**
  118943. * Free any resources and references associated to a mesh.
  118944. * Internal use
  118945. * @param mesh The mesh to free.
  118946. * @hidden
  118947. */
  118948. _disposeMesh(mesh: Mesh): void;
  118949. /**
  118950. * Dispose the highlight layer and free resources.
  118951. */
  118952. dispose(): void;
  118953. /**
  118954. * Gets the class name of the effect layer
  118955. * @returns the string with the class name of the effect layer
  118956. */
  118957. getClassName(): string;
  118958. /**
  118959. * Serializes this Highlight layer
  118960. * @returns a serialized Highlight layer object
  118961. */
  118962. serialize(): any;
  118963. /**
  118964. * Creates a Highlight layer from parsed Highlight layer data
  118965. * @param parsedHightlightLayer defines the Highlight layer data
  118966. * @param scene defines the current scene
  118967. * @param rootUrl defines the root URL containing the Highlight layer information
  118968. * @returns a parsed Highlight layer
  118969. */
  118970. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  118971. }
  118972. }
  118973. declare module BABYLON {
  118974. interface AbstractScene {
  118975. /**
  118976. * The list of layers (background and foreground) of the scene
  118977. */
  118978. layers: Array<Layer>;
  118979. }
  118980. /**
  118981. * Defines the layer scene component responsible to manage any layers
  118982. * in a given scene.
  118983. */
  118984. export class LayerSceneComponent implements ISceneComponent {
  118985. /**
  118986. * The component name helpfull to identify the component in the list of scene components.
  118987. */
  118988. readonly name: string;
  118989. /**
  118990. * The scene the component belongs to.
  118991. */
  118992. scene: Scene;
  118993. private _engine;
  118994. /**
  118995. * Creates a new instance of the component for the given scene
  118996. * @param scene Defines the scene to register the component in
  118997. */
  118998. constructor(scene: Scene);
  118999. /**
  119000. * Registers the component in a given scene
  119001. */
  119002. register(): void;
  119003. /**
  119004. * Rebuilds the elements related to this component in case of
  119005. * context lost for instance.
  119006. */
  119007. rebuild(): void;
  119008. /**
  119009. * Disposes the component and the associated ressources.
  119010. */
  119011. dispose(): void;
  119012. private _draw;
  119013. private _drawCameraPredicate;
  119014. private _drawCameraBackground;
  119015. private _drawCameraForeground;
  119016. private _drawRenderTargetPredicate;
  119017. private _drawRenderTargetBackground;
  119018. private _drawRenderTargetForeground;
  119019. /**
  119020. * Adds all the elements from the container to the scene
  119021. * @param container the container holding the elements
  119022. */
  119023. addFromContainer(container: AbstractScene): void;
  119024. /**
  119025. * Removes all the elements in the container from the scene
  119026. * @param container contains the elements to remove
  119027. * @param dispose if the removed element should be disposed (default: false)
  119028. */
  119029. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119030. }
  119031. }
  119032. declare module BABYLON {
  119033. /** @hidden */
  119034. export var layerPixelShader: {
  119035. name: string;
  119036. shader: string;
  119037. };
  119038. }
  119039. declare module BABYLON {
  119040. /** @hidden */
  119041. export var layerVertexShader: {
  119042. name: string;
  119043. shader: string;
  119044. };
  119045. }
  119046. declare module BABYLON {
  119047. /**
  119048. * This represents a full screen 2d layer.
  119049. * This can be useful to display a picture in the background of your scene for instance.
  119050. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119051. */
  119052. export class Layer {
  119053. /**
  119054. * Define the name of the layer.
  119055. */
  119056. name: string;
  119057. /**
  119058. * Define the texture the layer should display.
  119059. */
  119060. texture: Nullable<Texture>;
  119061. /**
  119062. * Is the layer in background or foreground.
  119063. */
  119064. isBackground: boolean;
  119065. /**
  119066. * Define the color of the layer (instead of texture).
  119067. */
  119068. color: Color4;
  119069. /**
  119070. * Define the scale of the layer in order to zoom in out of the texture.
  119071. */
  119072. scale: Vector2;
  119073. /**
  119074. * Define an offset for the layer in order to shift the texture.
  119075. */
  119076. offset: Vector2;
  119077. /**
  119078. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  119079. */
  119080. alphaBlendingMode: number;
  119081. /**
  119082. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  119083. * Alpha test will not mix with the background color in case of transparency.
  119084. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  119085. */
  119086. alphaTest: boolean;
  119087. /**
  119088. * Define a mask to restrict the layer to only some of the scene cameras.
  119089. */
  119090. layerMask: number;
  119091. /**
  119092. * Define the list of render target the layer is visible into.
  119093. */
  119094. renderTargetTextures: RenderTargetTexture[];
  119095. /**
  119096. * Define if the layer is only used in renderTarget or if it also
  119097. * renders in the main frame buffer of the canvas.
  119098. */
  119099. renderOnlyInRenderTargetTextures: boolean;
  119100. private _scene;
  119101. private _vertexBuffers;
  119102. private _indexBuffer;
  119103. private _effect;
  119104. private _alphaTestEffect;
  119105. /**
  119106. * An event triggered when the layer is disposed.
  119107. */
  119108. onDisposeObservable: Observable<Layer>;
  119109. private _onDisposeObserver;
  119110. /**
  119111. * Back compatibility with callback before the onDisposeObservable existed.
  119112. * The set callback will be triggered when the layer has been disposed.
  119113. */
  119114. onDispose: () => void;
  119115. /**
  119116. * An event triggered before rendering the scene
  119117. */
  119118. onBeforeRenderObservable: Observable<Layer>;
  119119. private _onBeforeRenderObserver;
  119120. /**
  119121. * Back compatibility with callback before the onBeforeRenderObservable existed.
  119122. * The set callback will be triggered just before rendering the layer.
  119123. */
  119124. onBeforeRender: () => void;
  119125. /**
  119126. * An event triggered after rendering the scene
  119127. */
  119128. onAfterRenderObservable: Observable<Layer>;
  119129. private _onAfterRenderObserver;
  119130. /**
  119131. * Back compatibility with callback before the onAfterRenderObservable existed.
  119132. * The set callback will be triggered just after rendering the layer.
  119133. */
  119134. onAfterRender: () => void;
  119135. /**
  119136. * Instantiates a new layer.
  119137. * This represents a full screen 2d layer.
  119138. * This can be useful to display a picture in the background of your scene for instance.
  119139. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119140. * @param name Define the name of the layer in the scene
  119141. * @param imgUrl Define the url of the texture to display in the layer
  119142. * @param scene Define the scene the layer belongs to
  119143. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  119144. * @param color Defines a color for the layer
  119145. */
  119146. constructor(
  119147. /**
  119148. * Define the name of the layer.
  119149. */
  119150. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  119151. private _createIndexBuffer;
  119152. /** @hidden */
  119153. _rebuild(): void;
  119154. /**
  119155. * Renders the layer in the scene.
  119156. */
  119157. render(): void;
  119158. /**
  119159. * Disposes and releases the associated ressources.
  119160. */
  119161. dispose(): void;
  119162. }
  119163. }
  119164. declare module BABYLON {
  119165. /** @hidden */
  119166. export var lensFlarePixelShader: {
  119167. name: string;
  119168. shader: string;
  119169. };
  119170. }
  119171. declare module BABYLON {
  119172. /** @hidden */
  119173. export var lensFlareVertexShader: {
  119174. name: string;
  119175. shader: string;
  119176. };
  119177. }
  119178. declare module BABYLON {
  119179. /**
  119180. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119181. * It is usually composed of several `lensFlare`.
  119182. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119183. */
  119184. export class LensFlareSystem {
  119185. /**
  119186. * Define the name of the lens flare system
  119187. */
  119188. name: string;
  119189. /**
  119190. * List of lens flares used in this system.
  119191. */
  119192. lensFlares: LensFlare[];
  119193. /**
  119194. * Define a limit from the border the lens flare can be visible.
  119195. */
  119196. borderLimit: number;
  119197. /**
  119198. * Define a viewport border we do not want to see the lens flare in.
  119199. */
  119200. viewportBorder: number;
  119201. /**
  119202. * Define a predicate which could limit the list of meshes able to occlude the effect.
  119203. */
  119204. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119205. /**
  119206. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  119207. */
  119208. layerMask: number;
  119209. /**
  119210. * Define the id of the lens flare system in the scene.
  119211. * (equal to name by default)
  119212. */
  119213. id: string;
  119214. private _scene;
  119215. private _emitter;
  119216. private _vertexBuffers;
  119217. private _indexBuffer;
  119218. private _effect;
  119219. private _positionX;
  119220. private _positionY;
  119221. private _isEnabled;
  119222. /** @hidden */
  119223. static _SceneComponentInitialization: (scene: Scene) => void;
  119224. /**
  119225. * Instantiates a lens flare system.
  119226. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119227. * It is usually composed of several `lensFlare`.
  119228. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119229. * @param name Define the name of the lens flare system in the scene
  119230. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  119231. * @param scene Define the scene the lens flare system belongs to
  119232. */
  119233. constructor(
  119234. /**
  119235. * Define the name of the lens flare system
  119236. */
  119237. name: string, emitter: any, scene: Scene);
  119238. /**
  119239. * Define if the lens flare system is enabled.
  119240. */
  119241. isEnabled: boolean;
  119242. /**
  119243. * Get the scene the effects belongs to.
  119244. * @returns the scene holding the lens flare system
  119245. */
  119246. getScene(): Scene;
  119247. /**
  119248. * Get the emitter of the lens flare system.
  119249. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119250. * @returns the emitter of the lens flare system
  119251. */
  119252. getEmitter(): any;
  119253. /**
  119254. * Set the emitter of the lens flare system.
  119255. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119256. * @param newEmitter Define the new emitter of the system
  119257. */
  119258. setEmitter(newEmitter: any): void;
  119259. /**
  119260. * Get the lens flare system emitter position.
  119261. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  119262. * @returns the position
  119263. */
  119264. getEmitterPosition(): Vector3;
  119265. /**
  119266. * @hidden
  119267. */
  119268. computeEffectivePosition(globalViewport: Viewport): boolean;
  119269. /** @hidden */
  119270. _isVisible(): boolean;
  119271. /**
  119272. * @hidden
  119273. */
  119274. render(): boolean;
  119275. /**
  119276. * Dispose and release the lens flare with its associated resources.
  119277. */
  119278. dispose(): void;
  119279. /**
  119280. * Parse a lens flare system from a JSON repressentation
  119281. * @param parsedLensFlareSystem Define the JSON to parse
  119282. * @param scene Define the scene the parsed system should be instantiated in
  119283. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  119284. * @returns the parsed system
  119285. */
  119286. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  119287. /**
  119288. * Serialize the current Lens Flare System into a JSON representation.
  119289. * @returns the serialized JSON
  119290. */
  119291. serialize(): any;
  119292. }
  119293. }
  119294. declare module BABYLON {
  119295. /**
  119296. * This represents one of the lens effect in a `lensFlareSystem`.
  119297. * It controls one of the indiviual texture used in the effect.
  119298. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119299. */
  119300. export class LensFlare {
  119301. /**
  119302. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119303. */
  119304. size: number;
  119305. /**
  119306. * 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.
  119307. */
  119308. position: number;
  119309. /**
  119310. * Define the lens color.
  119311. */
  119312. color: Color3;
  119313. /**
  119314. * Define the lens texture.
  119315. */
  119316. texture: Nullable<Texture>;
  119317. /**
  119318. * Define the alpha mode to render this particular lens.
  119319. */
  119320. alphaMode: number;
  119321. private _system;
  119322. /**
  119323. * Creates a new Lens Flare.
  119324. * This represents one of the lens effect in a `lensFlareSystem`.
  119325. * It controls one of the indiviual texture used in the effect.
  119326. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119327. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  119328. * @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.
  119329. * @param color Define the lens color
  119330. * @param imgUrl Define the lens texture url
  119331. * @param system Define the `lensFlareSystem` this flare is part of
  119332. * @returns The newly created Lens Flare
  119333. */
  119334. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  119335. /**
  119336. * Instantiates a new Lens Flare.
  119337. * This represents one of the lens effect in a `lensFlareSystem`.
  119338. * It controls one of the indiviual texture used in the effect.
  119339. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119340. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  119341. * @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.
  119342. * @param color Define the lens color
  119343. * @param imgUrl Define the lens texture url
  119344. * @param system Define the `lensFlareSystem` this flare is part of
  119345. */
  119346. constructor(
  119347. /**
  119348. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119349. */
  119350. size: number,
  119351. /**
  119352. * 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.
  119353. */
  119354. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  119355. /**
  119356. * Dispose and release the lens flare with its associated resources.
  119357. */
  119358. dispose(): void;
  119359. }
  119360. }
  119361. declare module BABYLON {
  119362. interface AbstractScene {
  119363. /**
  119364. * The list of lens flare system added to the scene
  119365. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119366. */
  119367. lensFlareSystems: Array<LensFlareSystem>;
  119368. /**
  119369. * Removes the given lens flare system from this scene.
  119370. * @param toRemove The lens flare system to remove
  119371. * @returns The index of the removed lens flare system
  119372. */
  119373. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  119374. /**
  119375. * Adds the given lens flare system to this scene
  119376. * @param newLensFlareSystem The lens flare system to add
  119377. */
  119378. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  119379. /**
  119380. * Gets a lens flare system using its name
  119381. * @param name defines the name to look for
  119382. * @returns the lens flare system or null if not found
  119383. */
  119384. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  119385. /**
  119386. * Gets a lens flare system using its id
  119387. * @param id defines the id to look for
  119388. * @returns the lens flare system or null if not found
  119389. */
  119390. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  119391. }
  119392. /**
  119393. * Defines the lens flare scene component responsible to manage any lens flares
  119394. * in a given scene.
  119395. */
  119396. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  119397. /**
  119398. * The component name helpfull to identify the component in the list of scene components.
  119399. */
  119400. readonly name: string;
  119401. /**
  119402. * The scene the component belongs to.
  119403. */
  119404. scene: Scene;
  119405. /**
  119406. * Creates a new instance of the component for the given scene
  119407. * @param scene Defines the scene to register the component in
  119408. */
  119409. constructor(scene: Scene);
  119410. /**
  119411. * Registers the component in a given scene
  119412. */
  119413. register(): void;
  119414. /**
  119415. * Rebuilds the elements related to this component in case of
  119416. * context lost for instance.
  119417. */
  119418. rebuild(): void;
  119419. /**
  119420. * Adds all the elements from the container to the scene
  119421. * @param container the container holding the elements
  119422. */
  119423. addFromContainer(container: AbstractScene): void;
  119424. /**
  119425. * Removes all the elements in the container from the scene
  119426. * @param container contains the elements to remove
  119427. * @param dispose if the removed element should be disposed (default: false)
  119428. */
  119429. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119430. /**
  119431. * Serializes the component data to the specified json object
  119432. * @param serializationObject The object to serialize to
  119433. */
  119434. serialize(serializationObject: any): void;
  119435. /**
  119436. * Disposes the component and the associated ressources.
  119437. */
  119438. dispose(): void;
  119439. private _draw;
  119440. }
  119441. }
  119442. declare module BABYLON {
  119443. /**
  119444. * Defines the shadow generator component responsible to manage any shadow generators
  119445. * in a given scene.
  119446. */
  119447. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  119448. /**
  119449. * The component name helpfull to identify the component in the list of scene components.
  119450. */
  119451. readonly name: string;
  119452. /**
  119453. * The scene the component belongs to.
  119454. */
  119455. scene: Scene;
  119456. /**
  119457. * Creates a new instance of the component for the given scene
  119458. * @param scene Defines the scene to register the component in
  119459. */
  119460. constructor(scene: Scene);
  119461. /**
  119462. * Registers the component in a given scene
  119463. */
  119464. register(): void;
  119465. /**
  119466. * Rebuilds the elements related to this component in case of
  119467. * context lost for instance.
  119468. */
  119469. rebuild(): void;
  119470. /**
  119471. * Serializes the component data to the specified json object
  119472. * @param serializationObject The object to serialize to
  119473. */
  119474. serialize(serializationObject: any): void;
  119475. /**
  119476. * Adds all the elements from the container to the scene
  119477. * @param container the container holding the elements
  119478. */
  119479. addFromContainer(container: AbstractScene): void;
  119480. /**
  119481. * Removes all the elements in the container from the scene
  119482. * @param container contains the elements to remove
  119483. * @param dispose if the removed element should be disposed (default: false)
  119484. */
  119485. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119486. /**
  119487. * Rebuilds the elements related to this component in case of
  119488. * context lost for instance.
  119489. */
  119490. dispose(): void;
  119491. private _gatherRenderTargets;
  119492. }
  119493. }
  119494. declare module BABYLON {
  119495. /**
  119496. * A point light is a light defined by an unique point in world space.
  119497. * The light is emitted in every direction from this point.
  119498. * A good example of a point light is a standard light bulb.
  119499. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119500. */
  119501. export class PointLight extends ShadowLight {
  119502. private _shadowAngle;
  119503. /**
  119504. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119505. * This specifies what angle the shadow will use to be created.
  119506. *
  119507. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119508. */
  119509. /**
  119510. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119511. * This specifies what angle the shadow will use to be created.
  119512. *
  119513. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119514. */
  119515. shadowAngle: number;
  119516. /**
  119517. * Gets the direction if it has been set.
  119518. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119519. */
  119520. /**
  119521. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119522. */
  119523. direction: Vector3;
  119524. /**
  119525. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  119526. * A PointLight emits the light in every direction.
  119527. * It can cast shadows.
  119528. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  119529. * ```javascript
  119530. * var pointLight = new PointLight("pl", camera.position, scene);
  119531. * ```
  119532. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119533. * @param name The light friendly name
  119534. * @param position The position of the point light in the scene
  119535. * @param scene The scene the lights belongs to
  119536. */
  119537. constructor(name: string, position: Vector3, scene: Scene);
  119538. /**
  119539. * Returns the string "PointLight"
  119540. * @returns the class name
  119541. */
  119542. getClassName(): string;
  119543. /**
  119544. * Returns the integer 0.
  119545. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119546. */
  119547. getTypeID(): number;
  119548. /**
  119549. * Specifies wether or not the shadowmap should be a cube texture.
  119550. * @returns true if the shadowmap needs to be a cube texture.
  119551. */
  119552. needCube(): boolean;
  119553. /**
  119554. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  119555. * @param faceIndex The index of the face we are computed the direction to generate shadow
  119556. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  119557. */
  119558. getShadowDirection(faceIndex?: number): Vector3;
  119559. /**
  119560. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  119561. * - fov = PI / 2
  119562. * - aspect ratio : 1.0
  119563. * - z-near and far equal to the active camera minZ and maxZ.
  119564. * Returns the PointLight.
  119565. */
  119566. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119567. protected _buildUniformLayout(): void;
  119568. /**
  119569. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  119570. * @param effect The effect to update
  119571. * @param lightIndex The index of the light in the effect to update
  119572. * @returns The point light
  119573. */
  119574. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  119575. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  119576. /**
  119577. * Prepares the list of defines specific to the light type.
  119578. * @param defines the list of defines
  119579. * @param lightIndex defines the index of the light for the effect
  119580. */
  119581. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119582. }
  119583. }
  119584. declare module BABYLON {
  119585. /**
  119586. * Header information of HDR texture files.
  119587. */
  119588. export interface HDRInfo {
  119589. /**
  119590. * The height of the texture in pixels.
  119591. */
  119592. height: number;
  119593. /**
  119594. * The width of the texture in pixels.
  119595. */
  119596. width: number;
  119597. /**
  119598. * The index of the beginning of the data in the binary file.
  119599. */
  119600. dataPosition: number;
  119601. }
  119602. /**
  119603. * This groups tools to convert HDR texture to native colors array.
  119604. */
  119605. export class HDRTools {
  119606. private static Ldexp;
  119607. private static Rgbe2float;
  119608. private static readStringLine;
  119609. /**
  119610. * Reads header information from an RGBE texture stored in a native array.
  119611. * More information on this format are available here:
  119612. * https://en.wikipedia.org/wiki/RGBE_image_format
  119613. *
  119614. * @param uint8array The binary file stored in native array.
  119615. * @return The header information.
  119616. */
  119617. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  119618. /**
  119619. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  119620. * This RGBE texture needs to store the information as a panorama.
  119621. *
  119622. * More information on this format are available here:
  119623. * https://en.wikipedia.org/wiki/RGBE_image_format
  119624. *
  119625. * @param buffer The binary file stored in an array buffer.
  119626. * @param size The expected size of the extracted cubemap.
  119627. * @return The Cube Map information.
  119628. */
  119629. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  119630. /**
  119631. * Returns the pixels data extracted from an RGBE texture.
  119632. * This pixels will be stored left to right up to down in the R G B order in one array.
  119633. *
  119634. * More information on this format are available here:
  119635. * https://en.wikipedia.org/wiki/RGBE_image_format
  119636. *
  119637. * @param uint8array The binary file stored in an array buffer.
  119638. * @param hdrInfo The header information of the file.
  119639. * @return The pixels data in RGB right to left up to down order.
  119640. */
  119641. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  119642. private static RGBE_ReadPixels_RLE;
  119643. }
  119644. }
  119645. declare module BABYLON {
  119646. /**
  119647. * This represents a texture coming from an HDR input.
  119648. *
  119649. * The only supported format is currently panorama picture stored in RGBE format.
  119650. * Example of such files can be found on HDRLib: http://hdrlib.com/
  119651. */
  119652. export class HDRCubeTexture extends BaseTexture {
  119653. private static _facesMapping;
  119654. private _generateHarmonics;
  119655. private _noMipmap;
  119656. private _textureMatrix;
  119657. private _size;
  119658. private _onLoad;
  119659. private _onError;
  119660. /**
  119661. * The texture URL.
  119662. */
  119663. url: string;
  119664. /**
  119665. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  119666. */
  119667. coordinatesMode: number;
  119668. protected _isBlocking: boolean;
  119669. /**
  119670. * Sets wether or not the texture is blocking during loading.
  119671. */
  119672. /**
  119673. * Gets wether or not the texture is blocking during loading.
  119674. */
  119675. isBlocking: boolean;
  119676. protected _rotationY: number;
  119677. /**
  119678. * Sets texture matrix rotation angle around Y axis in radians.
  119679. */
  119680. /**
  119681. * Gets texture matrix rotation angle around Y axis radians.
  119682. */
  119683. rotationY: number;
  119684. /**
  119685. * Gets or sets the center of the bounding box associated with the cube texture
  119686. * It must define where the camera used to render the texture was set
  119687. */
  119688. boundingBoxPosition: Vector3;
  119689. private _boundingBoxSize;
  119690. /**
  119691. * Gets or sets the size of the bounding box associated with the cube texture
  119692. * When defined, the cubemap will switch to local mode
  119693. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119694. * @example https://www.babylonjs-playground.com/#RNASML
  119695. */
  119696. boundingBoxSize: Vector3;
  119697. /**
  119698. * Instantiates an HDRTexture from the following parameters.
  119699. *
  119700. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  119701. * @param scene The scene the texture will be used in
  119702. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119703. * @param noMipmap Forces to not generate the mipmap if true
  119704. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  119705. * @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)
  119706. * @param reserved Reserved flag for internal use.
  119707. */
  119708. 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>);
  119709. /**
  119710. * Get the current class name of the texture useful for serialization or dynamic coding.
  119711. * @returns "HDRCubeTexture"
  119712. */
  119713. getClassName(): string;
  119714. /**
  119715. * Occurs when the file is raw .hdr file.
  119716. */
  119717. private loadTexture;
  119718. clone(): HDRCubeTexture;
  119719. delayLoad(): void;
  119720. /**
  119721. * Get the texture reflection matrix used to rotate/transform the reflection.
  119722. * @returns the reflection matrix
  119723. */
  119724. getReflectionTextureMatrix(): Matrix;
  119725. /**
  119726. * Set the texture reflection matrix used to rotate/transform the reflection.
  119727. * @param value Define the reflection matrix to set
  119728. */
  119729. setReflectionTextureMatrix(value: Matrix): void;
  119730. /**
  119731. * Parses a JSON representation of an HDR Texture in order to create the texture
  119732. * @param parsedTexture Define the JSON representation
  119733. * @param scene Define the scene the texture should be created in
  119734. * @param rootUrl Define the root url in case we need to load relative dependencies
  119735. * @returns the newly created texture after parsing
  119736. */
  119737. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  119738. serialize(): any;
  119739. }
  119740. }
  119741. declare module BABYLON {
  119742. /**
  119743. * Class used to control physics engine
  119744. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119745. */
  119746. export class PhysicsEngine implements IPhysicsEngine {
  119747. private _physicsPlugin;
  119748. /**
  119749. * Global value used to control the smallest number supported by the simulation
  119750. */
  119751. static Epsilon: number;
  119752. private _impostors;
  119753. private _joints;
  119754. /**
  119755. * Gets the gravity vector used by the simulation
  119756. */
  119757. gravity: Vector3;
  119758. /**
  119759. * Factory used to create the default physics plugin.
  119760. * @returns The default physics plugin
  119761. */
  119762. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  119763. /**
  119764. * Creates a new Physics Engine
  119765. * @param gravity defines the gravity vector used by the simulation
  119766. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  119767. */
  119768. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  119769. /**
  119770. * Sets the gravity vector used by the simulation
  119771. * @param gravity defines the gravity vector to use
  119772. */
  119773. setGravity(gravity: Vector3): void;
  119774. /**
  119775. * Set the time step of the physics engine.
  119776. * Default is 1/60.
  119777. * To slow it down, enter 1/600 for example.
  119778. * To speed it up, 1/30
  119779. * @param newTimeStep defines the new timestep to apply to this world.
  119780. */
  119781. setTimeStep(newTimeStep?: number): void;
  119782. /**
  119783. * Get the time step of the physics engine.
  119784. * @returns the current time step
  119785. */
  119786. getTimeStep(): number;
  119787. /**
  119788. * Release all resources
  119789. */
  119790. dispose(): void;
  119791. /**
  119792. * Gets the name of the current physics plugin
  119793. * @returns the name of the plugin
  119794. */
  119795. getPhysicsPluginName(): string;
  119796. /**
  119797. * Adding a new impostor for the impostor tracking.
  119798. * This will be done by the impostor itself.
  119799. * @param impostor the impostor to add
  119800. */
  119801. addImpostor(impostor: PhysicsImpostor): void;
  119802. /**
  119803. * Remove an impostor from the engine.
  119804. * This impostor and its mesh will not longer be updated by the physics engine.
  119805. * @param impostor the impostor to remove
  119806. */
  119807. removeImpostor(impostor: PhysicsImpostor): void;
  119808. /**
  119809. * Add a joint to the physics engine
  119810. * @param mainImpostor defines the main impostor to which the joint is added.
  119811. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  119812. * @param joint defines the joint that will connect both impostors.
  119813. */
  119814. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119815. /**
  119816. * Removes a joint from the simulation
  119817. * @param mainImpostor defines the impostor used with the joint
  119818. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  119819. * @param joint defines the joint to remove
  119820. */
  119821. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119822. /**
  119823. * Called by the scene. No need to call it.
  119824. * @param delta defines the timespam between frames
  119825. */
  119826. _step(delta: number): void;
  119827. /**
  119828. * Gets the current plugin used to run the simulation
  119829. * @returns current plugin
  119830. */
  119831. getPhysicsPlugin(): IPhysicsEnginePlugin;
  119832. /**
  119833. * Gets the list of physic impostors
  119834. * @returns an array of PhysicsImpostor
  119835. */
  119836. getImpostors(): Array<PhysicsImpostor>;
  119837. /**
  119838. * Gets the impostor for a physics enabled object
  119839. * @param object defines the object impersonated by the impostor
  119840. * @returns the PhysicsImpostor or null if not found
  119841. */
  119842. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  119843. /**
  119844. * Gets the impostor for a physics body object
  119845. * @param body defines physics body used by the impostor
  119846. * @returns the PhysicsImpostor or null if not found
  119847. */
  119848. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  119849. /**
  119850. * Does a raycast in the physics world
  119851. * @param from when should the ray start?
  119852. * @param to when should the ray end?
  119853. * @returns PhysicsRaycastResult
  119854. */
  119855. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119856. }
  119857. }
  119858. declare module BABYLON {
  119859. /** @hidden */
  119860. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  119861. private _useDeltaForWorldStep;
  119862. world: any;
  119863. name: string;
  119864. private _physicsMaterials;
  119865. private _fixedTimeStep;
  119866. private _cannonRaycastResult;
  119867. private _raycastResult;
  119868. private _physicsBodysToRemoveAfterStep;
  119869. BJSCANNON: any;
  119870. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  119871. setGravity(gravity: Vector3): void;
  119872. setTimeStep(timeStep: number): void;
  119873. getTimeStep(): number;
  119874. executeStep(delta: number): void;
  119875. private _removeMarkedPhysicsBodiesFromWorld;
  119876. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119877. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119878. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119879. private _processChildMeshes;
  119880. removePhysicsBody(impostor: PhysicsImpostor): void;
  119881. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119882. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119883. private _addMaterial;
  119884. private _checkWithEpsilon;
  119885. private _createShape;
  119886. private _createHeightmap;
  119887. private _minus90X;
  119888. private _plus90X;
  119889. private _tmpPosition;
  119890. private _tmpDeltaPosition;
  119891. private _tmpUnityRotation;
  119892. private _updatePhysicsBodyTransformation;
  119893. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119894. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119895. isSupported(): boolean;
  119896. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119897. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119898. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119899. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119900. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119901. getBodyMass(impostor: PhysicsImpostor): number;
  119902. getBodyFriction(impostor: PhysicsImpostor): number;
  119903. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119904. getBodyRestitution(impostor: PhysicsImpostor): number;
  119905. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119906. sleepBody(impostor: PhysicsImpostor): void;
  119907. wakeUpBody(impostor: PhysicsImpostor): void;
  119908. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  119909. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119910. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119911. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119912. getRadius(impostor: PhysicsImpostor): number;
  119913. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119914. dispose(): void;
  119915. private _extendNamespace;
  119916. /**
  119917. * Does a raycast in the physics world
  119918. * @param from when should the ray start?
  119919. * @param to when should the ray end?
  119920. * @returns PhysicsRaycastResult
  119921. */
  119922. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119923. }
  119924. }
  119925. declare module BABYLON {
  119926. /** @hidden */
  119927. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  119928. world: any;
  119929. name: string;
  119930. BJSOIMO: any;
  119931. private _raycastResult;
  119932. constructor(iterations?: number, oimoInjection?: any);
  119933. setGravity(gravity: Vector3): void;
  119934. setTimeStep(timeStep: number): void;
  119935. getTimeStep(): number;
  119936. private _tmpImpostorsArray;
  119937. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119938. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119939. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119940. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119941. private _tmpPositionVector;
  119942. removePhysicsBody(impostor: PhysicsImpostor): void;
  119943. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119944. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119945. isSupported(): boolean;
  119946. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119947. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119948. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119949. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119950. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119951. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119952. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119953. getBodyMass(impostor: PhysicsImpostor): number;
  119954. getBodyFriction(impostor: PhysicsImpostor): number;
  119955. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119956. getBodyRestitution(impostor: PhysicsImpostor): number;
  119957. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119958. sleepBody(impostor: PhysicsImpostor): void;
  119959. wakeUpBody(impostor: PhysicsImpostor): void;
  119960. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119961. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  119962. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  119963. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119964. getRadius(impostor: PhysicsImpostor): number;
  119965. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119966. dispose(): void;
  119967. /**
  119968. * Does a raycast in the physics world
  119969. * @param from when should the ray start?
  119970. * @param to when should the ray end?
  119971. * @returns PhysicsRaycastResult
  119972. */
  119973. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119974. }
  119975. }
  119976. declare module BABYLON {
  119977. /**
  119978. * Class containing static functions to help procedurally build meshes
  119979. */
  119980. export class RibbonBuilder {
  119981. /**
  119982. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119983. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119984. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119985. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119986. * * 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
  119987. * * 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
  119988. * * 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
  119989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119991. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119992. * * 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
  119993. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119994. * * 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
  119995. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119997. * @param name defines the name of the mesh
  119998. * @param options defines the options used to create the mesh
  119999. * @param scene defines the hosting scene
  120000. * @returns the ribbon mesh
  120001. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  120002. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120003. */
  120004. static CreateRibbon(name: string, options: {
  120005. pathArray: Vector3[][];
  120006. closeArray?: boolean;
  120007. closePath?: boolean;
  120008. offset?: number;
  120009. updatable?: boolean;
  120010. sideOrientation?: number;
  120011. frontUVs?: Vector4;
  120012. backUVs?: Vector4;
  120013. instance?: Mesh;
  120014. invertUV?: boolean;
  120015. uvs?: Vector2[];
  120016. colors?: Color4[];
  120017. }, scene?: Nullable<Scene>): Mesh;
  120018. }
  120019. }
  120020. declare module BABYLON {
  120021. /**
  120022. * Class containing static functions to help procedurally build meshes
  120023. */
  120024. export class ShapeBuilder {
  120025. /**
  120026. * 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.
  120027. * * 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.
  120028. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120029. * * 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.
  120030. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  120031. * * 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
  120032. * * 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
  120033. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  120034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120036. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  120037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120038. * @param name defines the name of the mesh
  120039. * @param options defines the options used to create the mesh
  120040. * @param scene defines the hosting scene
  120041. * @returns the extruded shape mesh
  120042. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120044. */
  120045. static ExtrudeShape(name: string, options: {
  120046. shape: Vector3[];
  120047. path: Vector3[];
  120048. scale?: number;
  120049. rotation?: number;
  120050. cap?: number;
  120051. updatable?: boolean;
  120052. sideOrientation?: number;
  120053. frontUVs?: Vector4;
  120054. backUVs?: Vector4;
  120055. instance?: Mesh;
  120056. invertUV?: boolean;
  120057. }, scene?: Nullable<Scene>): Mesh;
  120058. /**
  120059. * Creates an custom extruded shape mesh.
  120060. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  120061. * * 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.
  120062. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120063. * * 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
  120064. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  120065. * * 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
  120066. * * It must returns a float value that will be the scale value applied to the shape on each path point
  120067. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  120068. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  120069. * * 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
  120070. * * 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
  120071. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  120072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120074. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120076. * @param name defines the name of the mesh
  120077. * @param options defines the options used to create the mesh
  120078. * @param scene defines the hosting scene
  120079. * @returns the custom extruded shape mesh
  120080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  120081. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120083. */
  120084. static ExtrudeShapeCustom(name: string, options: {
  120085. shape: Vector3[];
  120086. path: Vector3[];
  120087. scaleFunction?: any;
  120088. rotationFunction?: any;
  120089. ribbonCloseArray?: boolean;
  120090. ribbonClosePath?: boolean;
  120091. cap?: number;
  120092. updatable?: boolean;
  120093. sideOrientation?: number;
  120094. frontUVs?: Vector4;
  120095. backUVs?: Vector4;
  120096. instance?: Mesh;
  120097. invertUV?: boolean;
  120098. }, scene?: Nullable<Scene>): Mesh;
  120099. private static _ExtrudeShapeGeneric;
  120100. }
  120101. }
  120102. declare module BABYLON {
  120103. /**
  120104. * AmmoJS Physics plugin
  120105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120106. * @see https://github.com/kripken/ammo.js/
  120107. */
  120108. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  120109. private _useDeltaForWorldStep;
  120110. /**
  120111. * Reference to the Ammo library
  120112. */
  120113. bjsAMMO: any;
  120114. /**
  120115. * Created ammoJS world which physics bodies are added to
  120116. */
  120117. world: any;
  120118. /**
  120119. * Name of the plugin
  120120. */
  120121. name: string;
  120122. private _timeStep;
  120123. private _fixedTimeStep;
  120124. private _maxSteps;
  120125. private _tmpQuaternion;
  120126. private _tmpAmmoTransform;
  120127. private _tmpAmmoQuaternion;
  120128. private _tmpAmmoConcreteContactResultCallback;
  120129. private _collisionConfiguration;
  120130. private _dispatcher;
  120131. private _overlappingPairCache;
  120132. private _solver;
  120133. private _softBodySolver;
  120134. private _tmpAmmoVectorA;
  120135. private _tmpAmmoVectorB;
  120136. private _tmpAmmoVectorC;
  120137. private _tmpAmmoVectorD;
  120138. private _tmpContactCallbackResult;
  120139. private _tmpAmmoVectorRCA;
  120140. private _tmpAmmoVectorRCB;
  120141. private _raycastResult;
  120142. private static readonly DISABLE_COLLISION_FLAG;
  120143. private static readonly KINEMATIC_FLAG;
  120144. private static readonly DISABLE_DEACTIVATION_FLAG;
  120145. /**
  120146. * Initializes the ammoJS plugin
  120147. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  120148. * @param ammoInjection can be used to inject your own ammo reference
  120149. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  120150. */
  120151. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  120152. /**
  120153. * Sets the gravity of the physics world (m/(s^2))
  120154. * @param gravity Gravity to set
  120155. */
  120156. setGravity(gravity: Vector3): void;
  120157. /**
  120158. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  120159. * @param timeStep timestep to use in seconds
  120160. */
  120161. setTimeStep(timeStep: number): void;
  120162. /**
  120163. * 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)
  120164. * @param fixedTimeStep fixedTimeStep to use in seconds
  120165. */
  120166. setFixedTimeStep(fixedTimeStep: number): void;
  120167. /**
  120168. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  120169. * @param maxSteps the maximum number of steps by the physics engine per frame
  120170. */
  120171. setMaxSteps(maxSteps: number): void;
  120172. /**
  120173. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  120174. * @returns the current timestep in seconds
  120175. */
  120176. getTimeStep(): number;
  120177. private _isImpostorInContact;
  120178. private _isImpostorPairInContact;
  120179. private _stepSimulation;
  120180. /**
  120181. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  120182. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  120183. * After the step the babylon meshes are set to the position of the physics imposters
  120184. * @param delta amount of time to step forward
  120185. * @param impostors array of imposters to update before/after the step
  120186. */
  120187. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120188. /**
  120189. * Update babylon mesh to match physics world object
  120190. * @param impostor imposter to match
  120191. */
  120192. private _afterSoftStep;
  120193. /**
  120194. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120195. * @param impostor imposter to match
  120196. */
  120197. private _ropeStep;
  120198. /**
  120199. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120200. * @param impostor imposter to match
  120201. */
  120202. private _softbodyOrClothStep;
  120203. private _tmpVector;
  120204. private _tmpMatrix;
  120205. /**
  120206. * Applies an impulse on the imposter
  120207. * @param impostor imposter to apply impulse to
  120208. * @param force amount of force to be applied to the imposter
  120209. * @param contactPoint the location to apply the impulse on the imposter
  120210. */
  120211. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120212. /**
  120213. * Applies a force on the imposter
  120214. * @param impostor imposter to apply force
  120215. * @param force amount of force to be applied to the imposter
  120216. * @param contactPoint the location to apply the force on the imposter
  120217. */
  120218. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120219. /**
  120220. * Creates a physics body using the plugin
  120221. * @param impostor the imposter to create the physics body on
  120222. */
  120223. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120224. /**
  120225. * Removes the physics body from the imposter and disposes of the body's memory
  120226. * @param impostor imposter to remove the physics body from
  120227. */
  120228. removePhysicsBody(impostor: PhysicsImpostor): void;
  120229. /**
  120230. * Generates a joint
  120231. * @param impostorJoint the imposter joint to create the joint with
  120232. */
  120233. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120234. /**
  120235. * Removes a joint
  120236. * @param impostorJoint the imposter joint to remove the joint from
  120237. */
  120238. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120239. private _addMeshVerts;
  120240. /**
  120241. * Initialise the soft body vertices to match its object's (mesh) vertices
  120242. * Softbody vertices (nodes) are in world space and to match this
  120243. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  120244. * @param impostor to create the softbody for
  120245. */
  120246. private _softVertexData;
  120247. /**
  120248. * Create an impostor's soft body
  120249. * @param impostor to create the softbody for
  120250. */
  120251. private _createSoftbody;
  120252. /**
  120253. * Create cloth for an impostor
  120254. * @param impostor to create the softbody for
  120255. */
  120256. private _createCloth;
  120257. /**
  120258. * Create rope for an impostor
  120259. * @param impostor to create the softbody for
  120260. */
  120261. private _createRope;
  120262. private _addHullVerts;
  120263. private _createShape;
  120264. /**
  120265. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  120266. * @param impostor imposter containing the physics body and babylon object
  120267. */
  120268. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120269. /**
  120270. * Sets the babylon object's position/rotation from the physics body's position/rotation
  120271. * @param impostor imposter containing the physics body and babylon object
  120272. * @param newPosition new position
  120273. * @param newRotation new rotation
  120274. */
  120275. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120276. /**
  120277. * If this plugin is supported
  120278. * @returns true if its supported
  120279. */
  120280. isSupported(): boolean;
  120281. /**
  120282. * Sets the linear velocity of the physics body
  120283. * @param impostor imposter to set the velocity on
  120284. * @param velocity velocity to set
  120285. */
  120286. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120287. /**
  120288. * Sets the angular velocity of the physics body
  120289. * @param impostor imposter to set the velocity on
  120290. * @param velocity velocity to set
  120291. */
  120292. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120293. /**
  120294. * gets the linear velocity
  120295. * @param impostor imposter to get linear velocity from
  120296. * @returns linear velocity
  120297. */
  120298. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120299. /**
  120300. * gets the angular velocity
  120301. * @param impostor imposter to get angular velocity from
  120302. * @returns angular velocity
  120303. */
  120304. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120305. /**
  120306. * Sets the mass of physics body
  120307. * @param impostor imposter to set the mass on
  120308. * @param mass mass to set
  120309. */
  120310. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120311. /**
  120312. * Gets the mass of the physics body
  120313. * @param impostor imposter to get the mass from
  120314. * @returns mass
  120315. */
  120316. getBodyMass(impostor: PhysicsImpostor): number;
  120317. /**
  120318. * Gets friction of the impostor
  120319. * @param impostor impostor to get friction from
  120320. * @returns friction value
  120321. */
  120322. getBodyFriction(impostor: PhysicsImpostor): number;
  120323. /**
  120324. * Sets friction of the impostor
  120325. * @param impostor impostor to set friction on
  120326. * @param friction friction value
  120327. */
  120328. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120329. /**
  120330. * Gets restitution of the impostor
  120331. * @param impostor impostor to get restitution from
  120332. * @returns restitution value
  120333. */
  120334. getBodyRestitution(impostor: PhysicsImpostor): number;
  120335. /**
  120336. * Sets resitution of the impostor
  120337. * @param impostor impostor to set resitution on
  120338. * @param restitution resitution value
  120339. */
  120340. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120341. /**
  120342. * Gets pressure inside the impostor
  120343. * @param impostor impostor to get pressure from
  120344. * @returns pressure value
  120345. */
  120346. getBodyPressure(impostor: PhysicsImpostor): number;
  120347. /**
  120348. * Sets pressure inside a soft body impostor
  120349. * Cloth and rope must remain 0 pressure
  120350. * @param impostor impostor to set pressure on
  120351. * @param pressure pressure value
  120352. */
  120353. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  120354. /**
  120355. * Gets stiffness of the impostor
  120356. * @param impostor impostor to get stiffness from
  120357. * @returns pressure value
  120358. */
  120359. getBodyStiffness(impostor: PhysicsImpostor): number;
  120360. /**
  120361. * Sets stiffness of the impostor
  120362. * @param impostor impostor to set stiffness on
  120363. * @param stiffness stiffness value from 0 to 1
  120364. */
  120365. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  120366. /**
  120367. * Gets velocityIterations of the impostor
  120368. * @param impostor impostor to get velocity iterations from
  120369. * @returns velocityIterations value
  120370. */
  120371. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  120372. /**
  120373. * Sets velocityIterations of the impostor
  120374. * @param impostor impostor to set velocity iterations on
  120375. * @param velocityIterations velocityIterations value
  120376. */
  120377. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  120378. /**
  120379. * Gets positionIterations of the impostor
  120380. * @param impostor impostor to get position iterations from
  120381. * @returns positionIterations value
  120382. */
  120383. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  120384. /**
  120385. * Sets positionIterations of the impostor
  120386. * @param impostor impostor to set position on
  120387. * @param positionIterations positionIterations value
  120388. */
  120389. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  120390. /**
  120391. * Append an anchor to a cloth object
  120392. * @param impostor is the cloth impostor to add anchor to
  120393. * @param otherImpostor is the rigid impostor to anchor to
  120394. * @param width ratio across width from 0 to 1
  120395. * @param height ratio up height from 0 to 1
  120396. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  120397. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120398. */
  120399. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120400. /**
  120401. * Append an hook to a rope object
  120402. * @param impostor is the rope impostor to add hook to
  120403. * @param otherImpostor is the rigid impostor to hook to
  120404. * @param length ratio along the rope from 0 to 1
  120405. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  120406. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120407. */
  120408. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120409. /**
  120410. * Sleeps the physics body and stops it from being active
  120411. * @param impostor impostor to sleep
  120412. */
  120413. sleepBody(impostor: PhysicsImpostor): void;
  120414. /**
  120415. * Activates the physics body
  120416. * @param impostor impostor to activate
  120417. */
  120418. wakeUpBody(impostor: PhysicsImpostor): void;
  120419. /**
  120420. * Updates the distance parameters of the joint
  120421. * @param joint joint to update
  120422. * @param maxDistance maximum distance of the joint
  120423. * @param minDistance minimum distance of the joint
  120424. */
  120425. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120426. /**
  120427. * Sets a motor on the joint
  120428. * @param joint joint to set motor on
  120429. * @param speed speed of the motor
  120430. * @param maxForce maximum force of the motor
  120431. * @param motorIndex index of the motor
  120432. */
  120433. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120434. /**
  120435. * Sets the motors limit
  120436. * @param joint joint to set limit on
  120437. * @param upperLimit upper limit
  120438. * @param lowerLimit lower limit
  120439. */
  120440. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120441. /**
  120442. * Syncs the position and rotation of a mesh with the impostor
  120443. * @param mesh mesh to sync
  120444. * @param impostor impostor to update the mesh with
  120445. */
  120446. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120447. /**
  120448. * Gets the radius of the impostor
  120449. * @param impostor impostor to get radius from
  120450. * @returns the radius
  120451. */
  120452. getRadius(impostor: PhysicsImpostor): number;
  120453. /**
  120454. * Gets the box size of the impostor
  120455. * @param impostor impostor to get box size from
  120456. * @param result the resulting box size
  120457. */
  120458. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120459. /**
  120460. * Disposes of the impostor
  120461. */
  120462. dispose(): void;
  120463. /**
  120464. * Does a raycast in the physics world
  120465. * @param from when should the ray start?
  120466. * @param to when should the ray end?
  120467. * @returns PhysicsRaycastResult
  120468. */
  120469. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120470. }
  120471. }
  120472. declare module BABYLON {
  120473. interface AbstractScene {
  120474. /**
  120475. * The list of reflection probes added to the scene
  120476. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120477. */
  120478. reflectionProbes: Array<ReflectionProbe>;
  120479. /**
  120480. * Removes the given reflection probe from this scene.
  120481. * @param toRemove The reflection probe to remove
  120482. * @returns The index of the removed reflection probe
  120483. */
  120484. removeReflectionProbe(toRemove: ReflectionProbe): number;
  120485. /**
  120486. * Adds the given reflection probe to this scene.
  120487. * @param newReflectionProbe The reflection probe to add
  120488. */
  120489. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  120490. }
  120491. /**
  120492. * Class used to generate realtime reflection / refraction cube textures
  120493. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120494. */
  120495. export class ReflectionProbe {
  120496. /** defines the name of the probe */
  120497. name: string;
  120498. private _scene;
  120499. private _renderTargetTexture;
  120500. private _projectionMatrix;
  120501. private _viewMatrix;
  120502. private _target;
  120503. private _add;
  120504. private _attachedMesh;
  120505. private _invertYAxis;
  120506. /** Gets or sets probe position (center of the cube map) */
  120507. position: Vector3;
  120508. /**
  120509. * Creates a new reflection probe
  120510. * @param name defines the name of the probe
  120511. * @param size defines the texture resolution (for each face)
  120512. * @param scene defines the hosting scene
  120513. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  120514. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  120515. */
  120516. constructor(
  120517. /** defines the name of the probe */
  120518. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  120519. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120520. samples: number;
  120521. /** Gets or sets the refresh rate to use (on every frame by default) */
  120522. refreshRate: number;
  120523. /**
  120524. * Gets the hosting scene
  120525. * @returns a Scene
  120526. */
  120527. getScene(): Scene;
  120528. /** Gets the internal CubeTexture used to render to */
  120529. readonly cubeTexture: RenderTargetTexture;
  120530. /** Gets the list of meshes to render */
  120531. readonly renderList: Nullable<AbstractMesh[]>;
  120532. /**
  120533. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120534. * @param mesh defines the mesh to attach to
  120535. */
  120536. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  120537. /**
  120538. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120539. * @param renderingGroupId The rendering group id corresponding to its index
  120540. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120541. */
  120542. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  120543. /**
  120544. * Clean all associated resources
  120545. */
  120546. dispose(): void;
  120547. /**
  120548. * Converts the reflection probe information to a readable string for debug purpose.
  120549. * @param fullDetails Supports for multiple levels of logging within scene loading
  120550. * @returns the human readable reflection probe info
  120551. */
  120552. toString(fullDetails?: boolean): string;
  120553. /**
  120554. * Get the class name of the relfection probe.
  120555. * @returns "ReflectionProbe"
  120556. */
  120557. getClassName(): string;
  120558. /**
  120559. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120560. * @returns The JSON representation of the texture
  120561. */
  120562. serialize(): any;
  120563. /**
  120564. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120565. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120566. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120567. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120568. * @returns The parsed reflection probe if successful
  120569. */
  120570. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  120571. }
  120572. }
  120573. declare module BABYLON {
  120574. /** @hidden */
  120575. export var _BabylonLoaderRegistered: boolean;
  120576. /**
  120577. * Helps setting up some configuration for the babylon file loader.
  120578. */
  120579. export class BabylonFileLoaderConfiguration {
  120580. /**
  120581. * The loader does not allow injecting custom physix engine into the plugins.
  120582. * Unfortunately in ES6, we need to manually inject them into the plugin.
  120583. * So you could set this variable to your engine import to make it work.
  120584. */
  120585. static LoaderInjectedPhysicsEngine: any;
  120586. }
  120587. }
  120588. declare module BABYLON {
  120589. /**
  120590. * The Physically based simple base material of BJS.
  120591. *
  120592. * This enables better naming and convention enforcements on top of the pbrMaterial.
  120593. * It is used as the base class for both the specGloss and metalRough conventions.
  120594. */
  120595. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  120596. /**
  120597. * Number of Simultaneous lights allowed on the material.
  120598. */
  120599. maxSimultaneousLights: number;
  120600. /**
  120601. * If sets to true, disables all the lights affecting the material.
  120602. */
  120603. disableLighting: boolean;
  120604. /**
  120605. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  120606. */
  120607. environmentTexture: BaseTexture;
  120608. /**
  120609. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  120610. */
  120611. invertNormalMapX: boolean;
  120612. /**
  120613. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  120614. */
  120615. invertNormalMapY: boolean;
  120616. /**
  120617. * Normal map used in the model.
  120618. */
  120619. normalTexture: BaseTexture;
  120620. /**
  120621. * Emissivie color used to self-illuminate the model.
  120622. */
  120623. emissiveColor: Color3;
  120624. /**
  120625. * Emissivie texture used to self-illuminate the model.
  120626. */
  120627. emissiveTexture: BaseTexture;
  120628. /**
  120629. * Occlusion Channel Strenght.
  120630. */
  120631. occlusionStrength: number;
  120632. /**
  120633. * Occlusion Texture of the material (adding extra occlusion effects).
  120634. */
  120635. occlusionTexture: BaseTexture;
  120636. /**
  120637. * Defines the alpha limits in alpha test mode.
  120638. */
  120639. alphaCutOff: number;
  120640. /**
  120641. * Gets the current double sided mode.
  120642. */
  120643. /**
  120644. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120645. */
  120646. doubleSided: boolean;
  120647. /**
  120648. * Stores the pre-calculated light information of a mesh in a texture.
  120649. */
  120650. lightmapTexture: BaseTexture;
  120651. /**
  120652. * If true, the light map contains occlusion information instead of lighting info.
  120653. */
  120654. useLightmapAsShadowmap: boolean;
  120655. /**
  120656. * Instantiates a new PBRMaterial instance.
  120657. *
  120658. * @param name The material name
  120659. * @param scene The scene the material will be use in.
  120660. */
  120661. constructor(name: string, scene: Scene);
  120662. getClassName(): string;
  120663. }
  120664. }
  120665. declare module BABYLON {
  120666. /**
  120667. * The PBR material of BJS following the metal roughness convention.
  120668. *
  120669. * This fits to the PBR convention in the GLTF definition:
  120670. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  120671. */
  120672. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  120673. /**
  120674. * The base color has two different interpretations depending on the value of metalness.
  120675. * When the material is a metal, the base color is the specific measured reflectance value
  120676. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  120677. * of the material.
  120678. */
  120679. baseColor: Color3;
  120680. /**
  120681. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  120682. * well as opacity information in the alpha channel.
  120683. */
  120684. baseTexture: BaseTexture;
  120685. /**
  120686. * Specifies the metallic scalar value of the material.
  120687. * Can also be used to scale the metalness values of the metallic texture.
  120688. */
  120689. metallic: number;
  120690. /**
  120691. * Specifies the roughness scalar value of the material.
  120692. * Can also be used to scale the roughness values of the metallic texture.
  120693. */
  120694. roughness: number;
  120695. /**
  120696. * Texture containing both the metallic value in the B channel and the
  120697. * roughness value in the G channel to keep better precision.
  120698. */
  120699. metallicRoughnessTexture: BaseTexture;
  120700. /**
  120701. * Instantiates a new PBRMetalRoughnessMaterial instance.
  120702. *
  120703. * @param name The material name
  120704. * @param scene The scene the material will be use in.
  120705. */
  120706. constructor(name: string, scene: Scene);
  120707. /**
  120708. * Return the currrent class name of the material.
  120709. */
  120710. getClassName(): string;
  120711. /**
  120712. * Makes a duplicate of the current material.
  120713. * @param name - name to use for the new material.
  120714. */
  120715. clone(name: string): PBRMetallicRoughnessMaterial;
  120716. /**
  120717. * Serialize the material to a parsable JSON object.
  120718. */
  120719. serialize(): any;
  120720. /**
  120721. * Parses a JSON object correponding to the serialize function.
  120722. */
  120723. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  120724. }
  120725. }
  120726. declare module BABYLON {
  120727. /**
  120728. * The PBR material of BJS following the specular glossiness convention.
  120729. *
  120730. * This fits to the PBR convention in the GLTF definition:
  120731. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  120732. */
  120733. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  120734. /**
  120735. * Specifies the diffuse color of the material.
  120736. */
  120737. diffuseColor: Color3;
  120738. /**
  120739. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  120740. * channel.
  120741. */
  120742. diffuseTexture: BaseTexture;
  120743. /**
  120744. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  120745. */
  120746. specularColor: Color3;
  120747. /**
  120748. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  120749. */
  120750. glossiness: number;
  120751. /**
  120752. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  120753. */
  120754. specularGlossinessTexture: BaseTexture;
  120755. /**
  120756. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  120757. *
  120758. * @param name The material name
  120759. * @param scene The scene the material will be use in.
  120760. */
  120761. constructor(name: string, scene: Scene);
  120762. /**
  120763. * Return the currrent class name of the material.
  120764. */
  120765. getClassName(): string;
  120766. /**
  120767. * Makes a duplicate of the current material.
  120768. * @param name - name to use for the new material.
  120769. */
  120770. clone(name: string): PBRSpecularGlossinessMaterial;
  120771. /**
  120772. * Serialize the material to a parsable JSON object.
  120773. */
  120774. serialize(): any;
  120775. /**
  120776. * Parses a JSON object correponding to the serialize function.
  120777. */
  120778. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  120779. }
  120780. }
  120781. declare module BABYLON {
  120782. /**
  120783. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  120784. * It can help converting any input color in a desired output one. This can then be used to create effects
  120785. * from sepia, black and white to sixties or futuristic rendering...
  120786. *
  120787. * The only supported format is currently 3dl.
  120788. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  120789. */
  120790. export class ColorGradingTexture extends BaseTexture {
  120791. /**
  120792. * The current texture matrix. (will always be identity in color grading texture)
  120793. */
  120794. private _textureMatrix;
  120795. /**
  120796. * The texture URL.
  120797. */
  120798. url: string;
  120799. /**
  120800. * Empty line regex stored for GC.
  120801. */
  120802. private static _noneEmptyLineRegex;
  120803. private _engine;
  120804. /**
  120805. * Instantiates a ColorGradingTexture from the following parameters.
  120806. *
  120807. * @param url The location of the color gradind data (currently only supporting 3dl)
  120808. * @param scene The scene the texture will be used in
  120809. */
  120810. constructor(url: string, scene: Scene);
  120811. /**
  120812. * Returns the texture matrix used in most of the material.
  120813. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  120814. */
  120815. getTextureMatrix(): Matrix;
  120816. /**
  120817. * Occurs when the file being loaded is a .3dl LUT file.
  120818. */
  120819. private load3dlTexture;
  120820. /**
  120821. * Starts the loading process of the texture.
  120822. */
  120823. private loadTexture;
  120824. /**
  120825. * Clones the color gradind texture.
  120826. */
  120827. clone(): ColorGradingTexture;
  120828. /**
  120829. * Called during delayed load for textures.
  120830. */
  120831. delayLoad(): void;
  120832. /**
  120833. * Parses a color grading texture serialized by Babylon.
  120834. * @param parsedTexture The texture information being parsedTexture
  120835. * @param scene The scene to load the texture in
  120836. * @param rootUrl The root url of the data assets to load
  120837. * @return A color gradind texture
  120838. */
  120839. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  120840. /**
  120841. * Serializes the LUT texture to json format.
  120842. */
  120843. serialize(): any;
  120844. }
  120845. }
  120846. declare module BABYLON {
  120847. /**
  120848. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  120849. */
  120850. export class EquiRectangularCubeTexture extends BaseTexture {
  120851. /** The six faces of the cube. */
  120852. private static _FacesMapping;
  120853. private _noMipmap;
  120854. private _onLoad;
  120855. private _onError;
  120856. /** The size of the cubemap. */
  120857. private _size;
  120858. /** The buffer of the image. */
  120859. private _buffer;
  120860. /** The width of the input image. */
  120861. private _width;
  120862. /** The height of the input image. */
  120863. private _height;
  120864. /** The URL to the image. */
  120865. url: string;
  120866. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  120867. coordinatesMode: number;
  120868. /**
  120869. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  120870. * @param url The location of the image
  120871. * @param scene The scene the texture will be used in
  120872. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120873. * @param noMipmap Forces to not generate the mipmap if true
  120874. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120875. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120876. * @param onLoad — defines a callback called when texture is loaded
  120877. * @param onError — defines a callback called if there is an error
  120878. */
  120879. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  120880. /**
  120881. * Load the image data, by putting the image on a canvas and extracting its buffer.
  120882. */
  120883. private loadImage;
  120884. /**
  120885. * Convert the image buffer into a cubemap and create a CubeTexture.
  120886. */
  120887. private loadTexture;
  120888. /**
  120889. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  120890. * @param buffer The ArrayBuffer that should be converted.
  120891. * @returns The buffer as Float32Array.
  120892. */
  120893. private getFloat32ArrayFromArrayBuffer;
  120894. /**
  120895. * Get the current class name of the texture useful for serialization or dynamic coding.
  120896. * @returns "EquiRectangularCubeTexture"
  120897. */
  120898. getClassName(): string;
  120899. /**
  120900. * Create a clone of the current EquiRectangularCubeTexture and return it.
  120901. * @returns A clone of the current EquiRectangularCubeTexture.
  120902. */
  120903. clone(): EquiRectangularCubeTexture;
  120904. }
  120905. }
  120906. declare module BABYLON {
  120907. /**
  120908. * Based on jsTGALoader - Javascript loader for TGA file
  120909. * By Vincent Thibault
  120910. * @see http://blog.robrowser.com/javascript-tga-loader.html
  120911. */
  120912. export class TGATools {
  120913. private static _TYPE_INDEXED;
  120914. private static _TYPE_RGB;
  120915. private static _TYPE_GREY;
  120916. private static _TYPE_RLE_INDEXED;
  120917. private static _TYPE_RLE_RGB;
  120918. private static _TYPE_RLE_GREY;
  120919. private static _ORIGIN_MASK;
  120920. private static _ORIGIN_SHIFT;
  120921. private static _ORIGIN_BL;
  120922. private static _ORIGIN_BR;
  120923. private static _ORIGIN_UL;
  120924. private static _ORIGIN_UR;
  120925. /**
  120926. * Gets the header of a TGA file
  120927. * @param data defines the TGA data
  120928. * @returns the header
  120929. */
  120930. static GetTGAHeader(data: Uint8Array): any;
  120931. /**
  120932. * Uploads TGA content to a Babylon Texture
  120933. * @hidden
  120934. */
  120935. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  120936. /** @hidden */
  120937. 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;
  120938. /** @hidden */
  120939. 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;
  120940. /** @hidden */
  120941. 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;
  120942. /** @hidden */
  120943. 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;
  120944. /** @hidden */
  120945. 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;
  120946. /** @hidden */
  120947. 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;
  120948. }
  120949. }
  120950. declare module BABYLON {
  120951. /**
  120952. * Implementation of the TGA Texture Loader.
  120953. * @hidden
  120954. */
  120955. export class _TGATextureLoader implements IInternalTextureLoader {
  120956. /**
  120957. * Defines wether the loader supports cascade loading the different faces.
  120958. */
  120959. readonly supportCascades: boolean;
  120960. /**
  120961. * This returns if the loader support the current file information.
  120962. * @param extension defines the file extension of the file being loaded
  120963. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120964. * @param fallback defines the fallback internal texture if any
  120965. * @param isBase64 defines whether the texture is encoded as a base64
  120966. * @param isBuffer defines whether the texture data are stored as a buffer
  120967. * @returns true if the loader can load the specified file
  120968. */
  120969. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120970. /**
  120971. * Transform the url before loading if required.
  120972. * @param rootUrl the url of the texture
  120973. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120974. * @returns the transformed texture
  120975. */
  120976. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120977. /**
  120978. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120979. * @param rootUrl the url of the texture
  120980. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120981. * @returns the fallback texture
  120982. */
  120983. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120984. /**
  120985. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120986. * @param data contains the texture data
  120987. * @param texture defines the BabylonJS internal texture
  120988. * @param createPolynomials will be true if polynomials have been requested
  120989. * @param onLoad defines the callback to trigger once the texture is ready
  120990. * @param onError defines the callback to trigger in case of error
  120991. */
  120992. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120993. /**
  120994. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120995. * @param data contains the texture data
  120996. * @param texture defines the BabylonJS internal texture
  120997. * @param callback defines the method to call once ready to upload
  120998. */
  120999. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121000. }
  121001. }
  121002. declare module BABYLON {
  121003. /**
  121004. * Info about the .basis files
  121005. */
  121006. class BasisFileInfo {
  121007. /**
  121008. * If the file has alpha
  121009. */
  121010. hasAlpha: boolean;
  121011. /**
  121012. * Info about each image of the basis file
  121013. */
  121014. images: Array<{
  121015. levels: Array<{
  121016. width: number;
  121017. height: number;
  121018. transcodedPixels: ArrayBufferView;
  121019. }>;
  121020. }>;
  121021. }
  121022. /**
  121023. * Result of transcoding a basis file
  121024. */
  121025. class TranscodeResult {
  121026. /**
  121027. * Info about the .basis file
  121028. */
  121029. fileInfo: BasisFileInfo;
  121030. /**
  121031. * Format to use when loading the file
  121032. */
  121033. format: number;
  121034. }
  121035. /**
  121036. * Configuration options for the Basis transcoder
  121037. */
  121038. export class BasisTranscodeConfiguration {
  121039. /**
  121040. * Supported compression formats used to determine the supported output format of the transcoder
  121041. */
  121042. supportedCompressionFormats?: {
  121043. /**
  121044. * etc1 compression format
  121045. */
  121046. etc1?: boolean;
  121047. /**
  121048. * s3tc compression format
  121049. */
  121050. s3tc?: boolean;
  121051. /**
  121052. * pvrtc compression format
  121053. */
  121054. pvrtc?: boolean;
  121055. /**
  121056. * etc2 compression format
  121057. */
  121058. etc2?: boolean;
  121059. };
  121060. /**
  121061. * If mipmap levels should be loaded for transcoded images (Default: true)
  121062. */
  121063. loadMipmapLevels?: boolean;
  121064. /**
  121065. * Index of a single image to load (Default: all images)
  121066. */
  121067. loadSingleImage?: number;
  121068. }
  121069. /**
  121070. * Used to load .Basis files
  121071. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  121072. */
  121073. export class BasisTools {
  121074. private static _IgnoreSupportedFormats;
  121075. /**
  121076. * URL to use when loading the basis transcoder
  121077. */
  121078. static JSModuleURL: string;
  121079. /**
  121080. * URL to use when loading the wasm module for the transcoder
  121081. */
  121082. static WasmModuleURL: string;
  121083. /**
  121084. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  121085. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  121086. * @returns internal format corresponding to the Basis format
  121087. */
  121088. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  121089. private static _WorkerPromise;
  121090. private static _Worker;
  121091. private static _actionId;
  121092. private static _CreateWorkerAsync;
  121093. /**
  121094. * Transcodes a loaded image file to compressed pixel data
  121095. * @param imageData image data to transcode
  121096. * @param config configuration options for the transcoding
  121097. * @returns a promise resulting in the transcoded image
  121098. */
  121099. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  121100. /**
  121101. * Loads a texture from the transcode result
  121102. * @param texture texture load to
  121103. * @param transcodeResult the result of transcoding the basis file to load from
  121104. */
  121105. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  121106. }
  121107. }
  121108. declare module BABYLON {
  121109. /**
  121110. * Loader for .basis file format
  121111. */
  121112. export class _BasisTextureLoader implements IInternalTextureLoader {
  121113. /**
  121114. * Defines whether the loader supports cascade loading the different faces.
  121115. */
  121116. readonly supportCascades: boolean;
  121117. /**
  121118. * This returns if the loader support the current file information.
  121119. * @param extension defines the file extension of the file being loaded
  121120. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121121. * @param fallback defines the fallback internal texture if any
  121122. * @param isBase64 defines whether the texture is encoded as a base64
  121123. * @param isBuffer defines whether the texture data are stored as a buffer
  121124. * @returns true if the loader can load the specified file
  121125. */
  121126. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121127. /**
  121128. * Transform the url before loading if required.
  121129. * @param rootUrl the url of the texture
  121130. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121131. * @returns the transformed texture
  121132. */
  121133. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121134. /**
  121135. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121136. * @param rootUrl the url of the texture
  121137. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121138. * @returns the fallback texture
  121139. */
  121140. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121141. /**
  121142. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  121143. * @param data contains the texture data
  121144. * @param texture defines the BabylonJS internal texture
  121145. * @param createPolynomials will be true if polynomials have been requested
  121146. * @param onLoad defines the callback to trigger once the texture is ready
  121147. * @param onError defines the callback to trigger in case of error
  121148. */
  121149. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121150. /**
  121151. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121152. * @param data contains the texture data
  121153. * @param texture defines the BabylonJS internal texture
  121154. * @param callback defines the method to call once ready to upload
  121155. */
  121156. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121157. }
  121158. }
  121159. declare module BABYLON {
  121160. /**
  121161. * 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.
  121162. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121163. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121164. */
  121165. export class CustomProceduralTexture extends ProceduralTexture {
  121166. private _animate;
  121167. private _time;
  121168. private _config;
  121169. private _texturePath;
  121170. /**
  121171. * Instantiates a new Custom Procedural Texture.
  121172. * 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.
  121173. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121174. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121175. * @param name Define the name of the texture
  121176. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  121177. * @param size Define the size of the texture to create
  121178. * @param scene Define the scene the texture belongs to
  121179. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  121180. * @param generateMipMaps Define if the texture should creates mip maps or not
  121181. */
  121182. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121183. private _loadJson;
  121184. /**
  121185. * Is the texture ready to be used ? (rendered at least once)
  121186. * @returns true if ready, otherwise, false.
  121187. */
  121188. isReady(): boolean;
  121189. /**
  121190. * Render the texture to its associated render target.
  121191. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  121192. */
  121193. render(useCameraPostProcess?: boolean): void;
  121194. /**
  121195. * Update the list of dependant textures samplers in the shader.
  121196. */
  121197. updateTextures(): void;
  121198. /**
  121199. * Update the uniform values of the procedural texture in the shader.
  121200. */
  121201. updateShaderUniforms(): void;
  121202. /**
  121203. * Define if the texture animates or not.
  121204. */
  121205. animate: boolean;
  121206. }
  121207. }
  121208. declare module BABYLON {
  121209. /** @hidden */
  121210. export var noisePixelShader: {
  121211. name: string;
  121212. shader: string;
  121213. };
  121214. }
  121215. declare module BABYLON {
  121216. /**
  121217. * Class used to generate noise procedural textures
  121218. */
  121219. export class NoiseProceduralTexture extends ProceduralTexture {
  121220. private _time;
  121221. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  121222. brightness: number;
  121223. /** Defines the number of octaves to process */
  121224. octaves: number;
  121225. /** Defines the level of persistence (0.8 by default) */
  121226. persistence: number;
  121227. /** Gets or sets animation speed factor (default is 1) */
  121228. animationSpeedFactor: number;
  121229. /**
  121230. * Creates a new NoiseProceduralTexture
  121231. * @param name defines the name fo the texture
  121232. * @param size defines the size of the texture (default is 256)
  121233. * @param scene defines the hosting scene
  121234. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  121235. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  121236. */
  121237. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121238. private _updateShaderUniforms;
  121239. protected _getDefines(): string;
  121240. /** Generate the current state of the procedural texture */
  121241. render(useCameraPostProcess?: boolean): void;
  121242. /**
  121243. * Serializes this noise procedural texture
  121244. * @returns a serialized noise procedural texture object
  121245. */
  121246. serialize(): any;
  121247. /**
  121248. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  121249. * @param parsedTexture defines parsed texture data
  121250. * @param scene defines the current scene
  121251. * @param rootUrl defines the root URL containing noise procedural texture information
  121252. * @returns a parsed NoiseProceduralTexture
  121253. */
  121254. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  121255. }
  121256. }
  121257. declare module BABYLON {
  121258. /**
  121259. * Raw cube texture where the raw buffers are passed in
  121260. */
  121261. export class RawCubeTexture extends CubeTexture {
  121262. /**
  121263. * Creates a cube texture where the raw buffers are passed in.
  121264. * @param scene defines the scene the texture is attached to
  121265. * @param data defines the array of data to use to create each face
  121266. * @param size defines the size of the textures
  121267. * @param format defines the format of the data
  121268. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  121269. * @param generateMipMaps defines if the engine should generate the mip levels
  121270. * @param invertY defines if data must be stored with Y axis inverted
  121271. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  121272. * @param compression defines the compression used (null by default)
  121273. */
  121274. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  121275. /**
  121276. * Updates the raw cube texture.
  121277. * @param data defines the data to store
  121278. * @param format defines the data format
  121279. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121280. * @param invertY defines if data must be stored with Y axis inverted
  121281. * @param compression defines the compression used (null by default)
  121282. * @param level defines which level of the texture to update
  121283. */
  121284. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  121285. /**
  121286. * Updates a raw cube texture with RGBD encoded data.
  121287. * @param data defines the array of data [mipmap][face] to use to create each face
  121288. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  121289. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121290. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121291. * @returns a promsie that resolves when the operation is complete
  121292. */
  121293. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  121294. /**
  121295. * Clones the raw cube texture.
  121296. * @return a new cube texture
  121297. */
  121298. clone(): CubeTexture;
  121299. /** @hidden */
  121300. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121301. }
  121302. }
  121303. declare module BABYLON {
  121304. /**
  121305. * Class used to store 3D textures containing user data
  121306. */
  121307. export class RawTexture3D extends Texture {
  121308. /** Gets or sets the texture format to use */
  121309. format: number;
  121310. private _engine;
  121311. /**
  121312. * Create a new RawTexture3D
  121313. * @param data defines the data of the texture
  121314. * @param width defines the width of the texture
  121315. * @param height defines the height of the texture
  121316. * @param depth defines the depth of the texture
  121317. * @param format defines the texture format to use
  121318. * @param scene defines the hosting scene
  121319. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121320. * @param invertY defines if texture must be stored with Y axis inverted
  121321. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121322. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121323. */
  121324. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121325. /** Gets or sets the texture format to use */
  121326. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121327. /**
  121328. * Update the texture with new data
  121329. * @param data defines the data to store in the texture
  121330. */
  121331. update(data: ArrayBufferView): void;
  121332. }
  121333. }
  121334. declare module BABYLON {
  121335. /**
  121336. * Class used to store 2D array textures containing user data
  121337. */
  121338. export class RawTexture2DArray extends Texture {
  121339. /** Gets or sets the texture format to use */
  121340. format: number;
  121341. private _engine;
  121342. /**
  121343. * Create a new RawTexture2DArray
  121344. * @param data defines the data of the texture
  121345. * @param width defines the width of the texture
  121346. * @param height defines the height of the texture
  121347. * @param depth defines the number of layers of the texture
  121348. * @param format defines the texture format to use
  121349. * @param scene defines the hosting scene
  121350. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121351. * @param invertY defines if texture must be stored with Y axis inverted
  121352. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121353. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121354. */
  121355. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121356. /** Gets or sets the texture format to use */
  121357. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121358. /**
  121359. * Update the texture with new data
  121360. * @param data defines the data to store in the texture
  121361. */
  121362. update(data: ArrayBufferView): void;
  121363. }
  121364. }
  121365. declare module BABYLON {
  121366. /**
  121367. * Creates a refraction texture used by refraction channel of the standard material.
  121368. * It is like a mirror but to see through a material.
  121369. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121370. */
  121371. export class RefractionTexture extends RenderTargetTexture {
  121372. /**
  121373. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  121374. * 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.
  121375. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121376. */
  121377. refractionPlane: Plane;
  121378. /**
  121379. * Define how deep under the surface we should see.
  121380. */
  121381. depth: number;
  121382. /**
  121383. * Creates a refraction texture used by refraction channel of the standard material.
  121384. * It is like a mirror but to see through a material.
  121385. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121386. * @param name Define the texture name
  121387. * @param size Define the size of the underlying texture
  121388. * @param scene Define the scene the refraction belongs to
  121389. * @param generateMipMaps Define if we need to generate mips level for the refraction
  121390. */
  121391. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  121392. /**
  121393. * Clone the refraction texture.
  121394. * @returns the cloned texture
  121395. */
  121396. clone(): RefractionTexture;
  121397. /**
  121398. * Serialize the texture to a JSON representation you could use in Parse later on
  121399. * @returns the serialized JSON representation
  121400. */
  121401. serialize(): any;
  121402. }
  121403. }
  121404. declare module BABYLON {
  121405. /**
  121406. * Defines the options related to the creation of an HtmlElementTexture
  121407. */
  121408. export interface IHtmlElementTextureOptions {
  121409. /**
  121410. * Defines wether mip maps should be created or not.
  121411. */
  121412. generateMipMaps?: boolean;
  121413. /**
  121414. * Defines the sampling mode of the texture.
  121415. */
  121416. samplingMode?: number;
  121417. /**
  121418. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  121419. */
  121420. engine: Nullable<ThinEngine>;
  121421. /**
  121422. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  121423. */
  121424. scene: Nullable<Scene>;
  121425. }
  121426. /**
  121427. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  121428. * To be as efficient as possible depending on your constraints nothing aside the first upload
  121429. * is automatically managed.
  121430. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  121431. * in your application.
  121432. *
  121433. * As the update is not automatic, you need to call them manually.
  121434. */
  121435. export class HtmlElementTexture extends BaseTexture {
  121436. /**
  121437. * The texture URL.
  121438. */
  121439. element: HTMLVideoElement | HTMLCanvasElement;
  121440. private static readonly DefaultOptions;
  121441. private _textureMatrix;
  121442. private _engine;
  121443. private _isVideo;
  121444. private _generateMipMaps;
  121445. private _samplingMode;
  121446. /**
  121447. * Instantiates a HtmlElementTexture from the following parameters.
  121448. *
  121449. * @param name Defines the name of the texture
  121450. * @param element Defines the video or canvas the texture is filled with
  121451. * @param options Defines the other none mandatory texture creation options
  121452. */
  121453. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  121454. private _createInternalTexture;
  121455. /**
  121456. * Returns the texture matrix used in most of the material.
  121457. */
  121458. getTextureMatrix(): Matrix;
  121459. /**
  121460. * Updates the content of the texture.
  121461. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  121462. */
  121463. update(invertY?: Nullable<boolean>): void;
  121464. }
  121465. }
  121466. declare module BABYLON {
  121467. /**
  121468. * Enum used to define the target of a block
  121469. */
  121470. export enum NodeMaterialBlockTargets {
  121471. /** Vertex shader */
  121472. Vertex = 1,
  121473. /** Fragment shader */
  121474. Fragment = 2,
  121475. /** Neutral */
  121476. Neutral = 4,
  121477. /** Vertex and Fragment */
  121478. VertexAndFragment = 3
  121479. }
  121480. }
  121481. declare module BABYLON {
  121482. /**
  121483. * Defines the kind of connection point for node based material
  121484. */
  121485. export enum NodeMaterialBlockConnectionPointTypes {
  121486. /** Float */
  121487. Float = 1,
  121488. /** Int */
  121489. Int = 2,
  121490. /** Vector2 */
  121491. Vector2 = 4,
  121492. /** Vector3 */
  121493. Vector3 = 8,
  121494. /** Vector4 */
  121495. Vector4 = 16,
  121496. /** Color3 */
  121497. Color3 = 32,
  121498. /** Color4 */
  121499. Color4 = 64,
  121500. /** Matrix */
  121501. Matrix = 128,
  121502. /** Detect type based on connection */
  121503. AutoDetect = 1024,
  121504. /** Output type that will be defined by input type */
  121505. BasedOnInput = 2048
  121506. }
  121507. }
  121508. declare module BABYLON {
  121509. /**
  121510. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  121511. */
  121512. export enum NodeMaterialBlockConnectionPointMode {
  121513. /** Value is an uniform */
  121514. Uniform = 0,
  121515. /** Value is a mesh attribute */
  121516. Attribute = 1,
  121517. /** Value is a varying between vertex and fragment shaders */
  121518. Varying = 2,
  121519. /** Mode is undefined */
  121520. Undefined = 3
  121521. }
  121522. }
  121523. declare module BABYLON {
  121524. /**
  121525. * Enum used to define system values e.g. values automatically provided by the system
  121526. */
  121527. export enum NodeMaterialSystemValues {
  121528. /** World */
  121529. World = 1,
  121530. /** View */
  121531. View = 2,
  121532. /** Projection */
  121533. Projection = 3,
  121534. /** ViewProjection */
  121535. ViewProjection = 4,
  121536. /** WorldView */
  121537. WorldView = 5,
  121538. /** WorldViewProjection */
  121539. WorldViewProjection = 6,
  121540. /** CameraPosition */
  121541. CameraPosition = 7,
  121542. /** Fog Color */
  121543. FogColor = 8,
  121544. /** Delta time */
  121545. DeltaTime = 9
  121546. }
  121547. }
  121548. declare module BABYLON {
  121549. /**
  121550. * Root class for all node material optimizers
  121551. */
  121552. export class NodeMaterialOptimizer {
  121553. /**
  121554. * Function used to optimize a NodeMaterial graph
  121555. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  121556. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  121557. */
  121558. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  121559. }
  121560. }
  121561. declare module BABYLON {
  121562. /**
  121563. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  121564. */
  121565. export class TransformBlock extends NodeMaterialBlock {
  121566. /**
  121567. * Defines the value to use to complement W value to transform it to a Vector4
  121568. */
  121569. complementW: number;
  121570. /**
  121571. * Defines the value to use to complement z value to transform it to a Vector4
  121572. */
  121573. complementZ: number;
  121574. /**
  121575. * Creates a new TransformBlock
  121576. * @param name defines the block name
  121577. */
  121578. constructor(name: string);
  121579. /**
  121580. * Gets the current class name
  121581. * @returns the class name
  121582. */
  121583. getClassName(): string;
  121584. /**
  121585. * Gets the vector input
  121586. */
  121587. readonly vector: NodeMaterialConnectionPoint;
  121588. /**
  121589. * Gets the output component
  121590. */
  121591. readonly output: NodeMaterialConnectionPoint;
  121592. /**
  121593. * Gets the matrix transform input
  121594. */
  121595. readonly transform: NodeMaterialConnectionPoint;
  121596. protected _buildBlock(state: NodeMaterialBuildState): this;
  121597. serialize(): any;
  121598. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121599. protected _dumpPropertiesCode(): string;
  121600. }
  121601. }
  121602. declare module BABYLON {
  121603. /**
  121604. * Block used to output the vertex position
  121605. */
  121606. export class VertexOutputBlock extends NodeMaterialBlock {
  121607. /**
  121608. * Creates a new VertexOutputBlock
  121609. * @param name defines the block name
  121610. */
  121611. constructor(name: string);
  121612. /**
  121613. * Gets the current class name
  121614. * @returns the class name
  121615. */
  121616. getClassName(): string;
  121617. /**
  121618. * Gets the vector input component
  121619. */
  121620. readonly vector: NodeMaterialConnectionPoint;
  121621. protected _buildBlock(state: NodeMaterialBuildState): this;
  121622. }
  121623. }
  121624. declare module BABYLON {
  121625. /**
  121626. * Block used to output the final color
  121627. */
  121628. export class FragmentOutputBlock extends NodeMaterialBlock {
  121629. /**
  121630. * Create a new FragmentOutputBlock
  121631. * @param name defines the block name
  121632. */
  121633. constructor(name: string);
  121634. /**
  121635. * Gets the current class name
  121636. * @returns the class name
  121637. */
  121638. getClassName(): string;
  121639. /**
  121640. * Gets the rgba input component
  121641. */
  121642. readonly rgba: NodeMaterialConnectionPoint;
  121643. /**
  121644. * Gets the rgb input component
  121645. */
  121646. readonly rgb: NodeMaterialConnectionPoint;
  121647. /**
  121648. * Gets the a input component
  121649. */
  121650. readonly a: NodeMaterialConnectionPoint;
  121651. protected _buildBlock(state: NodeMaterialBuildState): this;
  121652. }
  121653. }
  121654. declare module BABYLON {
  121655. /**
  121656. * Block used to read a reflection texture from a sampler
  121657. */
  121658. export class ReflectionTextureBlock extends NodeMaterialBlock {
  121659. private _define3DName;
  121660. private _defineCubicName;
  121661. private _defineExplicitName;
  121662. private _defineProjectionName;
  121663. private _defineLocalCubicName;
  121664. private _defineSphericalName;
  121665. private _definePlanarName;
  121666. private _defineEquirectangularName;
  121667. private _defineMirroredEquirectangularFixedName;
  121668. private _defineEquirectangularFixedName;
  121669. private _defineSkyboxName;
  121670. private _cubeSamplerName;
  121671. private _2DSamplerName;
  121672. private _positionUVWName;
  121673. private _directionWName;
  121674. private _reflectionCoordsName;
  121675. private _reflection2DCoordsName;
  121676. private _reflectionColorName;
  121677. private _reflectionMatrixName;
  121678. /**
  121679. * Gets or sets the texture associated with the node
  121680. */
  121681. texture: Nullable<BaseTexture>;
  121682. /**
  121683. * Create a new TextureBlock
  121684. * @param name defines the block name
  121685. */
  121686. constructor(name: string);
  121687. /**
  121688. * Gets the current class name
  121689. * @returns the class name
  121690. */
  121691. getClassName(): string;
  121692. /**
  121693. * Gets the world position input component
  121694. */
  121695. readonly position: NodeMaterialConnectionPoint;
  121696. /**
  121697. * Gets the world position input component
  121698. */
  121699. readonly worldPosition: NodeMaterialConnectionPoint;
  121700. /**
  121701. * Gets the world normal input component
  121702. */
  121703. readonly worldNormal: NodeMaterialConnectionPoint;
  121704. /**
  121705. * Gets the world input component
  121706. */
  121707. readonly world: NodeMaterialConnectionPoint;
  121708. /**
  121709. * Gets the camera (or eye) position component
  121710. */
  121711. readonly cameraPosition: NodeMaterialConnectionPoint;
  121712. /**
  121713. * Gets the view input component
  121714. */
  121715. readonly view: NodeMaterialConnectionPoint;
  121716. /**
  121717. * Gets the rgb output component
  121718. */
  121719. readonly rgb: NodeMaterialConnectionPoint;
  121720. /**
  121721. * Gets the r output component
  121722. */
  121723. readonly r: NodeMaterialConnectionPoint;
  121724. /**
  121725. * Gets the g output component
  121726. */
  121727. readonly g: NodeMaterialConnectionPoint;
  121728. /**
  121729. * Gets the b output component
  121730. */
  121731. readonly b: NodeMaterialConnectionPoint;
  121732. autoConfigure(material: NodeMaterial): void;
  121733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121734. isReady(): boolean;
  121735. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121736. private _injectVertexCode;
  121737. private _writeOutput;
  121738. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121739. protected _dumpPropertiesCode(): string;
  121740. serialize(): any;
  121741. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121742. }
  121743. }
  121744. declare module BABYLON {
  121745. /**
  121746. * Interface used to configure the node material editor
  121747. */
  121748. export interface INodeMaterialEditorOptions {
  121749. /** Define the URl to load node editor script */
  121750. editorURL?: string;
  121751. }
  121752. /** @hidden */
  121753. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  121754. /** BONES */
  121755. NUM_BONE_INFLUENCERS: number;
  121756. BonesPerMesh: number;
  121757. BONETEXTURE: boolean;
  121758. /** MORPH TARGETS */
  121759. MORPHTARGETS: boolean;
  121760. MORPHTARGETS_NORMAL: boolean;
  121761. MORPHTARGETS_TANGENT: boolean;
  121762. MORPHTARGETS_UV: boolean;
  121763. NUM_MORPH_INFLUENCERS: number;
  121764. /** IMAGE PROCESSING */
  121765. IMAGEPROCESSING: boolean;
  121766. VIGNETTE: boolean;
  121767. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121768. VIGNETTEBLENDMODEOPAQUE: boolean;
  121769. TONEMAPPING: boolean;
  121770. TONEMAPPING_ACES: boolean;
  121771. CONTRAST: boolean;
  121772. EXPOSURE: boolean;
  121773. COLORCURVES: boolean;
  121774. COLORGRADING: boolean;
  121775. COLORGRADING3D: boolean;
  121776. SAMPLER3DGREENDEPTH: boolean;
  121777. SAMPLER3DBGRMAP: boolean;
  121778. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121779. /** MISC. */
  121780. BUMPDIRECTUV: number;
  121781. constructor();
  121782. setValue(name: string, value: boolean): void;
  121783. }
  121784. /**
  121785. * Class used to configure NodeMaterial
  121786. */
  121787. export interface INodeMaterialOptions {
  121788. /**
  121789. * Defines if blocks should emit comments
  121790. */
  121791. emitComments: boolean;
  121792. }
  121793. /**
  121794. * Class used to create a node based material built by assembling shader blocks
  121795. */
  121796. export class NodeMaterial extends PushMaterial {
  121797. private static _BuildIdGenerator;
  121798. private _options;
  121799. private _vertexCompilationState;
  121800. private _fragmentCompilationState;
  121801. private _sharedData;
  121802. private _buildId;
  121803. private _buildWasSuccessful;
  121804. private _cachedWorldViewMatrix;
  121805. private _cachedWorldViewProjectionMatrix;
  121806. private _optimizers;
  121807. private _animationFrame;
  121808. /** Define the URl to load node editor script */
  121809. static EditorURL: string;
  121810. private BJSNODEMATERIALEDITOR;
  121811. /** Get the inspector from bundle or global */
  121812. private _getGlobalNodeMaterialEditor;
  121813. /**
  121814. * 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)
  121815. */
  121816. ignoreAlpha: boolean;
  121817. /**
  121818. * Defines the maximum number of lights that can be used in the material
  121819. */
  121820. maxSimultaneousLights: number;
  121821. /**
  121822. * Observable raised when the material is built
  121823. */
  121824. onBuildObservable: Observable<NodeMaterial>;
  121825. /**
  121826. * Gets or sets the root nodes of the material vertex shader
  121827. */
  121828. _vertexOutputNodes: NodeMaterialBlock[];
  121829. /**
  121830. * Gets or sets the root nodes of the material fragment (pixel) shader
  121831. */
  121832. _fragmentOutputNodes: NodeMaterialBlock[];
  121833. /** Gets or sets options to control the node material overall behavior */
  121834. options: INodeMaterialOptions;
  121835. /**
  121836. * Default configuration related to image processing available in the standard Material.
  121837. */
  121838. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121839. /**
  121840. * Gets the image processing configuration used either in this material.
  121841. */
  121842. /**
  121843. * Sets the Default image processing configuration used either in the this material.
  121844. *
  121845. * If sets to null, the scene one is in use.
  121846. */
  121847. imageProcessingConfiguration: ImageProcessingConfiguration;
  121848. /**
  121849. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  121850. */
  121851. attachedBlocks: NodeMaterialBlock[];
  121852. /**
  121853. * Create a new node based material
  121854. * @param name defines the material name
  121855. * @param scene defines the hosting scene
  121856. * @param options defines creation option
  121857. */
  121858. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  121859. /**
  121860. * Gets the current class name of the material e.g. "NodeMaterial"
  121861. * @returns the class name
  121862. */
  121863. getClassName(): string;
  121864. /**
  121865. * Keep track of the image processing observer to allow dispose and replace.
  121866. */
  121867. private _imageProcessingObserver;
  121868. /**
  121869. * Attaches a new image processing configuration to the Standard Material.
  121870. * @param configuration
  121871. */
  121872. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121873. /**
  121874. * Get a block by its name
  121875. * @param name defines the name of the block to retrieve
  121876. * @returns the required block or null if not found
  121877. */
  121878. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  121879. /**
  121880. * Get a block by its name
  121881. * @param predicate defines the predicate used to find the good candidate
  121882. * @returns the required block or null if not found
  121883. */
  121884. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  121885. /**
  121886. * Get an input block by its name
  121887. * @param predicate defines the predicate used to find the good candidate
  121888. * @returns the required input block or null if not found
  121889. */
  121890. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  121891. /**
  121892. * Gets the list of input blocks attached to this material
  121893. * @returns an array of InputBlocks
  121894. */
  121895. getInputBlocks(): InputBlock[];
  121896. /**
  121897. * Adds a new optimizer to the list of optimizers
  121898. * @param optimizer defines the optimizers to add
  121899. * @returns the current material
  121900. */
  121901. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121902. /**
  121903. * Remove an optimizer from the list of optimizers
  121904. * @param optimizer defines the optimizers to remove
  121905. * @returns the current material
  121906. */
  121907. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121908. /**
  121909. * Add a new block to the list of output nodes
  121910. * @param node defines the node to add
  121911. * @returns the current material
  121912. */
  121913. addOutputNode(node: NodeMaterialBlock): this;
  121914. /**
  121915. * Remove a block from the list of root nodes
  121916. * @param node defines the node to remove
  121917. * @returns the current material
  121918. */
  121919. removeOutputNode(node: NodeMaterialBlock): this;
  121920. private _addVertexOutputNode;
  121921. private _removeVertexOutputNode;
  121922. private _addFragmentOutputNode;
  121923. private _removeFragmentOutputNode;
  121924. /**
  121925. * Specifies if the material will require alpha blending
  121926. * @returns a boolean specifying if alpha blending is needed
  121927. */
  121928. needAlphaBlending(): boolean;
  121929. /**
  121930. * Specifies if this material should be rendered in alpha test mode
  121931. * @returns a boolean specifying if an alpha test is needed.
  121932. */
  121933. needAlphaTesting(): boolean;
  121934. private _initializeBlock;
  121935. private _resetDualBlocks;
  121936. /**
  121937. * Build the material and generates the inner effect
  121938. * @param verbose defines if the build should log activity
  121939. */
  121940. build(verbose?: boolean): void;
  121941. /**
  121942. * Runs an otpimization phase to try to improve the shader code
  121943. */
  121944. optimize(): void;
  121945. private _prepareDefinesForAttributes;
  121946. /**
  121947. * Get if the submesh is ready to be used and all its information available.
  121948. * Child classes can use it to update shaders
  121949. * @param mesh defines the mesh to check
  121950. * @param subMesh defines which submesh to check
  121951. * @param useInstances specifies that instances should be used
  121952. * @returns a boolean indicating that the submesh is ready or not
  121953. */
  121954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121955. /**
  121956. * Get a string representing the shaders built by the current node graph
  121957. */
  121958. readonly compiledShaders: string;
  121959. /**
  121960. * Binds the world matrix to the material
  121961. * @param world defines the world transformation matrix
  121962. */
  121963. bindOnlyWorldMatrix(world: Matrix): void;
  121964. /**
  121965. * Binds the submesh to this material by preparing the effect and shader to draw
  121966. * @param world defines the world transformation matrix
  121967. * @param mesh defines the mesh containing the submesh
  121968. * @param subMesh defines the submesh to bind the material to
  121969. */
  121970. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121971. /**
  121972. * Gets the active textures from the material
  121973. * @returns an array of textures
  121974. */
  121975. getActiveTextures(): BaseTexture[];
  121976. /**
  121977. * Gets the list of texture blocks
  121978. * @returns an array of texture blocks
  121979. */
  121980. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  121981. /**
  121982. * Specifies if the material uses a texture
  121983. * @param texture defines the texture to check against the material
  121984. * @returns a boolean specifying if the material uses the texture
  121985. */
  121986. hasTexture(texture: BaseTexture): boolean;
  121987. /**
  121988. * Disposes the material
  121989. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  121990. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  121991. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  121992. */
  121993. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  121994. /** Creates the node editor window. */
  121995. private _createNodeEditor;
  121996. /**
  121997. * Launch the node material editor
  121998. * @param config Define the configuration of the editor
  121999. * @return a promise fulfilled when the node editor is visible
  122000. */
  122001. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  122002. /**
  122003. * Clear the current material
  122004. */
  122005. clear(): void;
  122006. /**
  122007. * Clear the current material and set it to a default state
  122008. */
  122009. setToDefault(): void;
  122010. /**
  122011. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  122012. * @param url defines the url to load from
  122013. * @returns a promise that will fullfil when the material is fully loaded
  122014. */
  122015. loadAsync(url: string): Promise<void>;
  122016. private _gatherBlocks;
  122017. /**
  122018. * Generate a string containing the code declaration required to create an equivalent of this material
  122019. * @returns a string
  122020. */
  122021. generateCode(): string;
  122022. /**
  122023. * Serializes this material in a JSON representation
  122024. * @returns the serialized material object
  122025. */
  122026. serialize(): any;
  122027. private _restoreConnections;
  122028. /**
  122029. * Clear the current graph and load a new one from a serialization object
  122030. * @param source defines the JSON representation of the material
  122031. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122032. */
  122033. loadFromSerialization(source: any, rootUrl?: string): void;
  122034. /**
  122035. * Creates a node material from parsed material data
  122036. * @param source defines the JSON representation of the material
  122037. * @param scene defines the hosting scene
  122038. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122039. * @returns a new node material
  122040. */
  122041. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  122042. /**
  122043. * Creates a new node material set to default basic configuration
  122044. * @param name defines the name of the material
  122045. * @param scene defines the hosting scene
  122046. * @returns a new NodeMaterial
  122047. */
  122048. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  122049. }
  122050. }
  122051. declare module BABYLON {
  122052. /**
  122053. * Block used to read a texture from a sampler
  122054. */
  122055. export class TextureBlock extends NodeMaterialBlock {
  122056. private _defineName;
  122057. private _linearDefineName;
  122058. private _samplerName;
  122059. private _transformedUVName;
  122060. private _textureTransformName;
  122061. private _textureInfoName;
  122062. private _mainUVName;
  122063. private _mainUVDefineName;
  122064. /**
  122065. * Gets or sets the texture associated with the node
  122066. */
  122067. texture: Nullable<Texture>;
  122068. /**
  122069. * Create a new TextureBlock
  122070. * @param name defines the block name
  122071. */
  122072. constructor(name: string);
  122073. /**
  122074. * Gets the current class name
  122075. * @returns the class name
  122076. */
  122077. getClassName(): string;
  122078. /**
  122079. * Gets the uv input component
  122080. */
  122081. readonly uv: NodeMaterialConnectionPoint;
  122082. /**
  122083. * Gets the rgba output component
  122084. */
  122085. readonly rgba: NodeMaterialConnectionPoint;
  122086. /**
  122087. * Gets the rgb output component
  122088. */
  122089. readonly rgb: NodeMaterialConnectionPoint;
  122090. /**
  122091. * Gets the r output component
  122092. */
  122093. readonly r: NodeMaterialConnectionPoint;
  122094. /**
  122095. * Gets the g output component
  122096. */
  122097. readonly g: NodeMaterialConnectionPoint;
  122098. /**
  122099. * Gets the b output component
  122100. */
  122101. readonly b: NodeMaterialConnectionPoint;
  122102. /**
  122103. * Gets the a output component
  122104. */
  122105. readonly a: NodeMaterialConnectionPoint;
  122106. readonly target: NodeMaterialBlockTargets;
  122107. autoConfigure(material: NodeMaterial): void;
  122108. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122109. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122110. isReady(): boolean;
  122111. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122112. private readonly _isMixed;
  122113. private _injectVertexCode;
  122114. private _writeOutput;
  122115. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122116. protected _dumpPropertiesCode(): string;
  122117. serialize(): any;
  122118. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122119. }
  122120. }
  122121. declare module BABYLON {
  122122. /**
  122123. * Class used to store shared data between 2 NodeMaterialBuildState
  122124. */
  122125. export class NodeMaterialBuildStateSharedData {
  122126. /**
  122127. * Gets the list of emitted varyings
  122128. */
  122129. temps: string[];
  122130. /**
  122131. * Gets the list of emitted varyings
  122132. */
  122133. varyings: string[];
  122134. /**
  122135. * Gets the varying declaration string
  122136. */
  122137. varyingDeclaration: string;
  122138. /**
  122139. * Input blocks
  122140. */
  122141. inputBlocks: InputBlock[];
  122142. /**
  122143. * Input blocks
  122144. */
  122145. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  122146. /**
  122147. * Bindable blocks (Blocks that need to set data to the effect)
  122148. */
  122149. bindableBlocks: NodeMaterialBlock[];
  122150. /**
  122151. * List of blocks that can provide a compilation fallback
  122152. */
  122153. blocksWithFallbacks: NodeMaterialBlock[];
  122154. /**
  122155. * List of blocks that can provide a define update
  122156. */
  122157. blocksWithDefines: NodeMaterialBlock[];
  122158. /**
  122159. * List of blocks that can provide a repeatable content
  122160. */
  122161. repeatableContentBlocks: NodeMaterialBlock[];
  122162. /**
  122163. * List of blocks that can provide a dynamic list of uniforms
  122164. */
  122165. dynamicUniformBlocks: NodeMaterialBlock[];
  122166. /**
  122167. * List of blocks that can block the isReady function for the material
  122168. */
  122169. blockingBlocks: NodeMaterialBlock[];
  122170. /**
  122171. * Gets the list of animated inputs
  122172. */
  122173. animatedInputs: InputBlock[];
  122174. /**
  122175. * Build Id used to avoid multiple recompilations
  122176. */
  122177. buildId: number;
  122178. /** List of emitted variables */
  122179. variableNames: {
  122180. [key: string]: number;
  122181. };
  122182. /** List of emitted defines */
  122183. defineNames: {
  122184. [key: string]: number;
  122185. };
  122186. /** Should emit comments? */
  122187. emitComments: boolean;
  122188. /** Emit build activity */
  122189. verbose: boolean;
  122190. /** Gets or sets the hosting scene */
  122191. scene: Scene;
  122192. /**
  122193. * Gets the compilation hints emitted at compilation time
  122194. */
  122195. hints: {
  122196. needWorldViewMatrix: boolean;
  122197. needWorldViewProjectionMatrix: boolean;
  122198. needAlphaBlending: boolean;
  122199. needAlphaTesting: boolean;
  122200. };
  122201. /**
  122202. * List of compilation checks
  122203. */
  122204. checks: {
  122205. emitVertex: boolean;
  122206. emitFragment: boolean;
  122207. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  122208. };
  122209. /** Creates a new shared data */
  122210. constructor();
  122211. /**
  122212. * Emits console errors and exceptions if there is a failing check
  122213. */
  122214. emitErrors(): void;
  122215. }
  122216. }
  122217. declare module BABYLON {
  122218. /**
  122219. * Class used to store node based material build state
  122220. */
  122221. export class NodeMaterialBuildState {
  122222. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  122223. supportUniformBuffers: boolean;
  122224. /**
  122225. * Gets the list of emitted attributes
  122226. */
  122227. attributes: string[];
  122228. /**
  122229. * Gets the list of emitted uniforms
  122230. */
  122231. uniforms: string[];
  122232. /**
  122233. * Gets the list of emitted constants
  122234. */
  122235. constants: string[];
  122236. /**
  122237. * Gets the list of emitted samplers
  122238. */
  122239. samplers: string[];
  122240. /**
  122241. * Gets the list of emitted functions
  122242. */
  122243. functions: {
  122244. [key: string]: string;
  122245. };
  122246. /**
  122247. * Gets the list of emitted extensions
  122248. */
  122249. extensions: {
  122250. [key: string]: string;
  122251. };
  122252. /**
  122253. * Gets the target of the compilation state
  122254. */
  122255. target: NodeMaterialBlockTargets;
  122256. /**
  122257. * Gets the list of emitted counters
  122258. */
  122259. counters: {
  122260. [key: string]: number;
  122261. };
  122262. /**
  122263. * Shared data between multiple NodeMaterialBuildState instances
  122264. */
  122265. sharedData: NodeMaterialBuildStateSharedData;
  122266. /** @hidden */
  122267. _vertexState: NodeMaterialBuildState;
  122268. /** @hidden */
  122269. _attributeDeclaration: string;
  122270. /** @hidden */
  122271. _uniformDeclaration: string;
  122272. /** @hidden */
  122273. _constantDeclaration: string;
  122274. /** @hidden */
  122275. _samplerDeclaration: string;
  122276. /** @hidden */
  122277. _varyingTransfer: string;
  122278. private _repeatableContentAnchorIndex;
  122279. /** @hidden */
  122280. _builtCompilationString: string;
  122281. /**
  122282. * Gets the emitted compilation strings
  122283. */
  122284. compilationString: string;
  122285. /**
  122286. * Finalize the compilation strings
  122287. * @param state defines the current compilation state
  122288. */
  122289. finalize(state: NodeMaterialBuildState): void;
  122290. /** @hidden */
  122291. readonly _repeatableContentAnchor: string;
  122292. /** @hidden */
  122293. _getFreeVariableName(prefix: string): string;
  122294. /** @hidden */
  122295. _getFreeDefineName(prefix: string): string;
  122296. /** @hidden */
  122297. _excludeVariableName(name: string): void;
  122298. /** @hidden */
  122299. _emit2DSampler(name: string): void;
  122300. /** @hidden */
  122301. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  122302. /** @hidden */
  122303. _emitExtension(name: string, extension: string): void;
  122304. /** @hidden */
  122305. _emitFunction(name: string, code: string, comments: string): void;
  122306. /** @hidden */
  122307. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  122308. replaceStrings?: {
  122309. search: RegExp;
  122310. replace: string;
  122311. }[];
  122312. repeatKey?: string;
  122313. }): string;
  122314. /** @hidden */
  122315. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  122316. repeatKey?: string;
  122317. removeAttributes?: boolean;
  122318. removeUniforms?: boolean;
  122319. removeVaryings?: boolean;
  122320. removeIfDef?: boolean;
  122321. replaceStrings?: {
  122322. search: RegExp;
  122323. replace: string;
  122324. }[];
  122325. }, storeKey?: string): void;
  122326. /** @hidden */
  122327. _registerTempVariable(name: string): boolean;
  122328. /** @hidden */
  122329. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  122330. /** @hidden */
  122331. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  122332. /** @hidden */
  122333. _emitFloat(value: number): string;
  122334. }
  122335. }
  122336. declare module BABYLON {
  122337. /**
  122338. * Defines a block that can be used inside a node based material
  122339. */
  122340. export class NodeMaterialBlock {
  122341. private _buildId;
  122342. private _buildTarget;
  122343. private _target;
  122344. private _isFinalMerger;
  122345. private _isInput;
  122346. protected _isUnique: boolean;
  122347. /** @hidden */
  122348. _codeVariableName: string;
  122349. /** @hidden */
  122350. _inputs: NodeMaterialConnectionPoint[];
  122351. /** @hidden */
  122352. _outputs: NodeMaterialConnectionPoint[];
  122353. /** @hidden */
  122354. _preparationId: number;
  122355. /**
  122356. * Gets or sets the name of the block
  122357. */
  122358. name: string;
  122359. /**
  122360. * Gets or sets the unique id of the node
  122361. */
  122362. uniqueId: number;
  122363. /**
  122364. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  122365. */
  122366. readonly isUnique: boolean;
  122367. /**
  122368. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  122369. */
  122370. readonly isFinalMerger: boolean;
  122371. /**
  122372. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  122373. */
  122374. readonly isInput: boolean;
  122375. /**
  122376. * Gets or sets the build Id
  122377. */
  122378. buildId: number;
  122379. /**
  122380. * Gets or sets the target of the block
  122381. */
  122382. target: NodeMaterialBlockTargets;
  122383. /**
  122384. * Gets the list of input points
  122385. */
  122386. readonly inputs: NodeMaterialConnectionPoint[];
  122387. /** Gets the list of output points */
  122388. readonly outputs: NodeMaterialConnectionPoint[];
  122389. /**
  122390. * Find an input by its name
  122391. * @param name defines the name of the input to look for
  122392. * @returns the input or null if not found
  122393. */
  122394. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122395. /**
  122396. * Find an output by its name
  122397. * @param name defines the name of the outputto look for
  122398. * @returns the output or null if not found
  122399. */
  122400. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122401. /**
  122402. * Creates a new NodeMaterialBlock
  122403. * @param name defines the block name
  122404. * @param target defines the target of that block (Vertex by default)
  122405. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  122406. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  122407. */
  122408. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  122409. /**
  122410. * Initialize the block and prepare the context for build
  122411. * @param state defines the state that will be used for the build
  122412. */
  122413. initialize(state: NodeMaterialBuildState): void;
  122414. /**
  122415. * Bind data to effect. Will only be called for blocks with isBindable === true
  122416. * @param effect defines the effect to bind data to
  122417. * @param nodeMaterial defines the hosting NodeMaterial
  122418. * @param mesh defines the mesh that will be rendered
  122419. */
  122420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122421. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  122422. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  122423. protected _writeFloat(value: number): string;
  122424. /**
  122425. * Gets the current class name e.g. "NodeMaterialBlock"
  122426. * @returns the class name
  122427. */
  122428. getClassName(): string;
  122429. /**
  122430. * Register a new input. Must be called inside a block constructor
  122431. * @param name defines the connection point name
  122432. * @param type defines the connection point type
  122433. * @param isOptional defines a boolean indicating that this input can be omitted
  122434. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122435. * @returns the current block
  122436. */
  122437. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  122438. /**
  122439. * Register a new output. Must be called inside a block constructor
  122440. * @param name defines the connection point name
  122441. * @param type defines the connection point type
  122442. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122443. * @returns the current block
  122444. */
  122445. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  122446. /**
  122447. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  122448. * @param forOutput defines an optional connection point to check compatibility with
  122449. * @returns the first available input or null
  122450. */
  122451. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  122452. /**
  122453. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  122454. * @param forBlock defines an optional block to check compatibility with
  122455. * @returns the first available input or null
  122456. */
  122457. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  122458. /**
  122459. * Gets the sibling of the given output
  122460. * @param current defines the current output
  122461. * @returns the next output in the list or null
  122462. */
  122463. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  122464. /**
  122465. * Connect current block with another block
  122466. * @param other defines the block to connect with
  122467. * @param options define the various options to help pick the right connections
  122468. * @returns the current block
  122469. */
  122470. connectTo(other: NodeMaterialBlock, options?: {
  122471. input?: string;
  122472. output?: string;
  122473. outputSwizzle?: string;
  122474. }): this | undefined;
  122475. protected _buildBlock(state: NodeMaterialBuildState): void;
  122476. /**
  122477. * Add uniforms, samplers and uniform buffers at compilation time
  122478. * @param state defines the state to update
  122479. * @param nodeMaterial defines the node material requesting the update
  122480. * @param defines defines the material defines to update
  122481. * @param uniformBuffers defines the list of uniform buffer names
  122482. */
  122483. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122484. /**
  122485. * Add potential fallbacks if shader compilation fails
  122486. * @param mesh defines the mesh to be rendered
  122487. * @param fallbacks defines the current prioritized list of fallbacks
  122488. */
  122489. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122490. /**
  122491. * Initialize defines for shader compilation
  122492. * @param mesh defines the mesh to be rendered
  122493. * @param nodeMaterial defines the node material requesting the update
  122494. * @param defines defines the material defines to update
  122495. * @param useInstances specifies that instances should be used
  122496. */
  122497. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122498. /**
  122499. * Update defines for shader compilation
  122500. * @param mesh defines the mesh to be rendered
  122501. * @param nodeMaterial defines the node material requesting the update
  122502. * @param defines defines the material defines to update
  122503. * @param useInstances specifies that instances should be used
  122504. */
  122505. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122506. /**
  122507. * Lets the block try to connect some inputs automatically
  122508. * @param material defines the hosting NodeMaterial
  122509. */
  122510. autoConfigure(material: NodeMaterial): void;
  122511. /**
  122512. * Function called when a block is declared as repeatable content generator
  122513. * @param vertexShaderState defines the current compilation state for the vertex shader
  122514. * @param fragmentShaderState defines the current compilation state for the fragment shader
  122515. * @param mesh defines the mesh to be rendered
  122516. * @param defines defines the material defines to update
  122517. */
  122518. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122519. /**
  122520. * Checks if the block is ready
  122521. * @param mesh defines the mesh to be rendered
  122522. * @param nodeMaterial defines the node material requesting the update
  122523. * @param defines defines the material defines to update
  122524. * @param useInstances specifies that instances should be used
  122525. * @returns true if the block is ready
  122526. */
  122527. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  122528. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  122529. private _processBuild;
  122530. /**
  122531. * Compile the current node and generate the shader code
  122532. * @param state defines the current compilation state (uniforms, samplers, current string)
  122533. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  122534. * @returns true if already built
  122535. */
  122536. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  122537. protected _inputRename(name: string): string;
  122538. protected _outputRename(name: string): string;
  122539. protected _dumpPropertiesCode(): string;
  122540. /** @hidden */
  122541. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  122542. /** @hidden */
  122543. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  122544. /**
  122545. * Clone the current block to a new identical block
  122546. * @param scene defines the hosting scene
  122547. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122548. * @returns a copy of the current block
  122549. */
  122550. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  122551. /**
  122552. * Serializes this block in a JSON representation
  122553. * @returns the serialized block object
  122554. */
  122555. serialize(): any;
  122556. /** @hidden */
  122557. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122558. /**
  122559. * Release resources
  122560. */
  122561. dispose(): void;
  122562. }
  122563. }
  122564. declare module BABYLON {
  122565. /**
  122566. * Enum defining the type of animations supported by InputBlock
  122567. */
  122568. export enum AnimatedInputBlockTypes {
  122569. /** No animation */
  122570. None = 0,
  122571. /** Time based animation. Will only work for floats */
  122572. Time = 1
  122573. }
  122574. }
  122575. declare module BABYLON {
  122576. /**
  122577. * Block used to expose an input value
  122578. */
  122579. export class InputBlock extends NodeMaterialBlock {
  122580. private _mode;
  122581. private _associatedVariableName;
  122582. private _storedValue;
  122583. private _valueCallback;
  122584. private _type;
  122585. private _animationType;
  122586. /** Gets or set a value used to limit the range of float values */
  122587. min: number;
  122588. /** Gets or set a value used to limit the range of float values */
  122589. max: number;
  122590. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  122591. matrixMode: number;
  122592. /** @hidden */
  122593. _systemValue: Nullable<NodeMaterialSystemValues>;
  122594. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  122595. visibleInInspector: boolean;
  122596. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  122597. isConstant: boolean;
  122598. /**
  122599. * Gets or sets the connection point type (default is float)
  122600. */
  122601. readonly type: NodeMaterialBlockConnectionPointTypes;
  122602. /**
  122603. * Creates a new InputBlock
  122604. * @param name defines the block name
  122605. * @param target defines the target of that block (Vertex by default)
  122606. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  122607. */
  122608. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  122609. /**
  122610. * Gets the output component
  122611. */
  122612. readonly output: NodeMaterialConnectionPoint;
  122613. /**
  122614. * Set the source of this connection point to a vertex attribute
  122615. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  122616. * @returns the current connection point
  122617. */
  122618. setAsAttribute(attributeName?: string): InputBlock;
  122619. /**
  122620. * Set the source of this connection point to a system value
  122621. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  122622. * @returns the current connection point
  122623. */
  122624. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  122625. /**
  122626. * Gets or sets the value of that point.
  122627. * Please note that this value will be ignored if valueCallback is defined
  122628. */
  122629. value: any;
  122630. /**
  122631. * Gets or sets a callback used to get the value of that point.
  122632. * Please note that setting this value will force the connection point to ignore the value property
  122633. */
  122634. valueCallback: () => any;
  122635. /**
  122636. * Gets or sets the associated variable name in the shader
  122637. */
  122638. associatedVariableName: string;
  122639. /** Gets or sets the type of animation applied to the input */
  122640. animationType: AnimatedInputBlockTypes;
  122641. /**
  122642. * Gets a boolean indicating that this connection point not defined yet
  122643. */
  122644. readonly isUndefined: boolean;
  122645. /**
  122646. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  122647. * In this case the connection point name must be the name of the uniform to use.
  122648. * Can only be set on inputs
  122649. */
  122650. isUniform: boolean;
  122651. /**
  122652. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  122653. * In this case the connection point name must be the name of the attribute to use
  122654. * Can only be set on inputs
  122655. */
  122656. isAttribute: boolean;
  122657. /**
  122658. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  122659. * Can only be set on exit points
  122660. */
  122661. isVarying: boolean;
  122662. /**
  122663. * Gets a boolean indicating that the current connection point is a system value
  122664. */
  122665. readonly isSystemValue: boolean;
  122666. /**
  122667. * Gets or sets the current well known value or null if not defined as a system value
  122668. */
  122669. systemValue: Nullable<NodeMaterialSystemValues>;
  122670. /**
  122671. * Gets the current class name
  122672. * @returns the class name
  122673. */
  122674. getClassName(): string;
  122675. /**
  122676. * Animate the input if animationType !== None
  122677. * @param scene defines the rendering scene
  122678. */
  122679. animate(scene: Scene): void;
  122680. private _emitDefine;
  122681. initialize(state: NodeMaterialBuildState): void;
  122682. /**
  122683. * Set the input block to its default value (based on its type)
  122684. */
  122685. setDefaultValue(): void;
  122686. private _emitConstant;
  122687. private _emit;
  122688. /** @hidden */
  122689. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  122690. /** @hidden */
  122691. _transmit(effect: Effect, scene: Scene): void;
  122692. protected _buildBlock(state: NodeMaterialBuildState): void;
  122693. protected _dumpPropertiesCode(): string;
  122694. serialize(): any;
  122695. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122696. }
  122697. }
  122698. declare module BABYLON {
  122699. /**
  122700. * Enum used to define the compatibility state between two connection points
  122701. */
  122702. export enum NodeMaterialConnectionPointCompatibilityStates {
  122703. /** Points are compatibles */
  122704. Compatible = 0,
  122705. /** Points are incompatible because of their types */
  122706. TypeIncompatible = 1,
  122707. /** Points are incompatible because of their targets (vertex vs fragment) */
  122708. TargetIncompatible = 2
  122709. }
  122710. /**
  122711. * Defines a connection point for a block
  122712. */
  122713. export class NodeMaterialConnectionPoint {
  122714. /** @hidden */
  122715. _ownerBlock: NodeMaterialBlock;
  122716. /** @hidden */
  122717. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122718. private _endpoints;
  122719. private _associatedVariableName;
  122720. /** @hidden */
  122721. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122722. /** @hidden */
  122723. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122724. private _type;
  122725. /** @hidden */
  122726. _enforceAssociatedVariableName: boolean;
  122727. /**
  122728. * Gets or sets the additional types supported by this connection point
  122729. */
  122730. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122731. /**
  122732. * Gets or sets the additional types excluded by this connection point
  122733. */
  122734. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122735. /**
  122736. * Observable triggered when this point is connected
  122737. */
  122738. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  122739. /**
  122740. * Gets or sets the associated variable name in the shader
  122741. */
  122742. associatedVariableName: string;
  122743. /**
  122744. * Gets or sets the connection point type (default is float)
  122745. */
  122746. type: NodeMaterialBlockConnectionPointTypes;
  122747. /**
  122748. * Gets or sets the connection point name
  122749. */
  122750. name: string;
  122751. /**
  122752. * Gets or sets a boolean indicating that this connection point can be omitted
  122753. */
  122754. isOptional: boolean;
  122755. /**
  122756. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  122757. */
  122758. define: string;
  122759. /** @hidden */
  122760. _prioritizeVertex: boolean;
  122761. private _target;
  122762. /** Gets or sets the target of that connection point */
  122763. target: NodeMaterialBlockTargets;
  122764. /**
  122765. * Gets a boolean indicating that the current point is connected
  122766. */
  122767. readonly isConnected: boolean;
  122768. /**
  122769. * Gets a boolean indicating that the current point is connected to an input block
  122770. */
  122771. readonly isConnectedToInputBlock: boolean;
  122772. /**
  122773. * Gets a the connected input block (if any)
  122774. */
  122775. readonly connectInputBlock: Nullable<InputBlock>;
  122776. /** Get the other side of the connection (if any) */
  122777. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122778. /** Get the block that owns this connection point */
  122779. readonly ownerBlock: NodeMaterialBlock;
  122780. /** Get the block connected on the other side of this connection (if any) */
  122781. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  122782. /** Get the block connected on the endpoints of this connection (if any) */
  122783. readonly connectedBlocks: Array<NodeMaterialBlock>;
  122784. /** Gets the list of connected endpoints */
  122785. readonly endpoints: NodeMaterialConnectionPoint[];
  122786. /** Gets a boolean indicating if that output point is connected to at least one input */
  122787. readonly hasEndpoints: boolean;
  122788. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  122789. readonly isConnectedInVertexShader: boolean;
  122790. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  122791. readonly isConnectedInFragmentShader: boolean;
  122792. /**
  122793. * Creates a new connection point
  122794. * @param name defines the connection point name
  122795. * @param ownerBlock defines the block hosting this connection point
  122796. */
  122797. constructor(name: string, ownerBlock: NodeMaterialBlock);
  122798. /**
  122799. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  122800. * @returns the class name
  122801. */
  122802. getClassName(): string;
  122803. /**
  122804. * Gets a boolean indicating if the current point can be connected to another point
  122805. * @param connectionPoint defines the other connection point
  122806. * @returns a boolean
  122807. */
  122808. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  122809. /**
  122810. * Gets a number indicating if the current point can be connected to another point
  122811. * @param connectionPoint defines the other connection point
  122812. * @returns a number defining the compatibility state
  122813. */
  122814. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  122815. /**
  122816. * Connect this point to another connection point
  122817. * @param connectionPoint defines the other connection point
  122818. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  122819. * @returns the current connection point
  122820. */
  122821. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  122822. /**
  122823. * Disconnect this point from one of his endpoint
  122824. * @param endpoint defines the other connection point
  122825. * @returns the current connection point
  122826. */
  122827. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  122828. /**
  122829. * Serializes this point in a JSON representation
  122830. * @returns the serialized point object
  122831. */
  122832. serialize(): any;
  122833. /**
  122834. * Release resources
  122835. */
  122836. dispose(): void;
  122837. }
  122838. }
  122839. declare module BABYLON {
  122840. /**
  122841. * Block used to add support for vertex skinning (bones)
  122842. */
  122843. export class BonesBlock extends NodeMaterialBlock {
  122844. /**
  122845. * Creates a new BonesBlock
  122846. * @param name defines the block name
  122847. */
  122848. constructor(name: string);
  122849. /**
  122850. * Initialize the block and prepare the context for build
  122851. * @param state defines the state that will be used for the build
  122852. */
  122853. initialize(state: NodeMaterialBuildState): void;
  122854. /**
  122855. * Gets the current class name
  122856. * @returns the class name
  122857. */
  122858. getClassName(): string;
  122859. /**
  122860. * Gets the matrix indices input component
  122861. */
  122862. readonly matricesIndices: NodeMaterialConnectionPoint;
  122863. /**
  122864. * Gets the matrix weights input component
  122865. */
  122866. readonly matricesWeights: NodeMaterialConnectionPoint;
  122867. /**
  122868. * Gets the extra matrix indices input component
  122869. */
  122870. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  122871. /**
  122872. * Gets the extra matrix weights input component
  122873. */
  122874. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  122875. /**
  122876. * Gets the world input component
  122877. */
  122878. readonly world: NodeMaterialConnectionPoint;
  122879. /**
  122880. * Gets the output component
  122881. */
  122882. readonly output: NodeMaterialConnectionPoint;
  122883. autoConfigure(material: NodeMaterial): void;
  122884. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122885. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122886. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122887. protected _buildBlock(state: NodeMaterialBuildState): this;
  122888. }
  122889. }
  122890. declare module BABYLON {
  122891. /**
  122892. * Block used to add support for instances
  122893. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  122894. */
  122895. export class InstancesBlock extends NodeMaterialBlock {
  122896. /**
  122897. * Creates a new InstancesBlock
  122898. * @param name defines the block name
  122899. */
  122900. constructor(name: string);
  122901. /**
  122902. * Gets the current class name
  122903. * @returns the class name
  122904. */
  122905. getClassName(): string;
  122906. /**
  122907. * Gets the first world row input component
  122908. */
  122909. readonly world0: NodeMaterialConnectionPoint;
  122910. /**
  122911. * Gets the second world row input component
  122912. */
  122913. readonly world1: NodeMaterialConnectionPoint;
  122914. /**
  122915. * Gets the third world row input component
  122916. */
  122917. readonly world2: NodeMaterialConnectionPoint;
  122918. /**
  122919. * Gets the forth world row input component
  122920. */
  122921. readonly world3: NodeMaterialConnectionPoint;
  122922. /**
  122923. * Gets the world input component
  122924. */
  122925. readonly world: NodeMaterialConnectionPoint;
  122926. /**
  122927. * Gets the output component
  122928. */
  122929. readonly output: NodeMaterialConnectionPoint;
  122930. autoConfigure(material: NodeMaterial): void;
  122931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122932. protected _buildBlock(state: NodeMaterialBuildState): this;
  122933. }
  122934. }
  122935. declare module BABYLON {
  122936. /**
  122937. * Block used to add morph targets support to vertex shader
  122938. */
  122939. export class MorphTargetsBlock extends NodeMaterialBlock {
  122940. private _repeatableContentAnchor;
  122941. private _repeatebleContentGenerated;
  122942. /**
  122943. * Create a new MorphTargetsBlock
  122944. * @param name defines the block name
  122945. */
  122946. constructor(name: string);
  122947. /**
  122948. * Gets the current class name
  122949. * @returns the class name
  122950. */
  122951. getClassName(): string;
  122952. /**
  122953. * Gets the position input component
  122954. */
  122955. readonly position: NodeMaterialConnectionPoint;
  122956. /**
  122957. * Gets the normal input component
  122958. */
  122959. readonly normal: NodeMaterialConnectionPoint;
  122960. /**
  122961. * Gets the tangent input component
  122962. */
  122963. readonly tangent: NodeMaterialConnectionPoint;
  122964. /**
  122965. * Gets the tangent input component
  122966. */
  122967. readonly uv: NodeMaterialConnectionPoint;
  122968. /**
  122969. * Gets the position output component
  122970. */
  122971. readonly positionOutput: NodeMaterialConnectionPoint;
  122972. /**
  122973. * Gets the normal output component
  122974. */
  122975. readonly normalOutput: NodeMaterialConnectionPoint;
  122976. /**
  122977. * Gets the tangent output component
  122978. */
  122979. readonly tangentOutput: NodeMaterialConnectionPoint;
  122980. /**
  122981. * Gets the tangent output component
  122982. */
  122983. readonly uvOutput: NodeMaterialConnectionPoint;
  122984. initialize(state: NodeMaterialBuildState): void;
  122985. autoConfigure(material: NodeMaterial): void;
  122986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122987. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122988. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122989. protected _buildBlock(state: NodeMaterialBuildState): this;
  122990. }
  122991. }
  122992. declare module BABYLON {
  122993. /**
  122994. * Block used to get data information from a light
  122995. */
  122996. export class LightInformationBlock extends NodeMaterialBlock {
  122997. private _lightDataUniformName;
  122998. private _lightColorUniformName;
  122999. private _lightTypeDefineName;
  123000. /**
  123001. * Gets or sets the light associated with this block
  123002. */
  123003. light: Nullable<Light>;
  123004. /**
  123005. * Creates a new LightInformationBlock
  123006. * @param name defines the block name
  123007. */
  123008. constructor(name: string);
  123009. /**
  123010. * Gets the current class name
  123011. * @returns the class name
  123012. */
  123013. getClassName(): string;
  123014. /**
  123015. * Gets the world position input component
  123016. */
  123017. readonly worldPosition: NodeMaterialConnectionPoint;
  123018. /**
  123019. * Gets the direction output component
  123020. */
  123021. readonly direction: NodeMaterialConnectionPoint;
  123022. /**
  123023. * Gets the direction output component
  123024. */
  123025. readonly color: NodeMaterialConnectionPoint;
  123026. /**
  123027. * Gets the direction output component
  123028. */
  123029. readonly intensity: NodeMaterialConnectionPoint;
  123030. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123031. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123032. protected _buildBlock(state: NodeMaterialBuildState): this;
  123033. serialize(): any;
  123034. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123035. }
  123036. }
  123037. declare module BABYLON {
  123038. /**
  123039. * Block used to add image processing support to fragment shader
  123040. */
  123041. export class ImageProcessingBlock extends NodeMaterialBlock {
  123042. /**
  123043. * Create a new ImageProcessingBlock
  123044. * @param name defines the block name
  123045. */
  123046. constructor(name: string);
  123047. /**
  123048. * Gets the current class name
  123049. * @returns the class name
  123050. */
  123051. getClassName(): string;
  123052. /**
  123053. * Gets the color input component
  123054. */
  123055. readonly color: NodeMaterialConnectionPoint;
  123056. /**
  123057. * Gets the output component
  123058. */
  123059. readonly output: NodeMaterialConnectionPoint;
  123060. /**
  123061. * Initialize the block and prepare the context for build
  123062. * @param state defines the state that will be used for the build
  123063. */
  123064. initialize(state: NodeMaterialBuildState): void;
  123065. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  123066. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123068. protected _buildBlock(state: NodeMaterialBuildState): this;
  123069. }
  123070. }
  123071. declare module BABYLON {
  123072. /**
  123073. * Block used to pertub normals based on a normal map
  123074. */
  123075. export class PerturbNormalBlock extends NodeMaterialBlock {
  123076. private _tangentSpaceParameterName;
  123077. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  123078. invertX: boolean;
  123079. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  123080. invertY: boolean;
  123081. /**
  123082. * Create a new PerturbNormalBlock
  123083. * @param name defines the block name
  123084. */
  123085. constructor(name: string);
  123086. /**
  123087. * Gets the current class name
  123088. * @returns the class name
  123089. */
  123090. getClassName(): string;
  123091. /**
  123092. * Gets the world position input component
  123093. */
  123094. readonly worldPosition: NodeMaterialConnectionPoint;
  123095. /**
  123096. * Gets the world normal input component
  123097. */
  123098. readonly worldNormal: NodeMaterialConnectionPoint;
  123099. /**
  123100. * Gets the uv input component
  123101. */
  123102. readonly uv: NodeMaterialConnectionPoint;
  123103. /**
  123104. * Gets the normal map color input component
  123105. */
  123106. readonly normalMapColor: NodeMaterialConnectionPoint;
  123107. /**
  123108. * Gets the strength input component
  123109. */
  123110. readonly strength: NodeMaterialConnectionPoint;
  123111. /**
  123112. * Gets the output component
  123113. */
  123114. readonly output: NodeMaterialConnectionPoint;
  123115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123116. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123117. autoConfigure(material: NodeMaterial): void;
  123118. protected _buildBlock(state: NodeMaterialBuildState): this;
  123119. protected _dumpPropertiesCode(): string;
  123120. serialize(): any;
  123121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123122. }
  123123. }
  123124. declare module BABYLON {
  123125. /**
  123126. * Block used to discard a pixel if a value is smaller than a cutoff
  123127. */
  123128. export class DiscardBlock extends NodeMaterialBlock {
  123129. /**
  123130. * Create a new DiscardBlock
  123131. * @param name defines the block name
  123132. */
  123133. constructor(name: string);
  123134. /**
  123135. * Gets the current class name
  123136. * @returns the class name
  123137. */
  123138. getClassName(): string;
  123139. /**
  123140. * Gets the color input component
  123141. */
  123142. readonly value: NodeMaterialConnectionPoint;
  123143. /**
  123144. * Gets the cutoff input component
  123145. */
  123146. readonly cutoff: NodeMaterialConnectionPoint;
  123147. protected _buildBlock(state: NodeMaterialBuildState): this;
  123148. }
  123149. }
  123150. declare module BABYLON {
  123151. /**
  123152. * Block used to test if the fragment shader is front facing
  123153. */
  123154. export class FrontFacingBlock extends NodeMaterialBlock {
  123155. /**
  123156. * Creates a new FrontFacingBlock
  123157. * @param name defines the block name
  123158. */
  123159. constructor(name: string);
  123160. /**
  123161. * Gets the current class name
  123162. * @returns the class name
  123163. */
  123164. getClassName(): string;
  123165. /**
  123166. * Gets the output component
  123167. */
  123168. readonly output: NodeMaterialConnectionPoint;
  123169. protected _buildBlock(state: NodeMaterialBuildState): this;
  123170. }
  123171. }
  123172. declare module BABYLON {
  123173. /**
  123174. * Block used to add support for scene fog
  123175. */
  123176. export class FogBlock extends NodeMaterialBlock {
  123177. private _fogDistanceName;
  123178. private _fogParameters;
  123179. /**
  123180. * Create a new FogBlock
  123181. * @param name defines the block name
  123182. */
  123183. constructor(name: string);
  123184. /**
  123185. * Gets the current class name
  123186. * @returns the class name
  123187. */
  123188. getClassName(): string;
  123189. /**
  123190. * Gets the world position input component
  123191. */
  123192. readonly worldPosition: NodeMaterialConnectionPoint;
  123193. /**
  123194. * Gets the view input component
  123195. */
  123196. readonly view: NodeMaterialConnectionPoint;
  123197. /**
  123198. * Gets the color input component
  123199. */
  123200. readonly input: NodeMaterialConnectionPoint;
  123201. /**
  123202. * Gets the fog color input component
  123203. */
  123204. readonly fogColor: NodeMaterialConnectionPoint;
  123205. /**
  123206. * Gets the output component
  123207. */
  123208. readonly output: NodeMaterialConnectionPoint;
  123209. autoConfigure(material: NodeMaterial): void;
  123210. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123212. protected _buildBlock(state: NodeMaterialBuildState): this;
  123213. }
  123214. }
  123215. declare module BABYLON {
  123216. /**
  123217. * Block used to add light in the fragment shader
  123218. */
  123219. export class LightBlock extends NodeMaterialBlock {
  123220. private _lightId;
  123221. /**
  123222. * Gets or sets the light associated with this block
  123223. */
  123224. light: Nullable<Light>;
  123225. /**
  123226. * Create a new LightBlock
  123227. * @param name defines the block name
  123228. */
  123229. constructor(name: string);
  123230. /**
  123231. * Gets the current class name
  123232. * @returns the class name
  123233. */
  123234. getClassName(): string;
  123235. /**
  123236. * Gets the world position input component
  123237. */
  123238. readonly worldPosition: NodeMaterialConnectionPoint;
  123239. /**
  123240. * Gets the world normal input component
  123241. */
  123242. readonly worldNormal: NodeMaterialConnectionPoint;
  123243. /**
  123244. * Gets the camera (or eye) position component
  123245. */
  123246. readonly cameraPosition: NodeMaterialConnectionPoint;
  123247. /**
  123248. * Gets the glossiness component
  123249. */
  123250. readonly glossiness: NodeMaterialConnectionPoint;
  123251. /**
  123252. * Gets the glossinness power component
  123253. */
  123254. readonly glossPower: NodeMaterialConnectionPoint;
  123255. /**
  123256. * Gets the diffuse color component
  123257. */
  123258. readonly diffuseColor: NodeMaterialConnectionPoint;
  123259. /**
  123260. * Gets the specular color component
  123261. */
  123262. readonly specularColor: NodeMaterialConnectionPoint;
  123263. /**
  123264. * Gets the diffuse output component
  123265. */
  123266. readonly diffuseOutput: NodeMaterialConnectionPoint;
  123267. /**
  123268. * Gets the specular output component
  123269. */
  123270. readonly specularOutput: NodeMaterialConnectionPoint;
  123271. autoConfigure(material: NodeMaterial): void;
  123272. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123273. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123274. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123275. private _injectVertexCode;
  123276. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123277. serialize(): any;
  123278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123279. }
  123280. }
  123281. declare module BABYLON {
  123282. /**
  123283. * Block used to multiply 2 values
  123284. */
  123285. export class MultiplyBlock extends NodeMaterialBlock {
  123286. /**
  123287. * Creates a new MultiplyBlock
  123288. * @param name defines the block name
  123289. */
  123290. constructor(name: string);
  123291. /**
  123292. * Gets the current class name
  123293. * @returns the class name
  123294. */
  123295. getClassName(): string;
  123296. /**
  123297. * Gets the left operand input component
  123298. */
  123299. readonly left: NodeMaterialConnectionPoint;
  123300. /**
  123301. * Gets the right operand input component
  123302. */
  123303. readonly right: NodeMaterialConnectionPoint;
  123304. /**
  123305. * Gets the output component
  123306. */
  123307. readonly output: NodeMaterialConnectionPoint;
  123308. protected _buildBlock(state: NodeMaterialBuildState): this;
  123309. }
  123310. }
  123311. declare module BABYLON {
  123312. /**
  123313. * Block used to add 2 vectors
  123314. */
  123315. export class AddBlock extends NodeMaterialBlock {
  123316. /**
  123317. * Creates a new AddBlock
  123318. * @param name defines the block name
  123319. */
  123320. constructor(name: string);
  123321. /**
  123322. * Gets the current class name
  123323. * @returns the class name
  123324. */
  123325. getClassName(): string;
  123326. /**
  123327. * Gets the left operand input component
  123328. */
  123329. readonly left: NodeMaterialConnectionPoint;
  123330. /**
  123331. * Gets the right operand input component
  123332. */
  123333. readonly right: NodeMaterialConnectionPoint;
  123334. /**
  123335. * Gets the output component
  123336. */
  123337. readonly output: NodeMaterialConnectionPoint;
  123338. protected _buildBlock(state: NodeMaterialBuildState): this;
  123339. }
  123340. }
  123341. declare module BABYLON {
  123342. /**
  123343. * Block used to scale a vector by a float
  123344. */
  123345. export class ScaleBlock extends NodeMaterialBlock {
  123346. /**
  123347. * Creates a new ScaleBlock
  123348. * @param name defines the block name
  123349. */
  123350. constructor(name: string);
  123351. /**
  123352. * Gets the current class name
  123353. * @returns the class name
  123354. */
  123355. getClassName(): string;
  123356. /**
  123357. * Gets the input component
  123358. */
  123359. readonly input: NodeMaterialConnectionPoint;
  123360. /**
  123361. * Gets the factor input component
  123362. */
  123363. readonly factor: NodeMaterialConnectionPoint;
  123364. /**
  123365. * Gets the output component
  123366. */
  123367. readonly output: NodeMaterialConnectionPoint;
  123368. protected _buildBlock(state: NodeMaterialBuildState): this;
  123369. }
  123370. }
  123371. declare module BABYLON {
  123372. /**
  123373. * Block used to clamp a float
  123374. */
  123375. export class ClampBlock extends NodeMaterialBlock {
  123376. /** Gets or sets the minimum range */
  123377. minimum: number;
  123378. /** Gets or sets the maximum range */
  123379. maximum: number;
  123380. /**
  123381. * Creates a new ClampBlock
  123382. * @param name defines the block name
  123383. */
  123384. constructor(name: string);
  123385. /**
  123386. * Gets the current class name
  123387. * @returns the class name
  123388. */
  123389. getClassName(): string;
  123390. /**
  123391. * Gets the value input component
  123392. */
  123393. readonly value: NodeMaterialConnectionPoint;
  123394. /**
  123395. * Gets the output component
  123396. */
  123397. readonly output: NodeMaterialConnectionPoint;
  123398. protected _buildBlock(state: NodeMaterialBuildState): this;
  123399. protected _dumpPropertiesCode(): string;
  123400. serialize(): any;
  123401. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123402. }
  123403. }
  123404. declare module BABYLON {
  123405. /**
  123406. * Block used to apply a cross product between 2 vectors
  123407. */
  123408. export class CrossBlock extends NodeMaterialBlock {
  123409. /**
  123410. * Creates a new CrossBlock
  123411. * @param name defines the block name
  123412. */
  123413. constructor(name: string);
  123414. /**
  123415. * Gets the current class name
  123416. * @returns the class name
  123417. */
  123418. getClassName(): string;
  123419. /**
  123420. * Gets the left operand input component
  123421. */
  123422. readonly left: NodeMaterialConnectionPoint;
  123423. /**
  123424. * Gets the right operand input component
  123425. */
  123426. readonly right: NodeMaterialConnectionPoint;
  123427. /**
  123428. * Gets the output component
  123429. */
  123430. readonly output: NodeMaterialConnectionPoint;
  123431. protected _buildBlock(state: NodeMaterialBuildState): this;
  123432. }
  123433. }
  123434. declare module BABYLON {
  123435. /**
  123436. * Block used to apply a dot product between 2 vectors
  123437. */
  123438. export class DotBlock extends NodeMaterialBlock {
  123439. /**
  123440. * Creates a new DotBlock
  123441. * @param name defines the block name
  123442. */
  123443. constructor(name: string);
  123444. /**
  123445. * Gets the current class name
  123446. * @returns the class name
  123447. */
  123448. getClassName(): string;
  123449. /**
  123450. * Gets the left operand input component
  123451. */
  123452. readonly left: NodeMaterialConnectionPoint;
  123453. /**
  123454. * Gets the right operand input component
  123455. */
  123456. readonly right: NodeMaterialConnectionPoint;
  123457. /**
  123458. * Gets the output component
  123459. */
  123460. readonly output: NodeMaterialConnectionPoint;
  123461. protected _buildBlock(state: NodeMaterialBuildState): this;
  123462. }
  123463. }
  123464. declare module BABYLON {
  123465. /**
  123466. * Block used to remap a float from a range to a new one
  123467. */
  123468. export class RemapBlock extends NodeMaterialBlock {
  123469. /**
  123470. * Gets or sets the source range
  123471. */
  123472. sourceRange: Vector2;
  123473. /**
  123474. * Gets or sets the target range
  123475. */
  123476. targetRange: Vector2;
  123477. /**
  123478. * Creates a new RemapBlock
  123479. * @param name defines the block name
  123480. */
  123481. constructor(name: string);
  123482. /**
  123483. * Gets the current class name
  123484. * @returns the class name
  123485. */
  123486. getClassName(): string;
  123487. /**
  123488. * Gets the input component
  123489. */
  123490. readonly input: NodeMaterialConnectionPoint;
  123491. /**
  123492. * Gets the source min input component
  123493. */
  123494. readonly sourceMin: NodeMaterialConnectionPoint;
  123495. /**
  123496. * Gets the source max input component
  123497. */
  123498. readonly sourceMax: NodeMaterialConnectionPoint;
  123499. /**
  123500. * Gets the target min input component
  123501. */
  123502. readonly targetMin: NodeMaterialConnectionPoint;
  123503. /**
  123504. * Gets the target max input component
  123505. */
  123506. readonly targetMax: NodeMaterialConnectionPoint;
  123507. /**
  123508. * Gets the output component
  123509. */
  123510. readonly output: NodeMaterialConnectionPoint;
  123511. protected _buildBlock(state: NodeMaterialBuildState): this;
  123512. protected _dumpPropertiesCode(): string;
  123513. serialize(): any;
  123514. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123515. }
  123516. }
  123517. declare module BABYLON {
  123518. /**
  123519. * Block used to normalize a vector
  123520. */
  123521. export class NormalizeBlock extends NodeMaterialBlock {
  123522. /**
  123523. * Creates a new NormalizeBlock
  123524. * @param name defines the block name
  123525. */
  123526. constructor(name: string);
  123527. /**
  123528. * Gets the current class name
  123529. * @returns the class name
  123530. */
  123531. getClassName(): string;
  123532. /**
  123533. * Gets the input component
  123534. */
  123535. readonly input: NodeMaterialConnectionPoint;
  123536. /**
  123537. * Gets the output component
  123538. */
  123539. readonly output: NodeMaterialConnectionPoint;
  123540. protected _buildBlock(state: NodeMaterialBuildState): this;
  123541. }
  123542. }
  123543. declare module BABYLON {
  123544. /**
  123545. * Operations supported by the Trigonometry block
  123546. */
  123547. export enum TrigonometryBlockOperations {
  123548. /** Cos */
  123549. Cos = 0,
  123550. /** Sin */
  123551. Sin = 1,
  123552. /** Abs */
  123553. Abs = 2,
  123554. /** Exp */
  123555. Exp = 3,
  123556. /** Exp2 */
  123557. Exp2 = 4,
  123558. /** Round */
  123559. Round = 5,
  123560. /** Floor */
  123561. Floor = 6,
  123562. /** Ceiling */
  123563. Ceiling = 7,
  123564. /** Square root */
  123565. Sqrt = 8,
  123566. /** Log */
  123567. Log = 9,
  123568. /** Tangent */
  123569. Tan = 10,
  123570. /** Arc tangent */
  123571. ArcTan = 11,
  123572. /** Arc cosinus */
  123573. ArcCos = 12,
  123574. /** Arc sinus */
  123575. ArcSin = 13,
  123576. /** Fraction */
  123577. Fract = 14,
  123578. /** Sign */
  123579. Sign = 15,
  123580. /** To radians (from degrees) */
  123581. Radians = 16,
  123582. /** To degrees (from radians) */
  123583. Degrees = 17
  123584. }
  123585. /**
  123586. * Block used to apply trigonometry operation to floats
  123587. */
  123588. export class TrigonometryBlock extends NodeMaterialBlock {
  123589. /**
  123590. * Gets or sets the operation applied by the block
  123591. */
  123592. operation: TrigonometryBlockOperations;
  123593. /**
  123594. * Creates a new TrigonometryBlock
  123595. * @param name defines the block name
  123596. */
  123597. constructor(name: string);
  123598. /**
  123599. * Gets the current class name
  123600. * @returns the class name
  123601. */
  123602. getClassName(): string;
  123603. /**
  123604. * Gets the input component
  123605. */
  123606. readonly input: NodeMaterialConnectionPoint;
  123607. /**
  123608. * Gets the output component
  123609. */
  123610. readonly output: NodeMaterialConnectionPoint;
  123611. protected _buildBlock(state: NodeMaterialBuildState): this;
  123612. serialize(): any;
  123613. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123614. }
  123615. }
  123616. declare module BABYLON {
  123617. /**
  123618. * Block used to create a Color3/4 out of individual inputs (one for each component)
  123619. */
  123620. export class ColorMergerBlock extends NodeMaterialBlock {
  123621. /**
  123622. * Create a new ColorMergerBlock
  123623. * @param name defines the block name
  123624. */
  123625. constructor(name: string);
  123626. /**
  123627. * Gets the current class name
  123628. * @returns the class name
  123629. */
  123630. getClassName(): string;
  123631. /**
  123632. * Gets the r component (input)
  123633. */
  123634. readonly r: NodeMaterialConnectionPoint;
  123635. /**
  123636. * Gets the g component (input)
  123637. */
  123638. readonly g: NodeMaterialConnectionPoint;
  123639. /**
  123640. * Gets the b component (input)
  123641. */
  123642. readonly b: NodeMaterialConnectionPoint;
  123643. /**
  123644. * Gets the a component (input)
  123645. */
  123646. readonly a: NodeMaterialConnectionPoint;
  123647. /**
  123648. * Gets the rgba component (output)
  123649. */
  123650. readonly rgba: NodeMaterialConnectionPoint;
  123651. /**
  123652. * Gets the rgb component (output)
  123653. */
  123654. readonly rgb: NodeMaterialConnectionPoint;
  123655. protected _buildBlock(state: NodeMaterialBuildState): this;
  123656. }
  123657. }
  123658. declare module BABYLON {
  123659. /**
  123660. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  123661. */
  123662. export class VectorMergerBlock extends NodeMaterialBlock {
  123663. /**
  123664. * Create a new VectorMergerBlock
  123665. * @param name defines the block name
  123666. */
  123667. constructor(name: string);
  123668. /**
  123669. * Gets the current class name
  123670. * @returns the class name
  123671. */
  123672. getClassName(): string;
  123673. /**
  123674. * Gets the x component (input)
  123675. */
  123676. readonly x: NodeMaterialConnectionPoint;
  123677. /**
  123678. * Gets the y component (input)
  123679. */
  123680. readonly y: NodeMaterialConnectionPoint;
  123681. /**
  123682. * Gets the z component (input)
  123683. */
  123684. readonly z: NodeMaterialConnectionPoint;
  123685. /**
  123686. * Gets the w component (input)
  123687. */
  123688. readonly w: NodeMaterialConnectionPoint;
  123689. /**
  123690. * Gets the xyzw component (output)
  123691. */
  123692. readonly xyzw: NodeMaterialConnectionPoint;
  123693. /**
  123694. * Gets the xyz component (output)
  123695. */
  123696. readonly xyz: NodeMaterialConnectionPoint;
  123697. /**
  123698. * Gets the xy component (output)
  123699. */
  123700. readonly xy: NodeMaterialConnectionPoint;
  123701. protected _buildBlock(state: NodeMaterialBuildState): this;
  123702. }
  123703. }
  123704. declare module BABYLON {
  123705. /**
  123706. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  123707. */
  123708. export class ColorSplitterBlock extends NodeMaterialBlock {
  123709. /**
  123710. * Create a new ColorSplitterBlock
  123711. * @param name defines the block name
  123712. */
  123713. constructor(name: string);
  123714. /**
  123715. * Gets the current class name
  123716. * @returns the class name
  123717. */
  123718. getClassName(): string;
  123719. /**
  123720. * Gets the rgba component (input)
  123721. */
  123722. readonly rgba: NodeMaterialConnectionPoint;
  123723. /**
  123724. * Gets the rgb component (input)
  123725. */
  123726. readonly rgbIn: NodeMaterialConnectionPoint;
  123727. /**
  123728. * Gets the rgb component (output)
  123729. */
  123730. readonly rgbOut: NodeMaterialConnectionPoint;
  123731. /**
  123732. * Gets the r component (output)
  123733. */
  123734. readonly r: NodeMaterialConnectionPoint;
  123735. /**
  123736. * Gets the g component (output)
  123737. */
  123738. readonly g: NodeMaterialConnectionPoint;
  123739. /**
  123740. * Gets the b component (output)
  123741. */
  123742. readonly b: NodeMaterialConnectionPoint;
  123743. /**
  123744. * Gets the a component (output)
  123745. */
  123746. readonly a: NodeMaterialConnectionPoint;
  123747. protected _inputRename(name: string): string;
  123748. protected _outputRename(name: string): string;
  123749. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123750. }
  123751. }
  123752. declare module BABYLON {
  123753. /**
  123754. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  123755. */
  123756. export class VectorSplitterBlock extends NodeMaterialBlock {
  123757. /**
  123758. * Create a new VectorSplitterBlock
  123759. * @param name defines the block name
  123760. */
  123761. constructor(name: string);
  123762. /**
  123763. * Gets the current class name
  123764. * @returns the class name
  123765. */
  123766. getClassName(): string;
  123767. /**
  123768. * Gets the xyzw component (input)
  123769. */
  123770. readonly xyzw: NodeMaterialConnectionPoint;
  123771. /**
  123772. * Gets the xyz component (input)
  123773. */
  123774. readonly xyzIn: NodeMaterialConnectionPoint;
  123775. /**
  123776. * Gets the xy component (input)
  123777. */
  123778. readonly xyIn: NodeMaterialConnectionPoint;
  123779. /**
  123780. * Gets the xyz component (output)
  123781. */
  123782. readonly xyzOut: NodeMaterialConnectionPoint;
  123783. /**
  123784. * Gets the xy component (output)
  123785. */
  123786. readonly xyOut: NodeMaterialConnectionPoint;
  123787. /**
  123788. * Gets the x component (output)
  123789. */
  123790. readonly x: NodeMaterialConnectionPoint;
  123791. /**
  123792. * Gets the y component (output)
  123793. */
  123794. readonly y: NodeMaterialConnectionPoint;
  123795. /**
  123796. * Gets the z component (output)
  123797. */
  123798. readonly z: NodeMaterialConnectionPoint;
  123799. /**
  123800. * Gets the w component (output)
  123801. */
  123802. readonly w: NodeMaterialConnectionPoint;
  123803. protected _inputRename(name: string): string;
  123804. protected _outputRename(name: string): string;
  123805. protected _buildBlock(state: NodeMaterialBuildState): this;
  123806. }
  123807. }
  123808. declare module BABYLON {
  123809. /**
  123810. * Block used to lerp between 2 values
  123811. */
  123812. export class LerpBlock extends NodeMaterialBlock {
  123813. /**
  123814. * Creates a new LerpBlock
  123815. * @param name defines the block name
  123816. */
  123817. constructor(name: string);
  123818. /**
  123819. * Gets the current class name
  123820. * @returns the class name
  123821. */
  123822. getClassName(): string;
  123823. /**
  123824. * Gets the left operand input component
  123825. */
  123826. readonly left: NodeMaterialConnectionPoint;
  123827. /**
  123828. * Gets the right operand input component
  123829. */
  123830. readonly right: NodeMaterialConnectionPoint;
  123831. /**
  123832. * Gets the gradient operand input component
  123833. */
  123834. readonly gradient: NodeMaterialConnectionPoint;
  123835. /**
  123836. * Gets the output component
  123837. */
  123838. readonly output: NodeMaterialConnectionPoint;
  123839. protected _buildBlock(state: NodeMaterialBuildState): this;
  123840. }
  123841. }
  123842. declare module BABYLON {
  123843. /**
  123844. * Block used to divide 2 vectors
  123845. */
  123846. export class DivideBlock extends NodeMaterialBlock {
  123847. /**
  123848. * Creates a new DivideBlock
  123849. * @param name defines the block name
  123850. */
  123851. constructor(name: string);
  123852. /**
  123853. * Gets the current class name
  123854. * @returns the class name
  123855. */
  123856. getClassName(): string;
  123857. /**
  123858. * Gets the left operand input component
  123859. */
  123860. readonly left: NodeMaterialConnectionPoint;
  123861. /**
  123862. * Gets the right operand input component
  123863. */
  123864. readonly right: NodeMaterialConnectionPoint;
  123865. /**
  123866. * Gets the output component
  123867. */
  123868. readonly output: NodeMaterialConnectionPoint;
  123869. protected _buildBlock(state: NodeMaterialBuildState): this;
  123870. }
  123871. }
  123872. declare module BABYLON {
  123873. /**
  123874. * Block used to subtract 2 vectors
  123875. */
  123876. export class SubtractBlock extends NodeMaterialBlock {
  123877. /**
  123878. * Creates a new SubtractBlock
  123879. * @param name defines the block name
  123880. */
  123881. constructor(name: string);
  123882. /**
  123883. * Gets the current class name
  123884. * @returns the class name
  123885. */
  123886. getClassName(): string;
  123887. /**
  123888. * Gets the left operand input component
  123889. */
  123890. readonly left: NodeMaterialConnectionPoint;
  123891. /**
  123892. * Gets the right operand input component
  123893. */
  123894. readonly right: NodeMaterialConnectionPoint;
  123895. /**
  123896. * Gets the output component
  123897. */
  123898. readonly output: NodeMaterialConnectionPoint;
  123899. protected _buildBlock(state: NodeMaterialBuildState): this;
  123900. }
  123901. }
  123902. declare module BABYLON {
  123903. /**
  123904. * Block used to step a value
  123905. */
  123906. export class StepBlock extends NodeMaterialBlock {
  123907. /**
  123908. * Creates a new StepBlock
  123909. * @param name defines the block name
  123910. */
  123911. constructor(name: string);
  123912. /**
  123913. * Gets the current class name
  123914. * @returns the class name
  123915. */
  123916. getClassName(): string;
  123917. /**
  123918. * Gets the value operand input component
  123919. */
  123920. readonly value: NodeMaterialConnectionPoint;
  123921. /**
  123922. * Gets the edge operand input component
  123923. */
  123924. readonly edge: NodeMaterialConnectionPoint;
  123925. /**
  123926. * Gets the output component
  123927. */
  123928. readonly output: NodeMaterialConnectionPoint;
  123929. protected _buildBlock(state: NodeMaterialBuildState): this;
  123930. }
  123931. }
  123932. declare module BABYLON {
  123933. /**
  123934. * Block used to get the opposite (1 - x) of a value
  123935. */
  123936. export class OneMinusBlock extends NodeMaterialBlock {
  123937. /**
  123938. * Creates a new OneMinusBlock
  123939. * @param name defines the block name
  123940. */
  123941. constructor(name: string);
  123942. /**
  123943. * Gets the current class name
  123944. * @returns the class name
  123945. */
  123946. getClassName(): string;
  123947. /**
  123948. * Gets the input component
  123949. */
  123950. readonly input: NodeMaterialConnectionPoint;
  123951. /**
  123952. * Gets the output component
  123953. */
  123954. readonly output: NodeMaterialConnectionPoint;
  123955. protected _buildBlock(state: NodeMaterialBuildState): this;
  123956. }
  123957. }
  123958. declare module BABYLON {
  123959. /**
  123960. * Block used to get the view direction
  123961. */
  123962. export class ViewDirectionBlock extends NodeMaterialBlock {
  123963. /**
  123964. * Creates a new ViewDirectionBlock
  123965. * @param name defines the block name
  123966. */
  123967. constructor(name: string);
  123968. /**
  123969. * Gets the current class name
  123970. * @returns the class name
  123971. */
  123972. getClassName(): string;
  123973. /**
  123974. * Gets the world position component
  123975. */
  123976. readonly worldPosition: NodeMaterialConnectionPoint;
  123977. /**
  123978. * Gets the camera position component
  123979. */
  123980. readonly cameraPosition: NodeMaterialConnectionPoint;
  123981. /**
  123982. * Gets the output component
  123983. */
  123984. readonly output: NodeMaterialConnectionPoint;
  123985. autoConfigure(material: NodeMaterial): void;
  123986. protected _buildBlock(state: NodeMaterialBuildState): this;
  123987. }
  123988. }
  123989. declare module BABYLON {
  123990. /**
  123991. * Block used to compute fresnel value
  123992. */
  123993. export class FresnelBlock extends NodeMaterialBlock {
  123994. /**
  123995. * Create a new FresnelBlock
  123996. * @param name defines the block name
  123997. */
  123998. constructor(name: string);
  123999. /**
  124000. * Gets the current class name
  124001. * @returns the class name
  124002. */
  124003. getClassName(): string;
  124004. /**
  124005. * Gets the world normal input component
  124006. */
  124007. readonly worldNormal: NodeMaterialConnectionPoint;
  124008. /**
  124009. * Gets the view direction input component
  124010. */
  124011. readonly viewDirection: NodeMaterialConnectionPoint;
  124012. /**
  124013. * Gets the bias input component
  124014. */
  124015. readonly bias: NodeMaterialConnectionPoint;
  124016. /**
  124017. * Gets the camera (or eye) position component
  124018. */
  124019. readonly power: NodeMaterialConnectionPoint;
  124020. /**
  124021. * Gets the fresnel output component
  124022. */
  124023. readonly fresnel: NodeMaterialConnectionPoint;
  124024. autoConfigure(material: NodeMaterial): void;
  124025. protected _buildBlock(state: NodeMaterialBuildState): this;
  124026. }
  124027. }
  124028. declare module BABYLON {
  124029. /**
  124030. * Block used to get the max of 2 values
  124031. */
  124032. export class MaxBlock extends NodeMaterialBlock {
  124033. /**
  124034. * Creates a new MaxBlock
  124035. * @param name defines the block name
  124036. */
  124037. constructor(name: string);
  124038. /**
  124039. * Gets the current class name
  124040. * @returns the class name
  124041. */
  124042. getClassName(): string;
  124043. /**
  124044. * Gets the left operand input component
  124045. */
  124046. readonly left: NodeMaterialConnectionPoint;
  124047. /**
  124048. * Gets the right operand input component
  124049. */
  124050. readonly right: NodeMaterialConnectionPoint;
  124051. /**
  124052. * Gets the output component
  124053. */
  124054. readonly output: NodeMaterialConnectionPoint;
  124055. protected _buildBlock(state: NodeMaterialBuildState): this;
  124056. }
  124057. }
  124058. declare module BABYLON {
  124059. /**
  124060. * Block used to get the min of 2 values
  124061. */
  124062. export class MinBlock extends NodeMaterialBlock {
  124063. /**
  124064. * Creates a new MinBlock
  124065. * @param name defines the block name
  124066. */
  124067. constructor(name: string);
  124068. /**
  124069. * Gets the current class name
  124070. * @returns the class name
  124071. */
  124072. getClassName(): string;
  124073. /**
  124074. * Gets the left operand input component
  124075. */
  124076. readonly left: NodeMaterialConnectionPoint;
  124077. /**
  124078. * Gets the right operand input component
  124079. */
  124080. readonly right: NodeMaterialConnectionPoint;
  124081. /**
  124082. * Gets the output component
  124083. */
  124084. readonly output: NodeMaterialConnectionPoint;
  124085. protected _buildBlock(state: NodeMaterialBuildState): this;
  124086. }
  124087. }
  124088. declare module BABYLON {
  124089. /**
  124090. * Block used to get the distance between 2 values
  124091. */
  124092. export class DistanceBlock extends NodeMaterialBlock {
  124093. /**
  124094. * Creates a new DistanceBlock
  124095. * @param name defines the block name
  124096. */
  124097. constructor(name: string);
  124098. /**
  124099. * Gets the current class name
  124100. * @returns the class name
  124101. */
  124102. getClassName(): string;
  124103. /**
  124104. * Gets the left operand input component
  124105. */
  124106. readonly left: NodeMaterialConnectionPoint;
  124107. /**
  124108. * Gets the right operand input component
  124109. */
  124110. readonly right: NodeMaterialConnectionPoint;
  124111. /**
  124112. * Gets the output component
  124113. */
  124114. readonly output: NodeMaterialConnectionPoint;
  124115. protected _buildBlock(state: NodeMaterialBuildState): this;
  124116. }
  124117. }
  124118. declare module BABYLON {
  124119. /**
  124120. * Block used to get the length of a vector
  124121. */
  124122. export class LengthBlock extends NodeMaterialBlock {
  124123. /**
  124124. * Creates a new LengthBlock
  124125. * @param name defines the block name
  124126. */
  124127. constructor(name: string);
  124128. /**
  124129. * Gets the current class name
  124130. * @returns the class name
  124131. */
  124132. getClassName(): string;
  124133. /**
  124134. * Gets the value input component
  124135. */
  124136. readonly value: NodeMaterialConnectionPoint;
  124137. /**
  124138. * Gets the output component
  124139. */
  124140. readonly output: NodeMaterialConnectionPoint;
  124141. protected _buildBlock(state: NodeMaterialBuildState): this;
  124142. }
  124143. }
  124144. declare module BABYLON {
  124145. /**
  124146. * Block used to get negative version of a value (i.e. x * -1)
  124147. */
  124148. export class NegateBlock extends NodeMaterialBlock {
  124149. /**
  124150. * Creates a new NegateBlock
  124151. * @param name defines the block name
  124152. */
  124153. constructor(name: string);
  124154. /**
  124155. * Gets the current class name
  124156. * @returns the class name
  124157. */
  124158. getClassName(): string;
  124159. /**
  124160. * Gets the value input component
  124161. */
  124162. readonly value: NodeMaterialConnectionPoint;
  124163. /**
  124164. * Gets the output component
  124165. */
  124166. readonly output: NodeMaterialConnectionPoint;
  124167. protected _buildBlock(state: NodeMaterialBuildState): this;
  124168. }
  124169. }
  124170. declare module BABYLON {
  124171. /**
  124172. * Block used to get the value of the first parameter raised to the power of the second
  124173. */
  124174. export class PowBlock extends NodeMaterialBlock {
  124175. /**
  124176. * Creates a new PowBlock
  124177. * @param name defines the block name
  124178. */
  124179. constructor(name: string);
  124180. /**
  124181. * Gets the current class name
  124182. * @returns the class name
  124183. */
  124184. getClassName(): string;
  124185. /**
  124186. * Gets the value operand input component
  124187. */
  124188. readonly value: NodeMaterialConnectionPoint;
  124189. /**
  124190. * Gets the power operand input component
  124191. */
  124192. readonly power: NodeMaterialConnectionPoint;
  124193. /**
  124194. * Gets the output component
  124195. */
  124196. readonly output: NodeMaterialConnectionPoint;
  124197. protected _buildBlock(state: NodeMaterialBuildState): this;
  124198. }
  124199. }
  124200. declare module BABYLON {
  124201. /**
  124202. * Block used to get a random number
  124203. */
  124204. export class RandomNumberBlock extends NodeMaterialBlock {
  124205. /**
  124206. * Creates a new RandomNumberBlock
  124207. * @param name defines the block name
  124208. */
  124209. constructor(name: string);
  124210. /**
  124211. * Gets the current class name
  124212. * @returns the class name
  124213. */
  124214. getClassName(): string;
  124215. /**
  124216. * Gets the seed input component
  124217. */
  124218. readonly seed: NodeMaterialConnectionPoint;
  124219. /**
  124220. * Gets the output component
  124221. */
  124222. readonly output: NodeMaterialConnectionPoint;
  124223. protected _buildBlock(state: NodeMaterialBuildState): this;
  124224. }
  124225. }
  124226. declare module BABYLON {
  124227. /**
  124228. * Block used to compute arc tangent of 2 values
  124229. */
  124230. export class ArcTan2Block extends NodeMaterialBlock {
  124231. /**
  124232. * Creates a new ArcTan2Block
  124233. * @param name defines the block name
  124234. */
  124235. constructor(name: string);
  124236. /**
  124237. * Gets the current class name
  124238. * @returns the class name
  124239. */
  124240. getClassName(): string;
  124241. /**
  124242. * Gets the x operand input component
  124243. */
  124244. readonly x: NodeMaterialConnectionPoint;
  124245. /**
  124246. * Gets the y operand input component
  124247. */
  124248. readonly y: NodeMaterialConnectionPoint;
  124249. /**
  124250. * Gets the output component
  124251. */
  124252. readonly output: NodeMaterialConnectionPoint;
  124253. protected _buildBlock(state: NodeMaterialBuildState): this;
  124254. }
  124255. }
  124256. declare module BABYLON {
  124257. /**
  124258. * Block used to smooth step a value
  124259. */
  124260. export class SmoothStepBlock extends NodeMaterialBlock {
  124261. /**
  124262. * Creates a new SmoothStepBlock
  124263. * @param name defines the block name
  124264. */
  124265. constructor(name: string);
  124266. /**
  124267. * Gets the current class name
  124268. * @returns the class name
  124269. */
  124270. getClassName(): string;
  124271. /**
  124272. * Gets the value operand input component
  124273. */
  124274. readonly value: NodeMaterialConnectionPoint;
  124275. /**
  124276. * Gets the first edge operand input component
  124277. */
  124278. readonly edge0: NodeMaterialConnectionPoint;
  124279. /**
  124280. * Gets the second edge operand input component
  124281. */
  124282. readonly edge1: NodeMaterialConnectionPoint;
  124283. /**
  124284. * Gets the output component
  124285. */
  124286. readonly output: NodeMaterialConnectionPoint;
  124287. protected _buildBlock(state: NodeMaterialBuildState): this;
  124288. }
  124289. }
  124290. declare module BABYLON {
  124291. /**
  124292. * Block used to get the reciprocal (1 / x) of a value
  124293. */
  124294. export class ReciprocalBlock extends NodeMaterialBlock {
  124295. /**
  124296. * Creates a new ReciprocalBlock
  124297. * @param name defines the block name
  124298. */
  124299. constructor(name: string);
  124300. /**
  124301. * Gets the current class name
  124302. * @returns the class name
  124303. */
  124304. getClassName(): string;
  124305. /**
  124306. * Gets the input component
  124307. */
  124308. readonly input: NodeMaterialConnectionPoint;
  124309. /**
  124310. * Gets the output component
  124311. */
  124312. readonly output: NodeMaterialConnectionPoint;
  124313. protected _buildBlock(state: NodeMaterialBuildState): this;
  124314. }
  124315. }
  124316. declare module BABYLON {
  124317. /**
  124318. * Block used to replace a color by another one
  124319. */
  124320. export class ReplaceColorBlock extends NodeMaterialBlock {
  124321. /**
  124322. * Creates a new ReplaceColorBlock
  124323. * @param name defines the block name
  124324. */
  124325. constructor(name: string);
  124326. /**
  124327. * Gets the current class name
  124328. * @returns the class name
  124329. */
  124330. getClassName(): string;
  124331. /**
  124332. * Gets the value input component
  124333. */
  124334. readonly value: NodeMaterialConnectionPoint;
  124335. /**
  124336. * Gets the reference input component
  124337. */
  124338. readonly reference: NodeMaterialConnectionPoint;
  124339. /**
  124340. * Gets the distance input component
  124341. */
  124342. readonly distance: NodeMaterialConnectionPoint;
  124343. /**
  124344. * Gets the replacement input component
  124345. */
  124346. readonly replacement: NodeMaterialConnectionPoint;
  124347. /**
  124348. * Gets the output component
  124349. */
  124350. readonly output: NodeMaterialConnectionPoint;
  124351. protected _buildBlock(state: NodeMaterialBuildState): this;
  124352. }
  124353. }
  124354. declare module BABYLON {
  124355. /**
  124356. * Block used to posterize a value
  124357. * @see https://en.wikipedia.org/wiki/Posterization
  124358. */
  124359. export class PosterizeBlock extends NodeMaterialBlock {
  124360. /**
  124361. * Creates a new PosterizeBlock
  124362. * @param name defines the block name
  124363. */
  124364. constructor(name: string);
  124365. /**
  124366. * Gets the current class name
  124367. * @returns the class name
  124368. */
  124369. getClassName(): string;
  124370. /**
  124371. * Gets the value input component
  124372. */
  124373. readonly value: NodeMaterialConnectionPoint;
  124374. /**
  124375. * Gets the steps input component
  124376. */
  124377. readonly steps: NodeMaterialConnectionPoint;
  124378. /**
  124379. * Gets the output component
  124380. */
  124381. readonly output: NodeMaterialConnectionPoint;
  124382. protected _buildBlock(state: NodeMaterialBuildState): this;
  124383. }
  124384. }
  124385. declare module BABYLON {
  124386. /**
  124387. * Operations supported by the Wave block
  124388. */
  124389. export enum WaveBlockKind {
  124390. /** SawTooth */
  124391. SawTooth = 0,
  124392. /** Square */
  124393. Square = 1,
  124394. /** Triangle */
  124395. Triangle = 2
  124396. }
  124397. /**
  124398. * Block used to apply wave operation to floats
  124399. */
  124400. export class WaveBlock extends NodeMaterialBlock {
  124401. /**
  124402. * Gets or sets the kibnd of wave to be applied by the block
  124403. */
  124404. kind: WaveBlockKind;
  124405. /**
  124406. * Creates a new WaveBlock
  124407. * @param name defines the block name
  124408. */
  124409. constructor(name: string);
  124410. /**
  124411. * Gets the current class name
  124412. * @returns the class name
  124413. */
  124414. getClassName(): string;
  124415. /**
  124416. * Gets the input component
  124417. */
  124418. readonly input: NodeMaterialConnectionPoint;
  124419. /**
  124420. * Gets the output component
  124421. */
  124422. readonly output: NodeMaterialConnectionPoint;
  124423. protected _buildBlock(state: NodeMaterialBuildState): this;
  124424. serialize(): any;
  124425. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124426. }
  124427. }
  124428. declare module BABYLON {
  124429. /**
  124430. * Class used to store a color step for the GradientBlock
  124431. */
  124432. export class GradientBlockColorStep {
  124433. /**
  124434. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124435. */
  124436. step: number;
  124437. /**
  124438. * Gets or sets the color associated with this step
  124439. */
  124440. color: Color3;
  124441. /**
  124442. * Creates a new GradientBlockColorStep
  124443. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  124444. * @param color defines the color associated with this step
  124445. */
  124446. constructor(
  124447. /**
  124448. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124449. */
  124450. step: number,
  124451. /**
  124452. * Gets or sets the color associated with this step
  124453. */
  124454. color: Color3);
  124455. }
  124456. /**
  124457. * Block used to return a color from a gradient based on an input value between 0 and 1
  124458. */
  124459. export class GradientBlock extends NodeMaterialBlock {
  124460. /**
  124461. * Gets or sets the list of color steps
  124462. */
  124463. colorSteps: GradientBlockColorStep[];
  124464. /**
  124465. * Creates a new GradientBlock
  124466. * @param name defines the block name
  124467. */
  124468. constructor(name: string);
  124469. /**
  124470. * Gets the current class name
  124471. * @returns the class name
  124472. */
  124473. getClassName(): string;
  124474. /**
  124475. * Gets the gradient input component
  124476. */
  124477. readonly gradient: NodeMaterialConnectionPoint;
  124478. /**
  124479. * Gets the output component
  124480. */
  124481. readonly output: NodeMaterialConnectionPoint;
  124482. private _writeColorConstant;
  124483. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124484. serialize(): any;
  124485. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124486. protected _dumpPropertiesCode(): string;
  124487. }
  124488. }
  124489. declare module BABYLON {
  124490. /**
  124491. * Block used to normalize lerp between 2 values
  124492. */
  124493. export class NLerpBlock extends NodeMaterialBlock {
  124494. /**
  124495. * Creates a new NLerpBlock
  124496. * @param name defines the block name
  124497. */
  124498. constructor(name: string);
  124499. /**
  124500. * Gets the current class name
  124501. * @returns the class name
  124502. */
  124503. getClassName(): string;
  124504. /**
  124505. * Gets the left operand input component
  124506. */
  124507. readonly left: NodeMaterialConnectionPoint;
  124508. /**
  124509. * Gets the right operand input component
  124510. */
  124511. readonly right: NodeMaterialConnectionPoint;
  124512. /**
  124513. * Gets the gradient operand input component
  124514. */
  124515. readonly gradient: NodeMaterialConnectionPoint;
  124516. /**
  124517. * Gets the output component
  124518. */
  124519. readonly output: NodeMaterialConnectionPoint;
  124520. protected _buildBlock(state: NodeMaterialBuildState): this;
  124521. }
  124522. }
  124523. declare module BABYLON {
  124524. /**
  124525. * Effect Render Options
  124526. */
  124527. export interface IEffectRendererOptions {
  124528. /**
  124529. * Defines the vertices positions.
  124530. */
  124531. positions?: number[];
  124532. /**
  124533. * Defines the indices.
  124534. */
  124535. indices?: number[];
  124536. }
  124537. /**
  124538. * Helper class to render one or more effects
  124539. */
  124540. export class EffectRenderer {
  124541. private engine;
  124542. private static _DefaultOptions;
  124543. private _vertexBuffers;
  124544. private _indexBuffer;
  124545. private _ringBufferIndex;
  124546. private _ringScreenBuffer;
  124547. private _fullscreenViewport;
  124548. private _getNextFrameBuffer;
  124549. /**
  124550. * Creates an effect renderer
  124551. * @param engine the engine to use for rendering
  124552. * @param options defines the options of the effect renderer
  124553. */
  124554. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  124555. /**
  124556. * Sets the current viewport in normalized coordinates 0-1
  124557. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  124558. */
  124559. setViewport(viewport?: Viewport): void;
  124560. /**
  124561. * Binds the embedded attributes buffer to the effect.
  124562. * @param effect Defines the effect to bind the attributes for
  124563. */
  124564. bindBuffers(effect: Effect): void;
  124565. /**
  124566. * Sets the current effect wrapper to use during draw.
  124567. * The effect needs to be ready before calling this api.
  124568. * This also sets the default full screen position attribute.
  124569. * @param effectWrapper Defines the effect to draw with
  124570. */
  124571. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  124572. /**
  124573. * Draws a full screen quad.
  124574. */
  124575. draw(): void;
  124576. /**
  124577. * renders one or more effects to a specified texture
  124578. * @param effectWrappers list of effects to renderer
  124579. * @param outputTexture texture to draw to, if null it will render to the screen
  124580. */
  124581. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  124582. /**
  124583. * Disposes of the effect renderer
  124584. */
  124585. dispose(): void;
  124586. }
  124587. /**
  124588. * Options to create an EffectWrapper
  124589. */
  124590. interface EffectWrapperCreationOptions {
  124591. /**
  124592. * Engine to use to create the effect
  124593. */
  124594. engine: ThinEngine;
  124595. /**
  124596. * Fragment shader for the effect
  124597. */
  124598. fragmentShader: string;
  124599. /**
  124600. * Vertex shader for the effect
  124601. */
  124602. vertexShader?: string;
  124603. /**
  124604. * Attributes to use in the shader
  124605. */
  124606. attributeNames?: Array<string>;
  124607. /**
  124608. * Uniforms to use in the shader
  124609. */
  124610. uniformNames?: Array<string>;
  124611. /**
  124612. * Texture sampler names to use in the shader
  124613. */
  124614. samplerNames?: Array<string>;
  124615. /**
  124616. * The friendly name of the effect displayed in Spector.
  124617. */
  124618. name?: string;
  124619. }
  124620. /**
  124621. * Wraps an effect to be used for rendering
  124622. */
  124623. export class EffectWrapper {
  124624. /**
  124625. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  124626. */
  124627. onApplyObservable: Observable<{}>;
  124628. /**
  124629. * The underlying effect
  124630. */
  124631. effect: Effect;
  124632. /**
  124633. * Creates an effect to be renderer
  124634. * @param creationOptions options to create the effect
  124635. */
  124636. constructor(creationOptions: EffectWrapperCreationOptions);
  124637. /**
  124638. * Disposes of the effect wrapper
  124639. */
  124640. dispose(): void;
  124641. }
  124642. }
  124643. declare module BABYLON {
  124644. /**
  124645. * Helper class to push actions to a pool of workers.
  124646. */
  124647. export class WorkerPool implements IDisposable {
  124648. private _workerInfos;
  124649. private _pendingActions;
  124650. /**
  124651. * Constructor
  124652. * @param workers Array of workers to use for actions
  124653. */
  124654. constructor(workers: Array<Worker>);
  124655. /**
  124656. * Terminates all workers and clears any pending actions.
  124657. */
  124658. dispose(): void;
  124659. /**
  124660. * Pushes an action to the worker pool. If all the workers are active, the action will be
  124661. * pended until a worker has completed its action.
  124662. * @param action The action to perform. Call onComplete when the action is complete.
  124663. */
  124664. push(action: (worker: Worker, onComplete: () => void) => void): void;
  124665. private _execute;
  124666. }
  124667. }
  124668. declare module BABYLON {
  124669. /**
  124670. * Configuration for Draco compression
  124671. */
  124672. export interface IDracoCompressionConfiguration {
  124673. /**
  124674. * Configuration for the decoder.
  124675. */
  124676. decoder: {
  124677. /**
  124678. * The url to the WebAssembly module.
  124679. */
  124680. wasmUrl?: string;
  124681. /**
  124682. * The url to the WebAssembly binary.
  124683. */
  124684. wasmBinaryUrl?: string;
  124685. /**
  124686. * The url to the fallback JavaScript module.
  124687. */
  124688. fallbackUrl?: string;
  124689. };
  124690. }
  124691. /**
  124692. * Draco compression (https://google.github.io/draco/)
  124693. *
  124694. * This class wraps the Draco module.
  124695. *
  124696. * **Encoder**
  124697. *
  124698. * The encoder is not currently implemented.
  124699. *
  124700. * **Decoder**
  124701. *
  124702. * 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.
  124703. *
  124704. * To update the configuration, use the following code:
  124705. * ```javascript
  124706. * DracoCompression.Configuration = {
  124707. * decoder: {
  124708. * wasmUrl: "<url to the WebAssembly library>",
  124709. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  124710. * fallbackUrl: "<url to the fallback JavaScript library>",
  124711. * }
  124712. * };
  124713. * ```
  124714. *
  124715. * 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.
  124716. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  124717. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  124718. *
  124719. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  124720. * ```javascript
  124721. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  124722. * ```
  124723. *
  124724. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  124725. */
  124726. export class DracoCompression implements IDisposable {
  124727. private _workerPoolPromise?;
  124728. private _decoderModulePromise?;
  124729. /**
  124730. * The configuration. Defaults to the following urls:
  124731. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  124732. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  124733. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  124734. */
  124735. static Configuration: IDracoCompressionConfiguration;
  124736. /**
  124737. * Returns true if the decoder configuration is available.
  124738. */
  124739. static readonly DecoderAvailable: boolean;
  124740. /**
  124741. * Default number of workers to create when creating the draco compression object.
  124742. */
  124743. static DefaultNumWorkers: number;
  124744. private static GetDefaultNumWorkers;
  124745. private static _Default;
  124746. /**
  124747. * Default instance for the draco compression object.
  124748. */
  124749. static readonly Default: DracoCompression;
  124750. /**
  124751. * Constructor
  124752. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  124753. */
  124754. constructor(numWorkers?: number);
  124755. /**
  124756. * Stop all async operations and release resources.
  124757. */
  124758. dispose(): void;
  124759. /**
  124760. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  124761. * @returns a promise that resolves when ready
  124762. */
  124763. whenReadyAsync(): Promise<void>;
  124764. /**
  124765. * Decode Draco compressed mesh data to vertex data.
  124766. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  124767. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  124768. * @returns A promise that resolves with the decoded vertex data
  124769. */
  124770. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  124771. [kind: string]: number;
  124772. }): Promise<VertexData>;
  124773. }
  124774. }
  124775. declare module BABYLON {
  124776. /**
  124777. * Class for building Constructive Solid Geometry
  124778. */
  124779. export class CSG {
  124780. private polygons;
  124781. /**
  124782. * The world matrix
  124783. */
  124784. matrix: Matrix;
  124785. /**
  124786. * Stores the position
  124787. */
  124788. position: Vector3;
  124789. /**
  124790. * Stores the rotation
  124791. */
  124792. rotation: Vector3;
  124793. /**
  124794. * Stores the rotation quaternion
  124795. */
  124796. rotationQuaternion: Nullable<Quaternion>;
  124797. /**
  124798. * Stores the scaling vector
  124799. */
  124800. scaling: Vector3;
  124801. /**
  124802. * Convert the Mesh to CSG
  124803. * @param mesh The Mesh to convert to CSG
  124804. * @returns A new CSG from the Mesh
  124805. */
  124806. static FromMesh(mesh: Mesh): CSG;
  124807. /**
  124808. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  124809. * @param polygons Polygons used to construct a CSG solid
  124810. */
  124811. private static FromPolygons;
  124812. /**
  124813. * Clones, or makes a deep copy, of the CSG
  124814. * @returns A new CSG
  124815. */
  124816. clone(): CSG;
  124817. /**
  124818. * Unions this CSG with another CSG
  124819. * @param csg The CSG to union against this CSG
  124820. * @returns The unioned CSG
  124821. */
  124822. union(csg: CSG): CSG;
  124823. /**
  124824. * Unions this CSG with another CSG in place
  124825. * @param csg The CSG to union against this CSG
  124826. */
  124827. unionInPlace(csg: CSG): void;
  124828. /**
  124829. * Subtracts this CSG with another CSG
  124830. * @param csg The CSG to subtract against this CSG
  124831. * @returns A new CSG
  124832. */
  124833. subtract(csg: CSG): CSG;
  124834. /**
  124835. * Subtracts this CSG with another CSG in place
  124836. * @param csg The CSG to subtact against this CSG
  124837. */
  124838. subtractInPlace(csg: CSG): void;
  124839. /**
  124840. * Intersect this CSG with another CSG
  124841. * @param csg The CSG to intersect against this CSG
  124842. * @returns A new CSG
  124843. */
  124844. intersect(csg: CSG): CSG;
  124845. /**
  124846. * Intersects this CSG with another CSG in place
  124847. * @param csg The CSG to intersect against this CSG
  124848. */
  124849. intersectInPlace(csg: CSG): void;
  124850. /**
  124851. * Return a new CSG solid with solid and empty space switched. This solid is
  124852. * not modified.
  124853. * @returns A new CSG solid with solid and empty space switched
  124854. */
  124855. inverse(): CSG;
  124856. /**
  124857. * Inverses the CSG in place
  124858. */
  124859. inverseInPlace(): void;
  124860. /**
  124861. * This is used to keep meshes transformations so they can be restored
  124862. * when we build back a Babylon Mesh
  124863. * NB : All CSG operations are performed in world coordinates
  124864. * @param csg The CSG to copy the transform attributes from
  124865. * @returns This CSG
  124866. */
  124867. copyTransformAttributes(csg: CSG): CSG;
  124868. /**
  124869. * Build Raw mesh from CSG
  124870. * Coordinates here are in world space
  124871. * @param name The name of the mesh geometry
  124872. * @param scene The Scene
  124873. * @param keepSubMeshes Specifies if the submeshes should be kept
  124874. * @returns A new Mesh
  124875. */
  124876. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124877. /**
  124878. * Build Mesh from CSG taking material and transforms into account
  124879. * @param name The name of the Mesh
  124880. * @param material The material of the Mesh
  124881. * @param scene The Scene
  124882. * @param keepSubMeshes Specifies if submeshes should be kept
  124883. * @returns The new Mesh
  124884. */
  124885. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124886. }
  124887. }
  124888. declare module BABYLON {
  124889. /**
  124890. * Class used to create a trail following a mesh
  124891. */
  124892. export class TrailMesh extends Mesh {
  124893. private _generator;
  124894. private _autoStart;
  124895. private _running;
  124896. private _diameter;
  124897. private _length;
  124898. private _sectionPolygonPointsCount;
  124899. private _sectionVectors;
  124900. private _sectionNormalVectors;
  124901. private _beforeRenderObserver;
  124902. /**
  124903. * @constructor
  124904. * @param name The value used by scene.getMeshByName() to do a lookup.
  124905. * @param generator The mesh to generate a trail.
  124906. * @param scene The scene to add this mesh to.
  124907. * @param diameter Diameter of trailing mesh. Default is 1.
  124908. * @param length Length of trailing mesh. Default is 60.
  124909. * @param autoStart Automatically start trailing mesh. Default true.
  124910. */
  124911. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  124912. /**
  124913. * "TrailMesh"
  124914. * @returns "TrailMesh"
  124915. */
  124916. getClassName(): string;
  124917. private _createMesh;
  124918. /**
  124919. * Start trailing mesh.
  124920. */
  124921. start(): void;
  124922. /**
  124923. * Stop trailing mesh.
  124924. */
  124925. stop(): void;
  124926. /**
  124927. * Update trailing mesh geometry.
  124928. */
  124929. update(): void;
  124930. /**
  124931. * Returns a new TrailMesh object.
  124932. * @param name is a string, the name given to the new mesh
  124933. * @param newGenerator use new generator object for cloned trail mesh
  124934. * @returns a new mesh
  124935. */
  124936. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  124937. /**
  124938. * Serializes this trail mesh
  124939. * @param serializationObject object to write serialization to
  124940. */
  124941. serialize(serializationObject: any): void;
  124942. /**
  124943. * Parses a serialized trail mesh
  124944. * @param parsedMesh the serialized mesh
  124945. * @param scene the scene to create the trail mesh in
  124946. * @returns the created trail mesh
  124947. */
  124948. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  124949. }
  124950. }
  124951. declare module BABYLON {
  124952. /**
  124953. * Class containing static functions to help procedurally build meshes
  124954. */
  124955. export class TiledBoxBuilder {
  124956. /**
  124957. * Creates a box mesh
  124958. * 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)
  124959. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124963. * @param name defines the name of the mesh
  124964. * @param options defines the options used to create the mesh
  124965. * @param scene defines the hosting scene
  124966. * @returns the box mesh
  124967. */
  124968. static CreateTiledBox(name: string, options: {
  124969. pattern?: number;
  124970. width?: number;
  124971. height?: number;
  124972. depth?: number;
  124973. tileSize?: number;
  124974. tileWidth?: number;
  124975. tileHeight?: number;
  124976. alignHorizontal?: number;
  124977. alignVertical?: number;
  124978. faceUV?: Vector4[];
  124979. faceColors?: Color4[];
  124980. sideOrientation?: number;
  124981. updatable?: boolean;
  124982. }, scene?: Nullable<Scene>): Mesh;
  124983. }
  124984. }
  124985. declare module BABYLON {
  124986. /**
  124987. * Class containing static functions to help procedurally build meshes
  124988. */
  124989. export class TorusKnotBuilder {
  124990. /**
  124991. * Creates a torus knot mesh
  124992. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124993. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124994. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124995. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124999. * @param name defines the name of the mesh
  125000. * @param options defines the options used to create the mesh
  125001. * @param scene defines the hosting scene
  125002. * @returns the torus knot mesh
  125003. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125004. */
  125005. static CreateTorusKnot(name: string, options: {
  125006. radius?: number;
  125007. tube?: number;
  125008. radialSegments?: number;
  125009. tubularSegments?: number;
  125010. p?: number;
  125011. q?: number;
  125012. updatable?: boolean;
  125013. sideOrientation?: number;
  125014. frontUVs?: Vector4;
  125015. backUVs?: Vector4;
  125016. }, scene: any): Mesh;
  125017. }
  125018. }
  125019. declare module BABYLON {
  125020. /**
  125021. * Polygon
  125022. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  125023. */
  125024. export class Polygon {
  125025. /**
  125026. * Creates a rectangle
  125027. * @param xmin bottom X coord
  125028. * @param ymin bottom Y coord
  125029. * @param xmax top X coord
  125030. * @param ymax top Y coord
  125031. * @returns points that make the resulting rectation
  125032. */
  125033. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  125034. /**
  125035. * Creates a circle
  125036. * @param radius radius of circle
  125037. * @param cx scale in x
  125038. * @param cy scale in y
  125039. * @param numberOfSides number of sides that make up the circle
  125040. * @returns points that make the resulting circle
  125041. */
  125042. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  125043. /**
  125044. * Creates a polygon from input string
  125045. * @param input Input polygon data
  125046. * @returns the parsed points
  125047. */
  125048. static Parse(input: string): Vector2[];
  125049. /**
  125050. * Starts building a polygon from x and y coordinates
  125051. * @param x x coordinate
  125052. * @param y y coordinate
  125053. * @returns the started path2
  125054. */
  125055. static StartingAt(x: number, y: number): Path2;
  125056. }
  125057. /**
  125058. * Builds a polygon
  125059. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  125060. */
  125061. export class PolygonMeshBuilder {
  125062. private _points;
  125063. private _outlinepoints;
  125064. private _holes;
  125065. private _name;
  125066. private _scene;
  125067. private _epoints;
  125068. private _eholes;
  125069. private _addToepoint;
  125070. /**
  125071. * Babylon reference to the earcut plugin.
  125072. */
  125073. bjsEarcut: any;
  125074. /**
  125075. * Creates a PolygonMeshBuilder
  125076. * @param name name of the builder
  125077. * @param contours Path of the polygon
  125078. * @param scene scene to add to when creating the mesh
  125079. * @param earcutInjection can be used to inject your own earcut reference
  125080. */
  125081. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  125082. /**
  125083. * Adds a whole within the polygon
  125084. * @param hole Array of points defining the hole
  125085. * @returns this
  125086. */
  125087. addHole(hole: Vector2[]): PolygonMeshBuilder;
  125088. /**
  125089. * Creates the polygon
  125090. * @param updatable If the mesh should be updatable
  125091. * @param depth The depth of the mesh created
  125092. * @returns the created mesh
  125093. */
  125094. build(updatable?: boolean, depth?: number): Mesh;
  125095. /**
  125096. * Creates the polygon
  125097. * @param depth The depth of the mesh created
  125098. * @returns the created VertexData
  125099. */
  125100. buildVertexData(depth?: number): VertexData;
  125101. /**
  125102. * Adds a side to the polygon
  125103. * @param positions points that make the polygon
  125104. * @param normals normals of the polygon
  125105. * @param uvs uvs of the polygon
  125106. * @param indices indices of the polygon
  125107. * @param bounds bounds of the polygon
  125108. * @param points points of the polygon
  125109. * @param depth depth of the polygon
  125110. * @param flip flip of the polygon
  125111. */
  125112. private addSide;
  125113. }
  125114. }
  125115. declare module BABYLON {
  125116. /**
  125117. * Class containing static functions to help procedurally build meshes
  125118. */
  125119. export class PolygonBuilder {
  125120. /**
  125121. * Creates a polygon mesh
  125122. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125123. * * 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
  125124. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125127. * * Remember you can only change the shape positions, not their number when updating a polygon
  125128. * @param name defines the name of the mesh
  125129. * @param options defines the options used to create the mesh
  125130. * @param scene defines the hosting scene
  125131. * @param earcutInjection can be used to inject your own earcut reference
  125132. * @returns the polygon mesh
  125133. */
  125134. static CreatePolygon(name: string, options: {
  125135. shape: Vector3[];
  125136. holes?: Vector3[][];
  125137. depth?: number;
  125138. faceUV?: Vector4[];
  125139. faceColors?: Color4[];
  125140. updatable?: boolean;
  125141. sideOrientation?: number;
  125142. frontUVs?: Vector4;
  125143. backUVs?: Vector4;
  125144. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125145. /**
  125146. * Creates an extruded polygon mesh, with depth in the Y direction.
  125147. * * 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)
  125148. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125149. * @param name defines the name of the mesh
  125150. * @param options defines the options used to create the mesh
  125151. * @param scene defines the hosting scene
  125152. * @param earcutInjection can be used to inject your own earcut reference
  125153. * @returns the polygon mesh
  125154. */
  125155. static ExtrudePolygon(name: string, options: {
  125156. shape: Vector3[];
  125157. holes?: Vector3[][];
  125158. depth?: number;
  125159. faceUV?: Vector4[];
  125160. faceColors?: Color4[];
  125161. updatable?: boolean;
  125162. sideOrientation?: number;
  125163. frontUVs?: Vector4;
  125164. backUVs?: Vector4;
  125165. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125166. }
  125167. }
  125168. declare module BABYLON {
  125169. /**
  125170. * Class containing static functions to help procedurally build meshes
  125171. */
  125172. export class LatheBuilder {
  125173. /**
  125174. * Creates lathe mesh.
  125175. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125176. * * 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
  125177. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125178. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125179. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125180. * * 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
  125181. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125182. * * 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
  125183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125185. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125187. * @param name defines the name of the mesh
  125188. * @param options defines the options used to create the mesh
  125189. * @param scene defines the hosting scene
  125190. * @returns the lathe mesh
  125191. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125192. */
  125193. static CreateLathe(name: string, options: {
  125194. shape: Vector3[];
  125195. radius?: number;
  125196. tessellation?: number;
  125197. clip?: number;
  125198. arc?: number;
  125199. closed?: boolean;
  125200. updatable?: boolean;
  125201. sideOrientation?: number;
  125202. frontUVs?: Vector4;
  125203. backUVs?: Vector4;
  125204. cap?: number;
  125205. invertUV?: boolean;
  125206. }, scene?: Nullable<Scene>): Mesh;
  125207. }
  125208. }
  125209. declare module BABYLON {
  125210. /**
  125211. * Class containing static functions to help procedurally build meshes
  125212. */
  125213. export class TiledPlaneBuilder {
  125214. /**
  125215. * Creates a tiled plane mesh
  125216. * * The parameter `pattern` will, depending on value, do nothing or
  125217. * * * flip (reflect about central vertical) alternate tiles across and up
  125218. * * * flip every tile on alternate rows
  125219. * * * rotate (180 degs) alternate tiles across and up
  125220. * * * rotate every tile on alternate rows
  125221. * * * flip and rotate alternate tiles across and up
  125222. * * * flip and rotate every tile on alternate rows
  125223. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  125224. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  125225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125226. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125227. * * 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)
  125228. * * 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)
  125229. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125230. * @param name defines the name of the mesh
  125231. * @param options defines the options used to create the mesh
  125232. * @param scene defines the hosting scene
  125233. * @returns the box mesh
  125234. */
  125235. static CreateTiledPlane(name: string, options: {
  125236. pattern?: number;
  125237. tileSize?: number;
  125238. tileWidth?: number;
  125239. tileHeight?: number;
  125240. size?: number;
  125241. width?: number;
  125242. height?: number;
  125243. alignHorizontal?: number;
  125244. alignVertical?: number;
  125245. sideOrientation?: number;
  125246. frontUVs?: Vector4;
  125247. backUVs?: Vector4;
  125248. updatable?: boolean;
  125249. }, scene?: Nullable<Scene>): Mesh;
  125250. }
  125251. }
  125252. declare module BABYLON {
  125253. /**
  125254. * Class containing static functions to help procedurally build meshes
  125255. */
  125256. export class TubeBuilder {
  125257. /**
  125258. * Creates a tube mesh.
  125259. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125260. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125261. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125262. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125263. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125264. * * 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)
  125265. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125266. * * 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
  125267. * * 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
  125268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125270. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125272. * @param name defines the name of the mesh
  125273. * @param options defines the options used to create the mesh
  125274. * @param scene defines the hosting scene
  125275. * @returns the tube mesh
  125276. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125277. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125278. */
  125279. static CreateTube(name: string, options: {
  125280. path: Vector3[];
  125281. radius?: number;
  125282. tessellation?: number;
  125283. radiusFunction?: {
  125284. (i: number, distance: number): number;
  125285. };
  125286. cap?: number;
  125287. arc?: number;
  125288. updatable?: boolean;
  125289. sideOrientation?: number;
  125290. frontUVs?: Vector4;
  125291. backUVs?: Vector4;
  125292. instance?: Mesh;
  125293. invertUV?: boolean;
  125294. }, scene?: Nullable<Scene>): Mesh;
  125295. }
  125296. }
  125297. declare module BABYLON {
  125298. /**
  125299. * Class containing static functions to help procedurally build meshes
  125300. */
  125301. export class IcoSphereBuilder {
  125302. /**
  125303. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125304. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125305. * * 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`)
  125306. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125307. * * 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
  125308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125311. * @param name defines the name of the mesh
  125312. * @param options defines the options used to create the mesh
  125313. * @param scene defines the hosting scene
  125314. * @returns the icosahedron mesh
  125315. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125316. */
  125317. static CreateIcoSphere(name: string, options: {
  125318. radius?: number;
  125319. radiusX?: number;
  125320. radiusY?: number;
  125321. radiusZ?: number;
  125322. flat?: boolean;
  125323. subdivisions?: number;
  125324. sideOrientation?: number;
  125325. frontUVs?: Vector4;
  125326. backUVs?: Vector4;
  125327. updatable?: boolean;
  125328. }, scene?: Nullable<Scene>): Mesh;
  125329. }
  125330. }
  125331. declare module BABYLON {
  125332. /**
  125333. * Class containing static functions to help procedurally build meshes
  125334. */
  125335. export class DecalBuilder {
  125336. /**
  125337. * Creates a decal mesh.
  125338. * 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
  125339. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125340. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125341. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125342. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125343. * @param name defines the name of the mesh
  125344. * @param sourceMesh defines the mesh where the decal must be applied
  125345. * @param options defines the options used to create the mesh
  125346. * @param scene defines the hosting scene
  125347. * @returns the decal mesh
  125348. * @see https://doc.babylonjs.com/how_to/decals
  125349. */
  125350. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125351. position?: Vector3;
  125352. normal?: Vector3;
  125353. size?: Vector3;
  125354. angle?: number;
  125355. }): Mesh;
  125356. }
  125357. }
  125358. declare module BABYLON {
  125359. /**
  125360. * Class containing static functions to help procedurally build meshes
  125361. */
  125362. export class MeshBuilder {
  125363. /**
  125364. * Creates a box mesh
  125365. * * The parameter `size` sets the size (float) of each box side (default 1)
  125366. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  125367. * * 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)
  125368. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125372. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125373. * @param name defines the name of the mesh
  125374. * @param options defines the options used to create the mesh
  125375. * @param scene defines the hosting scene
  125376. * @returns the box mesh
  125377. */
  125378. static CreateBox(name: string, options: {
  125379. size?: number;
  125380. width?: number;
  125381. height?: number;
  125382. depth?: number;
  125383. faceUV?: Vector4[];
  125384. faceColors?: Color4[];
  125385. sideOrientation?: number;
  125386. frontUVs?: Vector4;
  125387. backUVs?: Vector4;
  125388. updatable?: boolean;
  125389. }, scene?: Nullable<Scene>): Mesh;
  125390. /**
  125391. * Creates a tiled box mesh
  125392. * * faceTiles sets the pattern, tile size and number of tiles for a face
  125393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125394. * @param name defines the name of the mesh
  125395. * @param options defines the options used to create the mesh
  125396. * @param scene defines the hosting scene
  125397. * @returns the tiled box mesh
  125398. */
  125399. static CreateTiledBox(name: string, options: {
  125400. pattern?: number;
  125401. size?: number;
  125402. width?: number;
  125403. height?: number;
  125404. depth: number;
  125405. tileSize?: number;
  125406. tileWidth?: number;
  125407. tileHeight?: number;
  125408. faceUV?: Vector4[];
  125409. faceColors?: Color4[];
  125410. alignHorizontal?: number;
  125411. alignVertical?: number;
  125412. sideOrientation?: number;
  125413. updatable?: boolean;
  125414. }, scene?: Nullable<Scene>): Mesh;
  125415. /**
  125416. * Creates a sphere mesh
  125417. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125418. * * 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`)
  125419. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125420. * * 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
  125421. * * 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)
  125422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125425. * @param name defines the name of the mesh
  125426. * @param options defines the options used to create the mesh
  125427. * @param scene defines the hosting scene
  125428. * @returns the sphere mesh
  125429. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125430. */
  125431. static CreateSphere(name: string, options: {
  125432. segments?: number;
  125433. diameter?: number;
  125434. diameterX?: number;
  125435. diameterY?: number;
  125436. diameterZ?: number;
  125437. arc?: number;
  125438. slice?: number;
  125439. sideOrientation?: number;
  125440. frontUVs?: Vector4;
  125441. backUVs?: Vector4;
  125442. updatable?: boolean;
  125443. }, scene?: Nullable<Scene>): Mesh;
  125444. /**
  125445. * Creates a plane polygonal mesh. By default, this is a disc
  125446. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  125447. * * 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
  125448. * * 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
  125449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125452. * @param name defines the name of the mesh
  125453. * @param options defines the options used to create the mesh
  125454. * @param scene defines the hosting scene
  125455. * @returns the plane polygonal mesh
  125456. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  125457. */
  125458. static CreateDisc(name: string, options: {
  125459. radius?: number;
  125460. tessellation?: number;
  125461. arc?: number;
  125462. updatable?: boolean;
  125463. sideOrientation?: number;
  125464. frontUVs?: Vector4;
  125465. backUVs?: Vector4;
  125466. }, scene?: Nullable<Scene>): Mesh;
  125467. /**
  125468. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125469. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125470. * * 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`)
  125471. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125472. * * 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
  125473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125476. * @param name defines the name of the mesh
  125477. * @param options defines the options used to create the mesh
  125478. * @param scene defines the hosting scene
  125479. * @returns the icosahedron mesh
  125480. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125481. */
  125482. static CreateIcoSphere(name: string, options: {
  125483. radius?: number;
  125484. radiusX?: number;
  125485. radiusY?: number;
  125486. radiusZ?: number;
  125487. flat?: boolean;
  125488. subdivisions?: number;
  125489. sideOrientation?: number;
  125490. frontUVs?: Vector4;
  125491. backUVs?: Vector4;
  125492. updatable?: boolean;
  125493. }, scene?: Nullable<Scene>): Mesh;
  125494. /**
  125495. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125496. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125497. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125498. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125499. * * 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
  125500. * * 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
  125501. * * 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
  125502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125505. * * 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
  125506. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125507. * * 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
  125508. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125510. * @param name defines the name of the mesh
  125511. * @param options defines the options used to create the mesh
  125512. * @param scene defines the hosting scene
  125513. * @returns the ribbon mesh
  125514. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125515. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125516. */
  125517. static CreateRibbon(name: string, options: {
  125518. pathArray: Vector3[][];
  125519. closeArray?: boolean;
  125520. closePath?: boolean;
  125521. offset?: number;
  125522. updatable?: boolean;
  125523. sideOrientation?: number;
  125524. frontUVs?: Vector4;
  125525. backUVs?: Vector4;
  125526. instance?: Mesh;
  125527. invertUV?: boolean;
  125528. uvs?: Vector2[];
  125529. colors?: Color4[];
  125530. }, scene?: Nullable<Scene>): Mesh;
  125531. /**
  125532. * Creates a cylinder or a cone mesh
  125533. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125534. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125535. * * 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.
  125536. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125537. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125538. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125539. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125540. * * 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).
  125541. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125542. * * 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).
  125543. * * 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
  125544. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125545. * * 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
  125546. * * 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.
  125547. * * If `enclose` is false, a ring surface is one element.
  125548. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125549. * * 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
  125550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125553. * @param name defines the name of the mesh
  125554. * @param options defines the options used to create the mesh
  125555. * @param scene defines the hosting scene
  125556. * @returns the cylinder mesh
  125557. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125558. */
  125559. static CreateCylinder(name: string, options: {
  125560. height?: number;
  125561. diameterTop?: number;
  125562. diameterBottom?: number;
  125563. diameter?: number;
  125564. tessellation?: number;
  125565. subdivisions?: number;
  125566. arc?: number;
  125567. faceColors?: Color4[];
  125568. faceUV?: Vector4[];
  125569. updatable?: boolean;
  125570. hasRings?: boolean;
  125571. enclose?: boolean;
  125572. cap?: number;
  125573. sideOrientation?: number;
  125574. frontUVs?: Vector4;
  125575. backUVs?: Vector4;
  125576. }, scene?: Nullable<Scene>): Mesh;
  125577. /**
  125578. * Creates a torus mesh
  125579. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125580. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125581. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125585. * @param name defines the name of the mesh
  125586. * @param options defines the options used to create the mesh
  125587. * @param scene defines the hosting scene
  125588. * @returns the torus mesh
  125589. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125590. */
  125591. static CreateTorus(name: string, options: {
  125592. diameter?: number;
  125593. thickness?: number;
  125594. tessellation?: number;
  125595. updatable?: boolean;
  125596. sideOrientation?: number;
  125597. frontUVs?: Vector4;
  125598. backUVs?: Vector4;
  125599. }, scene?: Nullable<Scene>): Mesh;
  125600. /**
  125601. * Creates a torus knot mesh
  125602. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125603. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125604. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125605. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125609. * @param name defines the name of the mesh
  125610. * @param options defines the options used to create the mesh
  125611. * @param scene defines the hosting scene
  125612. * @returns the torus knot mesh
  125613. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125614. */
  125615. static CreateTorusKnot(name: string, options: {
  125616. radius?: number;
  125617. tube?: number;
  125618. radialSegments?: number;
  125619. tubularSegments?: number;
  125620. p?: number;
  125621. q?: number;
  125622. updatable?: boolean;
  125623. sideOrientation?: number;
  125624. frontUVs?: Vector4;
  125625. backUVs?: Vector4;
  125626. }, scene?: Nullable<Scene>): Mesh;
  125627. /**
  125628. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125629. * * 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
  125630. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125631. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125632. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125633. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125634. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125635. * * 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
  125636. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125639. * @param name defines the name of the new line system
  125640. * @param options defines the options used to create the line system
  125641. * @param scene defines the hosting scene
  125642. * @returns a new line system mesh
  125643. */
  125644. static CreateLineSystem(name: string, options: {
  125645. lines: Vector3[][];
  125646. updatable?: boolean;
  125647. instance?: Nullable<LinesMesh>;
  125648. colors?: Nullable<Color4[][]>;
  125649. useVertexAlpha?: boolean;
  125650. }, scene: Nullable<Scene>): LinesMesh;
  125651. /**
  125652. * Creates a line mesh
  125653. * 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
  125654. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125655. * * The parameter `points` is an array successive Vector3
  125656. * * 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
  125657. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125658. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125659. * * When updating an instance, remember that only point positions can change, not the number of points
  125660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125662. * @param name defines the name of the new line system
  125663. * @param options defines the options used to create the line system
  125664. * @param scene defines the hosting scene
  125665. * @returns a new line mesh
  125666. */
  125667. static CreateLines(name: string, options: {
  125668. points: Vector3[];
  125669. updatable?: boolean;
  125670. instance?: Nullable<LinesMesh>;
  125671. colors?: Color4[];
  125672. useVertexAlpha?: boolean;
  125673. }, scene?: Nullable<Scene>): LinesMesh;
  125674. /**
  125675. * Creates a dashed line mesh
  125676. * * 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
  125677. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125678. * * The parameter `points` is an array successive Vector3
  125679. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125680. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125681. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125682. * * 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
  125683. * * When updating an instance, remember that only point positions can change, not the number of points
  125684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125685. * @param name defines the name of the mesh
  125686. * @param options defines the options used to create the mesh
  125687. * @param scene defines the hosting scene
  125688. * @returns the dashed line mesh
  125689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125690. */
  125691. static CreateDashedLines(name: string, options: {
  125692. points: Vector3[];
  125693. dashSize?: number;
  125694. gapSize?: number;
  125695. dashNb?: number;
  125696. updatable?: boolean;
  125697. instance?: LinesMesh;
  125698. }, scene?: Nullable<Scene>): LinesMesh;
  125699. /**
  125700. * 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.
  125701. * * 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.
  125702. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125703. * * 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.
  125704. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125705. * * 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
  125706. * * 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
  125707. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125710. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125712. * @param name defines the name of the mesh
  125713. * @param options defines the options used to create the mesh
  125714. * @param scene defines the hosting scene
  125715. * @returns the extruded shape mesh
  125716. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125717. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125718. */
  125719. static ExtrudeShape(name: string, options: {
  125720. shape: Vector3[];
  125721. path: Vector3[];
  125722. scale?: number;
  125723. rotation?: number;
  125724. cap?: number;
  125725. updatable?: boolean;
  125726. sideOrientation?: number;
  125727. frontUVs?: Vector4;
  125728. backUVs?: Vector4;
  125729. instance?: Mesh;
  125730. invertUV?: boolean;
  125731. }, scene?: Nullable<Scene>): Mesh;
  125732. /**
  125733. * Creates an custom extruded shape mesh.
  125734. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125735. * * 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.
  125736. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125737. * * 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
  125738. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125739. * * 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
  125740. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125741. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125742. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125743. * * 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
  125744. * * 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
  125745. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125748. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125750. * @param name defines the name of the mesh
  125751. * @param options defines the options used to create the mesh
  125752. * @param scene defines the hosting scene
  125753. * @returns the custom extruded shape mesh
  125754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  125755. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125757. */
  125758. static ExtrudeShapeCustom(name: string, options: {
  125759. shape: Vector3[];
  125760. path: Vector3[];
  125761. scaleFunction?: any;
  125762. rotationFunction?: any;
  125763. ribbonCloseArray?: boolean;
  125764. ribbonClosePath?: boolean;
  125765. cap?: number;
  125766. updatable?: boolean;
  125767. sideOrientation?: number;
  125768. frontUVs?: Vector4;
  125769. backUVs?: Vector4;
  125770. instance?: Mesh;
  125771. invertUV?: boolean;
  125772. }, scene?: Nullable<Scene>): Mesh;
  125773. /**
  125774. * Creates lathe mesh.
  125775. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125776. * * 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
  125777. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125778. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125779. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125780. * * 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
  125781. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125782. * * 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
  125783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125785. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125787. * @param name defines the name of the mesh
  125788. * @param options defines the options used to create the mesh
  125789. * @param scene defines the hosting scene
  125790. * @returns the lathe mesh
  125791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125792. */
  125793. static CreateLathe(name: string, options: {
  125794. shape: Vector3[];
  125795. radius?: number;
  125796. tessellation?: number;
  125797. clip?: number;
  125798. arc?: number;
  125799. closed?: boolean;
  125800. updatable?: boolean;
  125801. sideOrientation?: number;
  125802. frontUVs?: Vector4;
  125803. backUVs?: Vector4;
  125804. cap?: number;
  125805. invertUV?: boolean;
  125806. }, scene?: Nullable<Scene>): Mesh;
  125807. /**
  125808. * Creates a tiled plane mesh
  125809. * * You can set a limited pattern arrangement with the tiles
  125810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125813. * @param name defines the name of the mesh
  125814. * @param options defines the options used to create the mesh
  125815. * @param scene defines the hosting scene
  125816. * @returns the plane mesh
  125817. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125818. */
  125819. static CreateTiledPlane(name: string, options: {
  125820. pattern?: number;
  125821. tileSize?: number;
  125822. tileWidth?: number;
  125823. tileHeight?: number;
  125824. size?: number;
  125825. width?: number;
  125826. height?: number;
  125827. alignHorizontal?: number;
  125828. alignVertical?: number;
  125829. sideOrientation?: number;
  125830. frontUVs?: Vector4;
  125831. backUVs?: Vector4;
  125832. updatable?: boolean;
  125833. }, scene?: Nullable<Scene>): Mesh;
  125834. /**
  125835. * Creates a plane mesh
  125836. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  125837. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  125838. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  125839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125842. * @param name defines the name of the mesh
  125843. * @param options defines the options used to create the mesh
  125844. * @param scene defines the hosting scene
  125845. * @returns the plane mesh
  125846. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125847. */
  125848. static CreatePlane(name: string, options: {
  125849. size?: number;
  125850. width?: number;
  125851. height?: number;
  125852. sideOrientation?: number;
  125853. frontUVs?: Vector4;
  125854. backUVs?: Vector4;
  125855. updatable?: boolean;
  125856. sourcePlane?: Plane;
  125857. }, scene?: Nullable<Scene>): Mesh;
  125858. /**
  125859. * Creates a ground mesh
  125860. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125861. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125863. * @param name defines the name of the mesh
  125864. * @param options defines the options used to create the mesh
  125865. * @param scene defines the hosting scene
  125866. * @returns the ground mesh
  125867. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125868. */
  125869. static CreateGround(name: string, options: {
  125870. width?: number;
  125871. height?: number;
  125872. subdivisions?: number;
  125873. subdivisionsX?: number;
  125874. subdivisionsY?: number;
  125875. updatable?: boolean;
  125876. }, scene?: Nullable<Scene>): Mesh;
  125877. /**
  125878. * Creates a tiled ground mesh
  125879. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125880. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125881. * * 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
  125882. * * 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
  125883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125884. * @param name defines the name of the mesh
  125885. * @param options defines the options used to create the mesh
  125886. * @param scene defines the hosting scene
  125887. * @returns the tiled ground mesh
  125888. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125889. */
  125890. static CreateTiledGround(name: string, options: {
  125891. xmin: number;
  125892. zmin: number;
  125893. xmax: number;
  125894. zmax: number;
  125895. subdivisions?: {
  125896. w: number;
  125897. h: number;
  125898. };
  125899. precision?: {
  125900. w: number;
  125901. h: number;
  125902. };
  125903. updatable?: boolean;
  125904. }, scene?: Nullable<Scene>): Mesh;
  125905. /**
  125906. * Creates a ground mesh from a height map
  125907. * * The parameter `url` sets the URL of the height map image resource.
  125908. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125909. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125910. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125911. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125912. * * 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.
  125913. * * 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).
  125914. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125916. * @param name defines the name of the mesh
  125917. * @param url defines the url to the height map
  125918. * @param options defines the options used to create the mesh
  125919. * @param scene defines the hosting scene
  125920. * @returns the ground mesh
  125921. * @see https://doc.babylonjs.com/babylon101/height_map
  125922. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125923. */
  125924. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125925. width?: number;
  125926. height?: number;
  125927. subdivisions?: number;
  125928. minHeight?: number;
  125929. maxHeight?: number;
  125930. colorFilter?: Color3;
  125931. alphaFilter?: number;
  125932. updatable?: boolean;
  125933. onReady?: (mesh: GroundMesh) => void;
  125934. }, scene?: Nullable<Scene>): GroundMesh;
  125935. /**
  125936. * Creates a polygon mesh
  125937. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125938. * * 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
  125939. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125941. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125942. * * Remember you can only change the shape positions, not their number when updating a polygon
  125943. * @param name defines the name of the mesh
  125944. * @param options defines the options used to create the mesh
  125945. * @param scene defines the hosting scene
  125946. * @param earcutInjection can be used to inject your own earcut reference
  125947. * @returns the polygon mesh
  125948. */
  125949. static CreatePolygon(name: string, options: {
  125950. shape: Vector3[];
  125951. holes?: Vector3[][];
  125952. depth?: number;
  125953. faceUV?: Vector4[];
  125954. faceColors?: Color4[];
  125955. updatable?: boolean;
  125956. sideOrientation?: number;
  125957. frontUVs?: Vector4;
  125958. backUVs?: Vector4;
  125959. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125960. /**
  125961. * Creates an extruded polygon mesh, with depth in the Y direction.
  125962. * * 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)
  125963. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125964. * @param name defines the name of the mesh
  125965. * @param options defines the options used to create the mesh
  125966. * @param scene defines the hosting scene
  125967. * @param earcutInjection can be used to inject your own earcut reference
  125968. * @returns the polygon mesh
  125969. */
  125970. static ExtrudePolygon(name: string, options: {
  125971. shape: Vector3[];
  125972. holes?: Vector3[][];
  125973. depth?: number;
  125974. faceUV?: Vector4[];
  125975. faceColors?: Color4[];
  125976. updatable?: boolean;
  125977. sideOrientation?: number;
  125978. frontUVs?: Vector4;
  125979. backUVs?: Vector4;
  125980. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125981. /**
  125982. * Creates a tube mesh.
  125983. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125984. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125985. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125986. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125987. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125988. * * 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)
  125989. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125990. * * 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
  125991. * * 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
  125992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125994. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125996. * @param name defines the name of the mesh
  125997. * @param options defines the options used to create the mesh
  125998. * @param scene defines the hosting scene
  125999. * @returns the tube mesh
  126000. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126001. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  126002. */
  126003. static CreateTube(name: string, options: {
  126004. path: Vector3[];
  126005. radius?: number;
  126006. tessellation?: number;
  126007. radiusFunction?: {
  126008. (i: number, distance: number): number;
  126009. };
  126010. cap?: number;
  126011. arc?: number;
  126012. updatable?: boolean;
  126013. sideOrientation?: number;
  126014. frontUVs?: Vector4;
  126015. backUVs?: Vector4;
  126016. instance?: Mesh;
  126017. invertUV?: boolean;
  126018. }, scene?: Nullable<Scene>): Mesh;
  126019. /**
  126020. * Creates a polyhedron mesh
  126021. * * 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
  126022. * * The parameter `size` (positive float, default 1) sets the polygon size
  126023. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  126024. * * 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`
  126025. * * 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
  126026. * * 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)`)
  126027. * * 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
  126028. * * 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
  126029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126030. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126032. * @param name defines the name of the mesh
  126033. * @param options defines the options used to create the mesh
  126034. * @param scene defines the hosting scene
  126035. * @returns the polyhedron mesh
  126036. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  126037. */
  126038. static CreatePolyhedron(name: string, options: {
  126039. type?: number;
  126040. size?: number;
  126041. sizeX?: number;
  126042. sizeY?: number;
  126043. sizeZ?: number;
  126044. custom?: any;
  126045. faceUV?: Vector4[];
  126046. faceColors?: Color4[];
  126047. flat?: boolean;
  126048. updatable?: boolean;
  126049. sideOrientation?: number;
  126050. frontUVs?: Vector4;
  126051. backUVs?: Vector4;
  126052. }, scene?: Nullable<Scene>): Mesh;
  126053. /**
  126054. * Creates a decal mesh.
  126055. * 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
  126056. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126057. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126058. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126059. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126060. * @param name defines the name of the mesh
  126061. * @param sourceMesh defines the mesh where the decal must be applied
  126062. * @param options defines the options used to create the mesh
  126063. * @param scene defines the hosting scene
  126064. * @returns the decal mesh
  126065. * @see https://doc.babylonjs.com/how_to/decals
  126066. */
  126067. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126068. position?: Vector3;
  126069. normal?: Vector3;
  126070. size?: Vector3;
  126071. angle?: number;
  126072. }): Mesh;
  126073. }
  126074. }
  126075. declare module BABYLON {
  126076. /**
  126077. * A simplifier interface for future simplification implementations
  126078. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126079. */
  126080. export interface ISimplifier {
  126081. /**
  126082. * Simplification of a given mesh according to the given settings.
  126083. * Since this requires computation, it is assumed that the function runs async.
  126084. * @param settings The settings of the simplification, including quality and distance
  126085. * @param successCallback A callback that will be called after the mesh was simplified.
  126086. * @param errorCallback in case of an error, this callback will be called. optional.
  126087. */
  126088. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  126089. }
  126090. /**
  126091. * Expected simplification settings.
  126092. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  126093. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126094. */
  126095. export interface ISimplificationSettings {
  126096. /**
  126097. * Gets or sets the expected quality
  126098. */
  126099. quality: number;
  126100. /**
  126101. * Gets or sets the distance when this optimized version should be used
  126102. */
  126103. distance: number;
  126104. /**
  126105. * Gets an already optimized mesh
  126106. */
  126107. optimizeMesh?: boolean;
  126108. }
  126109. /**
  126110. * Class used to specify simplification options
  126111. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126112. */
  126113. export class SimplificationSettings implements ISimplificationSettings {
  126114. /** expected quality */
  126115. quality: number;
  126116. /** distance when this optimized version should be used */
  126117. distance: number;
  126118. /** already optimized mesh */
  126119. optimizeMesh?: boolean | undefined;
  126120. /**
  126121. * Creates a SimplificationSettings
  126122. * @param quality expected quality
  126123. * @param distance distance when this optimized version should be used
  126124. * @param optimizeMesh already optimized mesh
  126125. */
  126126. constructor(
  126127. /** expected quality */
  126128. quality: number,
  126129. /** distance when this optimized version should be used */
  126130. distance: number,
  126131. /** already optimized mesh */
  126132. optimizeMesh?: boolean | undefined);
  126133. }
  126134. /**
  126135. * Interface used to define a simplification task
  126136. */
  126137. export interface ISimplificationTask {
  126138. /**
  126139. * Array of settings
  126140. */
  126141. settings: Array<ISimplificationSettings>;
  126142. /**
  126143. * Simplification type
  126144. */
  126145. simplificationType: SimplificationType;
  126146. /**
  126147. * Mesh to simplify
  126148. */
  126149. mesh: Mesh;
  126150. /**
  126151. * Callback called on success
  126152. */
  126153. successCallback?: () => void;
  126154. /**
  126155. * Defines if parallel processing can be used
  126156. */
  126157. parallelProcessing: boolean;
  126158. }
  126159. /**
  126160. * Queue used to order the simplification tasks
  126161. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126162. */
  126163. export class SimplificationQueue {
  126164. private _simplificationArray;
  126165. /**
  126166. * Gets a boolean indicating that the process is still running
  126167. */
  126168. running: boolean;
  126169. /**
  126170. * Creates a new queue
  126171. */
  126172. constructor();
  126173. /**
  126174. * Adds a new simplification task
  126175. * @param task defines a task to add
  126176. */
  126177. addTask(task: ISimplificationTask): void;
  126178. /**
  126179. * Execute next task
  126180. */
  126181. executeNext(): void;
  126182. /**
  126183. * Execute a simplification task
  126184. * @param task defines the task to run
  126185. */
  126186. runSimplification(task: ISimplificationTask): void;
  126187. private getSimplifier;
  126188. }
  126189. /**
  126190. * The implemented types of simplification
  126191. * At the moment only Quadratic Error Decimation is implemented
  126192. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126193. */
  126194. export enum SimplificationType {
  126195. /** Quadratic error decimation */
  126196. QUADRATIC = 0
  126197. }
  126198. }
  126199. declare module BABYLON {
  126200. interface Scene {
  126201. /** @hidden (Backing field) */
  126202. _simplificationQueue: SimplificationQueue;
  126203. /**
  126204. * Gets or sets the simplification queue attached to the scene
  126205. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126206. */
  126207. simplificationQueue: SimplificationQueue;
  126208. }
  126209. interface Mesh {
  126210. /**
  126211. * Simplify the mesh according to the given array of settings.
  126212. * Function will return immediately and will simplify async
  126213. * @param settings a collection of simplification settings
  126214. * @param parallelProcessing should all levels calculate parallel or one after the other
  126215. * @param simplificationType the type of simplification to run
  126216. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  126217. * @returns the current mesh
  126218. */
  126219. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  126220. }
  126221. /**
  126222. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  126223. * created in a scene
  126224. */
  126225. export class SimplicationQueueSceneComponent implements ISceneComponent {
  126226. /**
  126227. * The component name helpfull to identify the component in the list of scene components.
  126228. */
  126229. readonly name: string;
  126230. /**
  126231. * The scene the component belongs to.
  126232. */
  126233. scene: Scene;
  126234. /**
  126235. * Creates a new instance of the component for the given scene
  126236. * @param scene Defines the scene to register the component in
  126237. */
  126238. constructor(scene: Scene);
  126239. /**
  126240. * Registers the component in a given scene
  126241. */
  126242. register(): void;
  126243. /**
  126244. * Rebuilds the elements related to this component in case of
  126245. * context lost for instance.
  126246. */
  126247. rebuild(): void;
  126248. /**
  126249. * Disposes the component and the associated ressources
  126250. */
  126251. dispose(): void;
  126252. private _beforeCameraUpdate;
  126253. }
  126254. }
  126255. declare module BABYLON {
  126256. /**
  126257. * Navigation plugin interface to add navigation constrained by a navigation mesh
  126258. */
  126259. export interface INavigationEnginePlugin {
  126260. /**
  126261. * plugin name
  126262. */
  126263. name: string;
  126264. /**
  126265. * Creates a navigation mesh
  126266. * @param meshes array of all the geometry used to compute the navigatio mesh
  126267. * @param parameters bunch of parameters used to filter geometry
  126268. */
  126269. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126270. /**
  126271. * Create a navigation mesh debug mesh
  126272. * @param scene is where the mesh will be added
  126273. * @returns debug display mesh
  126274. */
  126275. createDebugNavMesh(scene: Scene): Mesh;
  126276. /**
  126277. * Get a navigation mesh constrained position, closest to the parameter position
  126278. * @param position world position
  126279. * @returns the closest point to position constrained by the navigation mesh
  126280. */
  126281. getClosestPoint(position: Vector3): Vector3;
  126282. /**
  126283. * Get a navigation mesh constrained position, within a particular radius
  126284. * @param position world position
  126285. * @param maxRadius the maximum distance to the constrained world position
  126286. * @returns the closest point to position constrained by the navigation mesh
  126287. */
  126288. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126289. /**
  126290. * Compute the final position from a segment made of destination-position
  126291. * @param position world position
  126292. * @param destination world position
  126293. * @returns the resulting point along the navmesh
  126294. */
  126295. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126296. /**
  126297. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126298. * @param start world position
  126299. * @param end world position
  126300. * @returns array containing world position composing the path
  126301. */
  126302. computePath(start: Vector3, end: Vector3): Vector3[];
  126303. /**
  126304. * If this plugin is supported
  126305. * @returns true if plugin is supported
  126306. */
  126307. isSupported(): boolean;
  126308. /**
  126309. * Create a new Crowd so you can add agents
  126310. * @param maxAgents the maximum agent count in the crowd
  126311. * @param maxAgentRadius the maximum radius an agent can have
  126312. * @param scene to attach the crowd to
  126313. * @returns the crowd you can add agents to
  126314. */
  126315. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126316. /**
  126317. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126318. * The queries will try to find a solution within those bounds
  126319. * default is (1,1,1)
  126320. * @param extent x,y,z value that define the extent around the queries point of reference
  126321. */
  126322. setDefaultQueryExtent(extent: Vector3): void;
  126323. /**
  126324. * Get the Bounding box extent specified by setDefaultQueryExtent
  126325. * @returns the box extent values
  126326. */
  126327. getDefaultQueryExtent(): Vector3;
  126328. /**
  126329. * Release all resources
  126330. */
  126331. dispose(): void;
  126332. }
  126333. /**
  126334. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  126335. */
  126336. export interface ICrowd {
  126337. /**
  126338. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126339. * You can attach anything to that node. The node position is updated in the scene update tick.
  126340. * @param pos world position that will be constrained by the navigation mesh
  126341. * @param parameters agent parameters
  126342. * @param transform hooked to the agent that will be update by the scene
  126343. * @returns agent index
  126344. */
  126345. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126346. /**
  126347. * Returns the agent position in world space
  126348. * @param index agent index returned by addAgent
  126349. * @returns world space position
  126350. */
  126351. getAgentPosition(index: number): Vector3;
  126352. /**
  126353. * Gets the agent velocity in world space
  126354. * @param index agent index returned by addAgent
  126355. * @returns world space velocity
  126356. */
  126357. getAgentVelocity(index: number): Vector3;
  126358. /**
  126359. * remove a particular agent previously created
  126360. * @param index agent index returned by addAgent
  126361. */
  126362. removeAgent(index: number): void;
  126363. /**
  126364. * get the list of all agents attached to this crowd
  126365. * @returns list of agent indices
  126366. */
  126367. getAgents(): number[];
  126368. /**
  126369. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126370. * @param deltaTime in seconds
  126371. */
  126372. update(deltaTime: number): void;
  126373. /**
  126374. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126375. * @param index agent index returned by addAgent
  126376. * @param destination targeted world position
  126377. */
  126378. agentGoto(index: number, destination: Vector3): void;
  126379. /**
  126380. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126381. * The queries will try to find a solution within those bounds
  126382. * default is (1,1,1)
  126383. * @param extent x,y,z value that define the extent around the queries point of reference
  126384. */
  126385. setDefaultQueryExtent(extent: Vector3): void;
  126386. /**
  126387. * Get the Bounding box extent specified by setDefaultQueryExtent
  126388. * @returns the box extent values
  126389. */
  126390. getDefaultQueryExtent(): Vector3;
  126391. /**
  126392. * Release all resources
  126393. */
  126394. dispose(): void;
  126395. }
  126396. /**
  126397. * Configures an agent
  126398. */
  126399. export interface IAgentParameters {
  126400. /**
  126401. * Agent radius. [Limit: >= 0]
  126402. */
  126403. radius: number;
  126404. /**
  126405. * Agent height. [Limit: > 0]
  126406. */
  126407. height: number;
  126408. /**
  126409. * Maximum allowed acceleration. [Limit: >= 0]
  126410. */
  126411. maxAcceleration: number;
  126412. /**
  126413. * Maximum allowed speed. [Limit: >= 0]
  126414. */
  126415. maxSpeed: number;
  126416. /**
  126417. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  126418. */
  126419. collisionQueryRange: number;
  126420. /**
  126421. * The path visibility optimization range. [Limit: > 0]
  126422. */
  126423. pathOptimizationRange: number;
  126424. /**
  126425. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  126426. */
  126427. separationWeight: number;
  126428. }
  126429. /**
  126430. * Configures the navigation mesh creation
  126431. */
  126432. export interface INavMeshParameters {
  126433. /**
  126434. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  126435. */
  126436. cs: number;
  126437. /**
  126438. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  126439. */
  126440. ch: number;
  126441. /**
  126442. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  126443. */
  126444. walkableSlopeAngle: number;
  126445. /**
  126446. * Minimum floor to 'ceiling' height that will still allow the floor area to
  126447. * be considered walkable. [Limit: >= 3] [Units: vx]
  126448. */
  126449. walkableHeight: number;
  126450. /**
  126451. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  126452. */
  126453. walkableClimb: number;
  126454. /**
  126455. * The distance to erode/shrink the walkable area of the heightfield away from
  126456. * obstructions. [Limit: >=0] [Units: vx]
  126457. */
  126458. walkableRadius: number;
  126459. /**
  126460. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  126461. */
  126462. maxEdgeLen: number;
  126463. /**
  126464. * The maximum distance a simplfied contour's border edges should deviate
  126465. * the original raw contour. [Limit: >=0] [Units: vx]
  126466. */
  126467. maxSimplificationError: number;
  126468. /**
  126469. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  126470. */
  126471. minRegionArea: number;
  126472. /**
  126473. * Any regions with a span count smaller than this value will, if possible,
  126474. * be merged with larger regions. [Limit: >=0] [Units: vx]
  126475. */
  126476. mergeRegionArea: number;
  126477. /**
  126478. * The maximum number of vertices allowed for polygons generated during the
  126479. * contour to polygon conversion process. [Limit: >= 3]
  126480. */
  126481. maxVertsPerPoly: number;
  126482. /**
  126483. * Sets the sampling distance to use when generating the detail mesh.
  126484. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  126485. */
  126486. detailSampleDist: number;
  126487. /**
  126488. * The maximum distance the detail mesh surface should deviate from heightfield
  126489. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  126490. */
  126491. detailSampleMaxError: number;
  126492. }
  126493. }
  126494. declare module BABYLON {
  126495. /**
  126496. * RecastJS navigation plugin
  126497. */
  126498. export class RecastJSPlugin implements INavigationEnginePlugin {
  126499. /**
  126500. * Reference to the Recast library
  126501. */
  126502. bjsRECAST: any;
  126503. /**
  126504. * plugin name
  126505. */
  126506. name: string;
  126507. /**
  126508. * the first navmesh created. We might extend this to support multiple navmeshes
  126509. */
  126510. navMesh: any;
  126511. /**
  126512. * Initializes the recastJS plugin
  126513. * @param recastInjection can be used to inject your own recast reference
  126514. */
  126515. constructor(recastInjection?: any);
  126516. /**
  126517. * Creates a navigation mesh
  126518. * @param meshes array of all the geometry used to compute the navigatio mesh
  126519. * @param parameters bunch of parameters used to filter geometry
  126520. */
  126521. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126522. /**
  126523. * Create a navigation mesh debug mesh
  126524. * @param scene is where the mesh will be added
  126525. * @returns debug display mesh
  126526. */
  126527. createDebugNavMesh(scene: Scene): Mesh;
  126528. /**
  126529. * Get a navigation mesh constrained position, closest to the parameter position
  126530. * @param position world position
  126531. * @returns the closest point to position constrained by the navigation mesh
  126532. */
  126533. getClosestPoint(position: Vector3): Vector3;
  126534. /**
  126535. * Get a navigation mesh constrained position, within a particular radius
  126536. * @param position world position
  126537. * @param maxRadius the maximum distance to the constrained world position
  126538. * @returns the closest point to position constrained by the navigation mesh
  126539. */
  126540. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126541. /**
  126542. * Compute the final position from a segment made of destination-position
  126543. * @param position world position
  126544. * @param destination world position
  126545. * @returns the resulting point along the navmesh
  126546. */
  126547. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126548. /**
  126549. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126550. * @param start world position
  126551. * @param end world position
  126552. * @returns array containing world position composing the path
  126553. */
  126554. computePath(start: Vector3, end: Vector3): Vector3[];
  126555. /**
  126556. * Create a new Crowd so you can add agents
  126557. * @param maxAgents the maximum agent count in the crowd
  126558. * @param maxAgentRadius the maximum radius an agent can have
  126559. * @param scene to attach the crowd to
  126560. * @returns the crowd you can add agents to
  126561. */
  126562. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126563. /**
  126564. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126565. * The queries will try to find a solution within those bounds
  126566. * default is (1,1,1)
  126567. * @param extent x,y,z value that define the extent around the queries point of reference
  126568. */
  126569. setDefaultQueryExtent(extent: Vector3): void;
  126570. /**
  126571. * Get the Bounding box extent specified by setDefaultQueryExtent
  126572. * @returns the box extent values
  126573. */
  126574. getDefaultQueryExtent(): Vector3;
  126575. /**
  126576. * Disposes
  126577. */
  126578. dispose(): void;
  126579. /**
  126580. * If this plugin is supported
  126581. * @returns true if plugin is supported
  126582. */
  126583. isSupported(): boolean;
  126584. }
  126585. /**
  126586. * Recast detour crowd implementation
  126587. */
  126588. export class RecastJSCrowd implements ICrowd {
  126589. /**
  126590. * Recast/detour plugin
  126591. */
  126592. bjsRECASTPlugin: RecastJSPlugin;
  126593. /**
  126594. * Link to the detour crowd
  126595. */
  126596. recastCrowd: any;
  126597. /**
  126598. * One transform per agent
  126599. */
  126600. transforms: TransformNode[];
  126601. /**
  126602. * All agents created
  126603. */
  126604. agents: number[];
  126605. /**
  126606. * Link to the scene is kept to unregister the crowd from the scene
  126607. */
  126608. private _scene;
  126609. /**
  126610. * Observer for crowd updates
  126611. */
  126612. private _onBeforeAnimationsObserver;
  126613. /**
  126614. * Constructor
  126615. * @param plugin recastJS plugin
  126616. * @param maxAgents the maximum agent count in the crowd
  126617. * @param maxAgentRadius the maximum radius an agent can have
  126618. * @param scene to attach the crowd to
  126619. * @returns the crowd you can add agents to
  126620. */
  126621. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  126622. /**
  126623. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126624. * You can attach anything to that node. The node position is updated in the scene update tick.
  126625. * @param pos world position that will be constrained by the navigation mesh
  126626. * @param parameters agent parameters
  126627. * @param transform hooked to the agent that will be update by the scene
  126628. * @returns agent index
  126629. */
  126630. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126631. /**
  126632. * Returns the agent position in world space
  126633. * @param index agent index returned by addAgent
  126634. * @returns world space position
  126635. */
  126636. getAgentPosition(index: number): Vector3;
  126637. /**
  126638. * Returns the agent velocity in world space
  126639. * @param index agent index returned by addAgent
  126640. * @returns world space velocity
  126641. */
  126642. getAgentVelocity(index: number): Vector3;
  126643. /**
  126644. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126645. * @param index agent index returned by addAgent
  126646. * @param destination targeted world position
  126647. */
  126648. agentGoto(index: number, destination: Vector3): void;
  126649. /**
  126650. * remove a particular agent previously created
  126651. * @param index agent index returned by addAgent
  126652. */
  126653. removeAgent(index: number): void;
  126654. /**
  126655. * get the list of all agents attached to this crowd
  126656. * @returns list of agent indices
  126657. */
  126658. getAgents(): number[];
  126659. /**
  126660. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126661. * @param deltaTime in seconds
  126662. */
  126663. update(deltaTime: number): void;
  126664. /**
  126665. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126666. * The queries will try to find a solution within those bounds
  126667. * default is (1,1,1)
  126668. * @param extent x,y,z value that define the extent around the queries point of reference
  126669. */
  126670. setDefaultQueryExtent(extent: Vector3): void;
  126671. /**
  126672. * Get the Bounding box extent specified by setDefaultQueryExtent
  126673. * @returns the box extent values
  126674. */
  126675. getDefaultQueryExtent(): Vector3;
  126676. /**
  126677. * Release all resources
  126678. */
  126679. dispose(): void;
  126680. }
  126681. }
  126682. declare module BABYLON {
  126683. /**
  126684. * Class used to enable access to IndexedDB
  126685. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  126686. */
  126687. export class Database implements IOfflineProvider {
  126688. private _callbackManifestChecked;
  126689. private _currentSceneUrl;
  126690. private _db;
  126691. private _enableSceneOffline;
  126692. private _enableTexturesOffline;
  126693. private _manifestVersionFound;
  126694. private _mustUpdateRessources;
  126695. private _hasReachedQuota;
  126696. private _isSupported;
  126697. private _idbFactory;
  126698. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  126699. private static IsUASupportingBlobStorage;
  126700. /**
  126701. * Gets a boolean indicating if Database storate is enabled (off by default)
  126702. */
  126703. static IDBStorageEnabled: boolean;
  126704. /**
  126705. * Gets a boolean indicating if scene must be saved in the database
  126706. */
  126707. readonly enableSceneOffline: boolean;
  126708. /**
  126709. * Gets a boolean indicating if textures must be saved in the database
  126710. */
  126711. readonly enableTexturesOffline: boolean;
  126712. /**
  126713. * Creates a new Database
  126714. * @param urlToScene defines the url to load the scene
  126715. * @param callbackManifestChecked defines the callback to use when manifest is checked
  126716. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  126717. */
  126718. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  126719. private static _ParseURL;
  126720. private static _ReturnFullUrlLocation;
  126721. private _checkManifestFile;
  126722. /**
  126723. * Open the database and make it available
  126724. * @param successCallback defines the callback to call on success
  126725. * @param errorCallback defines the callback to call on error
  126726. */
  126727. open(successCallback: () => void, errorCallback: () => void): void;
  126728. /**
  126729. * Loads an image from the database
  126730. * @param url defines the url to load from
  126731. * @param image defines the target DOM image
  126732. */
  126733. loadImage(url: string, image: HTMLImageElement): void;
  126734. private _loadImageFromDBAsync;
  126735. private _saveImageIntoDBAsync;
  126736. private _checkVersionFromDB;
  126737. private _loadVersionFromDBAsync;
  126738. private _saveVersionIntoDBAsync;
  126739. /**
  126740. * Loads a file from database
  126741. * @param url defines the URL to load from
  126742. * @param sceneLoaded defines a callback to call on success
  126743. * @param progressCallBack defines a callback to call when progress changed
  126744. * @param errorCallback defines a callback to call on error
  126745. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  126746. */
  126747. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  126748. private _loadFileAsync;
  126749. private _saveFileAsync;
  126750. /**
  126751. * Validates if xhr data is correct
  126752. * @param xhr defines the request to validate
  126753. * @param dataType defines the expected data type
  126754. * @returns true if data is correct
  126755. */
  126756. private static _ValidateXHRData;
  126757. }
  126758. }
  126759. declare module BABYLON {
  126760. /** @hidden */
  126761. export var gpuUpdateParticlesPixelShader: {
  126762. name: string;
  126763. shader: string;
  126764. };
  126765. }
  126766. declare module BABYLON {
  126767. /** @hidden */
  126768. export var gpuUpdateParticlesVertexShader: {
  126769. name: string;
  126770. shader: string;
  126771. };
  126772. }
  126773. declare module BABYLON {
  126774. /** @hidden */
  126775. export var clipPlaneFragmentDeclaration2: {
  126776. name: string;
  126777. shader: string;
  126778. };
  126779. }
  126780. declare module BABYLON {
  126781. /** @hidden */
  126782. export var gpuRenderParticlesPixelShader: {
  126783. name: string;
  126784. shader: string;
  126785. };
  126786. }
  126787. declare module BABYLON {
  126788. /** @hidden */
  126789. export var clipPlaneVertexDeclaration2: {
  126790. name: string;
  126791. shader: string;
  126792. };
  126793. }
  126794. declare module BABYLON {
  126795. /** @hidden */
  126796. export var gpuRenderParticlesVertexShader: {
  126797. name: string;
  126798. shader: string;
  126799. };
  126800. }
  126801. declare module BABYLON {
  126802. /**
  126803. * This represents a GPU particle system in Babylon
  126804. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  126805. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  126806. */
  126807. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  126808. /**
  126809. * The layer mask we are rendering the particles through.
  126810. */
  126811. layerMask: number;
  126812. private _capacity;
  126813. private _activeCount;
  126814. private _currentActiveCount;
  126815. private _accumulatedCount;
  126816. private _renderEffect;
  126817. private _updateEffect;
  126818. private _buffer0;
  126819. private _buffer1;
  126820. private _spriteBuffer;
  126821. private _updateVAO;
  126822. private _renderVAO;
  126823. private _targetIndex;
  126824. private _sourceBuffer;
  126825. private _targetBuffer;
  126826. private _engine;
  126827. private _currentRenderId;
  126828. private _started;
  126829. private _stopped;
  126830. private _timeDelta;
  126831. private _randomTexture;
  126832. private _randomTexture2;
  126833. private _attributesStrideSize;
  126834. private _updateEffectOptions;
  126835. private _randomTextureSize;
  126836. private _actualFrame;
  126837. private readonly _rawTextureWidth;
  126838. /**
  126839. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  126840. */
  126841. static readonly IsSupported: boolean;
  126842. /**
  126843. * An event triggered when the system is disposed.
  126844. */
  126845. onDisposeObservable: Observable<GPUParticleSystem>;
  126846. /**
  126847. * Gets the maximum number of particles active at the same time.
  126848. * @returns The max number of active particles.
  126849. */
  126850. getCapacity(): number;
  126851. /**
  126852. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  126853. * to override the particles.
  126854. */
  126855. forceDepthWrite: boolean;
  126856. /**
  126857. * Gets or set the number of active particles
  126858. */
  126859. activeParticleCount: number;
  126860. private _preWarmDone;
  126861. /**
  126862. * Is this system ready to be used/rendered
  126863. * @return true if the system is ready
  126864. */
  126865. isReady(): boolean;
  126866. /**
  126867. * Gets if the system has been started. (Note: this will still be true after stop is called)
  126868. * @returns True if it has been started, otherwise false.
  126869. */
  126870. isStarted(): boolean;
  126871. /**
  126872. * Starts the particle system and begins to emit
  126873. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  126874. */
  126875. start(delay?: number): void;
  126876. /**
  126877. * Stops the particle system.
  126878. */
  126879. stop(): void;
  126880. /**
  126881. * Remove all active particles
  126882. */
  126883. reset(): void;
  126884. /**
  126885. * Returns the string "GPUParticleSystem"
  126886. * @returns a string containing the class name
  126887. */
  126888. getClassName(): string;
  126889. private _colorGradientsTexture;
  126890. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  126891. /**
  126892. * Adds a new color gradient
  126893. * @param gradient defines the gradient to use (between 0 and 1)
  126894. * @param color1 defines the color to affect to the specified gradient
  126895. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  126896. * @returns the current particle system
  126897. */
  126898. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  126899. /**
  126900. * Remove a specific color gradient
  126901. * @param gradient defines the gradient to remove
  126902. * @returns the current particle system
  126903. */
  126904. removeColorGradient(gradient: number): GPUParticleSystem;
  126905. private _angularSpeedGradientsTexture;
  126906. private _sizeGradientsTexture;
  126907. private _velocityGradientsTexture;
  126908. private _limitVelocityGradientsTexture;
  126909. private _dragGradientsTexture;
  126910. private _addFactorGradient;
  126911. /**
  126912. * Adds a new size gradient
  126913. * @param gradient defines the gradient to use (between 0 and 1)
  126914. * @param factor defines the size factor to affect to the specified gradient
  126915. * @returns the current particle system
  126916. */
  126917. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  126918. /**
  126919. * Remove a specific size gradient
  126920. * @param gradient defines the gradient to remove
  126921. * @returns the current particle system
  126922. */
  126923. removeSizeGradient(gradient: number): GPUParticleSystem;
  126924. /**
  126925. * Adds a new angular speed gradient
  126926. * @param gradient defines the gradient to use (between 0 and 1)
  126927. * @param factor defines the angular speed to affect to the specified gradient
  126928. * @returns the current particle system
  126929. */
  126930. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  126931. /**
  126932. * Remove a specific angular speed gradient
  126933. * @param gradient defines the gradient to remove
  126934. * @returns the current particle system
  126935. */
  126936. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  126937. /**
  126938. * Adds a new velocity gradient
  126939. * @param gradient defines the gradient to use (between 0 and 1)
  126940. * @param factor defines the velocity to affect to the specified gradient
  126941. * @returns the current particle system
  126942. */
  126943. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126944. /**
  126945. * Remove a specific velocity gradient
  126946. * @param gradient defines the gradient to remove
  126947. * @returns the current particle system
  126948. */
  126949. removeVelocityGradient(gradient: number): GPUParticleSystem;
  126950. /**
  126951. * Adds a new limit velocity gradient
  126952. * @param gradient defines the gradient to use (between 0 and 1)
  126953. * @param factor defines the limit velocity value to affect to the specified gradient
  126954. * @returns the current particle system
  126955. */
  126956. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126957. /**
  126958. * Remove a specific limit velocity gradient
  126959. * @param gradient defines the gradient to remove
  126960. * @returns the current particle system
  126961. */
  126962. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  126963. /**
  126964. * Adds a new drag gradient
  126965. * @param gradient defines the gradient to use (between 0 and 1)
  126966. * @param factor defines the drag value to affect to the specified gradient
  126967. * @returns the current particle system
  126968. */
  126969. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  126970. /**
  126971. * Remove a specific drag gradient
  126972. * @param gradient defines the gradient to remove
  126973. * @returns the current particle system
  126974. */
  126975. removeDragGradient(gradient: number): GPUParticleSystem;
  126976. /**
  126977. * Not supported by GPUParticleSystem
  126978. * @param gradient defines the gradient to use (between 0 and 1)
  126979. * @param factor defines the emit rate value to affect to the specified gradient
  126980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126981. * @returns the current particle system
  126982. */
  126983. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126984. /**
  126985. * Not supported by GPUParticleSystem
  126986. * @param gradient defines the gradient to remove
  126987. * @returns the current particle system
  126988. */
  126989. removeEmitRateGradient(gradient: number): IParticleSystem;
  126990. /**
  126991. * Not supported by GPUParticleSystem
  126992. * @param gradient defines the gradient to use (between 0 and 1)
  126993. * @param factor defines the start size value to affect to the specified gradient
  126994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126995. * @returns the current particle system
  126996. */
  126997. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126998. /**
  126999. * Not supported by GPUParticleSystem
  127000. * @param gradient defines the gradient to remove
  127001. * @returns the current particle system
  127002. */
  127003. removeStartSizeGradient(gradient: number): IParticleSystem;
  127004. /**
  127005. * Not supported by GPUParticleSystem
  127006. * @param gradient defines the gradient to use (between 0 and 1)
  127007. * @param min defines the color remap minimal range
  127008. * @param max defines the color remap maximal range
  127009. * @returns the current particle system
  127010. */
  127011. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  127012. /**
  127013. * Not supported by GPUParticleSystem
  127014. * @param gradient defines the gradient to remove
  127015. * @returns the current particle system
  127016. */
  127017. removeColorRemapGradient(): IParticleSystem;
  127018. /**
  127019. * Not supported by GPUParticleSystem
  127020. * @param gradient defines the gradient to use (between 0 and 1)
  127021. * @param min defines the alpha remap minimal range
  127022. * @param max defines the alpha remap maximal range
  127023. * @returns the current particle system
  127024. */
  127025. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  127026. /**
  127027. * Not supported by GPUParticleSystem
  127028. * @param gradient defines the gradient to remove
  127029. * @returns the current particle system
  127030. */
  127031. removeAlphaRemapGradient(): IParticleSystem;
  127032. /**
  127033. * Not supported by GPUParticleSystem
  127034. * @param gradient defines the gradient to use (between 0 and 1)
  127035. * @param color defines the color to affect to the specified gradient
  127036. * @returns the current particle system
  127037. */
  127038. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  127039. /**
  127040. * Not supported by GPUParticleSystem
  127041. * @param gradient defines the gradient to remove
  127042. * @returns the current particle system
  127043. */
  127044. removeRampGradient(): IParticleSystem;
  127045. /**
  127046. * Not supported by GPUParticleSystem
  127047. * @returns the list of ramp gradients
  127048. */
  127049. getRampGradients(): Nullable<Array<Color3Gradient>>;
  127050. /**
  127051. * Not supported by GPUParticleSystem
  127052. * Gets or sets a boolean indicating that ramp gradients must be used
  127053. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  127054. */
  127055. useRampGradients: boolean;
  127056. /**
  127057. * Not supported by GPUParticleSystem
  127058. * @param gradient defines the gradient to use (between 0 and 1)
  127059. * @param factor defines the life time factor to affect to the specified gradient
  127060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127061. * @returns the current particle system
  127062. */
  127063. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127064. /**
  127065. * Not supported by GPUParticleSystem
  127066. * @param gradient defines the gradient to remove
  127067. * @returns the current particle system
  127068. */
  127069. removeLifeTimeGradient(gradient: number): IParticleSystem;
  127070. /**
  127071. * Instantiates a GPU particle system.
  127072. * 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.
  127073. * @param name The name of the particle system
  127074. * @param options The options used to create the system
  127075. * @param scene The scene the particle system belongs to
  127076. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  127077. */
  127078. constructor(name: string, options: Partial<{
  127079. capacity: number;
  127080. randomTextureSize: number;
  127081. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  127082. protected _reset(): void;
  127083. private _createUpdateVAO;
  127084. private _createRenderVAO;
  127085. private _initialize;
  127086. /** @hidden */
  127087. _recreateUpdateEffect(): void;
  127088. /** @hidden */
  127089. _recreateRenderEffect(): void;
  127090. /**
  127091. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  127092. * @param preWarm defines if we are in the pre-warmimg phase
  127093. */
  127094. animate(preWarm?: boolean): void;
  127095. private _createFactorGradientTexture;
  127096. private _createSizeGradientTexture;
  127097. private _createAngularSpeedGradientTexture;
  127098. private _createVelocityGradientTexture;
  127099. private _createLimitVelocityGradientTexture;
  127100. private _createDragGradientTexture;
  127101. private _createColorGradientTexture;
  127102. /**
  127103. * Renders the particle system in its current state
  127104. * @param preWarm defines if the system should only update the particles but not render them
  127105. * @returns the current number of particles
  127106. */
  127107. render(preWarm?: boolean): number;
  127108. /**
  127109. * Rebuilds the particle system
  127110. */
  127111. rebuild(): void;
  127112. private _releaseBuffers;
  127113. private _releaseVAOs;
  127114. /**
  127115. * Disposes the particle system and free the associated resources
  127116. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  127117. */
  127118. dispose(disposeTexture?: boolean): void;
  127119. /**
  127120. * Clones the particle system.
  127121. * @param name The name of the cloned object
  127122. * @param newEmitter The new emitter to use
  127123. * @returns the cloned particle system
  127124. */
  127125. clone(name: string, newEmitter: any): GPUParticleSystem;
  127126. /**
  127127. * Serializes the particle system to a JSON object.
  127128. * @returns the JSON object
  127129. */
  127130. serialize(): any;
  127131. /**
  127132. * Parses a JSON object to create a GPU particle system.
  127133. * @param parsedParticleSystem The JSON object to parse
  127134. * @param scene The scene to create the particle system in
  127135. * @param rootUrl The root url to use to load external dependencies like texture
  127136. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  127137. * @returns the parsed GPU particle system
  127138. */
  127139. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  127140. }
  127141. }
  127142. declare module BABYLON {
  127143. /**
  127144. * Represents a set of particle systems working together to create a specific effect
  127145. */
  127146. export class ParticleSystemSet implements IDisposable {
  127147. /**
  127148. * Gets or sets base Assets URL
  127149. */
  127150. static BaseAssetsUrl: string;
  127151. private _emitterCreationOptions;
  127152. private _emitterNode;
  127153. /**
  127154. * Gets the particle system list
  127155. */
  127156. systems: IParticleSystem[];
  127157. /**
  127158. * Gets the emitter node used with this set
  127159. */
  127160. readonly emitterNode: Nullable<TransformNode>;
  127161. /**
  127162. * Creates a new emitter mesh as a sphere
  127163. * @param options defines the options used to create the sphere
  127164. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  127165. * @param scene defines the hosting scene
  127166. */
  127167. setEmitterAsSphere(options: {
  127168. diameter: number;
  127169. segments: number;
  127170. color: Color3;
  127171. }, renderingGroupId: number, scene: Scene): void;
  127172. /**
  127173. * Starts all particle systems of the set
  127174. * @param emitter defines an optional mesh to use as emitter for the particle systems
  127175. */
  127176. start(emitter?: AbstractMesh): void;
  127177. /**
  127178. * Release all associated resources
  127179. */
  127180. dispose(): void;
  127181. /**
  127182. * Serialize the set into a JSON compatible object
  127183. * @returns a JSON compatible representation of the set
  127184. */
  127185. serialize(): any;
  127186. /**
  127187. * Parse a new ParticleSystemSet from a serialized source
  127188. * @param data defines a JSON compatible representation of the set
  127189. * @param scene defines the hosting scene
  127190. * @param gpu defines if we want GPU particles or CPU particles
  127191. * @returns a new ParticleSystemSet
  127192. */
  127193. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  127194. }
  127195. }
  127196. declare module BABYLON {
  127197. /**
  127198. * This class is made for on one-liner static method to help creating particle system set.
  127199. */
  127200. export class ParticleHelper {
  127201. /**
  127202. * Gets or sets base Assets URL
  127203. */
  127204. static BaseAssetsUrl: string;
  127205. /**
  127206. * Create a default particle system that you can tweak
  127207. * @param emitter defines the emitter to use
  127208. * @param capacity defines the system capacity (default is 500 particles)
  127209. * @param scene defines the hosting scene
  127210. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  127211. * @returns the new Particle system
  127212. */
  127213. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  127214. /**
  127215. * This is the main static method (one-liner) of this helper to create different particle systems
  127216. * @param type This string represents the type to the particle system to create
  127217. * @param scene The scene where the particle system should live
  127218. * @param gpu If the system will use gpu
  127219. * @returns the ParticleSystemSet created
  127220. */
  127221. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  127222. /**
  127223. * Static function used to export a particle system to a ParticleSystemSet variable.
  127224. * Please note that the emitter shape is not exported
  127225. * @param systems defines the particle systems to export
  127226. * @returns the created particle system set
  127227. */
  127228. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  127229. }
  127230. }
  127231. declare module BABYLON {
  127232. interface Engine {
  127233. /**
  127234. * Create an effect to use with particle systems.
  127235. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  127236. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  127237. * @param uniformsNames defines a list of attribute names
  127238. * @param samplers defines an array of string used to represent textures
  127239. * @param defines defines the string containing the defines to use to compile the shaders
  127240. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  127241. * @param onCompiled defines a function to call when the effect creation is successful
  127242. * @param onError defines a function to call when the effect creation has failed
  127243. * @returns the new Effect
  127244. */
  127245. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  127246. }
  127247. interface Mesh {
  127248. /**
  127249. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  127250. * @returns an array of IParticleSystem
  127251. */
  127252. getEmittedParticleSystems(): IParticleSystem[];
  127253. /**
  127254. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  127255. * @returns an array of IParticleSystem
  127256. */
  127257. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  127258. }
  127259. /**
  127260. * @hidden
  127261. */
  127262. export var _IDoNeedToBeInTheBuild: number;
  127263. }
  127264. declare module BABYLON {
  127265. /** Defines the 4 color options */
  127266. export enum PointColor {
  127267. /** color value */
  127268. Color = 2,
  127269. /** uv value */
  127270. UV = 1,
  127271. /** random value */
  127272. Random = 0,
  127273. /** stated value */
  127274. Stated = 3
  127275. }
  127276. /**
  127277. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  127278. * 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.
  127279. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  127280. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  127281. *
  127282. * Full documentation here : TO BE ENTERED
  127283. */
  127284. export class PointsCloudSystem implements IDisposable {
  127285. /**
  127286. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  127287. * Example : var p = SPS.particles[i];
  127288. */
  127289. particles: CloudPoint[];
  127290. /**
  127291. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  127292. */
  127293. nbParticles: number;
  127294. /**
  127295. * This a counter for your own usage. It's not set by any SPS functions.
  127296. */
  127297. counter: number;
  127298. /**
  127299. * The PCS name. This name is also given to the underlying mesh.
  127300. */
  127301. name: string;
  127302. /**
  127303. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  127304. */
  127305. mesh: Mesh;
  127306. /**
  127307. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  127308. * Please read :
  127309. */
  127310. vars: any;
  127311. /**
  127312. * @hidden
  127313. */
  127314. _size: number;
  127315. private _scene;
  127316. private _promises;
  127317. private _positions;
  127318. private _indices;
  127319. private _normals;
  127320. private _colors;
  127321. private _uvs;
  127322. private _indices32;
  127323. private _positions32;
  127324. private _colors32;
  127325. private _uvs32;
  127326. private _updatable;
  127327. private _isVisibilityBoxLocked;
  127328. private _alwaysVisible;
  127329. private _groups;
  127330. private _groupCounter;
  127331. private _computeParticleColor;
  127332. private _computeParticleTexture;
  127333. private _computeParticleRotation;
  127334. private _computeBoundingBox;
  127335. private _isReady;
  127336. /**
  127337. * Creates a PCS (Points Cloud System) object
  127338. * @param name (String) is the PCS name, this will be the underlying mesh name
  127339. * @param pointSize (number) is the size for each point
  127340. * @param scene (Scene) is the scene in which the PCS is added
  127341. * @param options defines the options of the PCS e.g.
  127342. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  127343. */
  127344. constructor(name: string, pointSize: number, scene: Scene, options?: {
  127345. updatable?: boolean;
  127346. });
  127347. /**
  127348. * Builds the PCS underlying mesh. Returns a standard Mesh.
  127349. * If no points were added to the PCS, the returned mesh is just a single point.
  127350. * @returns a promise for the created mesh
  127351. */
  127352. buildMeshAsync(): Promise<Mesh>;
  127353. /**
  127354. * @hidden
  127355. */
  127356. private _buildMesh;
  127357. private _addParticle;
  127358. private _randomUnitVector;
  127359. private _getColorIndicesForCoord;
  127360. private _setPointsColorOrUV;
  127361. private _colorFromTexture;
  127362. private _calculateDensity;
  127363. /**
  127364. * Adds points to the PCS in random positions within a unit sphere
  127365. * @param nb (positive integer) the number of particles to be created from this model
  127366. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  127367. * @returns the number of groups in the system
  127368. */
  127369. addPoints(nb: number, pointFunction?: any): number;
  127370. /**
  127371. * Adds points to the PCS from the surface of the model shape
  127372. * @param mesh is any Mesh object that will be used as a surface model for the points
  127373. * @param nb (positive integer) the number of particles to be created from this model
  127374. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127375. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127376. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127377. * @returns the number of groups in the system
  127378. */
  127379. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127380. /**
  127381. * Adds points to the PCS inside the model shape
  127382. * @param mesh is any Mesh object that will be used as a surface model for the points
  127383. * @param nb (positive integer) the number of particles to be created from this model
  127384. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127385. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127386. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127387. * @returns the number of groups in the system
  127388. */
  127389. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127390. /**
  127391. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  127392. * This method calls `updateParticle()` for each particle of the SPS.
  127393. * For an animated SPS, it is usually called within the render loop.
  127394. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  127395. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  127396. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  127397. * @returns the PCS.
  127398. */
  127399. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  127400. /**
  127401. * Disposes the PCS.
  127402. */
  127403. dispose(): void;
  127404. /**
  127405. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  127406. * doc :
  127407. * @returns the PCS.
  127408. */
  127409. refreshVisibleSize(): PointsCloudSystem;
  127410. /**
  127411. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  127412. * @param size the size (float) of the visibility box
  127413. * note : this doesn't lock the PCS mesh bounding box.
  127414. * doc :
  127415. */
  127416. setVisibilityBox(size: number): void;
  127417. /**
  127418. * Gets whether the PCS is always visible or not
  127419. * doc :
  127420. */
  127421. /**
  127422. * Sets the PCS as always visible or not
  127423. * doc :
  127424. */
  127425. isAlwaysVisible: boolean;
  127426. /**
  127427. * Tells to `setParticles()` to compute the particle rotations or not
  127428. * Default value : false. The PCS is faster when it's set to false
  127429. * Note : particle rotations are only applied to parent particles
  127430. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  127431. */
  127432. computeParticleRotation: boolean;
  127433. /**
  127434. * Tells to `setParticles()` to compute the particle colors or not.
  127435. * Default value : true. The PCS is faster when it's set to false.
  127436. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127437. */
  127438. /**
  127439. * Gets if `setParticles()` computes the particle colors or not.
  127440. * Default value : false. The PCS is faster when it's set to false.
  127441. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127442. */
  127443. computeParticleColor: boolean;
  127444. /**
  127445. * Gets if `setParticles()` computes the particle textures or not.
  127446. * Default value : false. The PCS is faster when it's set to false.
  127447. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  127448. */
  127449. computeParticleTexture: boolean;
  127450. /**
  127451. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  127452. */
  127453. /**
  127454. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  127455. */
  127456. computeBoundingBox: boolean;
  127457. /**
  127458. * This function does nothing. It may be overwritten to set all the particle first values.
  127459. * The PCS doesn't call this function, you may have to call it by your own.
  127460. * doc :
  127461. */
  127462. initParticles(): void;
  127463. /**
  127464. * This function does nothing. It may be overwritten to recycle a particle
  127465. * The PCS doesn't call this function, you can to call it
  127466. * doc :
  127467. * @param particle The particle to recycle
  127468. * @returns the recycled particle
  127469. */
  127470. recycleParticle(particle: CloudPoint): CloudPoint;
  127471. /**
  127472. * Updates a particle : this function should be overwritten by the user.
  127473. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  127474. * doc :
  127475. * @example : just set a particle position or velocity and recycle conditions
  127476. * @param particle The particle to update
  127477. * @returns the updated particle
  127478. */
  127479. updateParticle(particle: CloudPoint): CloudPoint;
  127480. /**
  127481. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  127482. * This does nothing and may be overwritten by the user.
  127483. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127484. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127485. * @param update the boolean update value actually passed to setParticles()
  127486. */
  127487. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127488. /**
  127489. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  127490. * This will be passed three parameters.
  127491. * This does nothing and may be overwritten by the user.
  127492. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127493. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127494. * @param update the boolean update value actually passed to setParticles()
  127495. */
  127496. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127497. }
  127498. }
  127499. declare module BABYLON {
  127500. /**
  127501. * Represents one particle of a points cloud system.
  127502. */
  127503. export class CloudPoint {
  127504. /**
  127505. * particle global index
  127506. */
  127507. idx: number;
  127508. /**
  127509. * The color of the particle
  127510. */
  127511. color: Nullable<Color4>;
  127512. /**
  127513. * The world space position of the particle.
  127514. */
  127515. position: Vector3;
  127516. /**
  127517. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  127518. */
  127519. rotation: Vector3;
  127520. /**
  127521. * The world space rotation quaternion of the particle.
  127522. */
  127523. rotationQuaternion: Nullable<Quaternion>;
  127524. /**
  127525. * The uv of the particle.
  127526. */
  127527. uv: Nullable<Vector2>;
  127528. /**
  127529. * The current speed of the particle.
  127530. */
  127531. velocity: Vector3;
  127532. /**
  127533. * The pivot point in the particle local space.
  127534. */
  127535. pivot: Vector3;
  127536. /**
  127537. * Must the particle be translated from its pivot point in its local space ?
  127538. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  127539. * Default : false
  127540. */
  127541. translateFromPivot: boolean;
  127542. /**
  127543. * Index of this particle in the global "positions" array (Internal use)
  127544. * @hidden
  127545. */
  127546. _pos: number;
  127547. /**
  127548. * @hidden Index of this particle in the global "indices" array (Internal use)
  127549. */
  127550. _ind: number;
  127551. /**
  127552. * Group this particle belongs to
  127553. */
  127554. _group: PointsGroup;
  127555. /**
  127556. * Group id of this particle
  127557. */
  127558. groupId: number;
  127559. /**
  127560. * Index of the particle in its group id (Internal use)
  127561. */
  127562. idxInGroup: number;
  127563. /**
  127564. * @hidden Particle BoundingInfo object (Internal use)
  127565. */
  127566. _boundingInfo: BoundingInfo;
  127567. /**
  127568. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  127569. */
  127570. _pcs: PointsCloudSystem;
  127571. /**
  127572. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  127573. */
  127574. _stillInvisible: boolean;
  127575. /**
  127576. * @hidden Last computed particle rotation matrix
  127577. */
  127578. _rotationMatrix: number[];
  127579. /**
  127580. * Parent particle Id, if any.
  127581. * Default null.
  127582. */
  127583. parentId: Nullable<number>;
  127584. /**
  127585. * @hidden Internal global position in the PCS.
  127586. */
  127587. _globalPosition: Vector3;
  127588. /**
  127589. * Creates a Point Cloud object.
  127590. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  127591. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  127592. * @param group (PointsGroup) is the group the particle belongs to
  127593. * @param groupId (integer) is the group identifier in the PCS.
  127594. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  127595. * @param pcs defines the PCS it is associated to
  127596. */
  127597. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  127598. /**
  127599. * get point size
  127600. */
  127601. /**
  127602. * Set point size
  127603. */
  127604. size: Vector3;
  127605. /**
  127606. * Legacy support, changed quaternion to rotationQuaternion
  127607. */
  127608. /**
  127609. * Legacy support, changed quaternion to rotationQuaternion
  127610. */
  127611. quaternion: Nullable<Quaternion>;
  127612. /**
  127613. * Returns a boolean. True if the particle intersects a mesh, else false
  127614. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  127615. * @param target is the object (point or mesh) what the intersection is computed against
  127616. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  127617. * @returns true if it intersects
  127618. */
  127619. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  127620. /**
  127621. * get the rotation matrix of the particle
  127622. * @hidden
  127623. */
  127624. getRotationMatrix(m: Matrix): void;
  127625. }
  127626. /**
  127627. * Represents a group of points in a points cloud system
  127628. * * PCS internal tool, don't use it manually.
  127629. */
  127630. export class PointsGroup {
  127631. /**
  127632. * The group id
  127633. * @hidden
  127634. */
  127635. groupID: number;
  127636. /**
  127637. * image data for group (internal use)
  127638. * @hidden
  127639. */
  127640. _groupImageData: Nullable<ArrayBufferView>;
  127641. /**
  127642. * Image Width (internal use)
  127643. * @hidden
  127644. */
  127645. _groupImgWidth: number;
  127646. /**
  127647. * Image Height (internal use)
  127648. * @hidden
  127649. */
  127650. _groupImgHeight: number;
  127651. /**
  127652. * Custom position function (internal use)
  127653. * @hidden
  127654. */
  127655. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  127656. /**
  127657. * density per facet for surface points
  127658. * @hidden
  127659. */
  127660. _groupDensity: number[];
  127661. /**
  127662. * Only when points are colored by texture carries pointer to texture list array
  127663. * @hidden
  127664. */
  127665. _textureNb: number;
  127666. /**
  127667. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  127668. * PCS internal tool, don't use it manually.
  127669. * @hidden
  127670. */
  127671. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  127672. }
  127673. }
  127674. declare module BABYLON {
  127675. interface Scene {
  127676. /** @hidden (Backing field) */
  127677. _physicsEngine: Nullable<IPhysicsEngine>;
  127678. /**
  127679. * Gets the current physics engine
  127680. * @returns a IPhysicsEngine or null if none attached
  127681. */
  127682. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  127683. /**
  127684. * Enables physics to the current scene
  127685. * @param gravity defines the scene's gravity for the physics engine
  127686. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  127687. * @return a boolean indicating if the physics engine was initialized
  127688. */
  127689. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  127690. /**
  127691. * Disables and disposes the physics engine associated with the scene
  127692. */
  127693. disablePhysicsEngine(): void;
  127694. /**
  127695. * Gets a boolean indicating if there is an active physics engine
  127696. * @returns a boolean indicating if there is an active physics engine
  127697. */
  127698. isPhysicsEnabled(): boolean;
  127699. /**
  127700. * Deletes a physics compound impostor
  127701. * @param compound defines the compound to delete
  127702. */
  127703. deleteCompoundImpostor(compound: any): void;
  127704. /**
  127705. * An event triggered when physic simulation is about to be run
  127706. */
  127707. onBeforePhysicsObservable: Observable<Scene>;
  127708. /**
  127709. * An event triggered when physic simulation has been done
  127710. */
  127711. onAfterPhysicsObservable: Observable<Scene>;
  127712. }
  127713. interface AbstractMesh {
  127714. /** @hidden */
  127715. _physicsImpostor: Nullable<PhysicsImpostor>;
  127716. /**
  127717. * Gets or sets impostor used for physic simulation
  127718. * @see http://doc.babylonjs.com/features/physics_engine
  127719. */
  127720. physicsImpostor: Nullable<PhysicsImpostor>;
  127721. /**
  127722. * Gets the current physics impostor
  127723. * @see http://doc.babylonjs.com/features/physics_engine
  127724. * @returns a physics impostor or null
  127725. */
  127726. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  127727. /** Apply a physic impulse to the mesh
  127728. * @param force defines the force to apply
  127729. * @param contactPoint defines where to apply the force
  127730. * @returns the current mesh
  127731. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127732. */
  127733. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  127734. /**
  127735. * Creates a physic joint between two meshes
  127736. * @param otherMesh defines the other mesh to use
  127737. * @param pivot1 defines the pivot to use on this mesh
  127738. * @param pivot2 defines the pivot to use on the other mesh
  127739. * @param options defines additional options (can be plugin dependent)
  127740. * @returns the current mesh
  127741. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  127742. */
  127743. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  127744. /** @hidden */
  127745. _disposePhysicsObserver: Nullable<Observer<Node>>;
  127746. }
  127747. /**
  127748. * Defines the physics engine scene component responsible to manage a physics engine
  127749. */
  127750. export class PhysicsEngineSceneComponent implements ISceneComponent {
  127751. /**
  127752. * The component name helpful to identify the component in the list of scene components.
  127753. */
  127754. readonly name: string;
  127755. /**
  127756. * The scene the component belongs to.
  127757. */
  127758. scene: Scene;
  127759. /**
  127760. * Creates a new instance of the component for the given scene
  127761. * @param scene Defines the scene to register the component in
  127762. */
  127763. constructor(scene: Scene);
  127764. /**
  127765. * Registers the component in a given scene
  127766. */
  127767. register(): void;
  127768. /**
  127769. * Rebuilds the elements related to this component in case of
  127770. * context lost for instance.
  127771. */
  127772. rebuild(): void;
  127773. /**
  127774. * Disposes the component and the associated ressources
  127775. */
  127776. dispose(): void;
  127777. }
  127778. }
  127779. declare module BABYLON {
  127780. /**
  127781. * A helper for physics simulations
  127782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127783. */
  127784. export class PhysicsHelper {
  127785. private _scene;
  127786. private _physicsEngine;
  127787. /**
  127788. * Initializes the Physics helper
  127789. * @param scene Babylon.js scene
  127790. */
  127791. constructor(scene: Scene);
  127792. /**
  127793. * Applies a radial explosion impulse
  127794. * @param origin the origin of the explosion
  127795. * @param radiusOrEventOptions the radius or the options of radial explosion
  127796. * @param strength the explosion strength
  127797. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127798. * @returns A physics radial explosion event, or null
  127799. */
  127800. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127801. /**
  127802. * Applies a radial explosion force
  127803. * @param origin the origin of the explosion
  127804. * @param radiusOrEventOptions the radius or the options of radial explosion
  127805. * @param strength the explosion strength
  127806. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127807. * @returns A physics radial explosion event, or null
  127808. */
  127809. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127810. /**
  127811. * Creates a gravitational field
  127812. * @param origin the origin of the explosion
  127813. * @param radiusOrEventOptions the radius or the options of radial explosion
  127814. * @param strength the explosion strength
  127815. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127816. * @returns A physics gravitational field event, or null
  127817. */
  127818. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  127819. /**
  127820. * Creates a physics updraft event
  127821. * @param origin the origin of the updraft
  127822. * @param radiusOrEventOptions the radius or the options of the updraft
  127823. * @param strength the strength of the updraft
  127824. * @param height the height of the updraft
  127825. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  127826. * @returns A physics updraft event, or null
  127827. */
  127828. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  127829. /**
  127830. * Creates a physics vortex event
  127831. * @param origin the of the vortex
  127832. * @param radiusOrEventOptions the radius or the options of the vortex
  127833. * @param strength the strength of the vortex
  127834. * @param height the height of the vortex
  127835. * @returns a Physics vortex event, or null
  127836. * A physics vortex event or null
  127837. */
  127838. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  127839. }
  127840. /**
  127841. * Represents a physics radial explosion event
  127842. */
  127843. class PhysicsRadialExplosionEvent {
  127844. private _scene;
  127845. private _options;
  127846. private _sphere;
  127847. private _dataFetched;
  127848. /**
  127849. * Initializes a radial explosioin event
  127850. * @param _scene BabylonJS scene
  127851. * @param _options The options for the vortex event
  127852. */
  127853. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  127854. /**
  127855. * Returns the data related to the radial explosion event (sphere).
  127856. * @returns The radial explosion event data
  127857. */
  127858. getData(): PhysicsRadialExplosionEventData;
  127859. /**
  127860. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  127861. * @param impostor A physics imposter
  127862. * @param origin the origin of the explosion
  127863. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  127864. */
  127865. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  127866. /**
  127867. * Triggers affecterd impostors callbacks
  127868. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  127869. */
  127870. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  127871. /**
  127872. * Disposes the sphere.
  127873. * @param force Specifies if the sphere should be disposed by force
  127874. */
  127875. dispose(force?: boolean): void;
  127876. /*** Helpers ***/
  127877. private _prepareSphere;
  127878. private _intersectsWithSphere;
  127879. }
  127880. /**
  127881. * Represents a gravitational field event
  127882. */
  127883. class PhysicsGravitationalFieldEvent {
  127884. private _physicsHelper;
  127885. private _scene;
  127886. private _origin;
  127887. private _options;
  127888. private _tickCallback;
  127889. private _sphere;
  127890. private _dataFetched;
  127891. /**
  127892. * Initializes the physics gravitational field event
  127893. * @param _physicsHelper A physics helper
  127894. * @param _scene BabylonJS scene
  127895. * @param _origin The origin position of the gravitational field event
  127896. * @param _options The options for the vortex event
  127897. */
  127898. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  127899. /**
  127900. * Returns the data related to the gravitational field event (sphere).
  127901. * @returns A gravitational field event
  127902. */
  127903. getData(): PhysicsGravitationalFieldEventData;
  127904. /**
  127905. * Enables the gravitational field.
  127906. */
  127907. enable(): void;
  127908. /**
  127909. * Disables the gravitational field.
  127910. */
  127911. disable(): void;
  127912. /**
  127913. * Disposes the sphere.
  127914. * @param force The force to dispose from the gravitational field event
  127915. */
  127916. dispose(force?: boolean): void;
  127917. private _tick;
  127918. }
  127919. /**
  127920. * Represents a physics updraft event
  127921. */
  127922. class PhysicsUpdraftEvent {
  127923. private _scene;
  127924. private _origin;
  127925. private _options;
  127926. private _physicsEngine;
  127927. private _originTop;
  127928. private _originDirection;
  127929. private _tickCallback;
  127930. private _cylinder;
  127931. private _cylinderPosition;
  127932. private _dataFetched;
  127933. /**
  127934. * Initializes the physics updraft event
  127935. * @param _scene BabylonJS scene
  127936. * @param _origin The origin position of the updraft
  127937. * @param _options The options for the updraft event
  127938. */
  127939. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  127940. /**
  127941. * Returns the data related to the updraft event (cylinder).
  127942. * @returns A physics updraft event
  127943. */
  127944. getData(): PhysicsUpdraftEventData;
  127945. /**
  127946. * Enables the updraft.
  127947. */
  127948. enable(): void;
  127949. /**
  127950. * Disables the updraft.
  127951. */
  127952. disable(): void;
  127953. /**
  127954. * Disposes the cylinder.
  127955. * @param force Specifies if the updraft should be disposed by force
  127956. */
  127957. dispose(force?: boolean): void;
  127958. private getImpostorHitData;
  127959. private _tick;
  127960. /*** Helpers ***/
  127961. private _prepareCylinder;
  127962. private _intersectsWithCylinder;
  127963. }
  127964. /**
  127965. * Represents a physics vortex event
  127966. */
  127967. class PhysicsVortexEvent {
  127968. private _scene;
  127969. private _origin;
  127970. private _options;
  127971. private _physicsEngine;
  127972. private _originTop;
  127973. private _tickCallback;
  127974. private _cylinder;
  127975. private _cylinderPosition;
  127976. private _dataFetched;
  127977. /**
  127978. * Initializes the physics vortex event
  127979. * @param _scene The BabylonJS scene
  127980. * @param _origin The origin position of the vortex
  127981. * @param _options The options for the vortex event
  127982. */
  127983. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  127984. /**
  127985. * Returns the data related to the vortex event (cylinder).
  127986. * @returns The physics vortex event data
  127987. */
  127988. getData(): PhysicsVortexEventData;
  127989. /**
  127990. * Enables the vortex.
  127991. */
  127992. enable(): void;
  127993. /**
  127994. * Disables the cortex.
  127995. */
  127996. disable(): void;
  127997. /**
  127998. * Disposes the sphere.
  127999. * @param force
  128000. */
  128001. dispose(force?: boolean): void;
  128002. private getImpostorHitData;
  128003. private _tick;
  128004. /*** Helpers ***/
  128005. private _prepareCylinder;
  128006. private _intersectsWithCylinder;
  128007. }
  128008. /**
  128009. * Options fot the radial explosion event
  128010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128011. */
  128012. export class PhysicsRadialExplosionEventOptions {
  128013. /**
  128014. * The radius of the sphere for the radial explosion.
  128015. */
  128016. radius: number;
  128017. /**
  128018. * The strenth of the explosion.
  128019. */
  128020. strength: number;
  128021. /**
  128022. * The strenght of the force in correspondence to the distance of the affected object
  128023. */
  128024. falloff: PhysicsRadialImpulseFalloff;
  128025. /**
  128026. * Sphere options for the radial explosion.
  128027. */
  128028. sphere: {
  128029. segments: number;
  128030. diameter: number;
  128031. };
  128032. /**
  128033. * Sphere options for the radial explosion.
  128034. */
  128035. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  128036. }
  128037. /**
  128038. * Options fot the updraft event
  128039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128040. */
  128041. export class PhysicsUpdraftEventOptions {
  128042. /**
  128043. * The radius of the cylinder for the vortex
  128044. */
  128045. radius: number;
  128046. /**
  128047. * The strenth of the updraft.
  128048. */
  128049. strength: number;
  128050. /**
  128051. * The height of the cylinder for the updraft.
  128052. */
  128053. height: number;
  128054. /**
  128055. * The mode for the the updraft.
  128056. */
  128057. updraftMode: PhysicsUpdraftMode;
  128058. }
  128059. /**
  128060. * Options fot the vortex event
  128061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128062. */
  128063. export class PhysicsVortexEventOptions {
  128064. /**
  128065. * The radius of the cylinder for the vortex
  128066. */
  128067. radius: number;
  128068. /**
  128069. * The strenth of the vortex.
  128070. */
  128071. strength: number;
  128072. /**
  128073. * The height of the cylinder for the vortex.
  128074. */
  128075. height: number;
  128076. /**
  128077. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  128078. */
  128079. centripetalForceThreshold: number;
  128080. /**
  128081. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  128082. */
  128083. centripetalForceMultiplier: number;
  128084. /**
  128085. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  128086. */
  128087. centrifugalForceMultiplier: number;
  128088. /**
  128089. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  128090. */
  128091. updraftForceMultiplier: number;
  128092. }
  128093. /**
  128094. * The strenght of the force in correspondence to the distance of the affected object
  128095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128096. */
  128097. export enum PhysicsRadialImpulseFalloff {
  128098. /** Defines that impulse is constant in strength across it's whole radius */
  128099. Constant = 0,
  128100. /** Defines that impulse gets weaker if it's further from the origin */
  128101. Linear = 1
  128102. }
  128103. /**
  128104. * The strength of the force in correspondence to the distance of the affected object
  128105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128106. */
  128107. export enum PhysicsUpdraftMode {
  128108. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  128109. Center = 0,
  128110. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  128111. Perpendicular = 1
  128112. }
  128113. /**
  128114. * Interface for a physics hit data
  128115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128116. */
  128117. export interface PhysicsHitData {
  128118. /**
  128119. * The force applied at the contact point
  128120. */
  128121. force: Vector3;
  128122. /**
  128123. * The contact point
  128124. */
  128125. contactPoint: Vector3;
  128126. /**
  128127. * The distance from the origin to the contact point
  128128. */
  128129. distanceFromOrigin: number;
  128130. }
  128131. /**
  128132. * Interface for radial explosion event data
  128133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128134. */
  128135. export interface PhysicsRadialExplosionEventData {
  128136. /**
  128137. * A sphere used for the radial explosion event
  128138. */
  128139. sphere: Mesh;
  128140. }
  128141. /**
  128142. * Interface for gravitational field event data
  128143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128144. */
  128145. export interface PhysicsGravitationalFieldEventData {
  128146. /**
  128147. * A sphere mesh used for the gravitational field event
  128148. */
  128149. sphere: Mesh;
  128150. }
  128151. /**
  128152. * Interface for updraft event data
  128153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128154. */
  128155. export interface PhysicsUpdraftEventData {
  128156. /**
  128157. * A cylinder used for the updraft event
  128158. */
  128159. cylinder: Mesh;
  128160. }
  128161. /**
  128162. * Interface for vortex event data
  128163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128164. */
  128165. export interface PhysicsVortexEventData {
  128166. /**
  128167. * A cylinder used for the vortex event
  128168. */
  128169. cylinder: Mesh;
  128170. }
  128171. /**
  128172. * Interface for an affected physics impostor
  128173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128174. */
  128175. export interface PhysicsAffectedImpostorWithData {
  128176. /**
  128177. * The impostor affected by the effect
  128178. */
  128179. impostor: PhysicsImpostor;
  128180. /**
  128181. * The data about the hit/horce from the explosion
  128182. */
  128183. hitData: PhysicsHitData;
  128184. }
  128185. }
  128186. declare module BABYLON {
  128187. /** @hidden */
  128188. export var blackAndWhitePixelShader: {
  128189. name: string;
  128190. shader: string;
  128191. };
  128192. }
  128193. declare module BABYLON {
  128194. /**
  128195. * Post process used to render in black and white
  128196. */
  128197. export class BlackAndWhitePostProcess extends PostProcess {
  128198. /**
  128199. * Linear about to convert he result to black and white (default: 1)
  128200. */
  128201. degree: number;
  128202. /**
  128203. * Creates a black and white post process
  128204. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  128205. * @param name The name of the effect.
  128206. * @param options The required width/height ratio to downsize to before computing the render pass.
  128207. * @param camera The camera to apply the render pass to.
  128208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128209. * @param engine The engine which the post process will be applied. (default: current engine)
  128210. * @param reusable If the post process can be reused on the same frame. (default: false)
  128211. */
  128212. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128213. }
  128214. }
  128215. declare module BABYLON {
  128216. /**
  128217. * This represents a set of one or more post processes in Babylon.
  128218. * A post process can be used to apply a shader to a texture after it is rendered.
  128219. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128220. */
  128221. export class PostProcessRenderEffect {
  128222. private _postProcesses;
  128223. private _getPostProcesses;
  128224. private _singleInstance;
  128225. private _cameras;
  128226. private _indicesForCamera;
  128227. /**
  128228. * Name of the effect
  128229. * @hidden
  128230. */
  128231. _name: string;
  128232. /**
  128233. * Instantiates a post process render effect.
  128234. * A post process can be used to apply a shader to a texture after it is rendered.
  128235. * @param engine The engine the effect is tied to
  128236. * @param name The name of the effect
  128237. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  128238. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  128239. */
  128240. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  128241. /**
  128242. * Checks if all the post processes in the effect are supported.
  128243. */
  128244. readonly isSupported: boolean;
  128245. /**
  128246. * Updates the current state of the effect
  128247. * @hidden
  128248. */
  128249. _update(): void;
  128250. /**
  128251. * Attaches the effect on cameras
  128252. * @param cameras The camera to attach to.
  128253. * @hidden
  128254. */
  128255. _attachCameras(cameras: Camera): void;
  128256. /**
  128257. * Attaches the effect on cameras
  128258. * @param cameras The camera to attach to.
  128259. * @hidden
  128260. */
  128261. _attachCameras(cameras: Camera[]): void;
  128262. /**
  128263. * Detaches the effect on cameras
  128264. * @param cameras The camera to detatch from.
  128265. * @hidden
  128266. */
  128267. _detachCameras(cameras: Camera): void;
  128268. /**
  128269. * Detatches the effect on cameras
  128270. * @param cameras The camera to detatch from.
  128271. * @hidden
  128272. */
  128273. _detachCameras(cameras: Camera[]): void;
  128274. /**
  128275. * Enables the effect on given cameras
  128276. * @param cameras The camera to enable.
  128277. * @hidden
  128278. */
  128279. _enable(cameras: Camera): void;
  128280. /**
  128281. * Enables the effect on given cameras
  128282. * @param cameras The camera to enable.
  128283. * @hidden
  128284. */
  128285. _enable(cameras: Nullable<Camera[]>): void;
  128286. /**
  128287. * Disables the effect on the given cameras
  128288. * @param cameras The camera to disable.
  128289. * @hidden
  128290. */
  128291. _disable(cameras: Camera): void;
  128292. /**
  128293. * Disables the effect on the given cameras
  128294. * @param cameras The camera to disable.
  128295. * @hidden
  128296. */
  128297. _disable(cameras: Nullable<Camera[]>): void;
  128298. /**
  128299. * Gets a list of the post processes contained in the effect.
  128300. * @param camera The camera to get the post processes on.
  128301. * @returns The list of the post processes in the effect.
  128302. */
  128303. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  128304. }
  128305. }
  128306. declare module BABYLON {
  128307. /** @hidden */
  128308. export var extractHighlightsPixelShader: {
  128309. name: string;
  128310. shader: string;
  128311. };
  128312. }
  128313. declare module BABYLON {
  128314. /**
  128315. * 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.
  128316. */
  128317. export class ExtractHighlightsPostProcess extends PostProcess {
  128318. /**
  128319. * The luminance threshold, pixels below this value will be set to black.
  128320. */
  128321. threshold: number;
  128322. /** @hidden */
  128323. _exposure: number;
  128324. /**
  128325. * Post process which has the input texture to be used when performing highlight extraction
  128326. * @hidden
  128327. */
  128328. _inputPostProcess: Nullable<PostProcess>;
  128329. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128330. }
  128331. }
  128332. declare module BABYLON {
  128333. /** @hidden */
  128334. export var bloomMergePixelShader: {
  128335. name: string;
  128336. shader: string;
  128337. };
  128338. }
  128339. declare module BABYLON {
  128340. /**
  128341. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128342. */
  128343. export class BloomMergePostProcess extends PostProcess {
  128344. /** Weight of the bloom to be added to the original input. */
  128345. weight: number;
  128346. /**
  128347. * Creates a new instance of @see BloomMergePostProcess
  128348. * @param name The name of the effect.
  128349. * @param originalFromInput Post process which's input will be used for the merge.
  128350. * @param blurred Blurred highlights post process which's output will be used.
  128351. * @param weight Weight of the bloom to be added to the original input.
  128352. * @param options The required width/height ratio to downsize to before computing the render pass.
  128353. * @param camera The camera to apply the render pass to.
  128354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128355. * @param engine The engine which the post process will be applied. (default: current engine)
  128356. * @param reusable If the post process can be reused on the same frame. (default: false)
  128357. * @param textureType Type of textures used when performing the post process. (default: 0)
  128358. * @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)
  128359. */
  128360. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  128361. /** Weight of the bloom to be added to the original input. */
  128362. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128363. }
  128364. }
  128365. declare module BABYLON {
  128366. /**
  128367. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  128368. */
  128369. export class BloomEffect extends PostProcessRenderEffect {
  128370. private bloomScale;
  128371. /**
  128372. * @hidden Internal
  128373. */
  128374. _effects: Array<PostProcess>;
  128375. /**
  128376. * @hidden Internal
  128377. */
  128378. _downscale: ExtractHighlightsPostProcess;
  128379. private _blurX;
  128380. private _blurY;
  128381. private _merge;
  128382. /**
  128383. * The luminance threshold to find bright areas of the image to bloom.
  128384. */
  128385. threshold: number;
  128386. /**
  128387. * The strength of the bloom.
  128388. */
  128389. weight: number;
  128390. /**
  128391. * Specifies the size of the bloom blur kernel, relative to the final output size
  128392. */
  128393. kernel: number;
  128394. /**
  128395. * Creates a new instance of @see BloomEffect
  128396. * @param scene The scene the effect belongs to.
  128397. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  128398. * @param bloomKernel The size of the kernel to be used when applying the blur.
  128399. * @param bloomWeight The the strength of bloom.
  128400. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128401. * @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)
  128402. */
  128403. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  128404. /**
  128405. * Disposes each of the internal effects for a given camera.
  128406. * @param camera The camera to dispose the effect on.
  128407. */
  128408. disposeEffects(camera: Camera): void;
  128409. /**
  128410. * @hidden Internal
  128411. */
  128412. _updateEffects(): void;
  128413. /**
  128414. * Internal
  128415. * @returns if all the contained post processes are ready.
  128416. * @hidden
  128417. */
  128418. _isReady(): boolean;
  128419. }
  128420. }
  128421. declare module BABYLON {
  128422. /** @hidden */
  128423. export var chromaticAberrationPixelShader: {
  128424. name: string;
  128425. shader: string;
  128426. };
  128427. }
  128428. declare module BABYLON {
  128429. /**
  128430. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  128431. */
  128432. export class ChromaticAberrationPostProcess extends PostProcess {
  128433. /**
  128434. * The amount of seperation of rgb channels (default: 30)
  128435. */
  128436. aberrationAmount: number;
  128437. /**
  128438. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  128439. */
  128440. radialIntensity: number;
  128441. /**
  128442. * 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))
  128443. */
  128444. direction: Vector2;
  128445. /**
  128446. * 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))
  128447. */
  128448. centerPosition: Vector2;
  128449. /**
  128450. * Creates a new instance ChromaticAberrationPostProcess
  128451. * @param name The name of the effect.
  128452. * @param screenWidth The width of the screen to apply the effect on.
  128453. * @param screenHeight The height of the screen to apply the effect on.
  128454. * @param options The required width/height ratio to downsize to before computing the render pass.
  128455. * @param camera The camera to apply the render pass to.
  128456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128457. * @param engine The engine which the post process will be applied. (default: current engine)
  128458. * @param reusable If the post process can be reused on the same frame. (default: false)
  128459. * @param textureType Type of textures used when performing the post process. (default: 0)
  128460. * @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)
  128461. */
  128462. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128463. }
  128464. }
  128465. declare module BABYLON {
  128466. /** @hidden */
  128467. export var circleOfConfusionPixelShader: {
  128468. name: string;
  128469. shader: string;
  128470. };
  128471. }
  128472. declare module BABYLON {
  128473. /**
  128474. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  128475. */
  128476. export class CircleOfConfusionPostProcess extends PostProcess {
  128477. /**
  128478. * 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.
  128479. */
  128480. lensSize: number;
  128481. /**
  128482. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128483. */
  128484. fStop: number;
  128485. /**
  128486. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128487. */
  128488. focusDistance: number;
  128489. /**
  128490. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  128491. */
  128492. focalLength: number;
  128493. private _depthTexture;
  128494. /**
  128495. * Creates a new instance CircleOfConfusionPostProcess
  128496. * @param name The name of the effect.
  128497. * @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.
  128498. * @param options The required width/height ratio to downsize to before computing the render pass.
  128499. * @param camera The camera to apply the render pass to.
  128500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128501. * @param engine The engine which the post process will be applied. (default: current engine)
  128502. * @param reusable If the post process can be reused on the same frame. (default: false)
  128503. * @param textureType Type of textures used when performing the post process. (default: 0)
  128504. * @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)
  128505. */
  128506. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128507. /**
  128508. * 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.
  128509. */
  128510. depthTexture: RenderTargetTexture;
  128511. }
  128512. }
  128513. declare module BABYLON {
  128514. /** @hidden */
  128515. export var colorCorrectionPixelShader: {
  128516. name: string;
  128517. shader: string;
  128518. };
  128519. }
  128520. declare module BABYLON {
  128521. /**
  128522. *
  128523. * This post-process allows the modification of rendered colors by using
  128524. * a 'look-up table' (LUT). This effect is also called Color Grading.
  128525. *
  128526. * The object needs to be provided an url to a texture containing the color
  128527. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  128528. * Use an image editing software to tweak the LUT to match your needs.
  128529. *
  128530. * For an example of a color LUT, see here:
  128531. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  128532. * For explanations on color grading, see here:
  128533. * @see http://udn.epicgames.com/Three/ColorGrading.html
  128534. *
  128535. */
  128536. export class ColorCorrectionPostProcess extends PostProcess {
  128537. private _colorTableTexture;
  128538. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128539. }
  128540. }
  128541. declare module BABYLON {
  128542. /** @hidden */
  128543. export var convolutionPixelShader: {
  128544. name: string;
  128545. shader: string;
  128546. };
  128547. }
  128548. declare module BABYLON {
  128549. /**
  128550. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  128551. * input texture to perform effects such as edge detection or sharpening
  128552. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128553. */
  128554. export class ConvolutionPostProcess extends PostProcess {
  128555. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128556. kernel: number[];
  128557. /**
  128558. * Creates a new instance ConvolutionPostProcess
  128559. * @param name The name of the effect.
  128560. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  128561. * @param options The required width/height ratio to downsize to before computing the render pass.
  128562. * @param camera The camera to apply the render pass to.
  128563. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128564. * @param engine The engine which the post process will be applied. (default: current engine)
  128565. * @param reusable If the post process can be reused on the same frame. (default: false)
  128566. * @param textureType Type of textures used when performing the post process. (default: 0)
  128567. */
  128568. constructor(name: string,
  128569. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128570. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128571. /**
  128572. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128573. */
  128574. static EdgeDetect0Kernel: number[];
  128575. /**
  128576. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128577. */
  128578. static EdgeDetect1Kernel: number[];
  128579. /**
  128580. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128581. */
  128582. static EdgeDetect2Kernel: number[];
  128583. /**
  128584. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128585. */
  128586. static SharpenKernel: number[];
  128587. /**
  128588. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128589. */
  128590. static EmbossKernel: number[];
  128591. /**
  128592. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128593. */
  128594. static GaussianKernel: number[];
  128595. }
  128596. }
  128597. declare module BABYLON {
  128598. /**
  128599. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  128600. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  128601. * based on samples that have a large difference in distance than the center pixel.
  128602. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  128603. */
  128604. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  128605. direction: Vector2;
  128606. /**
  128607. * Creates a new instance CircleOfConfusionPostProcess
  128608. * @param name The name of the effect.
  128609. * @param scene The scene the effect belongs to.
  128610. * @param direction The direction the blur should be applied.
  128611. * @param kernel The size of the kernel used to blur.
  128612. * @param options The required width/height ratio to downsize to before computing the render pass.
  128613. * @param camera The camera to apply the render pass to.
  128614. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  128615. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  128616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128617. * @param engine The engine which the post process will be applied. (default: current engine)
  128618. * @param reusable If the post process can be reused on the same frame. (default: false)
  128619. * @param textureType Type of textures used when performing the post process. (default: 0)
  128620. * @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)
  128621. */
  128622. 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);
  128623. }
  128624. }
  128625. declare module BABYLON {
  128626. /** @hidden */
  128627. export var depthOfFieldMergePixelShader: {
  128628. name: string;
  128629. shader: string;
  128630. };
  128631. }
  128632. declare module BABYLON {
  128633. /**
  128634. * Options to be set when merging outputs from the default pipeline.
  128635. */
  128636. export class DepthOfFieldMergePostProcessOptions {
  128637. /**
  128638. * The original image to merge on top of
  128639. */
  128640. originalFromInput: PostProcess;
  128641. /**
  128642. * Parameters to perform the merge of the depth of field effect
  128643. */
  128644. depthOfField?: {
  128645. circleOfConfusion: PostProcess;
  128646. blurSteps: Array<PostProcess>;
  128647. };
  128648. /**
  128649. * Parameters to perform the merge of bloom effect
  128650. */
  128651. bloom?: {
  128652. blurred: PostProcess;
  128653. weight: number;
  128654. };
  128655. }
  128656. /**
  128657. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128658. */
  128659. export class DepthOfFieldMergePostProcess extends PostProcess {
  128660. private blurSteps;
  128661. /**
  128662. * Creates a new instance of DepthOfFieldMergePostProcess
  128663. * @param name The name of the effect.
  128664. * @param originalFromInput Post process which's input will be used for the merge.
  128665. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  128666. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  128667. * @param options The required width/height ratio to downsize to before computing the render pass.
  128668. * @param camera The camera to apply the render pass to.
  128669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128670. * @param engine The engine which the post process will be applied. (default: current engine)
  128671. * @param reusable If the post process can be reused on the same frame. (default: false)
  128672. * @param textureType Type of textures used when performing the post process. (default: 0)
  128673. * @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)
  128674. */
  128675. 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);
  128676. /**
  128677. * Updates the effect with the current post process compile time values and recompiles the shader.
  128678. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  128679. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  128680. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  128681. * @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
  128682. * @param onCompiled Called when the shader has been compiled.
  128683. * @param onError Called if there is an error when compiling a shader.
  128684. */
  128685. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  128686. }
  128687. }
  128688. declare module BABYLON {
  128689. /**
  128690. * Specifies the level of max blur that should be applied when using the depth of field effect
  128691. */
  128692. export enum DepthOfFieldEffectBlurLevel {
  128693. /**
  128694. * Subtle blur
  128695. */
  128696. Low = 0,
  128697. /**
  128698. * Medium blur
  128699. */
  128700. Medium = 1,
  128701. /**
  128702. * Large blur
  128703. */
  128704. High = 2
  128705. }
  128706. /**
  128707. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  128708. */
  128709. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  128710. private _circleOfConfusion;
  128711. /**
  128712. * @hidden Internal, blurs from high to low
  128713. */
  128714. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  128715. private _depthOfFieldBlurY;
  128716. private _dofMerge;
  128717. /**
  128718. * @hidden Internal post processes in depth of field effect
  128719. */
  128720. _effects: Array<PostProcess>;
  128721. /**
  128722. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  128723. */
  128724. focalLength: number;
  128725. /**
  128726. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128727. */
  128728. fStop: number;
  128729. /**
  128730. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128731. */
  128732. focusDistance: number;
  128733. /**
  128734. * 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.
  128735. */
  128736. lensSize: number;
  128737. /**
  128738. * Creates a new instance DepthOfFieldEffect
  128739. * @param scene The scene the effect belongs to.
  128740. * @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.
  128741. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128742. * @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)
  128743. */
  128744. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  128745. /**
  128746. * Get the current class name of the current effet
  128747. * @returns "DepthOfFieldEffect"
  128748. */
  128749. getClassName(): string;
  128750. /**
  128751. * 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.
  128752. */
  128753. depthTexture: RenderTargetTexture;
  128754. /**
  128755. * Disposes each of the internal effects for a given camera.
  128756. * @param camera The camera to dispose the effect on.
  128757. */
  128758. disposeEffects(camera: Camera): void;
  128759. /**
  128760. * @hidden Internal
  128761. */
  128762. _updateEffects(): void;
  128763. /**
  128764. * Internal
  128765. * @returns if all the contained post processes are ready.
  128766. * @hidden
  128767. */
  128768. _isReady(): boolean;
  128769. }
  128770. }
  128771. declare module BABYLON {
  128772. /** @hidden */
  128773. export var displayPassPixelShader: {
  128774. name: string;
  128775. shader: string;
  128776. };
  128777. }
  128778. declare module BABYLON {
  128779. /**
  128780. * DisplayPassPostProcess which produces an output the same as it's input
  128781. */
  128782. export class DisplayPassPostProcess extends PostProcess {
  128783. /**
  128784. * Creates the DisplayPassPostProcess
  128785. * @param name The name of the effect.
  128786. * @param options The required width/height ratio to downsize to before computing the render pass.
  128787. * @param camera The camera to apply the render pass to.
  128788. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128789. * @param engine The engine which the post process will be applied. (default: current engine)
  128790. * @param reusable If the post process can be reused on the same frame. (default: false)
  128791. */
  128792. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128793. }
  128794. }
  128795. declare module BABYLON {
  128796. /** @hidden */
  128797. export var filterPixelShader: {
  128798. name: string;
  128799. shader: string;
  128800. };
  128801. }
  128802. declare module BABYLON {
  128803. /**
  128804. * Applies a kernel filter to the image
  128805. */
  128806. export class FilterPostProcess extends PostProcess {
  128807. /** The matrix to be applied to the image */
  128808. kernelMatrix: Matrix;
  128809. /**
  128810. *
  128811. * @param name The name of the effect.
  128812. * @param kernelMatrix The matrix to be applied to the image
  128813. * @param options The required width/height ratio to downsize to before computing the render pass.
  128814. * @param camera The camera to apply the render pass to.
  128815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128816. * @param engine The engine which the post process will be applied. (default: current engine)
  128817. * @param reusable If the post process can be reused on the same frame. (default: false)
  128818. */
  128819. constructor(name: string,
  128820. /** The matrix to be applied to the image */
  128821. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128822. }
  128823. }
  128824. declare module BABYLON {
  128825. /** @hidden */
  128826. export var fxaaPixelShader: {
  128827. name: string;
  128828. shader: string;
  128829. };
  128830. }
  128831. declare module BABYLON {
  128832. /** @hidden */
  128833. export var fxaaVertexShader: {
  128834. name: string;
  128835. shader: string;
  128836. };
  128837. }
  128838. declare module BABYLON {
  128839. /**
  128840. * Fxaa post process
  128841. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  128842. */
  128843. export class FxaaPostProcess extends PostProcess {
  128844. /** @hidden */
  128845. texelWidth: number;
  128846. /** @hidden */
  128847. texelHeight: number;
  128848. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128849. private _getDefines;
  128850. }
  128851. }
  128852. declare module BABYLON {
  128853. /** @hidden */
  128854. export var grainPixelShader: {
  128855. name: string;
  128856. shader: string;
  128857. };
  128858. }
  128859. declare module BABYLON {
  128860. /**
  128861. * The GrainPostProcess adds noise to the image at mid luminance levels
  128862. */
  128863. export class GrainPostProcess extends PostProcess {
  128864. /**
  128865. * The intensity of the grain added (default: 30)
  128866. */
  128867. intensity: number;
  128868. /**
  128869. * If the grain should be randomized on every frame
  128870. */
  128871. animated: boolean;
  128872. /**
  128873. * Creates a new instance of @see GrainPostProcess
  128874. * @param name The name of the effect.
  128875. * @param options The required width/height ratio to downsize to before computing the render pass.
  128876. * @param camera The camera to apply the render pass to.
  128877. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128878. * @param engine The engine which the post process will be applied. (default: current engine)
  128879. * @param reusable If the post process can be reused on the same frame. (default: false)
  128880. * @param textureType Type of textures used when performing the post process. (default: 0)
  128881. * @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)
  128882. */
  128883. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128884. }
  128885. }
  128886. declare module BABYLON {
  128887. /** @hidden */
  128888. export var highlightsPixelShader: {
  128889. name: string;
  128890. shader: string;
  128891. };
  128892. }
  128893. declare module BABYLON {
  128894. /**
  128895. * Extracts highlights from the image
  128896. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128897. */
  128898. export class HighlightsPostProcess extends PostProcess {
  128899. /**
  128900. * Extracts highlights from the image
  128901. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128902. * @param name The name of the effect.
  128903. * @param options The required width/height ratio to downsize to before computing the render pass.
  128904. * @param camera The camera to apply the render pass to.
  128905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128906. * @param engine The engine which the post process will be applied. (default: current engine)
  128907. * @param reusable If the post process can be reused on the same frame. (default: false)
  128908. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  128909. */
  128910. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128911. }
  128912. }
  128913. declare module BABYLON {
  128914. /** @hidden */
  128915. export var mrtFragmentDeclaration: {
  128916. name: string;
  128917. shader: string;
  128918. };
  128919. }
  128920. declare module BABYLON {
  128921. /** @hidden */
  128922. export var geometryPixelShader: {
  128923. name: string;
  128924. shader: string;
  128925. };
  128926. }
  128927. declare module BABYLON {
  128928. /** @hidden */
  128929. export var geometryVertexShader: {
  128930. name: string;
  128931. shader: string;
  128932. };
  128933. }
  128934. declare module BABYLON {
  128935. /** @hidden */
  128936. interface ISavedTransformationMatrix {
  128937. world: Matrix;
  128938. viewProjection: Matrix;
  128939. }
  128940. /**
  128941. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  128942. */
  128943. export class GeometryBufferRenderer {
  128944. /**
  128945. * Constant used to retrieve the position texture index in the G-Buffer textures array
  128946. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  128947. */
  128948. static readonly POSITION_TEXTURE_TYPE: number;
  128949. /**
  128950. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  128951. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  128952. */
  128953. static readonly VELOCITY_TEXTURE_TYPE: number;
  128954. /**
  128955. * Dictionary used to store the previous transformation matrices of each rendered mesh
  128956. * in order to compute objects velocities when enableVelocity is set to "true"
  128957. * @hidden
  128958. */
  128959. _previousTransformationMatrices: {
  128960. [index: number]: ISavedTransformationMatrix;
  128961. };
  128962. /**
  128963. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  128964. * in order to compute objects velocities when enableVelocity is set to "true"
  128965. * @hidden
  128966. */
  128967. _previousBonesTransformationMatrices: {
  128968. [index: number]: Float32Array;
  128969. };
  128970. /**
  128971. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  128972. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  128973. */
  128974. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  128975. private _scene;
  128976. private _multiRenderTarget;
  128977. private _ratio;
  128978. private _enablePosition;
  128979. private _enableVelocity;
  128980. private _positionIndex;
  128981. private _velocityIndex;
  128982. protected _effect: Effect;
  128983. protected _cachedDefines: string;
  128984. /**
  128985. * Set the render list (meshes to be rendered) used in the G buffer.
  128986. */
  128987. renderList: Mesh[];
  128988. /**
  128989. * Gets wether or not G buffer are supported by the running hardware.
  128990. * This requires draw buffer supports
  128991. */
  128992. readonly isSupported: boolean;
  128993. /**
  128994. * Returns the index of the given texture type in the G-Buffer textures array
  128995. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  128996. * @returns the index of the given texture type in the G-Buffer textures array
  128997. */
  128998. getTextureIndex(textureType: number): number;
  128999. /**
  129000. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  129001. */
  129002. /**
  129003. * Sets whether or not objects positions are enabled for the G buffer.
  129004. */
  129005. enablePosition: boolean;
  129006. /**
  129007. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  129008. */
  129009. /**
  129010. * Sets wether or not objects velocities are enabled for the G buffer.
  129011. */
  129012. enableVelocity: boolean;
  129013. /**
  129014. * Gets the scene associated with the buffer.
  129015. */
  129016. readonly scene: Scene;
  129017. /**
  129018. * Gets the ratio used by the buffer during its creation.
  129019. * How big is the buffer related to the main canvas.
  129020. */
  129021. readonly ratio: number;
  129022. /** @hidden */
  129023. static _SceneComponentInitialization: (scene: Scene) => void;
  129024. /**
  129025. * Creates a new G Buffer for the scene
  129026. * @param scene The scene the buffer belongs to
  129027. * @param ratio How big is the buffer related to the main canvas.
  129028. */
  129029. constructor(scene: Scene, ratio?: number);
  129030. /**
  129031. * Checks wether everything is ready to render a submesh to the G buffer.
  129032. * @param subMesh the submesh to check readiness for
  129033. * @param useInstances is the mesh drawn using instance or not
  129034. * @returns true if ready otherwise false
  129035. */
  129036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129037. /**
  129038. * Gets the current underlying G Buffer.
  129039. * @returns the buffer
  129040. */
  129041. getGBuffer(): MultiRenderTarget;
  129042. /**
  129043. * Gets the number of samples used to render the buffer (anti aliasing).
  129044. */
  129045. /**
  129046. * Sets the number of samples used to render the buffer (anti aliasing).
  129047. */
  129048. samples: number;
  129049. /**
  129050. * Disposes the renderer and frees up associated resources.
  129051. */
  129052. dispose(): void;
  129053. protected _createRenderTargets(): void;
  129054. private _copyBonesTransformationMatrices;
  129055. }
  129056. }
  129057. declare module BABYLON {
  129058. interface Scene {
  129059. /** @hidden (Backing field) */
  129060. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129061. /**
  129062. * Gets or Sets the current geometry buffer associated to the scene.
  129063. */
  129064. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129065. /**
  129066. * Enables a GeometryBufferRender and associates it with the scene
  129067. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  129068. * @returns the GeometryBufferRenderer
  129069. */
  129070. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  129071. /**
  129072. * Disables the GeometryBufferRender associated with the scene
  129073. */
  129074. disableGeometryBufferRenderer(): void;
  129075. }
  129076. /**
  129077. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  129078. * in several rendering techniques.
  129079. */
  129080. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  129081. /**
  129082. * The component name helpful to identify the component in the list of scene components.
  129083. */
  129084. readonly name: string;
  129085. /**
  129086. * The scene the component belongs to.
  129087. */
  129088. scene: Scene;
  129089. /**
  129090. * Creates a new instance of the component for the given scene
  129091. * @param scene Defines the scene to register the component in
  129092. */
  129093. constructor(scene: Scene);
  129094. /**
  129095. * Registers the component in a given scene
  129096. */
  129097. register(): void;
  129098. /**
  129099. * Rebuilds the elements related to this component in case of
  129100. * context lost for instance.
  129101. */
  129102. rebuild(): void;
  129103. /**
  129104. * Disposes the component and the associated ressources
  129105. */
  129106. dispose(): void;
  129107. private _gatherRenderTargets;
  129108. }
  129109. }
  129110. declare module BABYLON {
  129111. /** @hidden */
  129112. export var motionBlurPixelShader: {
  129113. name: string;
  129114. shader: string;
  129115. };
  129116. }
  129117. declare module BABYLON {
  129118. /**
  129119. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  129120. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  129121. * As an example, all you have to do is to create the post-process:
  129122. * var mb = new BABYLON.MotionBlurPostProcess(
  129123. * 'mb', // The name of the effect.
  129124. * scene, // The scene containing the objects to blur according to their velocity.
  129125. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  129126. * camera // The camera to apply the render pass to.
  129127. * );
  129128. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  129129. */
  129130. export class MotionBlurPostProcess extends PostProcess {
  129131. /**
  129132. * Defines how much the image is blurred by the movement. Default value is equal to 1
  129133. */
  129134. motionStrength: number;
  129135. /**
  129136. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  129137. */
  129138. /**
  129139. * Sets the number of iterations to be used for motion blur quality
  129140. */
  129141. motionBlurSamples: number;
  129142. private _motionBlurSamples;
  129143. private _geometryBufferRenderer;
  129144. /**
  129145. * Creates a new instance MotionBlurPostProcess
  129146. * @param name The name of the effect.
  129147. * @param scene The scene containing the objects to blur according to their velocity.
  129148. * @param options The required width/height ratio to downsize to before computing the render pass.
  129149. * @param camera The camera to apply the render pass to.
  129150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129151. * @param engine The engine which the post process will be applied. (default: current engine)
  129152. * @param reusable If the post process can be reused on the same frame. (default: false)
  129153. * @param textureType Type of textures used when performing the post process. (default: 0)
  129154. * @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)
  129155. */
  129156. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129157. /**
  129158. * Excludes the given skinned mesh from computing bones velocities.
  129159. * 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.
  129160. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  129161. */
  129162. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129163. /**
  129164. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  129165. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  129166. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  129167. */
  129168. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129169. /**
  129170. * Disposes the post process.
  129171. * @param camera The camera to dispose the post process on.
  129172. */
  129173. dispose(camera?: Camera): void;
  129174. }
  129175. }
  129176. declare module BABYLON {
  129177. /** @hidden */
  129178. export var refractionPixelShader: {
  129179. name: string;
  129180. shader: string;
  129181. };
  129182. }
  129183. declare module BABYLON {
  129184. /**
  129185. * Post process which applies a refractin texture
  129186. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129187. */
  129188. export class RefractionPostProcess extends PostProcess {
  129189. /** the base color of the refraction (used to taint the rendering) */
  129190. color: Color3;
  129191. /** simulated refraction depth */
  129192. depth: number;
  129193. /** the coefficient of the base color (0 to remove base color tainting) */
  129194. colorLevel: number;
  129195. private _refTexture;
  129196. private _ownRefractionTexture;
  129197. /**
  129198. * Gets or sets the refraction texture
  129199. * Please note that you are responsible for disposing the texture if you set it manually
  129200. */
  129201. refractionTexture: Texture;
  129202. /**
  129203. * Initializes the RefractionPostProcess
  129204. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129205. * @param name The name of the effect.
  129206. * @param refractionTextureUrl Url of the refraction texture to use
  129207. * @param color the base color of the refraction (used to taint the rendering)
  129208. * @param depth simulated refraction depth
  129209. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  129210. * @param camera The camera to apply the render pass to.
  129211. * @param options The required width/height ratio to downsize to before computing the render pass.
  129212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129213. * @param engine The engine which the post process will be applied. (default: current engine)
  129214. * @param reusable If the post process can be reused on the same frame. (default: false)
  129215. */
  129216. constructor(name: string, refractionTextureUrl: string,
  129217. /** the base color of the refraction (used to taint the rendering) */
  129218. color: Color3,
  129219. /** simulated refraction depth */
  129220. depth: number,
  129221. /** the coefficient of the base color (0 to remove base color tainting) */
  129222. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129223. /**
  129224. * Disposes of the post process
  129225. * @param camera Camera to dispose post process on
  129226. */
  129227. dispose(camera: Camera): void;
  129228. }
  129229. }
  129230. declare module BABYLON {
  129231. /** @hidden */
  129232. export var sharpenPixelShader: {
  129233. name: string;
  129234. shader: string;
  129235. };
  129236. }
  129237. declare module BABYLON {
  129238. /**
  129239. * The SharpenPostProcess applies a sharpen kernel to every pixel
  129240. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  129241. */
  129242. export class SharpenPostProcess extends PostProcess {
  129243. /**
  129244. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  129245. */
  129246. colorAmount: number;
  129247. /**
  129248. * How much sharpness should be applied (default: 0.3)
  129249. */
  129250. edgeAmount: number;
  129251. /**
  129252. * Creates a new instance ConvolutionPostProcess
  129253. * @param name The name of the effect.
  129254. * @param options The required width/height ratio to downsize to before computing the render pass.
  129255. * @param camera The camera to apply the render pass to.
  129256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129257. * @param engine The engine which the post process will be applied. (default: current engine)
  129258. * @param reusable If the post process can be reused on the same frame. (default: false)
  129259. * @param textureType Type of textures used when performing the post process. (default: 0)
  129260. * @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)
  129261. */
  129262. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129263. }
  129264. }
  129265. declare module BABYLON {
  129266. /**
  129267. * PostProcessRenderPipeline
  129268. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129269. */
  129270. export class PostProcessRenderPipeline {
  129271. private engine;
  129272. private _renderEffects;
  129273. private _renderEffectsForIsolatedPass;
  129274. /**
  129275. * List of inspectable custom properties (used by the Inspector)
  129276. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  129277. */
  129278. inspectableCustomProperties: IInspectable[];
  129279. /**
  129280. * @hidden
  129281. */
  129282. protected _cameras: Camera[];
  129283. /** @hidden */
  129284. _name: string;
  129285. /**
  129286. * Gets pipeline name
  129287. */
  129288. readonly name: string;
  129289. /** Gets the list of attached cameras */
  129290. readonly cameras: Camera[];
  129291. /**
  129292. * Initializes a PostProcessRenderPipeline
  129293. * @param engine engine to add the pipeline to
  129294. * @param name name of the pipeline
  129295. */
  129296. constructor(engine: Engine, name: string);
  129297. /**
  129298. * Gets the class name
  129299. * @returns "PostProcessRenderPipeline"
  129300. */
  129301. getClassName(): string;
  129302. /**
  129303. * If all the render effects in the pipeline are supported
  129304. */
  129305. readonly isSupported: boolean;
  129306. /**
  129307. * Adds an effect to the pipeline
  129308. * @param renderEffect the effect to add
  129309. */
  129310. addEffect(renderEffect: PostProcessRenderEffect): void;
  129311. /** @hidden */
  129312. _rebuild(): void;
  129313. /** @hidden */
  129314. _enableEffect(renderEffectName: string, cameras: Camera): void;
  129315. /** @hidden */
  129316. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  129317. /** @hidden */
  129318. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129319. /** @hidden */
  129320. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129321. /** @hidden */
  129322. _attachCameras(cameras: Camera, unique: boolean): void;
  129323. /** @hidden */
  129324. _attachCameras(cameras: Camera[], unique: boolean): void;
  129325. /** @hidden */
  129326. _detachCameras(cameras: Camera): void;
  129327. /** @hidden */
  129328. _detachCameras(cameras: Nullable<Camera[]>): void;
  129329. /** @hidden */
  129330. _update(): void;
  129331. /** @hidden */
  129332. _reset(): void;
  129333. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  129334. /**
  129335. * Disposes of the pipeline
  129336. */
  129337. dispose(): void;
  129338. }
  129339. }
  129340. declare module BABYLON {
  129341. /**
  129342. * PostProcessRenderPipelineManager class
  129343. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129344. */
  129345. export class PostProcessRenderPipelineManager {
  129346. private _renderPipelines;
  129347. /**
  129348. * Initializes a PostProcessRenderPipelineManager
  129349. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129350. */
  129351. constructor();
  129352. /**
  129353. * Gets the list of supported render pipelines
  129354. */
  129355. readonly supportedPipelines: PostProcessRenderPipeline[];
  129356. /**
  129357. * Adds a pipeline to the manager
  129358. * @param renderPipeline The pipeline to add
  129359. */
  129360. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  129361. /**
  129362. * Attaches a camera to the pipeline
  129363. * @param renderPipelineName The name of the pipeline to attach to
  129364. * @param cameras the camera to attach
  129365. * @param unique if the camera can be attached multiple times to the pipeline
  129366. */
  129367. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  129368. /**
  129369. * Detaches a camera from the pipeline
  129370. * @param renderPipelineName The name of the pipeline to detach from
  129371. * @param cameras the camera to detach
  129372. */
  129373. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  129374. /**
  129375. * Enables an effect by name on a pipeline
  129376. * @param renderPipelineName the name of the pipeline to enable the effect in
  129377. * @param renderEffectName the name of the effect to enable
  129378. * @param cameras the cameras that the effect should be enabled on
  129379. */
  129380. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129381. /**
  129382. * Disables an effect by name on a pipeline
  129383. * @param renderPipelineName the name of the pipeline to disable the effect in
  129384. * @param renderEffectName the name of the effect to disable
  129385. * @param cameras the cameras that the effect should be disabled on
  129386. */
  129387. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129388. /**
  129389. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  129390. */
  129391. update(): void;
  129392. /** @hidden */
  129393. _rebuild(): void;
  129394. /**
  129395. * Disposes of the manager and pipelines
  129396. */
  129397. dispose(): void;
  129398. }
  129399. }
  129400. declare module BABYLON {
  129401. interface Scene {
  129402. /** @hidden (Backing field) */
  129403. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129404. /**
  129405. * Gets the postprocess render pipeline manager
  129406. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129407. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129408. */
  129409. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129410. }
  129411. /**
  129412. * Defines the Render Pipeline scene component responsible to rendering pipelines
  129413. */
  129414. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  129415. /**
  129416. * The component name helpfull to identify the component in the list of scene components.
  129417. */
  129418. readonly name: string;
  129419. /**
  129420. * The scene the component belongs to.
  129421. */
  129422. scene: Scene;
  129423. /**
  129424. * Creates a new instance of the component for the given scene
  129425. * @param scene Defines the scene to register the component in
  129426. */
  129427. constructor(scene: Scene);
  129428. /**
  129429. * Registers the component in a given scene
  129430. */
  129431. register(): void;
  129432. /**
  129433. * Rebuilds the elements related to this component in case of
  129434. * context lost for instance.
  129435. */
  129436. rebuild(): void;
  129437. /**
  129438. * Disposes the component and the associated ressources
  129439. */
  129440. dispose(): void;
  129441. private _gatherRenderTargets;
  129442. }
  129443. }
  129444. declare module BABYLON {
  129445. /**
  129446. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  129447. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129448. */
  129449. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129450. private _scene;
  129451. private _camerasToBeAttached;
  129452. /**
  129453. * ID of the sharpen post process,
  129454. */
  129455. private readonly SharpenPostProcessId;
  129456. /**
  129457. * @ignore
  129458. * ID of the image processing post process;
  129459. */
  129460. readonly ImageProcessingPostProcessId: string;
  129461. /**
  129462. * @ignore
  129463. * ID of the Fast Approximate Anti-Aliasing post process;
  129464. */
  129465. readonly FxaaPostProcessId: string;
  129466. /**
  129467. * ID of the chromatic aberration post process,
  129468. */
  129469. private readonly ChromaticAberrationPostProcessId;
  129470. /**
  129471. * ID of the grain post process
  129472. */
  129473. private readonly GrainPostProcessId;
  129474. /**
  129475. * Sharpen post process which will apply a sharpen convolution to enhance edges
  129476. */
  129477. sharpen: SharpenPostProcess;
  129478. private _sharpenEffect;
  129479. private bloom;
  129480. /**
  129481. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  129482. */
  129483. depthOfField: DepthOfFieldEffect;
  129484. /**
  129485. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129486. */
  129487. fxaa: FxaaPostProcess;
  129488. /**
  129489. * Image post processing pass used to perform operations such as tone mapping or color grading.
  129490. */
  129491. imageProcessing: ImageProcessingPostProcess;
  129492. /**
  129493. * Chromatic aberration post process which will shift rgb colors in the image
  129494. */
  129495. chromaticAberration: ChromaticAberrationPostProcess;
  129496. private _chromaticAberrationEffect;
  129497. /**
  129498. * Grain post process which add noise to the image
  129499. */
  129500. grain: GrainPostProcess;
  129501. private _grainEffect;
  129502. /**
  129503. * Glow post process which adds a glow to emissive areas of the image
  129504. */
  129505. private _glowLayer;
  129506. /**
  129507. * Animations which can be used to tweak settings over a period of time
  129508. */
  129509. animations: Animation[];
  129510. private _imageProcessingConfigurationObserver;
  129511. private _sharpenEnabled;
  129512. private _bloomEnabled;
  129513. private _depthOfFieldEnabled;
  129514. private _depthOfFieldBlurLevel;
  129515. private _fxaaEnabled;
  129516. private _imageProcessingEnabled;
  129517. private _defaultPipelineTextureType;
  129518. private _bloomScale;
  129519. private _chromaticAberrationEnabled;
  129520. private _grainEnabled;
  129521. private _buildAllowed;
  129522. /**
  129523. * Gets active scene
  129524. */
  129525. readonly scene: Scene;
  129526. /**
  129527. * Enable or disable the sharpen process from the pipeline
  129528. */
  129529. sharpenEnabled: boolean;
  129530. private _resizeObserver;
  129531. private _hardwareScaleLevel;
  129532. private _bloomKernel;
  129533. /**
  129534. * Specifies the size of the bloom blur kernel, relative to the final output size
  129535. */
  129536. bloomKernel: number;
  129537. /**
  129538. * Specifies the weight of the bloom in the final rendering
  129539. */
  129540. private _bloomWeight;
  129541. /**
  129542. * Specifies the luma threshold for the area that will be blurred by the bloom
  129543. */
  129544. private _bloomThreshold;
  129545. private _hdr;
  129546. /**
  129547. * The strength of the bloom.
  129548. */
  129549. bloomWeight: number;
  129550. /**
  129551. * The strength of the bloom.
  129552. */
  129553. bloomThreshold: number;
  129554. /**
  129555. * The scale of the bloom, lower value will provide better performance.
  129556. */
  129557. bloomScale: number;
  129558. /**
  129559. * Enable or disable the bloom from the pipeline
  129560. */
  129561. bloomEnabled: boolean;
  129562. private _rebuildBloom;
  129563. /**
  129564. * If the depth of field is enabled.
  129565. */
  129566. depthOfFieldEnabled: boolean;
  129567. /**
  129568. * Blur level of the depth of field effect. (Higher blur will effect performance)
  129569. */
  129570. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  129571. /**
  129572. * If the anti aliasing is enabled.
  129573. */
  129574. fxaaEnabled: boolean;
  129575. private _samples;
  129576. /**
  129577. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129578. */
  129579. samples: number;
  129580. /**
  129581. * If image processing is enabled.
  129582. */
  129583. imageProcessingEnabled: boolean;
  129584. /**
  129585. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  129586. */
  129587. glowLayerEnabled: boolean;
  129588. /**
  129589. * Gets the glow layer (or null if not defined)
  129590. */
  129591. readonly glowLayer: Nullable<GlowLayer>;
  129592. /**
  129593. * Enable or disable the chromaticAberration process from the pipeline
  129594. */
  129595. chromaticAberrationEnabled: boolean;
  129596. /**
  129597. * Enable or disable the grain process from the pipeline
  129598. */
  129599. grainEnabled: boolean;
  129600. /**
  129601. * @constructor
  129602. * @param name - The rendering pipeline name (default: "")
  129603. * @param hdr - If high dynamic range textures should be used (default: true)
  129604. * @param scene - The scene linked to this pipeline (default: the last created scene)
  129605. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  129606. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  129607. */
  129608. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  129609. /**
  129610. * Get the class name
  129611. * @returns "DefaultRenderingPipeline"
  129612. */
  129613. getClassName(): string;
  129614. /**
  129615. * Force the compilation of the entire pipeline.
  129616. */
  129617. prepare(): void;
  129618. private _hasCleared;
  129619. private _prevPostProcess;
  129620. private _prevPrevPostProcess;
  129621. private _setAutoClearAndTextureSharing;
  129622. private _depthOfFieldSceneObserver;
  129623. private _buildPipeline;
  129624. private _disposePostProcesses;
  129625. /**
  129626. * Adds a camera to the pipeline
  129627. * @param camera the camera to be added
  129628. */
  129629. addCamera(camera: Camera): void;
  129630. /**
  129631. * Removes a camera from the pipeline
  129632. * @param camera the camera to remove
  129633. */
  129634. removeCamera(camera: Camera): void;
  129635. /**
  129636. * Dispose of the pipeline and stop all post processes
  129637. */
  129638. dispose(): void;
  129639. /**
  129640. * Serialize the rendering pipeline (Used when exporting)
  129641. * @returns the serialized object
  129642. */
  129643. serialize(): any;
  129644. /**
  129645. * Parse the serialized pipeline
  129646. * @param source Source pipeline.
  129647. * @param scene The scene to load the pipeline to.
  129648. * @param rootUrl The URL of the serialized pipeline.
  129649. * @returns An instantiated pipeline from the serialized object.
  129650. */
  129651. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  129652. }
  129653. }
  129654. declare module BABYLON {
  129655. /** @hidden */
  129656. export var lensHighlightsPixelShader: {
  129657. name: string;
  129658. shader: string;
  129659. };
  129660. }
  129661. declare module BABYLON {
  129662. /** @hidden */
  129663. export var depthOfFieldPixelShader: {
  129664. name: string;
  129665. shader: string;
  129666. };
  129667. }
  129668. declare module BABYLON {
  129669. /**
  129670. * BABYLON.JS Chromatic Aberration GLSL Shader
  129671. * Author: Olivier Guyot
  129672. * Separates very slightly R, G and B colors on the edges of the screen
  129673. * Inspired by Francois Tarlier & Martins Upitis
  129674. */
  129675. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  129676. /**
  129677. * @ignore
  129678. * The chromatic aberration PostProcess id in the pipeline
  129679. */
  129680. LensChromaticAberrationEffect: string;
  129681. /**
  129682. * @ignore
  129683. * The highlights enhancing PostProcess id in the pipeline
  129684. */
  129685. HighlightsEnhancingEffect: string;
  129686. /**
  129687. * @ignore
  129688. * The depth-of-field PostProcess id in the pipeline
  129689. */
  129690. LensDepthOfFieldEffect: string;
  129691. private _scene;
  129692. private _depthTexture;
  129693. private _grainTexture;
  129694. private _chromaticAberrationPostProcess;
  129695. private _highlightsPostProcess;
  129696. private _depthOfFieldPostProcess;
  129697. private _edgeBlur;
  129698. private _grainAmount;
  129699. private _chromaticAberration;
  129700. private _distortion;
  129701. private _highlightsGain;
  129702. private _highlightsThreshold;
  129703. private _dofDistance;
  129704. private _dofAperture;
  129705. private _dofDarken;
  129706. private _dofPentagon;
  129707. private _blurNoise;
  129708. /**
  129709. * @constructor
  129710. *
  129711. * Effect parameters are as follow:
  129712. * {
  129713. * chromatic_aberration: number; // from 0 to x (1 for realism)
  129714. * edge_blur: number; // from 0 to x (1 for realism)
  129715. * distortion: number; // from 0 to x (1 for realism)
  129716. * grain_amount: number; // from 0 to 1
  129717. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  129718. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  129719. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  129720. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  129721. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  129722. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  129723. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  129724. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  129725. * }
  129726. * Note: if an effect parameter is unset, effect is disabled
  129727. *
  129728. * @param name The rendering pipeline name
  129729. * @param parameters - An object containing all parameters (see above)
  129730. * @param scene The scene linked to this pipeline
  129731. * @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)
  129732. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129733. */
  129734. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  129735. /**
  129736. * Get the class name
  129737. * @returns "LensRenderingPipeline"
  129738. */
  129739. getClassName(): string;
  129740. /**
  129741. * Gets associated scene
  129742. */
  129743. readonly scene: Scene;
  129744. /**
  129745. * Gets or sets the edge blur
  129746. */
  129747. edgeBlur: number;
  129748. /**
  129749. * Gets or sets the grain amount
  129750. */
  129751. grainAmount: number;
  129752. /**
  129753. * Gets or sets the chromatic aberration amount
  129754. */
  129755. chromaticAberration: number;
  129756. /**
  129757. * Gets or sets the depth of field aperture
  129758. */
  129759. dofAperture: number;
  129760. /**
  129761. * Gets or sets the edge distortion
  129762. */
  129763. edgeDistortion: number;
  129764. /**
  129765. * Gets or sets the depth of field distortion
  129766. */
  129767. dofDistortion: number;
  129768. /**
  129769. * Gets or sets the darken out of focus amount
  129770. */
  129771. darkenOutOfFocus: number;
  129772. /**
  129773. * Gets or sets a boolean indicating if blur noise is enabled
  129774. */
  129775. blurNoise: boolean;
  129776. /**
  129777. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  129778. */
  129779. pentagonBokeh: boolean;
  129780. /**
  129781. * Gets or sets the highlight grain amount
  129782. */
  129783. highlightsGain: number;
  129784. /**
  129785. * Gets or sets the highlight threshold
  129786. */
  129787. highlightsThreshold: number;
  129788. /**
  129789. * Sets the amount of blur at the edges
  129790. * @param amount blur amount
  129791. */
  129792. setEdgeBlur(amount: number): void;
  129793. /**
  129794. * Sets edge blur to 0
  129795. */
  129796. disableEdgeBlur(): void;
  129797. /**
  129798. * Sets the amout of grain
  129799. * @param amount Amount of grain
  129800. */
  129801. setGrainAmount(amount: number): void;
  129802. /**
  129803. * Set grain amount to 0
  129804. */
  129805. disableGrain(): void;
  129806. /**
  129807. * Sets the chromatic aberration amount
  129808. * @param amount amount of chromatic aberration
  129809. */
  129810. setChromaticAberration(amount: number): void;
  129811. /**
  129812. * Sets chromatic aberration amount to 0
  129813. */
  129814. disableChromaticAberration(): void;
  129815. /**
  129816. * Sets the EdgeDistortion amount
  129817. * @param amount amount of EdgeDistortion
  129818. */
  129819. setEdgeDistortion(amount: number): void;
  129820. /**
  129821. * Sets edge distortion to 0
  129822. */
  129823. disableEdgeDistortion(): void;
  129824. /**
  129825. * Sets the FocusDistance amount
  129826. * @param amount amount of FocusDistance
  129827. */
  129828. setFocusDistance(amount: number): void;
  129829. /**
  129830. * Disables depth of field
  129831. */
  129832. disableDepthOfField(): void;
  129833. /**
  129834. * Sets the Aperture amount
  129835. * @param amount amount of Aperture
  129836. */
  129837. setAperture(amount: number): void;
  129838. /**
  129839. * Sets the DarkenOutOfFocus amount
  129840. * @param amount amount of DarkenOutOfFocus
  129841. */
  129842. setDarkenOutOfFocus(amount: number): void;
  129843. private _pentagonBokehIsEnabled;
  129844. /**
  129845. * Creates a pentagon bokeh effect
  129846. */
  129847. enablePentagonBokeh(): void;
  129848. /**
  129849. * Disables the pentagon bokeh effect
  129850. */
  129851. disablePentagonBokeh(): void;
  129852. /**
  129853. * Enables noise blur
  129854. */
  129855. enableNoiseBlur(): void;
  129856. /**
  129857. * Disables noise blur
  129858. */
  129859. disableNoiseBlur(): void;
  129860. /**
  129861. * Sets the HighlightsGain amount
  129862. * @param amount amount of HighlightsGain
  129863. */
  129864. setHighlightsGain(amount: number): void;
  129865. /**
  129866. * Sets the HighlightsThreshold amount
  129867. * @param amount amount of HighlightsThreshold
  129868. */
  129869. setHighlightsThreshold(amount: number): void;
  129870. /**
  129871. * Disables highlights
  129872. */
  129873. disableHighlights(): void;
  129874. /**
  129875. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  129876. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  129877. */
  129878. dispose(disableDepthRender?: boolean): void;
  129879. private _createChromaticAberrationPostProcess;
  129880. private _createHighlightsPostProcess;
  129881. private _createDepthOfFieldPostProcess;
  129882. private _createGrainTexture;
  129883. }
  129884. }
  129885. declare module BABYLON {
  129886. /** @hidden */
  129887. export var ssao2PixelShader: {
  129888. name: string;
  129889. shader: string;
  129890. };
  129891. }
  129892. declare module BABYLON {
  129893. /** @hidden */
  129894. export var ssaoCombinePixelShader: {
  129895. name: string;
  129896. shader: string;
  129897. };
  129898. }
  129899. declare module BABYLON {
  129900. /**
  129901. * Render pipeline to produce ssao effect
  129902. */
  129903. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  129904. /**
  129905. * @ignore
  129906. * The PassPostProcess id in the pipeline that contains the original scene color
  129907. */
  129908. SSAOOriginalSceneColorEffect: string;
  129909. /**
  129910. * @ignore
  129911. * The SSAO PostProcess id in the pipeline
  129912. */
  129913. SSAORenderEffect: string;
  129914. /**
  129915. * @ignore
  129916. * The horizontal blur PostProcess id in the pipeline
  129917. */
  129918. SSAOBlurHRenderEffect: string;
  129919. /**
  129920. * @ignore
  129921. * The vertical blur PostProcess id in the pipeline
  129922. */
  129923. SSAOBlurVRenderEffect: string;
  129924. /**
  129925. * @ignore
  129926. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129927. */
  129928. SSAOCombineRenderEffect: string;
  129929. /**
  129930. * The output strength of the SSAO post-process. Default value is 1.0.
  129931. */
  129932. totalStrength: number;
  129933. /**
  129934. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  129935. */
  129936. maxZ: number;
  129937. /**
  129938. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  129939. */
  129940. minZAspect: number;
  129941. private _samples;
  129942. /**
  129943. * Number of samples used for the SSAO calculations. Default value is 8
  129944. */
  129945. samples: number;
  129946. private _textureSamples;
  129947. /**
  129948. * Number of samples to use for antialiasing
  129949. */
  129950. textureSamples: number;
  129951. /**
  129952. * Ratio object used for SSAO ratio and blur ratio
  129953. */
  129954. private _ratio;
  129955. /**
  129956. * Dynamically generated sphere sampler.
  129957. */
  129958. private _sampleSphere;
  129959. /**
  129960. * Blur filter offsets
  129961. */
  129962. private _samplerOffsets;
  129963. private _expensiveBlur;
  129964. /**
  129965. * If bilateral blur should be used
  129966. */
  129967. expensiveBlur: boolean;
  129968. /**
  129969. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  129970. */
  129971. radius: number;
  129972. /**
  129973. * The base color of the SSAO post-process
  129974. * The final result is "base + ssao" between [0, 1]
  129975. */
  129976. base: number;
  129977. /**
  129978. * Support test.
  129979. */
  129980. static readonly IsSupported: boolean;
  129981. private _scene;
  129982. private _depthTexture;
  129983. private _normalTexture;
  129984. private _randomTexture;
  129985. private _originalColorPostProcess;
  129986. private _ssaoPostProcess;
  129987. private _blurHPostProcess;
  129988. private _blurVPostProcess;
  129989. private _ssaoCombinePostProcess;
  129990. /**
  129991. * Gets active scene
  129992. */
  129993. readonly scene: Scene;
  129994. /**
  129995. * @constructor
  129996. * @param name The rendering pipeline name
  129997. * @param scene The scene linked to this pipeline
  129998. * @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 }
  129999. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130000. */
  130001. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130002. /**
  130003. * Get the class name
  130004. * @returns "SSAO2RenderingPipeline"
  130005. */
  130006. getClassName(): string;
  130007. /**
  130008. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130009. */
  130010. dispose(disableGeometryBufferRenderer?: boolean): void;
  130011. private _createBlurPostProcess;
  130012. /** @hidden */
  130013. _rebuild(): void;
  130014. private _bits;
  130015. private _radicalInverse_VdC;
  130016. private _hammersley;
  130017. private _hemisphereSample_uniform;
  130018. private _generateHemisphere;
  130019. private _createSSAOPostProcess;
  130020. private _createSSAOCombinePostProcess;
  130021. private _createRandomTexture;
  130022. /**
  130023. * Serialize the rendering pipeline (Used when exporting)
  130024. * @returns the serialized object
  130025. */
  130026. serialize(): any;
  130027. /**
  130028. * Parse the serialized pipeline
  130029. * @param source Source pipeline.
  130030. * @param scene The scene to load the pipeline to.
  130031. * @param rootUrl The URL of the serialized pipeline.
  130032. * @returns An instantiated pipeline from the serialized object.
  130033. */
  130034. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  130035. }
  130036. }
  130037. declare module BABYLON {
  130038. /** @hidden */
  130039. export var ssaoPixelShader: {
  130040. name: string;
  130041. shader: string;
  130042. };
  130043. }
  130044. declare module BABYLON {
  130045. /**
  130046. * Render pipeline to produce ssao effect
  130047. */
  130048. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  130049. /**
  130050. * @ignore
  130051. * The PassPostProcess id in the pipeline that contains the original scene color
  130052. */
  130053. SSAOOriginalSceneColorEffect: string;
  130054. /**
  130055. * @ignore
  130056. * The SSAO PostProcess id in the pipeline
  130057. */
  130058. SSAORenderEffect: string;
  130059. /**
  130060. * @ignore
  130061. * The horizontal blur PostProcess id in the pipeline
  130062. */
  130063. SSAOBlurHRenderEffect: string;
  130064. /**
  130065. * @ignore
  130066. * The vertical blur PostProcess id in the pipeline
  130067. */
  130068. SSAOBlurVRenderEffect: string;
  130069. /**
  130070. * @ignore
  130071. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130072. */
  130073. SSAOCombineRenderEffect: string;
  130074. /**
  130075. * The output strength of the SSAO post-process. Default value is 1.0.
  130076. */
  130077. totalStrength: number;
  130078. /**
  130079. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  130080. */
  130081. radius: number;
  130082. /**
  130083. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  130084. * Must not be equal to fallOff and superior to fallOff.
  130085. * Default value is 0.0075
  130086. */
  130087. area: number;
  130088. /**
  130089. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  130090. * Must not be equal to area and inferior to area.
  130091. * Default value is 0.000001
  130092. */
  130093. fallOff: number;
  130094. /**
  130095. * The base color of the SSAO post-process
  130096. * The final result is "base + ssao" between [0, 1]
  130097. */
  130098. base: number;
  130099. private _scene;
  130100. private _depthTexture;
  130101. private _randomTexture;
  130102. private _originalColorPostProcess;
  130103. private _ssaoPostProcess;
  130104. private _blurHPostProcess;
  130105. private _blurVPostProcess;
  130106. private _ssaoCombinePostProcess;
  130107. private _firstUpdate;
  130108. /**
  130109. * Gets active scene
  130110. */
  130111. readonly scene: Scene;
  130112. /**
  130113. * @constructor
  130114. * @param name - The rendering pipeline name
  130115. * @param scene - The scene linked to this pipeline
  130116. * @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 }
  130117. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  130118. */
  130119. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130120. /**
  130121. * Get the class name
  130122. * @returns "SSAORenderingPipeline"
  130123. */
  130124. getClassName(): string;
  130125. /**
  130126. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130127. */
  130128. dispose(disableDepthRender?: boolean): void;
  130129. private _createBlurPostProcess;
  130130. /** @hidden */
  130131. _rebuild(): void;
  130132. private _createSSAOPostProcess;
  130133. private _createSSAOCombinePostProcess;
  130134. private _createRandomTexture;
  130135. }
  130136. }
  130137. declare module BABYLON {
  130138. /** @hidden */
  130139. export var standardPixelShader: {
  130140. name: string;
  130141. shader: string;
  130142. };
  130143. }
  130144. declare module BABYLON {
  130145. /**
  130146. * Standard rendering pipeline
  130147. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130148. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  130149. */
  130150. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130151. /**
  130152. * Public members
  130153. */
  130154. /**
  130155. * Post-process which contains the original scene color before the pipeline applies all the effects
  130156. */
  130157. originalPostProcess: Nullable<PostProcess>;
  130158. /**
  130159. * Post-process used to down scale an image x4
  130160. */
  130161. downSampleX4PostProcess: Nullable<PostProcess>;
  130162. /**
  130163. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  130164. */
  130165. brightPassPostProcess: Nullable<PostProcess>;
  130166. /**
  130167. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  130168. */
  130169. blurHPostProcesses: PostProcess[];
  130170. /**
  130171. * Post-process array storing all the vertical blur post-processes used by the pipeline
  130172. */
  130173. blurVPostProcesses: PostProcess[];
  130174. /**
  130175. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  130176. */
  130177. textureAdderPostProcess: Nullable<PostProcess>;
  130178. /**
  130179. * Post-process used to create volumetric lighting effect
  130180. */
  130181. volumetricLightPostProcess: Nullable<PostProcess>;
  130182. /**
  130183. * Post-process used to smooth the previous volumetric light post-process on the X axis
  130184. */
  130185. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  130186. /**
  130187. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  130188. */
  130189. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  130190. /**
  130191. * Post-process used to merge the volumetric light effect and the real scene color
  130192. */
  130193. volumetricLightMergePostProces: Nullable<PostProcess>;
  130194. /**
  130195. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  130196. */
  130197. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  130198. /**
  130199. * Base post-process used to calculate the average luminance of the final image for HDR
  130200. */
  130201. luminancePostProcess: Nullable<PostProcess>;
  130202. /**
  130203. * Post-processes used to create down sample post-processes in order to get
  130204. * the average luminance of the final image for HDR
  130205. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  130206. */
  130207. luminanceDownSamplePostProcesses: PostProcess[];
  130208. /**
  130209. * Post-process used to create a HDR effect (light adaptation)
  130210. */
  130211. hdrPostProcess: Nullable<PostProcess>;
  130212. /**
  130213. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  130214. */
  130215. textureAdderFinalPostProcess: Nullable<PostProcess>;
  130216. /**
  130217. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  130218. */
  130219. lensFlareFinalPostProcess: Nullable<PostProcess>;
  130220. /**
  130221. * Post-process used to merge the final HDR post-process and the real scene color
  130222. */
  130223. hdrFinalPostProcess: Nullable<PostProcess>;
  130224. /**
  130225. * Post-process used to create a lens flare effect
  130226. */
  130227. lensFlarePostProcess: Nullable<PostProcess>;
  130228. /**
  130229. * Post-process that merges the result of the lens flare post-process and the real scene color
  130230. */
  130231. lensFlareComposePostProcess: Nullable<PostProcess>;
  130232. /**
  130233. * Post-process used to create a motion blur effect
  130234. */
  130235. motionBlurPostProcess: Nullable<PostProcess>;
  130236. /**
  130237. * Post-process used to create a depth of field effect
  130238. */
  130239. depthOfFieldPostProcess: Nullable<PostProcess>;
  130240. /**
  130241. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  130242. */
  130243. fxaaPostProcess: Nullable<FxaaPostProcess>;
  130244. /**
  130245. * Represents the brightness threshold in order to configure the illuminated surfaces
  130246. */
  130247. brightThreshold: number;
  130248. /**
  130249. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  130250. */
  130251. blurWidth: number;
  130252. /**
  130253. * Sets if the blur for highlighted surfaces must be only horizontal
  130254. */
  130255. horizontalBlur: boolean;
  130256. /**
  130257. * Gets the overall exposure used by the pipeline
  130258. */
  130259. /**
  130260. * Sets the overall exposure used by the pipeline
  130261. */
  130262. exposure: number;
  130263. /**
  130264. * Texture used typically to simulate "dirty" on camera lens
  130265. */
  130266. lensTexture: Nullable<Texture>;
  130267. /**
  130268. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  130269. */
  130270. volumetricLightCoefficient: number;
  130271. /**
  130272. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  130273. */
  130274. volumetricLightPower: number;
  130275. /**
  130276. * Used the set the blur intensity to smooth the volumetric lights
  130277. */
  130278. volumetricLightBlurScale: number;
  130279. /**
  130280. * Light (spot or directional) used to generate the volumetric lights rays
  130281. * The source light must have a shadow generate so the pipeline can get its
  130282. * depth map
  130283. */
  130284. sourceLight: Nullable<SpotLight | DirectionalLight>;
  130285. /**
  130286. * For eye adaptation, represents the minimum luminance the eye can see
  130287. */
  130288. hdrMinimumLuminance: number;
  130289. /**
  130290. * For eye adaptation, represents the decrease luminance speed
  130291. */
  130292. hdrDecreaseRate: number;
  130293. /**
  130294. * For eye adaptation, represents the increase luminance speed
  130295. */
  130296. hdrIncreaseRate: number;
  130297. /**
  130298. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130299. */
  130300. /**
  130301. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130302. */
  130303. hdrAutoExposure: boolean;
  130304. /**
  130305. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  130306. */
  130307. lensColorTexture: Nullable<Texture>;
  130308. /**
  130309. * The overall strengh for the lens flare effect
  130310. */
  130311. lensFlareStrength: number;
  130312. /**
  130313. * Dispersion coefficient for lens flare ghosts
  130314. */
  130315. lensFlareGhostDispersal: number;
  130316. /**
  130317. * Main lens flare halo width
  130318. */
  130319. lensFlareHaloWidth: number;
  130320. /**
  130321. * Based on the lens distortion effect, defines how much the lens flare result
  130322. * is distorted
  130323. */
  130324. lensFlareDistortionStrength: number;
  130325. /**
  130326. * Configures the blur intensity used for for lens flare (halo)
  130327. */
  130328. lensFlareBlurWidth: number;
  130329. /**
  130330. * Lens star texture must be used to simulate rays on the flares and is available
  130331. * in the documentation
  130332. */
  130333. lensStarTexture: Nullable<Texture>;
  130334. /**
  130335. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  130336. * flare effect by taking account of the dirt texture
  130337. */
  130338. lensFlareDirtTexture: Nullable<Texture>;
  130339. /**
  130340. * Represents the focal length for the depth of field effect
  130341. */
  130342. depthOfFieldDistance: number;
  130343. /**
  130344. * Represents the blur intensity for the blurred part of the depth of field effect
  130345. */
  130346. depthOfFieldBlurWidth: number;
  130347. /**
  130348. * Gets how much the image is blurred by the movement while using the motion blur post-process
  130349. */
  130350. /**
  130351. * Sets how much the image is blurred by the movement while using the motion blur post-process
  130352. */
  130353. motionStrength: number;
  130354. /**
  130355. * Gets wether or not the motion blur post-process is object based or screen based.
  130356. */
  130357. /**
  130358. * Sets wether or not the motion blur post-process should be object based or screen based
  130359. */
  130360. objectBasedMotionBlur: boolean;
  130361. /**
  130362. * List of animations for the pipeline (IAnimatable implementation)
  130363. */
  130364. animations: Animation[];
  130365. /**
  130366. * Private members
  130367. */
  130368. private _scene;
  130369. private _currentDepthOfFieldSource;
  130370. private _basePostProcess;
  130371. private _fixedExposure;
  130372. private _currentExposure;
  130373. private _hdrAutoExposure;
  130374. private _hdrCurrentLuminance;
  130375. private _motionStrength;
  130376. private _isObjectBasedMotionBlur;
  130377. private _floatTextureType;
  130378. private _camerasToBeAttached;
  130379. private _ratio;
  130380. private _bloomEnabled;
  130381. private _depthOfFieldEnabled;
  130382. private _vlsEnabled;
  130383. private _lensFlareEnabled;
  130384. private _hdrEnabled;
  130385. private _motionBlurEnabled;
  130386. private _fxaaEnabled;
  130387. private _motionBlurSamples;
  130388. private _volumetricLightStepsCount;
  130389. private _samples;
  130390. /**
  130391. * @ignore
  130392. * Specifies if the bloom pipeline is enabled
  130393. */
  130394. BloomEnabled: boolean;
  130395. /**
  130396. * @ignore
  130397. * Specifies if the depth of field pipeline is enabed
  130398. */
  130399. DepthOfFieldEnabled: boolean;
  130400. /**
  130401. * @ignore
  130402. * Specifies if the lens flare pipeline is enabed
  130403. */
  130404. LensFlareEnabled: boolean;
  130405. /**
  130406. * @ignore
  130407. * Specifies if the HDR pipeline is enabled
  130408. */
  130409. HDREnabled: boolean;
  130410. /**
  130411. * @ignore
  130412. * Specifies if the volumetric lights scattering effect is enabled
  130413. */
  130414. VLSEnabled: boolean;
  130415. /**
  130416. * @ignore
  130417. * Specifies if the motion blur effect is enabled
  130418. */
  130419. MotionBlurEnabled: boolean;
  130420. /**
  130421. * Specifies if anti-aliasing is enabled
  130422. */
  130423. fxaaEnabled: boolean;
  130424. /**
  130425. * Specifies the number of steps used to calculate the volumetric lights
  130426. * Typically in interval [50, 200]
  130427. */
  130428. volumetricLightStepsCount: number;
  130429. /**
  130430. * Specifies the number of samples used for the motion blur effect
  130431. * Typically in interval [16, 64]
  130432. */
  130433. motionBlurSamples: number;
  130434. /**
  130435. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130436. */
  130437. samples: number;
  130438. /**
  130439. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130440. * @constructor
  130441. * @param name The rendering pipeline name
  130442. * @param scene The scene linked to this pipeline
  130443. * @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)
  130444. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  130445. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130446. */
  130447. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  130448. private _buildPipeline;
  130449. private _createDownSampleX4PostProcess;
  130450. private _createBrightPassPostProcess;
  130451. private _createBlurPostProcesses;
  130452. private _createTextureAdderPostProcess;
  130453. private _createVolumetricLightPostProcess;
  130454. private _createLuminancePostProcesses;
  130455. private _createHdrPostProcess;
  130456. private _createLensFlarePostProcess;
  130457. private _createDepthOfFieldPostProcess;
  130458. private _createMotionBlurPostProcess;
  130459. private _getDepthTexture;
  130460. private _disposePostProcesses;
  130461. /**
  130462. * Dispose of the pipeline and stop all post processes
  130463. */
  130464. dispose(): void;
  130465. /**
  130466. * Serialize the rendering pipeline (Used when exporting)
  130467. * @returns the serialized object
  130468. */
  130469. serialize(): any;
  130470. /**
  130471. * Parse the serialized pipeline
  130472. * @param source Source pipeline.
  130473. * @param scene The scene to load the pipeline to.
  130474. * @param rootUrl The URL of the serialized pipeline.
  130475. * @returns An instantiated pipeline from the serialized object.
  130476. */
  130477. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  130478. /**
  130479. * Luminance steps
  130480. */
  130481. static LuminanceSteps: number;
  130482. }
  130483. }
  130484. declare module BABYLON {
  130485. /** @hidden */
  130486. export var tonemapPixelShader: {
  130487. name: string;
  130488. shader: string;
  130489. };
  130490. }
  130491. declare module BABYLON {
  130492. /** Defines operator used for tonemapping */
  130493. export enum TonemappingOperator {
  130494. /** Hable */
  130495. Hable = 0,
  130496. /** Reinhard */
  130497. Reinhard = 1,
  130498. /** HejiDawson */
  130499. HejiDawson = 2,
  130500. /** Photographic */
  130501. Photographic = 3
  130502. }
  130503. /**
  130504. * Defines a post process to apply tone mapping
  130505. */
  130506. export class TonemapPostProcess extends PostProcess {
  130507. private _operator;
  130508. /** Defines the required exposure adjustement */
  130509. exposureAdjustment: number;
  130510. /**
  130511. * Creates a new TonemapPostProcess
  130512. * @param name defines the name of the postprocess
  130513. * @param _operator defines the operator to use
  130514. * @param exposureAdjustment defines the required exposure adjustement
  130515. * @param camera defines the camera to use (can be null)
  130516. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  130517. * @param engine defines the hosting engine (can be ignore if camera is set)
  130518. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130519. */
  130520. constructor(name: string, _operator: TonemappingOperator,
  130521. /** Defines the required exposure adjustement */
  130522. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  130523. }
  130524. }
  130525. declare module BABYLON {
  130526. /** @hidden */
  130527. export var depthVertexShader: {
  130528. name: string;
  130529. shader: string;
  130530. };
  130531. }
  130532. declare module BABYLON {
  130533. /** @hidden */
  130534. export var volumetricLightScatteringPixelShader: {
  130535. name: string;
  130536. shader: string;
  130537. };
  130538. }
  130539. declare module BABYLON {
  130540. /** @hidden */
  130541. export var volumetricLightScatteringPassVertexShader: {
  130542. name: string;
  130543. shader: string;
  130544. };
  130545. }
  130546. declare module BABYLON {
  130547. /** @hidden */
  130548. export var volumetricLightScatteringPassPixelShader: {
  130549. name: string;
  130550. shader: string;
  130551. };
  130552. }
  130553. declare module BABYLON {
  130554. /**
  130555. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  130556. */
  130557. export class VolumetricLightScatteringPostProcess extends PostProcess {
  130558. private _volumetricLightScatteringPass;
  130559. private _volumetricLightScatteringRTT;
  130560. private _viewPort;
  130561. private _screenCoordinates;
  130562. private _cachedDefines;
  130563. /**
  130564. * If not undefined, the mesh position is computed from the attached node position
  130565. */
  130566. attachedNode: {
  130567. position: Vector3;
  130568. };
  130569. /**
  130570. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  130571. */
  130572. customMeshPosition: Vector3;
  130573. /**
  130574. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  130575. */
  130576. useCustomMeshPosition: boolean;
  130577. /**
  130578. * If the post-process should inverse the light scattering direction
  130579. */
  130580. invert: boolean;
  130581. /**
  130582. * The internal mesh used by the post-process
  130583. */
  130584. mesh: Mesh;
  130585. /**
  130586. * @hidden
  130587. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  130588. */
  130589. useDiffuseColor: boolean;
  130590. /**
  130591. * Array containing the excluded meshes not rendered in the internal pass
  130592. */
  130593. excludedMeshes: AbstractMesh[];
  130594. /**
  130595. * Controls the overall intensity of the post-process
  130596. */
  130597. exposure: number;
  130598. /**
  130599. * Dissipates each sample's contribution in range [0, 1]
  130600. */
  130601. decay: number;
  130602. /**
  130603. * Controls the overall intensity of each sample
  130604. */
  130605. weight: number;
  130606. /**
  130607. * Controls the density of each sample
  130608. */
  130609. density: number;
  130610. /**
  130611. * @constructor
  130612. * @param name The post-process name
  130613. * @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)
  130614. * @param camera The camera that the post-process will be attached to
  130615. * @param mesh The mesh used to create the light scattering
  130616. * @param samples The post-process quality, default 100
  130617. * @param samplingModeThe post-process filtering mode
  130618. * @param engine The babylon engine
  130619. * @param reusable If the post-process is reusable
  130620. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  130621. */
  130622. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  130623. /**
  130624. * Returns the string "VolumetricLightScatteringPostProcess"
  130625. * @returns "VolumetricLightScatteringPostProcess"
  130626. */
  130627. getClassName(): string;
  130628. private _isReady;
  130629. /**
  130630. * Sets the new light position for light scattering effect
  130631. * @param position The new custom light position
  130632. */
  130633. setCustomMeshPosition(position: Vector3): void;
  130634. /**
  130635. * Returns the light position for light scattering effect
  130636. * @return Vector3 The custom light position
  130637. */
  130638. getCustomMeshPosition(): Vector3;
  130639. /**
  130640. * Disposes the internal assets and detaches the post-process from the camera
  130641. */
  130642. dispose(camera: Camera): void;
  130643. /**
  130644. * Returns the render target texture used by the post-process
  130645. * @return the render target texture used by the post-process
  130646. */
  130647. getPass(): RenderTargetTexture;
  130648. private _meshExcluded;
  130649. private _createPass;
  130650. private _updateMeshScreenCoordinates;
  130651. /**
  130652. * Creates a default mesh for the Volumeric Light Scattering post-process
  130653. * @param name The mesh name
  130654. * @param scene The scene where to create the mesh
  130655. * @return the default mesh
  130656. */
  130657. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  130658. }
  130659. }
  130660. declare module BABYLON {
  130661. interface Scene {
  130662. /** @hidden (Backing field) */
  130663. _boundingBoxRenderer: BoundingBoxRenderer;
  130664. /** @hidden (Backing field) */
  130665. _forceShowBoundingBoxes: boolean;
  130666. /**
  130667. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  130668. */
  130669. forceShowBoundingBoxes: boolean;
  130670. /**
  130671. * Gets the bounding box renderer associated with the scene
  130672. * @returns a BoundingBoxRenderer
  130673. */
  130674. getBoundingBoxRenderer(): BoundingBoxRenderer;
  130675. }
  130676. interface AbstractMesh {
  130677. /** @hidden (Backing field) */
  130678. _showBoundingBox: boolean;
  130679. /**
  130680. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  130681. */
  130682. showBoundingBox: boolean;
  130683. }
  130684. /**
  130685. * Component responsible of rendering the bounding box of the meshes in a scene.
  130686. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  130687. */
  130688. export class BoundingBoxRenderer implements ISceneComponent {
  130689. /**
  130690. * The component name helpfull to identify the component in the list of scene components.
  130691. */
  130692. readonly name: string;
  130693. /**
  130694. * The scene the component belongs to.
  130695. */
  130696. scene: Scene;
  130697. /**
  130698. * Color of the bounding box lines placed in front of an object
  130699. */
  130700. frontColor: Color3;
  130701. /**
  130702. * Color of the bounding box lines placed behind an object
  130703. */
  130704. backColor: Color3;
  130705. /**
  130706. * Defines if the renderer should show the back lines or not
  130707. */
  130708. showBackLines: boolean;
  130709. /**
  130710. * @hidden
  130711. */
  130712. renderList: SmartArray<BoundingBox>;
  130713. private _colorShader;
  130714. private _vertexBuffers;
  130715. private _indexBuffer;
  130716. private _fillIndexBuffer;
  130717. private _fillIndexData;
  130718. /**
  130719. * Instantiates a new bounding box renderer in a scene.
  130720. * @param scene the scene the renderer renders in
  130721. */
  130722. constructor(scene: Scene);
  130723. /**
  130724. * Registers the component in a given scene
  130725. */
  130726. register(): void;
  130727. private _evaluateSubMesh;
  130728. private _activeMesh;
  130729. private _prepareRessources;
  130730. private _createIndexBuffer;
  130731. /**
  130732. * Rebuilds the elements related to this component in case of
  130733. * context lost for instance.
  130734. */
  130735. rebuild(): void;
  130736. /**
  130737. * @hidden
  130738. */
  130739. reset(): void;
  130740. /**
  130741. * Render the bounding boxes of a specific rendering group
  130742. * @param renderingGroupId defines the rendering group to render
  130743. */
  130744. render(renderingGroupId: number): void;
  130745. /**
  130746. * In case of occlusion queries, we can render the occlusion bounding box through this method
  130747. * @param mesh Define the mesh to render the occlusion bounding box for
  130748. */
  130749. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  130750. /**
  130751. * Dispose and release the resources attached to this renderer.
  130752. */
  130753. dispose(): void;
  130754. }
  130755. }
  130756. declare module BABYLON {
  130757. /** @hidden */
  130758. export var depthPixelShader: {
  130759. name: string;
  130760. shader: string;
  130761. };
  130762. }
  130763. declare module BABYLON {
  130764. /**
  130765. * This represents a depth renderer in Babylon.
  130766. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130767. */
  130768. export class DepthRenderer {
  130769. private _scene;
  130770. private _depthMap;
  130771. private _effect;
  130772. private readonly _storeNonLinearDepth;
  130773. private readonly _clearColor;
  130774. /** Get if the depth renderer is using packed depth or not */
  130775. readonly isPacked: boolean;
  130776. private _cachedDefines;
  130777. private _camera;
  130778. /**
  130779. * Specifiess that the depth renderer will only be used within
  130780. * the camera it is created for.
  130781. * This can help forcing its rendering during the camera processing.
  130782. */
  130783. useOnlyInActiveCamera: boolean;
  130784. /** @hidden */
  130785. static _SceneComponentInitialization: (scene: Scene) => void;
  130786. /**
  130787. * Instantiates a depth renderer
  130788. * @param scene The scene the renderer belongs to
  130789. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130790. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130791. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130792. */
  130793. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130794. /**
  130795. * Creates the depth rendering effect and checks if the effect is ready.
  130796. * @param subMesh The submesh to be used to render the depth map of
  130797. * @param useInstances If multiple world instances should be used
  130798. * @returns if the depth renderer is ready to render the depth map
  130799. */
  130800. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130801. /**
  130802. * Gets the texture which the depth map will be written to.
  130803. * @returns The depth map texture
  130804. */
  130805. getDepthMap(): RenderTargetTexture;
  130806. /**
  130807. * Disposes of the depth renderer.
  130808. */
  130809. dispose(): void;
  130810. }
  130811. }
  130812. declare module BABYLON {
  130813. interface Scene {
  130814. /** @hidden (Backing field) */
  130815. _depthRenderer: {
  130816. [id: string]: DepthRenderer;
  130817. };
  130818. /**
  130819. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  130820. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  130821. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130822. * @returns the created depth renderer
  130823. */
  130824. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  130825. /**
  130826. * Disables a depth renderer for a given camera
  130827. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  130828. */
  130829. disableDepthRenderer(camera?: Nullable<Camera>): void;
  130830. }
  130831. /**
  130832. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  130833. * in several rendering techniques.
  130834. */
  130835. export class DepthRendererSceneComponent implements ISceneComponent {
  130836. /**
  130837. * The component name helpfull to identify the component in the list of scene components.
  130838. */
  130839. readonly name: string;
  130840. /**
  130841. * The scene the component belongs to.
  130842. */
  130843. scene: Scene;
  130844. /**
  130845. * Creates a new instance of the component for the given scene
  130846. * @param scene Defines the scene to register the component in
  130847. */
  130848. constructor(scene: Scene);
  130849. /**
  130850. * Registers the component in a given scene
  130851. */
  130852. register(): void;
  130853. /**
  130854. * Rebuilds the elements related to this component in case of
  130855. * context lost for instance.
  130856. */
  130857. rebuild(): void;
  130858. /**
  130859. * Disposes the component and the associated ressources
  130860. */
  130861. dispose(): void;
  130862. private _gatherRenderTargets;
  130863. private _gatherActiveCameraRenderTargets;
  130864. }
  130865. }
  130866. declare module BABYLON {
  130867. /** @hidden */
  130868. export var outlinePixelShader: {
  130869. name: string;
  130870. shader: string;
  130871. };
  130872. }
  130873. declare module BABYLON {
  130874. /** @hidden */
  130875. export var outlineVertexShader: {
  130876. name: string;
  130877. shader: string;
  130878. };
  130879. }
  130880. declare module BABYLON {
  130881. interface Scene {
  130882. /** @hidden */
  130883. _outlineRenderer: OutlineRenderer;
  130884. /**
  130885. * Gets the outline renderer associated with the scene
  130886. * @returns a OutlineRenderer
  130887. */
  130888. getOutlineRenderer(): OutlineRenderer;
  130889. }
  130890. interface AbstractMesh {
  130891. /** @hidden (Backing field) */
  130892. _renderOutline: boolean;
  130893. /**
  130894. * Gets or sets a boolean indicating if the outline must be rendered as well
  130895. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  130896. */
  130897. renderOutline: boolean;
  130898. /** @hidden (Backing field) */
  130899. _renderOverlay: boolean;
  130900. /**
  130901. * Gets or sets a boolean indicating if the overlay must be rendered as well
  130902. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  130903. */
  130904. renderOverlay: boolean;
  130905. }
  130906. /**
  130907. * This class is responsible to draw bothe outline/overlay of meshes.
  130908. * It should not be used directly but through the available method on mesh.
  130909. */
  130910. export class OutlineRenderer implements ISceneComponent {
  130911. /**
  130912. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  130913. */
  130914. private static _StencilReference;
  130915. /**
  130916. * The name of the component. Each component must have a unique name.
  130917. */
  130918. name: string;
  130919. /**
  130920. * The scene the component belongs to.
  130921. */
  130922. scene: Scene;
  130923. /**
  130924. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  130925. */
  130926. zOffset: number;
  130927. private _engine;
  130928. private _effect;
  130929. private _cachedDefines;
  130930. private _savedDepthWrite;
  130931. /**
  130932. * Instantiates a new outline renderer. (There could be only one per scene).
  130933. * @param scene Defines the scene it belongs to
  130934. */
  130935. constructor(scene: Scene);
  130936. /**
  130937. * Register the component to one instance of a scene.
  130938. */
  130939. register(): void;
  130940. /**
  130941. * Rebuilds the elements related to this component in case of
  130942. * context lost for instance.
  130943. */
  130944. rebuild(): void;
  130945. /**
  130946. * Disposes the component and the associated ressources.
  130947. */
  130948. dispose(): void;
  130949. /**
  130950. * Renders the outline in the canvas.
  130951. * @param subMesh Defines the sumesh to render
  130952. * @param batch Defines the batch of meshes in case of instances
  130953. * @param useOverlay Defines if the rendering is for the overlay or the outline
  130954. */
  130955. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  130956. /**
  130957. * Returns whether or not the outline renderer is ready for a given submesh.
  130958. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  130959. * @param subMesh Defines the submesh to check readyness for
  130960. * @param useInstances Defines wheter wee are trying to render instances or not
  130961. * @returns true if ready otherwise false
  130962. */
  130963. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130964. private _beforeRenderingMesh;
  130965. private _afterRenderingMesh;
  130966. }
  130967. }
  130968. declare module BABYLON {
  130969. /**
  130970. * Class used to manage multiple sprites of different sizes on the same spritesheet
  130971. * @see http://doc.babylonjs.com/babylon101/sprites
  130972. */
  130973. export class SpritePackedManager extends SpriteManager {
  130974. /** defines the packed manager's name */
  130975. name: string;
  130976. /**
  130977. * Creates a new sprite manager from a packed sprite sheet
  130978. * @param name defines the manager's name
  130979. * @param imgUrl defines the sprite sheet url
  130980. * @param capacity defines the maximum allowed number of sprites
  130981. * @param scene defines the hosting scene
  130982. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  130983. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  130984. * @param samplingMode defines the smapling mode to use with spritesheet
  130985. * @param fromPacked set to true; do not alter
  130986. */
  130987. constructor(
  130988. /** defines the packed manager's name */
  130989. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  130990. }
  130991. }
  130992. declare module BABYLON {
  130993. /**
  130994. * Defines the list of states available for a task inside a AssetsManager
  130995. */
  130996. export enum AssetTaskState {
  130997. /**
  130998. * Initialization
  130999. */
  131000. INIT = 0,
  131001. /**
  131002. * Running
  131003. */
  131004. RUNNING = 1,
  131005. /**
  131006. * Done
  131007. */
  131008. DONE = 2,
  131009. /**
  131010. * Error
  131011. */
  131012. ERROR = 3
  131013. }
  131014. /**
  131015. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  131016. */
  131017. export abstract class AbstractAssetTask {
  131018. /**
  131019. * Task name
  131020. */ name: string;
  131021. /**
  131022. * Callback called when the task is successful
  131023. */
  131024. onSuccess: (task: any) => void;
  131025. /**
  131026. * Callback called when the task is not successful
  131027. */
  131028. onError: (task: any, message?: string, exception?: any) => void;
  131029. /**
  131030. * Creates a new AssetsManager
  131031. * @param name defines the name of the task
  131032. */
  131033. constructor(
  131034. /**
  131035. * Task name
  131036. */ name: string);
  131037. private _isCompleted;
  131038. private _taskState;
  131039. private _errorObject;
  131040. /**
  131041. * Get if the task is completed
  131042. */
  131043. readonly isCompleted: boolean;
  131044. /**
  131045. * Gets the current state of the task
  131046. */
  131047. readonly taskState: AssetTaskState;
  131048. /**
  131049. * Gets the current error object (if task is in error)
  131050. */
  131051. readonly errorObject: {
  131052. message?: string;
  131053. exception?: any;
  131054. };
  131055. /**
  131056. * Internal only
  131057. * @hidden
  131058. */
  131059. _setErrorObject(message?: string, exception?: any): void;
  131060. /**
  131061. * Execute the current task
  131062. * @param scene defines the scene where you want your assets to be loaded
  131063. * @param onSuccess is a callback called when the task is successfully executed
  131064. * @param onError is a callback called if an error occurs
  131065. */
  131066. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131067. /**
  131068. * Execute the current task
  131069. * @param scene defines the scene where you want your assets to be loaded
  131070. * @param onSuccess is a callback called when the task is successfully executed
  131071. * @param onError is a callback called if an error occurs
  131072. */
  131073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131074. /**
  131075. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  131076. * This can be used with failed tasks that have the reason for failure fixed.
  131077. */
  131078. reset(): void;
  131079. private onErrorCallback;
  131080. private onDoneCallback;
  131081. }
  131082. /**
  131083. * Define the interface used by progress events raised during assets loading
  131084. */
  131085. export interface IAssetsProgressEvent {
  131086. /**
  131087. * Defines the number of remaining tasks to process
  131088. */
  131089. remainingCount: number;
  131090. /**
  131091. * Defines the total number of tasks
  131092. */
  131093. totalCount: number;
  131094. /**
  131095. * Defines the task that was just processed
  131096. */
  131097. task: AbstractAssetTask;
  131098. }
  131099. /**
  131100. * Class used to share progress information about assets loading
  131101. */
  131102. export class AssetsProgressEvent implements IAssetsProgressEvent {
  131103. /**
  131104. * Defines the number of remaining tasks to process
  131105. */
  131106. remainingCount: number;
  131107. /**
  131108. * Defines the total number of tasks
  131109. */
  131110. totalCount: number;
  131111. /**
  131112. * Defines the task that was just processed
  131113. */
  131114. task: AbstractAssetTask;
  131115. /**
  131116. * Creates a AssetsProgressEvent
  131117. * @param remainingCount defines the number of remaining tasks to process
  131118. * @param totalCount defines the total number of tasks
  131119. * @param task defines the task that was just processed
  131120. */
  131121. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  131122. }
  131123. /**
  131124. * Define a task used by AssetsManager to load meshes
  131125. */
  131126. export class MeshAssetTask extends AbstractAssetTask {
  131127. /**
  131128. * Defines the name of the task
  131129. */
  131130. name: string;
  131131. /**
  131132. * Defines the list of mesh's names you want to load
  131133. */
  131134. meshesNames: any;
  131135. /**
  131136. * Defines the root url to use as a base to load your meshes and associated resources
  131137. */
  131138. rootUrl: string;
  131139. /**
  131140. * Defines the filename of the scene to load from
  131141. */
  131142. sceneFilename: string;
  131143. /**
  131144. * Gets the list of loaded meshes
  131145. */
  131146. loadedMeshes: Array<AbstractMesh>;
  131147. /**
  131148. * Gets the list of loaded particle systems
  131149. */
  131150. loadedParticleSystems: Array<IParticleSystem>;
  131151. /**
  131152. * Gets the list of loaded skeletons
  131153. */
  131154. loadedSkeletons: Array<Skeleton>;
  131155. /**
  131156. * Gets the list of loaded animation groups
  131157. */
  131158. loadedAnimationGroups: Array<AnimationGroup>;
  131159. /**
  131160. * Callback called when the task is successful
  131161. */
  131162. onSuccess: (task: MeshAssetTask) => void;
  131163. /**
  131164. * Callback called when the task is successful
  131165. */
  131166. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  131167. /**
  131168. * Creates a new MeshAssetTask
  131169. * @param name defines the name of the task
  131170. * @param meshesNames defines the list of mesh's names you want to load
  131171. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  131172. * @param sceneFilename defines the filename of the scene to load from
  131173. */
  131174. constructor(
  131175. /**
  131176. * Defines the name of the task
  131177. */
  131178. name: string,
  131179. /**
  131180. * Defines the list of mesh's names you want to load
  131181. */
  131182. meshesNames: any,
  131183. /**
  131184. * Defines the root url to use as a base to load your meshes and associated resources
  131185. */
  131186. rootUrl: string,
  131187. /**
  131188. * Defines the filename of the scene to load from
  131189. */
  131190. sceneFilename: string);
  131191. /**
  131192. * Execute the current task
  131193. * @param scene defines the scene where you want your assets to be loaded
  131194. * @param onSuccess is a callback called when the task is successfully executed
  131195. * @param onError is a callback called if an error occurs
  131196. */
  131197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131198. }
  131199. /**
  131200. * Define a task used by AssetsManager to load text content
  131201. */
  131202. export class TextFileAssetTask extends AbstractAssetTask {
  131203. /**
  131204. * Defines the name of the task
  131205. */
  131206. name: string;
  131207. /**
  131208. * Defines the location of the file to load
  131209. */
  131210. url: string;
  131211. /**
  131212. * Gets the loaded text string
  131213. */
  131214. text: string;
  131215. /**
  131216. * Callback called when the task is successful
  131217. */
  131218. onSuccess: (task: TextFileAssetTask) => void;
  131219. /**
  131220. * Callback called when the task is successful
  131221. */
  131222. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  131223. /**
  131224. * Creates a new TextFileAssetTask object
  131225. * @param name defines the name of the task
  131226. * @param url defines the location of the file to load
  131227. */
  131228. constructor(
  131229. /**
  131230. * Defines the name of the task
  131231. */
  131232. name: string,
  131233. /**
  131234. * Defines the location of the file to load
  131235. */
  131236. url: string);
  131237. /**
  131238. * Execute the current task
  131239. * @param scene defines the scene where you want your assets to be loaded
  131240. * @param onSuccess is a callback called when the task is successfully executed
  131241. * @param onError is a callback called if an error occurs
  131242. */
  131243. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131244. }
  131245. /**
  131246. * Define a task used by AssetsManager to load binary data
  131247. */
  131248. export class BinaryFileAssetTask extends AbstractAssetTask {
  131249. /**
  131250. * Defines the name of the task
  131251. */
  131252. name: string;
  131253. /**
  131254. * Defines the location of the file to load
  131255. */
  131256. url: string;
  131257. /**
  131258. * Gets the lodaded data (as an array buffer)
  131259. */
  131260. data: ArrayBuffer;
  131261. /**
  131262. * Callback called when the task is successful
  131263. */
  131264. onSuccess: (task: BinaryFileAssetTask) => void;
  131265. /**
  131266. * Callback called when the task is successful
  131267. */
  131268. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  131269. /**
  131270. * Creates a new BinaryFileAssetTask object
  131271. * @param name defines the name of the new task
  131272. * @param url defines the location of the file to load
  131273. */
  131274. constructor(
  131275. /**
  131276. * Defines the name of the task
  131277. */
  131278. name: string,
  131279. /**
  131280. * Defines the location of the file to load
  131281. */
  131282. url: string);
  131283. /**
  131284. * Execute the current task
  131285. * @param scene defines the scene where you want your assets to be loaded
  131286. * @param onSuccess is a callback called when the task is successfully executed
  131287. * @param onError is a callback called if an error occurs
  131288. */
  131289. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131290. }
  131291. /**
  131292. * Define a task used by AssetsManager to load images
  131293. */
  131294. export class ImageAssetTask extends AbstractAssetTask {
  131295. /**
  131296. * Defines the name of the task
  131297. */
  131298. name: string;
  131299. /**
  131300. * Defines the location of the image to load
  131301. */
  131302. url: string;
  131303. /**
  131304. * Gets the loaded images
  131305. */
  131306. image: HTMLImageElement;
  131307. /**
  131308. * Callback called when the task is successful
  131309. */
  131310. onSuccess: (task: ImageAssetTask) => void;
  131311. /**
  131312. * Callback called when the task is successful
  131313. */
  131314. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  131315. /**
  131316. * Creates a new ImageAssetTask
  131317. * @param name defines the name of the task
  131318. * @param url defines the location of the image to load
  131319. */
  131320. constructor(
  131321. /**
  131322. * Defines the name of the task
  131323. */
  131324. name: string,
  131325. /**
  131326. * Defines the location of the image to load
  131327. */
  131328. url: string);
  131329. /**
  131330. * Execute the current task
  131331. * @param scene defines the scene where you want your assets to be loaded
  131332. * @param onSuccess is a callback called when the task is successfully executed
  131333. * @param onError is a callback called if an error occurs
  131334. */
  131335. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131336. }
  131337. /**
  131338. * Defines the interface used by texture loading tasks
  131339. */
  131340. export interface ITextureAssetTask<TEX extends BaseTexture> {
  131341. /**
  131342. * Gets the loaded texture
  131343. */
  131344. texture: TEX;
  131345. }
  131346. /**
  131347. * Define a task used by AssetsManager to load 2D textures
  131348. */
  131349. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  131350. /**
  131351. * Defines the name of the task
  131352. */
  131353. name: string;
  131354. /**
  131355. * Defines the location of the file to load
  131356. */
  131357. url: string;
  131358. /**
  131359. * Defines if mipmap should not be generated (default is false)
  131360. */
  131361. noMipmap?: boolean | undefined;
  131362. /**
  131363. * Defines if texture must be inverted on Y axis (default is false)
  131364. */
  131365. invertY?: boolean | undefined;
  131366. /**
  131367. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131368. */
  131369. samplingMode: number;
  131370. /**
  131371. * Gets the loaded texture
  131372. */
  131373. texture: Texture;
  131374. /**
  131375. * Callback called when the task is successful
  131376. */
  131377. onSuccess: (task: TextureAssetTask) => void;
  131378. /**
  131379. * Callback called when the task is successful
  131380. */
  131381. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  131382. /**
  131383. * Creates a new TextureAssetTask object
  131384. * @param name defines the name of the task
  131385. * @param url defines the location of the file to load
  131386. * @param noMipmap defines if mipmap should not be generated (default is false)
  131387. * @param invertY defines if texture must be inverted on Y axis (default is false)
  131388. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131389. */
  131390. constructor(
  131391. /**
  131392. * Defines the name of the task
  131393. */
  131394. name: string,
  131395. /**
  131396. * Defines the location of the file to load
  131397. */
  131398. url: string,
  131399. /**
  131400. * Defines if mipmap should not be generated (default is false)
  131401. */
  131402. noMipmap?: boolean | undefined,
  131403. /**
  131404. * Defines if texture must be inverted on Y axis (default is false)
  131405. */
  131406. invertY?: boolean | undefined,
  131407. /**
  131408. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131409. */
  131410. samplingMode?: number);
  131411. /**
  131412. * Execute the current task
  131413. * @param scene defines the scene where you want your assets to be loaded
  131414. * @param onSuccess is a callback called when the task is successfully executed
  131415. * @param onError is a callback called if an error occurs
  131416. */
  131417. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131418. }
  131419. /**
  131420. * Define a task used by AssetsManager to load cube textures
  131421. */
  131422. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  131423. /**
  131424. * Defines the name of the task
  131425. */
  131426. name: string;
  131427. /**
  131428. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131429. */
  131430. url: string;
  131431. /**
  131432. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131433. */
  131434. extensions?: string[] | undefined;
  131435. /**
  131436. * Defines if mipmaps should not be generated (default is false)
  131437. */
  131438. noMipmap?: boolean | undefined;
  131439. /**
  131440. * Defines the explicit list of files (undefined by default)
  131441. */
  131442. files?: string[] | undefined;
  131443. /**
  131444. * Gets the loaded texture
  131445. */
  131446. texture: CubeTexture;
  131447. /**
  131448. * Callback called when the task is successful
  131449. */
  131450. onSuccess: (task: CubeTextureAssetTask) => void;
  131451. /**
  131452. * Callback called when the task is successful
  131453. */
  131454. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  131455. /**
  131456. * Creates a new CubeTextureAssetTask
  131457. * @param name defines the name of the task
  131458. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131459. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131460. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131461. * @param files defines the explicit list of files (undefined by default)
  131462. */
  131463. constructor(
  131464. /**
  131465. * Defines the name of the task
  131466. */
  131467. name: string,
  131468. /**
  131469. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131470. */
  131471. url: string,
  131472. /**
  131473. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131474. */
  131475. extensions?: string[] | undefined,
  131476. /**
  131477. * Defines if mipmaps should not be generated (default is false)
  131478. */
  131479. noMipmap?: boolean | undefined,
  131480. /**
  131481. * Defines the explicit list of files (undefined by default)
  131482. */
  131483. files?: string[] | undefined);
  131484. /**
  131485. * Execute the current task
  131486. * @param scene defines the scene where you want your assets to be loaded
  131487. * @param onSuccess is a callback called when the task is successfully executed
  131488. * @param onError is a callback called if an error occurs
  131489. */
  131490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131491. }
  131492. /**
  131493. * Define a task used by AssetsManager to load HDR cube textures
  131494. */
  131495. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  131496. /**
  131497. * Defines the name of the task
  131498. */
  131499. name: string;
  131500. /**
  131501. * Defines the location of the file to load
  131502. */
  131503. url: string;
  131504. /**
  131505. * Defines the desired size (the more it increases the longer the generation will be)
  131506. */
  131507. size: number;
  131508. /**
  131509. * Defines if mipmaps should not be generated (default is false)
  131510. */
  131511. noMipmap: boolean;
  131512. /**
  131513. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131514. */
  131515. generateHarmonics: boolean;
  131516. /**
  131517. * 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)
  131518. */
  131519. gammaSpace: boolean;
  131520. /**
  131521. * Internal Use Only
  131522. */
  131523. reserved: boolean;
  131524. /**
  131525. * Gets the loaded texture
  131526. */
  131527. texture: HDRCubeTexture;
  131528. /**
  131529. * Callback called when the task is successful
  131530. */
  131531. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  131532. /**
  131533. * Callback called when the task is successful
  131534. */
  131535. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  131536. /**
  131537. * Creates a new HDRCubeTextureAssetTask object
  131538. * @param name defines the name of the task
  131539. * @param url defines the location of the file to load
  131540. * @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.
  131541. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131542. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131543. * @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)
  131544. * @param reserved Internal use only
  131545. */
  131546. constructor(
  131547. /**
  131548. * Defines the name of the task
  131549. */
  131550. name: string,
  131551. /**
  131552. * Defines the location of the file to load
  131553. */
  131554. url: string,
  131555. /**
  131556. * Defines the desired size (the more it increases the longer the generation will be)
  131557. */
  131558. size: number,
  131559. /**
  131560. * Defines if mipmaps should not be generated (default is false)
  131561. */
  131562. noMipmap?: boolean,
  131563. /**
  131564. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131565. */
  131566. generateHarmonics?: boolean,
  131567. /**
  131568. * 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)
  131569. */
  131570. gammaSpace?: boolean,
  131571. /**
  131572. * Internal Use Only
  131573. */
  131574. reserved?: boolean);
  131575. /**
  131576. * Execute the current task
  131577. * @param scene defines the scene where you want your assets to be loaded
  131578. * @param onSuccess is a callback called when the task is successfully executed
  131579. * @param onError is a callback called if an error occurs
  131580. */
  131581. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131582. }
  131583. /**
  131584. * Define a task used by AssetsManager to load Equirectangular cube textures
  131585. */
  131586. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  131587. /**
  131588. * Defines the name of the task
  131589. */
  131590. name: string;
  131591. /**
  131592. * Defines the location of the file to load
  131593. */
  131594. url: string;
  131595. /**
  131596. * Defines the desired size (the more it increases the longer the generation will be)
  131597. */
  131598. size: number;
  131599. /**
  131600. * Defines if mipmaps should not be generated (default is false)
  131601. */
  131602. noMipmap: boolean;
  131603. /**
  131604. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131605. * but the standard material would require them in Gamma space) (default is true)
  131606. */
  131607. gammaSpace: boolean;
  131608. /**
  131609. * Gets the loaded texture
  131610. */
  131611. texture: EquiRectangularCubeTexture;
  131612. /**
  131613. * Callback called when the task is successful
  131614. */
  131615. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  131616. /**
  131617. * Callback called when the task is successful
  131618. */
  131619. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  131620. /**
  131621. * Creates a new EquiRectangularCubeTextureAssetTask object
  131622. * @param name defines the name of the task
  131623. * @param url defines the location of the file to load
  131624. * @param size defines the desired size (the more it increases the longer the generation will be)
  131625. * If the size is omitted this implies you are using a preprocessed cubemap.
  131626. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131627. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  131628. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  131629. * (default is true)
  131630. */
  131631. constructor(
  131632. /**
  131633. * Defines the name of the task
  131634. */
  131635. name: string,
  131636. /**
  131637. * Defines the location of the file to load
  131638. */
  131639. url: string,
  131640. /**
  131641. * Defines the desired size (the more it increases the longer the generation will be)
  131642. */
  131643. size: number,
  131644. /**
  131645. * Defines if mipmaps should not be generated (default is false)
  131646. */
  131647. noMipmap?: boolean,
  131648. /**
  131649. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131650. * but the standard material would require them in Gamma space) (default is true)
  131651. */
  131652. gammaSpace?: boolean);
  131653. /**
  131654. * Execute the current task
  131655. * @param scene defines the scene where you want your assets to be loaded
  131656. * @param onSuccess is a callback called when the task is successfully executed
  131657. * @param onError is a callback called if an error occurs
  131658. */
  131659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131660. }
  131661. /**
  131662. * This class can be used to easily import assets into a scene
  131663. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  131664. */
  131665. export class AssetsManager {
  131666. private _scene;
  131667. private _isLoading;
  131668. protected _tasks: AbstractAssetTask[];
  131669. protected _waitingTasksCount: number;
  131670. protected _totalTasksCount: number;
  131671. /**
  131672. * Callback called when all tasks are processed
  131673. */
  131674. onFinish: (tasks: AbstractAssetTask[]) => void;
  131675. /**
  131676. * Callback called when a task is successful
  131677. */
  131678. onTaskSuccess: (task: AbstractAssetTask) => void;
  131679. /**
  131680. * Callback called when a task had an error
  131681. */
  131682. onTaskError: (task: AbstractAssetTask) => void;
  131683. /**
  131684. * Callback called when a task is done (whatever the result is)
  131685. */
  131686. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  131687. /**
  131688. * Observable called when all tasks are processed
  131689. */
  131690. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  131691. /**
  131692. * Observable called when a task had an error
  131693. */
  131694. onTaskErrorObservable: Observable<AbstractAssetTask>;
  131695. /**
  131696. * Observable called when all tasks were executed
  131697. */
  131698. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  131699. /**
  131700. * Observable called when a task is done (whatever the result is)
  131701. */
  131702. onProgressObservable: Observable<IAssetsProgressEvent>;
  131703. /**
  131704. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  131705. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  131706. */
  131707. useDefaultLoadingScreen: boolean;
  131708. /**
  131709. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  131710. * when all assets have been downloaded.
  131711. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  131712. */
  131713. autoHideLoadingUI: boolean;
  131714. /**
  131715. * Creates a new AssetsManager
  131716. * @param scene defines the scene to work on
  131717. */
  131718. constructor(scene: Scene);
  131719. /**
  131720. * Add a MeshAssetTask to the list of active tasks
  131721. * @param taskName defines the name of the new task
  131722. * @param meshesNames defines the name of meshes to load
  131723. * @param rootUrl defines the root url to use to locate files
  131724. * @param sceneFilename defines the filename of the scene file
  131725. * @returns a new MeshAssetTask object
  131726. */
  131727. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  131728. /**
  131729. * Add a TextFileAssetTask to the list of active tasks
  131730. * @param taskName defines the name of the new task
  131731. * @param url defines the url of the file to load
  131732. * @returns a new TextFileAssetTask object
  131733. */
  131734. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  131735. /**
  131736. * Add a BinaryFileAssetTask to the list of active tasks
  131737. * @param taskName defines the name of the new task
  131738. * @param url defines the url of the file to load
  131739. * @returns a new BinaryFileAssetTask object
  131740. */
  131741. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  131742. /**
  131743. * Add a ImageAssetTask to the list of active tasks
  131744. * @param taskName defines the name of the new task
  131745. * @param url defines the url of the file to load
  131746. * @returns a new ImageAssetTask object
  131747. */
  131748. addImageTask(taskName: string, url: string): ImageAssetTask;
  131749. /**
  131750. * Add a TextureAssetTask to the list of active tasks
  131751. * @param taskName defines the name of the new task
  131752. * @param url defines the url of the file to load
  131753. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131754. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  131755. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131756. * @returns a new TextureAssetTask object
  131757. */
  131758. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  131759. /**
  131760. * Add a CubeTextureAssetTask to the list of active tasks
  131761. * @param taskName defines the name of the new task
  131762. * @param url defines the url of the file to load
  131763. * @param extensions defines the extension to use to load the cube map (can be null)
  131764. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131765. * @param files defines the list of files to load (can be null)
  131766. * @returns a new CubeTextureAssetTask object
  131767. */
  131768. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  131769. /**
  131770. *
  131771. * Add a HDRCubeTextureAssetTask to the list of active tasks
  131772. * @param taskName defines the name of the new task
  131773. * @param url defines the url of the file to load
  131774. * @param size defines the size you want for the cubemap (can be null)
  131775. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131776. * @param generateHarmonics defines if you want to automatically generate (true by default)
  131777. * @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)
  131778. * @param reserved Internal use only
  131779. * @returns a new HDRCubeTextureAssetTask object
  131780. */
  131781. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  131782. /**
  131783. *
  131784. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  131785. * @param taskName defines the name of the new task
  131786. * @param url defines the url of the file to load
  131787. * @param size defines the size you want for the cubemap (can be null)
  131788. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131789. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  131790. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  131791. * @returns a new EquiRectangularCubeTextureAssetTask object
  131792. */
  131793. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  131794. /**
  131795. * Remove a task from the assets manager.
  131796. * @param task the task to remove
  131797. */
  131798. removeTask(task: AbstractAssetTask): void;
  131799. private _decreaseWaitingTasksCount;
  131800. private _runTask;
  131801. /**
  131802. * Reset the AssetsManager and remove all tasks
  131803. * @return the current instance of the AssetsManager
  131804. */
  131805. reset(): AssetsManager;
  131806. /**
  131807. * Start the loading process
  131808. * @return the current instance of the AssetsManager
  131809. */
  131810. load(): AssetsManager;
  131811. /**
  131812. * Start the loading process as an async operation
  131813. * @return a promise returning the list of failed tasks
  131814. */
  131815. loadAsync(): Promise<void>;
  131816. }
  131817. }
  131818. declare module BABYLON {
  131819. /**
  131820. * Wrapper class for promise with external resolve and reject.
  131821. */
  131822. export class Deferred<T> {
  131823. /**
  131824. * The promise associated with this deferred object.
  131825. */
  131826. readonly promise: Promise<T>;
  131827. private _resolve;
  131828. private _reject;
  131829. /**
  131830. * The resolve method of the promise associated with this deferred object.
  131831. */
  131832. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  131833. /**
  131834. * The reject method of the promise associated with this deferred object.
  131835. */
  131836. readonly reject: (reason?: any) => void;
  131837. /**
  131838. * Constructor for this deferred object.
  131839. */
  131840. constructor();
  131841. }
  131842. }
  131843. declare module BABYLON {
  131844. /**
  131845. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  131846. */
  131847. export class MeshExploder {
  131848. private _centerMesh;
  131849. private _meshes;
  131850. private _meshesOrigins;
  131851. private _toCenterVectors;
  131852. private _scaledDirection;
  131853. private _newPosition;
  131854. private _centerPosition;
  131855. /**
  131856. * Explodes meshes from a center mesh.
  131857. * @param meshes The meshes to explode.
  131858. * @param centerMesh The mesh to be center of explosion.
  131859. */
  131860. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  131861. private _setCenterMesh;
  131862. /**
  131863. * Get class name
  131864. * @returns "MeshExploder"
  131865. */
  131866. getClassName(): string;
  131867. /**
  131868. * "Exploded meshes"
  131869. * @returns Array of meshes with the centerMesh at index 0.
  131870. */
  131871. getMeshes(): Array<Mesh>;
  131872. /**
  131873. * Explodes meshes giving a specific direction
  131874. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  131875. */
  131876. explode(direction?: number): void;
  131877. }
  131878. }
  131879. declare module BABYLON {
  131880. /**
  131881. * Class used to help managing file picking and drag'n'drop
  131882. */
  131883. export class FilesInput {
  131884. /**
  131885. * List of files ready to be loaded
  131886. */
  131887. static readonly FilesToLoad: {
  131888. [key: string]: File;
  131889. };
  131890. /**
  131891. * Callback called when a file is processed
  131892. */
  131893. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  131894. private _engine;
  131895. private _currentScene;
  131896. private _sceneLoadedCallback;
  131897. private _progressCallback;
  131898. private _additionalRenderLoopLogicCallback;
  131899. private _textureLoadingCallback;
  131900. private _startingProcessingFilesCallback;
  131901. private _onReloadCallback;
  131902. private _errorCallback;
  131903. private _elementToMonitor;
  131904. private _sceneFileToLoad;
  131905. private _filesToLoad;
  131906. /**
  131907. * Creates a new FilesInput
  131908. * @param engine defines the rendering engine
  131909. * @param scene defines the hosting scene
  131910. * @param sceneLoadedCallback callback called when scene is loaded
  131911. * @param progressCallback callback called to track progress
  131912. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  131913. * @param textureLoadingCallback callback called when a texture is loading
  131914. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  131915. * @param onReloadCallback callback called when a reload is requested
  131916. * @param errorCallback callback call if an error occurs
  131917. */
  131918. 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);
  131919. private _dragEnterHandler;
  131920. private _dragOverHandler;
  131921. private _dropHandler;
  131922. /**
  131923. * Calls this function to listen to drag'n'drop events on a specific DOM element
  131924. * @param elementToMonitor defines the DOM element to track
  131925. */
  131926. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  131927. /**
  131928. * Release all associated resources
  131929. */
  131930. dispose(): void;
  131931. private renderFunction;
  131932. private drag;
  131933. private drop;
  131934. private _traverseFolder;
  131935. private _processFiles;
  131936. /**
  131937. * Load files from a drop event
  131938. * @param event defines the drop event to use as source
  131939. */
  131940. loadFiles(event: any): void;
  131941. private _processReload;
  131942. /**
  131943. * Reload the current scene from the loaded files
  131944. */
  131945. reload(): void;
  131946. }
  131947. }
  131948. declare module BABYLON {
  131949. /**
  131950. * Defines the root class used to create scene optimization to use with SceneOptimizer
  131951. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131952. */
  131953. export class SceneOptimization {
  131954. /**
  131955. * Defines the priority of this optimization (0 by default which means first in the list)
  131956. */
  131957. priority: number;
  131958. /**
  131959. * Gets a string describing the action executed by the current optimization
  131960. * @returns description string
  131961. */
  131962. getDescription(): string;
  131963. /**
  131964. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131965. * @param scene defines the current scene where to apply this optimization
  131966. * @param optimizer defines the current optimizer
  131967. * @returns true if everything that can be done was applied
  131968. */
  131969. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131970. /**
  131971. * Creates the SceneOptimization object
  131972. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131973. * @param desc defines the description associated with the optimization
  131974. */
  131975. constructor(
  131976. /**
  131977. * Defines the priority of this optimization (0 by default which means first in the list)
  131978. */
  131979. priority?: number);
  131980. }
  131981. /**
  131982. * Defines an optimization used to reduce the size of render target textures
  131983. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131984. */
  131985. export class TextureOptimization extends SceneOptimization {
  131986. /**
  131987. * Defines the priority of this optimization (0 by default which means first in the list)
  131988. */
  131989. priority: number;
  131990. /**
  131991. * 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
  131992. */
  131993. maximumSize: number;
  131994. /**
  131995. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131996. */
  131997. step: number;
  131998. /**
  131999. * Gets a string describing the action executed by the current optimization
  132000. * @returns description string
  132001. */
  132002. getDescription(): string;
  132003. /**
  132004. * Creates the TextureOptimization object
  132005. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132006. * @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
  132007. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132008. */
  132009. constructor(
  132010. /**
  132011. * Defines the priority of this optimization (0 by default which means first in the list)
  132012. */
  132013. priority?: number,
  132014. /**
  132015. * 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
  132016. */
  132017. maximumSize?: number,
  132018. /**
  132019. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132020. */
  132021. step?: number);
  132022. /**
  132023. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132024. * @param scene defines the current scene where to apply this optimization
  132025. * @param optimizer defines the current optimizer
  132026. * @returns true if everything that can be done was applied
  132027. */
  132028. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132029. }
  132030. /**
  132031. * Defines an optimization used to increase or decrease the rendering resolution
  132032. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132033. */
  132034. export class HardwareScalingOptimization extends SceneOptimization {
  132035. /**
  132036. * Defines the priority of this optimization (0 by default which means first in the list)
  132037. */
  132038. priority: number;
  132039. /**
  132040. * Defines the maximum scale to use (2 by default)
  132041. */
  132042. maximumScale: number;
  132043. /**
  132044. * Defines the step to use between two passes (0.5 by default)
  132045. */
  132046. step: number;
  132047. private _currentScale;
  132048. private _directionOffset;
  132049. /**
  132050. * Gets a string describing the action executed by the current optimization
  132051. * @return description string
  132052. */
  132053. getDescription(): string;
  132054. /**
  132055. * Creates the HardwareScalingOptimization object
  132056. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132057. * @param maximumScale defines the maximum scale to use (2 by default)
  132058. * @param step defines the step to use between two passes (0.5 by default)
  132059. */
  132060. constructor(
  132061. /**
  132062. * Defines the priority of this optimization (0 by default which means first in the list)
  132063. */
  132064. priority?: number,
  132065. /**
  132066. * Defines the maximum scale to use (2 by default)
  132067. */
  132068. maximumScale?: number,
  132069. /**
  132070. * Defines the step to use between two passes (0.5 by default)
  132071. */
  132072. step?: number);
  132073. /**
  132074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132075. * @param scene defines the current scene where to apply this optimization
  132076. * @param optimizer defines the current optimizer
  132077. * @returns true if everything that can be done was applied
  132078. */
  132079. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132080. }
  132081. /**
  132082. * Defines an optimization used to remove shadows
  132083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132084. */
  132085. export class ShadowsOptimization extends SceneOptimization {
  132086. /**
  132087. * Gets a string describing the action executed by the current optimization
  132088. * @return description string
  132089. */
  132090. getDescription(): string;
  132091. /**
  132092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132093. * @param scene defines the current scene where to apply this optimization
  132094. * @param optimizer defines the current optimizer
  132095. * @returns true if everything that can be done was applied
  132096. */
  132097. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132098. }
  132099. /**
  132100. * Defines an optimization used to turn post-processes off
  132101. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132102. */
  132103. export class PostProcessesOptimization extends SceneOptimization {
  132104. /**
  132105. * Gets a string describing the action executed by the current optimization
  132106. * @return description string
  132107. */
  132108. getDescription(): string;
  132109. /**
  132110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132111. * @param scene defines the current scene where to apply this optimization
  132112. * @param optimizer defines the current optimizer
  132113. * @returns true if everything that can be done was applied
  132114. */
  132115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132116. }
  132117. /**
  132118. * Defines an optimization used to turn lens flares off
  132119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132120. */
  132121. export class LensFlaresOptimization extends SceneOptimization {
  132122. /**
  132123. * Gets a string describing the action executed by the current optimization
  132124. * @return description string
  132125. */
  132126. getDescription(): string;
  132127. /**
  132128. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132129. * @param scene defines the current scene where to apply this optimization
  132130. * @param optimizer defines the current optimizer
  132131. * @returns true if everything that can be done was applied
  132132. */
  132133. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132134. }
  132135. /**
  132136. * Defines an optimization based on user defined callback.
  132137. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132138. */
  132139. export class CustomOptimization extends SceneOptimization {
  132140. /**
  132141. * Callback called to apply the custom optimization.
  132142. */
  132143. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  132144. /**
  132145. * Callback called to get custom description
  132146. */
  132147. onGetDescription: () => string;
  132148. /**
  132149. * Gets a string describing the action executed by the current optimization
  132150. * @returns description string
  132151. */
  132152. getDescription(): string;
  132153. /**
  132154. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132155. * @param scene defines the current scene where to apply this optimization
  132156. * @param optimizer defines the current optimizer
  132157. * @returns true if everything that can be done was applied
  132158. */
  132159. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132160. }
  132161. /**
  132162. * Defines an optimization used to turn particles off
  132163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132164. */
  132165. export class ParticlesOptimization extends SceneOptimization {
  132166. /**
  132167. * Gets a string describing the action executed by the current optimization
  132168. * @return description string
  132169. */
  132170. getDescription(): string;
  132171. /**
  132172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132173. * @param scene defines the current scene where to apply this optimization
  132174. * @param optimizer defines the current optimizer
  132175. * @returns true if everything that can be done was applied
  132176. */
  132177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132178. }
  132179. /**
  132180. * Defines an optimization used to turn render targets off
  132181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132182. */
  132183. export class RenderTargetsOptimization extends SceneOptimization {
  132184. /**
  132185. * Gets a string describing the action executed by the current optimization
  132186. * @return description string
  132187. */
  132188. getDescription(): string;
  132189. /**
  132190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132191. * @param scene defines the current scene where to apply this optimization
  132192. * @param optimizer defines the current optimizer
  132193. * @returns true if everything that can be done was applied
  132194. */
  132195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132196. }
  132197. /**
  132198. * Defines an optimization used to merge meshes with compatible materials
  132199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132200. */
  132201. export class MergeMeshesOptimization extends SceneOptimization {
  132202. private static _UpdateSelectionTree;
  132203. /**
  132204. * Gets or sets a boolean which defines if optimization octree has to be updated
  132205. */
  132206. /**
  132207. * Gets or sets a boolean which defines if optimization octree has to be updated
  132208. */
  132209. static UpdateSelectionTree: boolean;
  132210. /**
  132211. * Gets a string describing the action executed by the current optimization
  132212. * @return description string
  132213. */
  132214. getDescription(): string;
  132215. private _canBeMerged;
  132216. /**
  132217. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132218. * @param scene defines the current scene where to apply this optimization
  132219. * @param optimizer defines the current optimizer
  132220. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  132221. * @returns true if everything that can be done was applied
  132222. */
  132223. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  132224. }
  132225. /**
  132226. * Defines a list of options used by SceneOptimizer
  132227. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132228. */
  132229. export class SceneOptimizerOptions {
  132230. /**
  132231. * Defines the target frame rate to reach (60 by default)
  132232. */
  132233. targetFrameRate: number;
  132234. /**
  132235. * Defines the interval between two checkes (2000ms by default)
  132236. */
  132237. trackerDuration: number;
  132238. /**
  132239. * Gets the list of optimizations to apply
  132240. */
  132241. optimizations: SceneOptimization[];
  132242. /**
  132243. * Creates a new list of options used by SceneOptimizer
  132244. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  132245. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  132246. */
  132247. constructor(
  132248. /**
  132249. * Defines the target frame rate to reach (60 by default)
  132250. */
  132251. targetFrameRate?: number,
  132252. /**
  132253. * Defines the interval between two checkes (2000ms by default)
  132254. */
  132255. trackerDuration?: number);
  132256. /**
  132257. * Add a new optimization
  132258. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  132259. * @returns the current SceneOptimizerOptions
  132260. */
  132261. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  132262. /**
  132263. * Add a new custom optimization
  132264. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  132265. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  132266. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132267. * @returns the current SceneOptimizerOptions
  132268. */
  132269. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  132270. /**
  132271. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  132272. * @param targetFrameRate defines the target frame rate (60 by default)
  132273. * @returns a SceneOptimizerOptions object
  132274. */
  132275. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132276. /**
  132277. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  132278. * @param targetFrameRate defines the target frame rate (60 by default)
  132279. * @returns a SceneOptimizerOptions object
  132280. */
  132281. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132282. /**
  132283. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  132284. * @param targetFrameRate defines the target frame rate (60 by default)
  132285. * @returns a SceneOptimizerOptions object
  132286. */
  132287. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132288. }
  132289. /**
  132290. * Class used to run optimizations in order to reach a target frame rate
  132291. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132292. */
  132293. export class SceneOptimizer implements IDisposable {
  132294. private _isRunning;
  132295. private _options;
  132296. private _scene;
  132297. private _currentPriorityLevel;
  132298. private _targetFrameRate;
  132299. private _trackerDuration;
  132300. private _currentFrameRate;
  132301. private _sceneDisposeObserver;
  132302. private _improvementMode;
  132303. /**
  132304. * Defines an observable called when the optimizer reaches the target frame rate
  132305. */
  132306. onSuccessObservable: Observable<SceneOptimizer>;
  132307. /**
  132308. * Defines an observable called when the optimizer enables an optimization
  132309. */
  132310. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  132311. /**
  132312. * Defines an observable called when the optimizer is not able to reach the target frame rate
  132313. */
  132314. onFailureObservable: Observable<SceneOptimizer>;
  132315. /**
  132316. * Gets a boolean indicating if the optimizer is in improvement mode
  132317. */
  132318. readonly isInImprovementMode: boolean;
  132319. /**
  132320. * Gets the current priority level (0 at start)
  132321. */
  132322. readonly currentPriorityLevel: number;
  132323. /**
  132324. * Gets the current frame rate checked by the SceneOptimizer
  132325. */
  132326. readonly currentFrameRate: number;
  132327. /**
  132328. * Gets or sets the current target frame rate (60 by default)
  132329. */
  132330. /**
  132331. * Gets or sets the current target frame rate (60 by default)
  132332. */
  132333. targetFrameRate: number;
  132334. /**
  132335. * Gets or sets the current interval between two checks (every 2000ms by default)
  132336. */
  132337. /**
  132338. * Gets or sets the current interval between two checks (every 2000ms by default)
  132339. */
  132340. trackerDuration: number;
  132341. /**
  132342. * Gets the list of active optimizations
  132343. */
  132344. readonly optimizations: SceneOptimization[];
  132345. /**
  132346. * Creates a new SceneOptimizer
  132347. * @param scene defines the scene to work on
  132348. * @param options defines the options to use with the SceneOptimizer
  132349. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  132350. * @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)
  132351. */
  132352. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  132353. /**
  132354. * Stops the current optimizer
  132355. */
  132356. stop(): void;
  132357. /**
  132358. * Reset the optimizer to initial step (current priority level = 0)
  132359. */
  132360. reset(): void;
  132361. /**
  132362. * Start the optimizer. By default it will try to reach a specific framerate
  132363. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  132364. */
  132365. start(): void;
  132366. private _checkCurrentState;
  132367. /**
  132368. * Release all resources
  132369. */
  132370. dispose(): void;
  132371. /**
  132372. * Helper function to create a SceneOptimizer with one single line of code
  132373. * @param scene defines the scene to work on
  132374. * @param options defines the options to use with the SceneOptimizer
  132375. * @param onSuccess defines a callback to call on success
  132376. * @param onFailure defines a callback to call on failure
  132377. * @returns the new SceneOptimizer object
  132378. */
  132379. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  132380. }
  132381. }
  132382. declare module BABYLON {
  132383. /**
  132384. * Class used to serialize a scene into a string
  132385. */
  132386. export class SceneSerializer {
  132387. /**
  132388. * Clear cache used by a previous serialization
  132389. */
  132390. static ClearCache(): void;
  132391. /**
  132392. * Serialize a scene into a JSON compatible object
  132393. * @param scene defines the scene to serialize
  132394. * @returns a JSON compatible object
  132395. */
  132396. static Serialize(scene: Scene): any;
  132397. /**
  132398. * Serialize a mesh into a JSON compatible object
  132399. * @param toSerialize defines the mesh to serialize
  132400. * @param withParents defines if parents must be serialized as well
  132401. * @param withChildren defines if children must be serialized as well
  132402. * @returns a JSON compatible object
  132403. */
  132404. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  132405. }
  132406. }
  132407. declare module BABYLON {
  132408. /**
  132409. * Class used to host texture specific utilities
  132410. */
  132411. export class TextureTools {
  132412. /**
  132413. * Uses the GPU to create a copy texture rescaled at a given size
  132414. * @param texture Texture to copy from
  132415. * @param width defines the desired width
  132416. * @param height defines the desired height
  132417. * @param useBilinearMode defines if bilinear mode has to be used
  132418. * @return the generated texture
  132419. */
  132420. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  132421. }
  132422. }
  132423. declare module BABYLON {
  132424. /**
  132425. * This represents the different options available for the video capture.
  132426. */
  132427. export interface VideoRecorderOptions {
  132428. /** Defines the mime type of the video. */
  132429. mimeType: string;
  132430. /** Defines the FPS the video should be recorded at. */
  132431. fps: number;
  132432. /** Defines the chunk size for the recording data. */
  132433. recordChunckSize: number;
  132434. /** The audio tracks to attach to the recording. */
  132435. audioTracks?: MediaStreamTrack[];
  132436. }
  132437. /**
  132438. * This can help with recording videos from BabylonJS.
  132439. * This is based on the available WebRTC functionalities of the browser.
  132440. *
  132441. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  132442. */
  132443. export class VideoRecorder {
  132444. private static readonly _defaultOptions;
  132445. /**
  132446. * Returns whether or not the VideoRecorder is available in your browser.
  132447. * @param engine Defines the Babylon Engine.
  132448. * @returns true if supported otherwise false.
  132449. */
  132450. static IsSupported(engine: Engine): boolean;
  132451. private readonly _options;
  132452. private _canvas;
  132453. private _mediaRecorder;
  132454. private _recordedChunks;
  132455. private _fileName;
  132456. private _resolve;
  132457. private _reject;
  132458. /**
  132459. * True when a recording is already in progress.
  132460. */
  132461. readonly isRecording: boolean;
  132462. /**
  132463. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  132464. * @param engine Defines the BabylonJS Engine you wish to record.
  132465. * @param options Defines options that can be used to customize the capture.
  132466. */
  132467. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  132468. /**
  132469. * Stops the current recording before the default capture timeout passed in the startRecording function.
  132470. */
  132471. stopRecording(): void;
  132472. /**
  132473. * Starts recording the canvas for a max duration specified in parameters.
  132474. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  132475. * If null no automatic download will start and you can rely on the promise to get the data back.
  132476. * @param maxDuration Defines the maximum recording time in seconds.
  132477. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  132478. * @return A promise callback at the end of the recording with the video data in Blob.
  132479. */
  132480. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  132481. /**
  132482. * Releases internal resources used during the recording.
  132483. */
  132484. dispose(): void;
  132485. private _handleDataAvailable;
  132486. private _handleError;
  132487. private _handleStop;
  132488. }
  132489. }
  132490. declare module BABYLON {
  132491. /**
  132492. * Class containing a set of static utilities functions for screenshots
  132493. */
  132494. export class ScreenshotTools {
  132495. /**
  132496. * Captures a screenshot of the current rendering
  132497. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132498. * @param engine defines the rendering engine
  132499. * @param camera defines the source camera
  132500. * @param size This parameter can be set to a single number or to an object with the
  132501. * following (optional) properties: precision, width, height. If a single number is passed,
  132502. * it will be used for both width and height. If an object is passed, the screenshot size
  132503. * will be derived from the parameters. The precision property is a multiplier allowing
  132504. * rendering at a higher or lower resolution
  132505. * @param successCallback defines the callback receives a single parameter which contains the
  132506. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132507. * src parameter of an <img> to display it
  132508. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132509. * Check your browser for supported MIME types
  132510. */
  132511. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  132512. /**
  132513. * Captures a screenshot of the current rendering
  132514. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132515. * @param engine defines the rendering engine
  132516. * @param camera defines the source camera
  132517. * @param size This parameter can be set to a single number or to an object with the
  132518. * following (optional) properties: precision, width, height. If a single number is passed,
  132519. * it will be used for both width and height. If an object is passed, the screenshot size
  132520. * will be derived from the parameters. The precision property is a multiplier allowing
  132521. * rendering at a higher or lower resolution
  132522. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132523. * Check your browser for supported MIME types
  132524. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132525. * to the src parameter of an <img> to display it
  132526. */
  132527. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  132528. /**
  132529. * Generates an image screenshot from the specified camera.
  132530. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132531. * @param engine The engine to use for rendering
  132532. * @param camera The camera to use for rendering
  132533. * @param size This parameter can be set to a single number or to an object with the
  132534. * following (optional) properties: precision, width, height. If a single number is passed,
  132535. * it will be used for both width and height. If an object is passed, the screenshot size
  132536. * will be derived from the parameters. The precision property is a multiplier allowing
  132537. * rendering at a higher or lower resolution
  132538. * @param successCallback The callback receives a single parameter which contains the
  132539. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132540. * src parameter of an <img> to display it
  132541. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132542. * Check your browser for supported MIME types
  132543. * @param samples Texture samples (default: 1)
  132544. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132545. * @param fileName A name for for the downloaded file.
  132546. */
  132547. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  132548. /**
  132549. * Generates an image screenshot from the specified camera.
  132550. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132551. * @param engine The engine to use for rendering
  132552. * @param camera The camera to use for rendering
  132553. * @param size This parameter can be set to a single number or to an object with the
  132554. * following (optional) properties: precision, width, height. If a single number is passed,
  132555. * it will be used for both width and height. If an object is passed, the screenshot size
  132556. * will be derived from the parameters. The precision property is a multiplier allowing
  132557. * rendering at a higher or lower resolution
  132558. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132559. * Check your browser for supported MIME types
  132560. * @param samples Texture samples (default: 1)
  132561. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132562. * @param fileName A name for for the downloaded file.
  132563. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132564. * to the src parameter of an <img> to display it
  132565. */
  132566. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  132567. /**
  132568. * Gets height and width for screenshot size
  132569. * @private
  132570. */
  132571. private static _getScreenshotSize;
  132572. }
  132573. }
  132574. declare module BABYLON {
  132575. /**
  132576. * Interface for a data buffer
  132577. */
  132578. export interface IDataBuffer {
  132579. /**
  132580. * Reads bytes from the data buffer.
  132581. * @param byteOffset The byte offset to read
  132582. * @param byteLength The byte length to read
  132583. * @returns A promise that resolves when the bytes are read
  132584. */
  132585. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  132586. /**
  132587. * The byte length of the buffer.
  132588. */
  132589. readonly byteLength: number;
  132590. }
  132591. /**
  132592. * Utility class for reading from a data buffer
  132593. */
  132594. export class DataReader {
  132595. /**
  132596. * The data buffer associated with this data reader.
  132597. */
  132598. readonly buffer: IDataBuffer;
  132599. /**
  132600. * The current byte offset from the beginning of the data buffer.
  132601. */
  132602. byteOffset: number;
  132603. private _dataView;
  132604. private _dataByteOffset;
  132605. /**
  132606. * Constructor
  132607. * @param buffer The buffer to read
  132608. */
  132609. constructor(buffer: IDataBuffer);
  132610. /**
  132611. * Loads the given byte length.
  132612. * @param byteLength The byte length to load
  132613. * @returns A promise that resolves when the load is complete
  132614. */
  132615. loadAsync(byteLength: number): Promise<void>;
  132616. /**
  132617. * Read a unsigned 32-bit integer from the currently loaded data range.
  132618. * @returns The 32-bit integer read
  132619. */
  132620. readUint32(): number;
  132621. /**
  132622. * Read a byte array from the currently loaded data range.
  132623. * @param byteLength The byte length to read
  132624. * @returns The byte array read
  132625. */
  132626. readUint8Array(byteLength: number): Uint8Array;
  132627. /**
  132628. * Read a string from the currently loaded data range.
  132629. * @param byteLength The byte length to read
  132630. * @returns The string read
  132631. */
  132632. readString(byteLength: number): string;
  132633. /**
  132634. * Skips the given byte length the currently loaded data range.
  132635. * @param byteLength The byte length to skip
  132636. */
  132637. skipBytes(byteLength: number): void;
  132638. }
  132639. }
  132640. declare module BABYLON {
  132641. /**
  132642. * A cursor which tracks a point on a path
  132643. */
  132644. export class PathCursor {
  132645. private path;
  132646. /**
  132647. * Stores path cursor callbacks for when an onchange event is triggered
  132648. */
  132649. private _onchange;
  132650. /**
  132651. * The value of the path cursor
  132652. */
  132653. value: number;
  132654. /**
  132655. * The animation array of the path cursor
  132656. */
  132657. animations: Animation[];
  132658. /**
  132659. * Initializes the path cursor
  132660. * @param path The path to track
  132661. */
  132662. constructor(path: Path2);
  132663. /**
  132664. * Gets the cursor point on the path
  132665. * @returns A point on the path cursor at the cursor location
  132666. */
  132667. getPoint(): Vector3;
  132668. /**
  132669. * Moves the cursor ahead by the step amount
  132670. * @param step The amount to move the cursor forward
  132671. * @returns This path cursor
  132672. */
  132673. moveAhead(step?: number): PathCursor;
  132674. /**
  132675. * Moves the cursor behind by the step amount
  132676. * @param step The amount to move the cursor back
  132677. * @returns This path cursor
  132678. */
  132679. moveBack(step?: number): PathCursor;
  132680. /**
  132681. * Moves the cursor by the step amount
  132682. * If the step amount is greater than one, an exception is thrown
  132683. * @param step The amount to move the cursor
  132684. * @returns This path cursor
  132685. */
  132686. move(step: number): PathCursor;
  132687. /**
  132688. * Ensures that the value is limited between zero and one
  132689. * @returns This path cursor
  132690. */
  132691. private ensureLimits;
  132692. /**
  132693. * Runs onchange callbacks on change (used by the animation engine)
  132694. * @returns This path cursor
  132695. */
  132696. private raiseOnChange;
  132697. /**
  132698. * Executes a function on change
  132699. * @param f A path cursor onchange callback
  132700. * @returns This path cursor
  132701. */
  132702. onchange(f: (cursor: PathCursor) => void): PathCursor;
  132703. }
  132704. }
  132705. declare module BABYLON {
  132706. /** @hidden */
  132707. export var blurPixelShader: {
  132708. name: string;
  132709. shader: string;
  132710. };
  132711. }
  132712. declare module BABYLON {
  132713. /** @hidden */
  132714. export var pointCloudVertexDeclaration: {
  132715. name: string;
  132716. shader: string;
  132717. };
  132718. }
  132719. // Mixins
  132720. interface Window {
  132721. mozIndexedDB: IDBFactory;
  132722. webkitIndexedDB: IDBFactory;
  132723. msIndexedDB: IDBFactory;
  132724. webkitURL: typeof URL;
  132725. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  132726. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  132727. WebGLRenderingContext: WebGLRenderingContext;
  132728. MSGesture: MSGesture;
  132729. CANNON: any;
  132730. AudioContext: AudioContext;
  132731. webkitAudioContext: AudioContext;
  132732. PointerEvent: any;
  132733. Math: Math;
  132734. Uint8Array: Uint8ArrayConstructor;
  132735. Float32Array: Float32ArrayConstructor;
  132736. mozURL: typeof URL;
  132737. msURL: typeof URL;
  132738. VRFrameData: any; // WebVR, from specs 1.1
  132739. DracoDecoderModule: any;
  132740. setImmediate(handler: (...args: any[]) => void): number;
  132741. }
  132742. interface HTMLCanvasElement {
  132743. requestPointerLock(): void;
  132744. msRequestPointerLock?(): void;
  132745. mozRequestPointerLock?(): void;
  132746. webkitRequestPointerLock?(): void;
  132747. /** Track wether a record is in progress */
  132748. isRecording: boolean;
  132749. /** Capture Stream method defined by some browsers */
  132750. captureStream(fps?: number): MediaStream;
  132751. }
  132752. interface CanvasRenderingContext2D {
  132753. msImageSmoothingEnabled: boolean;
  132754. }
  132755. interface MouseEvent {
  132756. mozMovementX: number;
  132757. mozMovementY: number;
  132758. webkitMovementX: number;
  132759. webkitMovementY: number;
  132760. msMovementX: number;
  132761. msMovementY: number;
  132762. }
  132763. interface Navigator {
  132764. mozGetVRDevices: (any: any) => any;
  132765. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132766. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132767. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132768. webkitGetGamepads(): Gamepad[];
  132769. msGetGamepads(): Gamepad[];
  132770. webkitGamepads(): Gamepad[];
  132771. }
  132772. interface HTMLVideoElement {
  132773. mozSrcObject: any;
  132774. }
  132775. interface Math {
  132776. fround(x: number): number;
  132777. imul(a: number, b: number): number;
  132778. }
  132779. interface WebGLRenderingContext {
  132780. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  132781. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  132782. vertexAttribDivisor(index: number, divisor: number): void;
  132783. createVertexArray(): any;
  132784. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  132785. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  132786. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  132787. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  132788. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  132789. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  132790. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  132791. // Queries
  132792. createQuery(): WebGLQuery;
  132793. deleteQuery(query: WebGLQuery): void;
  132794. beginQuery(target: number, query: WebGLQuery): void;
  132795. endQuery(target: number): void;
  132796. getQueryParameter(query: WebGLQuery, pname: number): any;
  132797. getQuery(target: number, pname: number): any;
  132798. MAX_SAMPLES: number;
  132799. RGBA8: number;
  132800. READ_FRAMEBUFFER: number;
  132801. DRAW_FRAMEBUFFER: number;
  132802. UNIFORM_BUFFER: number;
  132803. HALF_FLOAT_OES: number;
  132804. RGBA16F: number;
  132805. RGBA32F: number;
  132806. R32F: number;
  132807. RG32F: number;
  132808. RGB32F: number;
  132809. R16F: number;
  132810. RG16F: number;
  132811. RGB16F: number;
  132812. RED: number;
  132813. RG: number;
  132814. R8: number;
  132815. RG8: number;
  132816. UNSIGNED_INT_24_8: number;
  132817. DEPTH24_STENCIL8: number;
  132818. MIN: number;
  132819. MAX: number;
  132820. /* Multiple Render Targets */
  132821. drawBuffers(buffers: number[]): void;
  132822. readBuffer(src: number): void;
  132823. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  132824. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  132825. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  132826. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  132827. // Occlusion Query
  132828. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  132829. ANY_SAMPLES_PASSED: number;
  132830. QUERY_RESULT_AVAILABLE: number;
  132831. QUERY_RESULT: number;
  132832. }
  132833. interface WebGLProgram {
  132834. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  132835. }
  132836. interface EXT_disjoint_timer_query {
  132837. QUERY_COUNTER_BITS_EXT: number;
  132838. TIME_ELAPSED_EXT: number;
  132839. TIMESTAMP_EXT: number;
  132840. GPU_DISJOINT_EXT: number;
  132841. QUERY_RESULT_EXT: number;
  132842. QUERY_RESULT_AVAILABLE_EXT: number;
  132843. queryCounterEXT(query: WebGLQuery, target: number): void;
  132844. createQueryEXT(): WebGLQuery;
  132845. beginQueryEXT(target: number, query: WebGLQuery): void;
  132846. endQueryEXT(target: number): void;
  132847. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  132848. deleteQueryEXT(query: WebGLQuery): void;
  132849. }
  132850. interface WebGLUniformLocation {
  132851. _currentState: any;
  132852. }
  132853. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  132854. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  132855. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  132856. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132857. interface WebGLRenderingContext {
  132858. readonly RASTERIZER_DISCARD: number;
  132859. readonly DEPTH_COMPONENT24: number;
  132860. readonly TEXTURE_3D: number;
  132861. readonly TEXTURE_2D_ARRAY: number;
  132862. readonly TEXTURE_COMPARE_FUNC: number;
  132863. readonly TEXTURE_COMPARE_MODE: number;
  132864. readonly COMPARE_REF_TO_TEXTURE: number;
  132865. readonly TEXTURE_WRAP_R: number;
  132866. readonly HALF_FLOAT: number;
  132867. readonly RGB8: number;
  132868. readonly RED_INTEGER: number;
  132869. readonly RG_INTEGER: number;
  132870. readonly RGB_INTEGER: number;
  132871. readonly RGBA_INTEGER: number;
  132872. readonly R8_SNORM: number;
  132873. readonly RG8_SNORM: number;
  132874. readonly RGB8_SNORM: number;
  132875. readonly RGBA8_SNORM: number;
  132876. readonly R8I: number;
  132877. readonly RG8I: number;
  132878. readonly RGB8I: number;
  132879. readonly RGBA8I: number;
  132880. readonly R8UI: number;
  132881. readonly RG8UI: number;
  132882. readonly RGB8UI: number;
  132883. readonly RGBA8UI: number;
  132884. readonly R16I: number;
  132885. readonly RG16I: number;
  132886. readonly RGB16I: number;
  132887. readonly RGBA16I: number;
  132888. readonly R16UI: number;
  132889. readonly RG16UI: number;
  132890. readonly RGB16UI: number;
  132891. readonly RGBA16UI: number;
  132892. readonly R32I: number;
  132893. readonly RG32I: number;
  132894. readonly RGB32I: number;
  132895. readonly RGBA32I: number;
  132896. readonly R32UI: number;
  132897. readonly RG32UI: number;
  132898. readonly RGB32UI: number;
  132899. readonly RGBA32UI: number;
  132900. readonly RGB10_A2UI: number;
  132901. readonly R11F_G11F_B10F: number;
  132902. readonly RGB9_E5: number;
  132903. readonly RGB10_A2: number;
  132904. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  132905. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  132906. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  132907. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  132908. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  132909. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  132910. 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;
  132911. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  132912. readonly TRANSFORM_FEEDBACK: number;
  132913. readonly INTERLEAVED_ATTRIBS: number;
  132914. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  132915. createTransformFeedback(): WebGLTransformFeedback;
  132916. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  132917. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  132918. beginTransformFeedback(primitiveMode: number): void;
  132919. endTransformFeedback(): void;
  132920. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  132921. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132922. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132923. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132924. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  132925. }
  132926. interface ImageBitmap {
  132927. readonly width: number;
  132928. readonly height: number;
  132929. close(): void;
  132930. }
  132931. interface WebGLQuery extends WebGLObject {
  132932. }
  132933. declare var WebGLQuery: {
  132934. prototype: WebGLQuery;
  132935. new(): WebGLQuery;
  132936. };
  132937. interface WebGLSampler extends WebGLObject {
  132938. }
  132939. declare var WebGLSampler: {
  132940. prototype: WebGLSampler;
  132941. new(): WebGLSampler;
  132942. };
  132943. interface WebGLSync extends WebGLObject {
  132944. }
  132945. declare var WebGLSync: {
  132946. prototype: WebGLSync;
  132947. new(): WebGLSync;
  132948. };
  132949. interface WebGLTransformFeedback extends WebGLObject {
  132950. }
  132951. declare var WebGLTransformFeedback: {
  132952. prototype: WebGLTransformFeedback;
  132953. new(): WebGLTransformFeedback;
  132954. };
  132955. interface WebGLVertexArrayObject extends WebGLObject {
  132956. }
  132957. declare var WebGLVertexArrayObject: {
  132958. prototype: WebGLVertexArrayObject;
  132959. new(): WebGLVertexArrayObject;
  132960. };
  132961. // Type definitions for WebVR API
  132962. // Project: https://w3c.github.io/webvr/
  132963. // Definitions by: six a <https://github.com/lostfictions>
  132964. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132965. interface VRDisplay extends EventTarget {
  132966. /**
  132967. * Dictionary of capabilities describing the VRDisplay.
  132968. */
  132969. readonly capabilities: VRDisplayCapabilities;
  132970. /**
  132971. * z-depth defining the far plane of the eye view frustum
  132972. * enables mapping of values in the render target depth
  132973. * attachment to scene coordinates. Initially set to 10000.0.
  132974. */
  132975. depthFar: number;
  132976. /**
  132977. * z-depth defining the near plane of the eye view frustum
  132978. * enables mapping of values in the render target depth
  132979. * attachment to scene coordinates. Initially set to 0.01.
  132980. */
  132981. depthNear: number;
  132982. /**
  132983. * An identifier for this distinct VRDisplay. Used as an
  132984. * association point in the Gamepad API.
  132985. */
  132986. readonly displayId: number;
  132987. /**
  132988. * A display name, a user-readable name identifying it.
  132989. */
  132990. readonly displayName: string;
  132991. readonly isConnected: boolean;
  132992. readonly isPresenting: boolean;
  132993. /**
  132994. * If this VRDisplay supports room-scale experiences, the optional
  132995. * stage attribute contains details on the room-scale parameters.
  132996. */
  132997. readonly stageParameters: VRStageParameters | null;
  132998. /**
  132999. * Passing the value returned by `requestAnimationFrame` to
  133000. * `cancelAnimationFrame` will unregister the callback.
  133001. * @param handle Define the hanle of the request to cancel
  133002. */
  133003. cancelAnimationFrame(handle: number): void;
  133004. /**
  133005. * Stops presenting to the VRDisplay.
  133006. * @returns a promise to know when it stopped
  133007. */
  133008. exitPresent(): Promise<void>;
  133009. /**
  133010. * Return the current VREyeParameters for the given eye.
  133011. * @param whichEye Define the eye we want the parameter for
  133012. * @returns the eye parameters
  133013. */
  133014. getEyeParameters(whichEye: string): VREyeParameters;
  133015. /**
  133016. * Populates the passed VRFrameData with the information required to render
  133017. * the current frame.
  133018. * @param frameData Define the data structure to populate
  133019. * @returns true if ok otherwise false
  133020. */
  133021. getFrameData(frameData: VRFrameData): boolean;
  133022. /**
  133023. * Get the layers currently being presented.
  133024. * @returns the list of VR layers
  133025. */
  133026. getLayers(): VRLayer[];
  133027. /**
  133028. * Return a VRPose containing the future predicted pose of the VRDisplay
  133029. * when the current frame will be presented. The value returned will not
  133030. * change until JavaScript has returned control to the browser.
  133031. *
  133032. * The VRPose will contain the position, orientation, velocity,
  133033. * and acceleration of each of these properties.
  133034. * @returns the pose object
  133035. */
  133036. getPose(): VRPose;
  133037. /**
  133038. * Return the current instantaneous pose of the VRDisplay, with no
  133039. * prediction applied.
  133040. * @returns the current instantaneous pose
  133041. */
  133042. getImmediatePose(): VRPose;
  133043. /**
  133044. * The callback passed to `requestAnimationFrame` will be called
  133045. * any time a new frame should be rendered. When the VRDisplay is
  133046. * presenting the callback will be called at the native refresh
  133047. * rate of the HMD. When not presenting this function acts
  133048. * identically to how window.requestAnimationFrame acts. Content should
  133049. * make no assumptions of frame rate or vsync behavior as the HMD runs
  133050. * asynchronously from other displays and at differing refresh rates.
  133051. * @param callback Define the eaction to run next frame
  133052. * @returns the request handle it
  133053. */
  133054. requestAnimationFrame(callback: FrameRequestCallback): number;
  133055. /**
  133056. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  133057. * Repeat calls while already presenting will update the VRLayers being displayed.
  133058. * @param layers Define the list of layer to present
  133059. * @returns a promise to know when the request has been fulfilled
  133060. */
  133061. requestPresent(layers: VRLayer[]): Promise<void>;
  133062. /**
  133063. * Reset the pose for this display, treating its current position and
  133064. * orientation as the "origin/zero" values. VRPose.position,
  133065. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  133066. * updated when calling resetPose(). This should be called in only
  133067. * sitting-space experiences.
  133068. */
  133069. resetPose(): void;
  133070. /**
  133071. * The VRLayer provided to the VRDisplay will be captured and presented
  133072. * in the HMD. Calling this function has the same effect on the source
  133073. * canvas as any other operation that uses its source image, and canvases
  133074. * created without preserveDrawingBuffer set to true will be cleared.
  133075. * @param pose Define the pose to submit
  133076. */
  133077. submitFrame(pose?: VRPose): void;
  133078. }
  133079. declare var VRDisplay: {
  133080. prototype: VRDisplay;
  133081. new(): VRDisplay;
  133082. };
  133083. interface VRLayer {
  133084. leftBounds?: number[] | Float32Array | null;
  133085. rightBounds?: number[] | Float32Array | null;
  133086. source?: HTMLCanvasElement | null;
  133087. }
  133088. interface VRDisplayCapabilities {
  133089. readonly canPresent: boolean;
  133090. readonly hasExternalDisplay: boolean;
  133091. readonly hasOrientation: boolean;
  133092. readonly hasPosition: boolean;
  133093. readonly maxLayers: number;
  133094. }
  133095. interface VREyeParameters {
  133096. /** @deprecated */
  133097. readonly fieldOfView: VRFieldOfView;
  133098. readonly offset: Float32Array;
  133099. readonly renderHeight: number;
  133100. readonly renderWidth: number;
  133101. }
  133102. interface VRFieldOfView {
  133103. readonly downDegrees: number;
  133104. readonly leftDegrees: number;
  133105. readonly rightDegrees: number;
  133106. readonly upDegrees: number;
  133107. }
  133108. interface VRFrameData {
  133109. readonly leftProjectionMatrix: Float32Array;
  133110. readonly leftViewMatrix: Float32Array;
  133111. readonly pose: VRPose;
  133112. readonly rightProjectionMatrix: Float32Array;
  133113. readonly rightViewMatrix: Float32Array;
  133114. readonly timestamp: number;
  133115. }
  133116. interface VRPose {
  133117. readonly angularAcceleration: Float32Array | null;
  133118. readonly angularVelocity: Float32Array | null;
  133119. readonly linearAcceleration: Float32Array | null;
  133120. readonly linearVelocity: Float32Array | null;
  133121. readonly orientation: Float32Array | null;
  133122. readonly position: Float32Array | null;
  133123. readonly timestamp: number;
  133124. }
  133125. interface VRStageParameters {
  133126. sittingToStandingTransform?: Float32Array;
  133127. sizeX?: number;
  133128. sizeY?: number;
  133129. }
  133130. interface Navigator {
  133131. getVRDisplays(): Promise<VRDisplay[]>;
  133132. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  133133. }
  133134. interface Window {
  133135. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  133136. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  133137. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  133138. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133139. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133140. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  133141. }
  133142. interface Gamepad {
  133143. readonly displayId: number;
  133144. }
  133145. type XRSessionMode =
  133146. | "inline"
  133147. | "immersive-vr"
  133148. | "immersive-ar";
  133149. type XRReferenceSpaceType =
  133150. | "viewer"
  133151. | "local"
  133152. | "local-floor"
  133153. | "bounded-floor"
  133154. | "unbounded";
  133155. type XREnvironmentBlendMode =
  133156. | "opaque"
  133157. | "additive"
  133158. | "alpha-blend";
  133159. type XRVisibilityState =
  133160. | "visible"
  133161. | "visible-blurred"
  133162. | "hidden";
  133163. type XRHandedness =
  133164. | "none"
  133165. | "left"
  133166. | "right";
  133167. type XRTargetRayMode =
  133168. | "gaze"
  133169. | "tracked-pointer"
  133170. | "screen";
  133171. type XREye =
  133172. | "none"
  133173. | "left"
  133174. | "right";
  133175. interface XRSpace extends EventTarget {
  133176. }
  133177. interface XRRenderState {
  133178. depthNear?: number;
  133179. depthFar?: number;
  133180. inlineVerticalFieldOfView?: number;
  133181. baseLayer?: XRWebGLLayer;
  133182. }
  133183. interface XRInputSource {
  133184. handedness: XRHandedness;
  133185. targetRayMode: XRTargetRayMode;
  133186. targetRaySpace: XRSpace;
  133187. gripSpace: XRSpace | undefined;
  133188. gamepad: Gamepad | undefined;
  133189. profiles: Array<string>;
  133190. }
  133191. interface XRSession {
  133192. addEventListener: Function;
  133193. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  133194. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  133195. requestAnimationFrame: Function;
  133196. end(): Promise<void>;
  133197. renderState: XRRenderState;
  133198. inputSources: Array<XRInputSource>;
  133199. }
  133200. interface XRReferenceSpace extends XRSpace {
  133201. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  133202. onreset: any;
  133203. }
  133204. interface XRFrame {
  133205. session: XRSession;
  133206. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  133207. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  133208. }
  133209. interface XRViewerPose extends XRPose {
  133210. views: Array<XRView>;
  133211. }
  133212. interface XRPose {
  133213. transform: XRRigidTransform;
  133214. emulatedPosition: boolean;
  133215. }
  133216. interface XRWebGLLayerOptions {
  133217. antialias ?: boolean;
  133218. depth ?: boolean;
  133219. stencil ?: boolean;
  133220. alpha ?: boolean;
  133221. multiview ?: boolean;
  133222. framebufferScaleFactor ?: number;
  133223. }
  133224. declare var XRWebGLLayer: {
  133225. prototype: XRWebGLLayer;
  133226. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  133227. };
  133228. interface XRWebGLLayer {
  133229. framebuffer: WebGLFramebuffer;
  133230. framebufferWidth: number;
  133231. framebufferHeight: number;
  133232. getViewport: Function;
  133233. }
  133234. interface XRRigidTransform {
  133235. position: DOMPointReadOnly;
  133236. orientation: DOMPointReadOnly;
  133237. matrix: Float32Array;
  133238. inverse: XRRigidTransform;
  133239. }
  133240. interface XRView {
  133241. eye: XREye;
  133242. projectionMatrix: Float32Array;
  133243. transform: XRRigidTransform;
  133244. }
  133245. interface XRInputSourceChangeEvent {
  133246. session: XRSession;
  133247. removed: Array<XRInputSource>;
  133248. added: Array<XRInputSource>;
  133249. }